From be1221b7411b196c2e3e75794d28bed3cbf7c44f Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Sun, 29 Sep 2019 16:39:30 +0800 Subject: [PATCH] refactor: remove link material prop --- lib/scaffolds/utils.dart | 32 ++------------------------------ lib/screens/notifications.dart | 4 +--- lib/widgets/avatar.dart | 1 - lib/widgets/error_reload.dart | 4 +--- lib/widgets/link.dart | 9 --------- 5 files changed, 4 insertions(+), 46 deletions(-) diff --git a/lib/scaffolds/utils.dart b/lib/scaffolds/utils.dart index 368bd96..dad52aa 100644 --- a/lib/scaffolds/utils.dart +++ b/lib/scaffolds/utils.dart @@ -1,7 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:git_touch/models/theme.dart'; -import 'package:git_touch/widgets/link.dart'; +import 'package:git_touch/widgets/error_reload.dart'; import 'package:git_touch/widgets/loading.dart'; import 'package:provider/provider.dart'; @@ -90,35 +90,7 @@ class ErrorLoadingWrapper extends StatelessWidget { @override Widget build(BuildContext context) { if (error.isNotEmpty) { - return Container( - padding: EdgeInsets.symmetric(vertical: 30, horizontal: 20), - child: Column( - children: [ - Text( - 'Woops, something bad happened. Error message:', - style: TextStyle(fontSize: 16), - ), - Padding(padding: EdgeInsets.only(top: 10)), - Text( - error, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w300, - color: Colors.redAccent, - ), - ), - Padding(padding: EdgeInsets.only(top: 10)), - Link( - child: Text( - 'Reload', - style: TextStyle(fontSize: 20, color: Colors.blueAccent), - ), - onTap: reload, - material: false, - ), - ], - ), - ); + return ErrorReload(text: error, onTap: reload); } if (loading) { diff --git a/lib/screens/notifications.dart b/lib/screens/notifications.dart index 7c0181b..dccf9d4 100644 --- a/lib/screens/notifications.dart +++ b/lib/screens/notifications.dart @@ -7,7 +7,6 @@ import 'package:git_touch/models/notification.dart'; import 'package:git_touch/models/auth.dart'; import '../widgets/notification_item.dart'; import '../widgets/list_group.dart'; -import '../widgets/link.dart'; import '../widgets/empty.dart'; import '../utils/utils.dart'; @@ -109,8 +108,7 @@ $key: pullRequest(number: ${item.number}) { repo, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600), ), - Link( - material: false, + GestureDetector( onTap: () async { await Provider.of(context) .putWithCredentials('/repos/$repo/notifications'); diff --git a/lib/widgets/avatar.dart b/lib/widgets/avatar.dart index 04de832..30e9403 100644 --- a/lib/widgets/avatar.dart +++ b/lib/widgets/avatar.dart @@ -34,7 +34,6 @@ class Avatar extends StatelessWidget { return Link( screenBuilder: (_) => UserScreen(login), child: avatar, - material: false, ); } } diff --git a/lib/widgets/error_reload.dart b/lib/widgets/error_reload.dart index b66ac74..72f4cc6 100644 --- a/lib/widgets/error_reload.dart +++ b/lib/widgets/error_reload.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'link.dart'; class ErrorReload extends StatelessWidget { final String text; @@ -27,13 +26,12 @@ class ErrorReload extends StatelessWidget { ), ), Padding(padding: EdgeInsets.only(top: 10)), - Link( + GestureDetector( child: Text( 'Reload', style: TextStyle(fontSize: 20, color: Colors.blueAccent), ), onTap: onTap, - material: false, ), ], ), diff --git a/lib/widgets/link.dart b/lib/widgets/link.dart index 35b2917..f305e7f 100644 --- a/lib/widgets/link.dart +++ b/lib/widgets/link.dart @@ -9,14 +9,12 @@ class Link extends StatelessWidget { final String url; final WidgetBuilder screenBuilder; final Function onTap; - final bool material; Link({ this.child, this.url, this.screenBuilder, this.onTap, - this.material = true, }) : assert(screenBuilder == null || url == null); void _onTap(BuildContext context) { @@ -33,13 +31,6 @@ class Link extends StatelessWidget { @override Widget build(BuildContext context) { - if (!material) { - return GestureDetector( - child: child, - onTap: () => _onTap(context), - ); - } - return Material( child: Ink( color: Colors.white,