diff --git a/lib/main.dart b/lib/main.dart index 2c656dd..f7e77a0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -86,11 +86,7 @@ class _HomeState extends State { case ThemeMap.cupertino: return CupertinoApp( home: CupertinoTheme( - data: CupertinoThemeData( - // brightness: Brightness.dark, - // barBackgroundColor: Color.fromRGBO(0x24, 0x29, 0x2e, 1), - // primaryColor: Color(0xff24292e), - ), + data: CupertinoThemeData(), child: CupertinoTabScaffold( tabBar: CupertinoTabBar(items: _buildNavigationItems()), tabBuilder: (context, index) { @@ -103,9 +99,7 @@ class _HomeState extends State { ); default: return MaterialApp( - theme: ThemeData( - // primaryColor: Colors.black87, - ), + theme: ThemeData(), home: Scaffold( // appBar: AppBar(title: Text('Home')), body: _buildScreen(active), diff --git a/lib/providers/settings.dart b/lib/providers/settings.dart index 1199325..0ca8434 100644 --- a/lib/providers/settings.dart +++ b/lib/providers/settings.dart @@ -148,7 +148,7 @@ class _SettingsProviderState extends State { } else if (Platform.isIOS) { theme = ThemeMap.cupertino; } - theme = ThemeMap.material; + // theme = ThemeMap.material; setState(() { ready = true; diff --git a/lib/screens/login.dart b/lib/screens/login.dart index 453af57..d9ad411 100644 --- a/lib/screens/login.dart +++ b/lib/screens/login.dart @@ -13,30 +13,33 @@ class _LoginScreenState extends State { Widget build(BuildContext context) { var settings = SettingsProvider.of(context); - List children = - settings.githubAccountMap.entries.map((entry) { - return RaisedButton( - child: Text(entry.key), - onPressed: () { - settings.setActiveAccount(entry.key); - }, - ); - }).toList(); - - children.add(RaisedButton( - child: Text('Login'), - onPressed: () { - var state = settings.generateRandomString(); - launch( - 'https://github.com/login/oauth/authorize?client_id=$clientId&redirect_uri=gittouch://login&scope=user%20repo&state=$state', - forceSafariVC: false, // this makes URL Scheme work - ); - }, - )); - return MaterialApp( home: Scaffold( - body: Center(child: Column(children: children)), + body: Container( + padding: EdgeInsets.only(top: 200), + child: Column( + children: settings.githubAccountMap.entries.map((entry) { + return RaisedButton( + child: Text(entry.key), + onPressed: () { + settings.setActiveAccount(entry.key); + }, + ); + }).toList() + ..add( + RaisedButton( + child: Text('Login'), + onPressed: () { + var state = settings.generateRandomString(); + launch( + 'https://github.com/login/oauth/authorize?client_id=$clientId&redirect_uri=gittouch://login&scope=user%20repo&state=$state', + forceSafariVC: false, // this makes URL Scheme work + ); + }, + ), + ), + ), + ), ), ); } diff --git a/lib/screens/notifications.dart b/lib/screens/notifications.dart index 6e1c64a..2d7189c 100644 --- a/lib/screens/notifications.dart +++ b/lib/screens/notifications.dart @@ -32,13 +32,13 @@ class NotificationScreen extends StatefulWidget { class NotificationScreenState extends State { int active = 0; - bool loading; + bool loading = true; Map groupMap = {}; @override void initState() { super.initState(); - _refresh(); + nextTick(_onSwitchTab); } Future> fetchNotifications(int index) async { @@ -128,7 +128,7 @@ $key: pullRequest(number: ${item.number}) { beforeRedirect: () async { await SettingsProvider.of(context) .putWithCredentials('/repos/$repo/notifications'); - await _refresh(); + await _onSwitchTab(); }, child: Icon( Octicons.check, @@ -171,10 +171,6 @@ $key: pullRequest(number: ${item.number}) { } } - Future _refresh() async { - await _onSwitchTab(active); - } - var textMap = { 0: 'Unread', 1: 'Paticipating', @@ -204,7 +200,7 @@ $key: pullRequest(number: ${item.number}) { var value = await showConfirm(context, 'Mark all as read?'); if (value) { await SettingsProvider.of(context).putWithCredentials('/notifications'); - await _refresh(); + await _onSwitchTab(); } } @@ -244,7 +240,7 @@ $key: pullRequest(number: ${item.number}) { onPressed: _confirm, ) ], - onRefresh: _refresh, + onRefresh: _onSwitchTab, loading: loading, bodyBuilder: () { return Column( diff --git a/lib/screens/repo.dart b/lib/screens/repo.dart index 0fdb8e4..7639017 100644 --- a/lib/screens/repo.dart +++ b/lib/screens/repo.dart @@ -8,6 +8,7 @@ import '../widgets/repo_item.dart'; import '../widgets/entry_item.dart'; import '../screens/issues.dart'; import '../screens/pull_requests.dart'; +import '../utils/utils.dart'; class RepoScreen extends StatefulWidget { final String owner; @@ -22,12 +23,12 @@ class RepoScreen extends StatefulWidget { class _RepoScreenState extends State { Map payload; String readme; - bool loading; + bool loading = true; @override void initState() { super.initState(); - _refresh(); + nextTick(_refresh); } Future queryRepo(BuildContext context) async { diff --git a/lib/screens/user.dart b/lib/screens/user.dart index eccf1b7..85f7fa4 100644 --- a/lib/screens/user.dart +++ b/lib/screens/user.dart @@ -42,13 +42,13 @@ class UserScreen extends StatefulWidget { } class _UserScreenState extends State { - bool loading; + bool loading = true; Map payload = {}; @override void initState() { super.initState(); - _refresh(); + nextTick(_refresh); } Future queryUser(BuildContext context) async { diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 34c6182..494d85d 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -18,6 +18,12 @@ Color convertColor(String cssHex) { return Color(int.parse('ff' + cssHex, radix: 16)); } +void nextTick(Function callback) { + Future.delayed(Duration(seconds: 0)).then((_) { + callback(); + }); +} + class Option { final T value; final Widget widget; @@ -120,7 +126,7 @@ TextSpan createLinkSpan(BuildContext context, String text, Function handle) { return TextSpan( text: text, style: TextStyle( - color: Color(0xff0366d6), + color: Colors.black87, fontWeight: FontWeight.w600, // decoration: TextDecoration.underline, ),