diff --git a/lib/screens/news.dart b/lib/screens/news.dart index 09821f3..aa829cc 100644 --- a/lib/screens/news.dart +++ b/lib/screens/news.dart @@ -58,11 +58,11 @@ class NewsScreenState extends State { // return Loading(more: false); if (_events.length == 0) { return Loading(more: false); - } else if (index == _events.length) { - return Loading(more: true); - } else { - return EventItem(_events[index]); } + if (index == _events.length) { + return Loading(more: true); + } + return EventItem(_events[index]); } @override @@ -70,23 +70,25 @@ class NewsScreenState extends State { switch (SettingsProvider.of(context).layout) { case LayoutMap.cupertino: return CupertinoPageScaffold( - child: CustomScrollView( - controller: _controller, - slivers: [ - CupertinoSliverNavigationBar(largeTitle: const Text('News')), - CupertinoSliverRefreshControl(onRefresh: _refresh), - SliverSafeArea( - top: false, - sliver: SliverList( - delegate: SliverChildBuilderDelegate(_buildItems, - childCount: _events.length + 1), + navigationBar: CupertinoNavigationBar(middle: Text('News')), + child: SafeArea( + child: CustomScrollView( + controller: _controller, + slivers: [ + CupertinoSliverRefreshControl(onRefresh: _refresh), + SliverSafeArea( + top: false, + sliver: SliverList( + delegate: SliverChildBuilderDelegate(_buildItems, + childCount: _events.length + 1), + ), + // sliver: SliverList( + // delegate: + // SliverChildBuilderDelegate(_buildItems, childCount: 1), + // ), ), - // sliver: SliverList( - // delegate: - // SliverChildBuilderDelegate(_buildItems, childCount: 1), - // ), - ), - ], + ], + ), ), ); default: diff --git a/lib/screens/notifications.dart b/lib/screens/notifications.dart index 52e6a7a..9eb0847 100644 --- a/lib/screens/notifications.dart +++ b/lib/screens/notifications.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart' hide Notification; import 'package:flutter/cupertino.dart' hide Notification; import '../providers/settings.dart'; import '../providers/notification.dart'; -import '../screens/screens.dart'; +// import '../screens/screens.dart'; import '../widgets/notification_item.dart'; import '../widgets/loading.dart'; import '../utils/utils.dart'; @@ -33,26 +33,33 @@ class NotificationScreenState extends State { } Widget _buildGroupItem(BuildContext context, int index) { + if (loading) { + return Loading(more: false); + } + var group = groups[index]; - return Container( - // padding: EdgeInsets.all(10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Container( - padding: EdgeInsets.only(top: 10, left: 4, bottom: 4), - color: CupertinoColors.extraLightBackgroundGray, - child: Text( - group.fullName, - style: TextStyle(color: CupertinoColors.black), + return Padding( + padding: EdgeInsets.all(8), + child: Container( + decoration: BoxDecoration(border: Border.all(color: Colors.black12)), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Container( + padding: EdgeInsets.all(4), + color: Colors.black12, + child: Text( + group.fullName, + style: TextStyle(color: Colors.black, fontSize: 15), + ), ), - ), - Column( - children: group.items - .map((item) => NotificationItem(item: item)) - .toList()) - ], + Column( + children: group.items + .map((item) => NotificationItem(item: item)) + .toList()) + ], + ), ), ); } @@ -116,24 +123,13 @@ class NotificationScreenState extends State { top: false, sliver: SliverList( delegate: SliverChildBuilderDelegate( - (BuildContext context, int index) { - if (index == groups.length) { - return Loading(more: true); - } else { - return _buildGroupItem(context, index); - } - }, - childCount: groups.length + 1, + _buildGroupItem, + childCount: groups.length, ), ), ), ]), ), - // ListView.builder( - // shrinkWrap: true, - // itemCount: groups.length, - // itemBuilder: _buildGroupItem, - // ), ); default: return Scaffold( diff --git a/lib/screens/search.dart b/lib/screens/search.dart index b6b41cf..2820c06 100644 --- a/lib/screens/search.dart +++ b/lib/screens/search.dart @@ -1,66 +1,69 @@ +import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; -import '../providers/search.dart'; +import '../providers/settings.dart'; + +class SearchScreen extends StatefulWidget { + @override + _SearchScreenState createState() => _SearchScreenState(); +} + +class _SearchScreenState extends State { + int active = 0; + List users = []; -class SearchScreen extends StatelessWidget { @override Widget build(BuildContext context) { - SearchBloc bloc = SearchProvider.of(context); - - return SafeArea( - child: Column( - children: [ - CupertinoTextField( - placeholder: 'Type to search', - onChanged: (String value) { - bloc.keywordUpdate.add(value); - }, - onSubmitted: (String value) { - bloc.submit.add(value); - }, + switch (SettingsProvider.of(context).layout) { + case LayoutMap.cupertino: + return CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + middle: CupertinoTextField( + placeholder: 'Type to search', + onChanged: (String value) { + // + }, + onSubmitted: (String value) { + // + }, + ), ), - CupertinoSegmentedControl( - children: {0: Text('Repos'), 1: Text('Users')}, - onValueChanged: (int value) { - bloc.activeUpdate.add(value); - }, + child: SafeArea( + child: Column( + children: [ + CupertinoSegmentedControl( + children: {0: Text('Repos'), 1: Text('Users')}, + onValueChanged: (int value) { + // + }, + ), + ListView.builder( + shrinkWrap: true, + itemCount: users.length, + itemBuilder: (context, index) { + var user = users[index]; + return Row( + children: [ + Image.network( + user['avatarUrl'], + ), + Text(user['login']) + ], + ); + }, + ), + ], + ), ), - StreamBuilder( - stream: bloc.loading, - builder: (context, snapshot) { - if (snapshot.data == null || snapshot.data) { - return CupertinoActivityIndicator(); - } + ); - return StreamBuilder( - stream: bloc.users, - builder: (context, snapshot) { - var users = snapshot.data; - if (users == null) return Text(''); - if (users.length == 0) { - return Text("No result"); - } - - return ListView.builder( - shrinkWrap: true, - itemCount: users.length, - itemBuilder: (context, index) { - var user = users[index]; - return Row( - children: [ - Image.network( - user['avatarUrl'], - ), - Text(user['login']) - ], - ); - }, - ); - }, - ); - }, + default: + return Scaffold( + appBar: AppBar(title: Text('Search')), + body: ListView.builder( + itemCount: users.length, + itemBuilder: (context, index) => Text(''), ), - ], - ), - ); + ); + } } } diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 31c1608..ab0b946 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -9,7 +9,11 @@ export 'timeago.dart'; TextSpan createLinkSpan(BuildContext context, String text, Function handle) { return TextSpan( text: text, - style: TextStyle(color: Color(0xff0366d6)), + style: TextStyle( + color: Color(0xff0366d6), + fontWeight: FontWeight.w600, + decoration: TextDecoration.underline, + ), recognizer: TapGestureRecognizer() ..onTap = () { Navigator.of(context).push( diff --git a/lib/widgets/avatar.dart b/lib/widgets/avatar.dart index 48c184b..a35abb3 100644 --- a/lib/widgets/avatar.dart +++ b/lib/widgets/avatar.dart @@ -13,9 +13,8 @@ class Avatar extends StatelessWidget { Widget build(BuildContext context) { return Link( onTap: () { - Navigator.of(context).push( - CupertinoPageRoute(builder: (_) => UserScreen(login)), - ); + Navigator.of(context) + .push(CupertinoPageRoute(builder: (_) => UserScreen(login))); }, child: CircleAvatar( backgroundColor: Colors.transparent, diff --git a/lib/widgets/comment_item.dart b/lib/widgets/comment_item.dart index 8b0dac2..be724e1 100644 --- a/lib/widgets/comment_item.dart +++ b/lib/widgets/comment_item.dart @@ -26,7 +26,10 @@ class CommentItem extends StatelessWidget { ]), Padding( padding: const EdgeInsets.only(left: 20, top: 10), - child: MarkdownBody(data: item['body']), + child: MarkdownBody( + data: item['body'], + // styleSheet: MarkdownStyleSheet(code: TextStyle(fontSize: 14)), + ), ), ]); } diff --git a/lib/widgets/event_item.dart b/lib/widgets/event_item.dart index 32f893b..8bec351 100644 --- a/lib/widgets/event_item.dart +++ b/lib/widgets/event_item.dart @@ -1,6 +1,7 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; +import 'package:flutter/services.dart'; import '../screens/screens.dart'; import '../utils/utils.dart'; import '../widgets/widgets.dart'; @@ -82,7 +83,7 @@ class EventItem extends StatelessWidget { } } - String _buildOriginalComment() { + String _buildDetail() { switch (event.type) { case 'IssueCommentEvent': return event.payload['comment']['body']; @@ -97,27 +98,6 @@ class EventItem extends StatelessWidget { } } - String _buildComment() { - return _buildOriginalComment(); - } - - TextSpan _buildLink(BuildContext context, String text, Function handle) { - return TextSpan( - text: text, - style: TextStyle(color: Color(0xff0366d6)), - recognizer: TapGestureRecognizer() - ..onTap = () { - Navigator.of(context).push( - CupertinoPageRoute( - builder: (context) { - return handle(); - }, - ), - ); - }, - ); - } - TextSpan _buildRepo(BuildContext context) { String name = event.repo.name; var arr = name.split('/'); @@ -128,14 +108,14 @@ class EventItem extends StatelessWidget { int id = event.payload['issue']['number']; String name = event.repo.name; var arr = name.split('/'); - return _buildLink( + return createLinkSpan( context, '#' + id.toString(), () => IssueScreen(id, arr[0], arr[1])); } TextSpan _buildPullRequest(BuildContext context, int id) { String name = event.repo.name; var arr = name.split('/'); - return _buildLink(context, '#' + id.toString(), + return createLinkSpan(context, '#' + id.toString(), () => PullRequestScreen(id, arr[0], arr[1])); } @@ -159,46 +139,57 @@ class EventItem extends StatelessWidget { } @override - build(context) { - return Link( - onTap: () {}, - child: Container( - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - border: Border( - bottom: - BorderSide(color: CupertinoColors.lightBackgroundGray))), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Avatar(event.actor.login, event.actor.avatarUrl), - Padding(padding: EdgeInsets.only(left: 10)), - Expanded( - child: RichText( - text: TextSpan( - style: TextStyle(color: Color(0xff24292e), height: 1.2), - children: [ - _buildLink(context, event.actor.login, - () => UserScreen(event.actor.login)), - _buildEvent(context), - ], + build(BuildContext context) { + return Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + border: Border(bottom: BorderSide(color: Colors.black12))), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Avatar(event.actor.login, event.actor.avatarUrl), + Padding(padding: EdgeInsets.only(left: 10)), + Expanded( + child: RichText( + text: TextSpan( + style: TextStyle( + color: Colors.black, + height: 1.3, + fontSize: 15, ), + children: [ + createLinkSpan(context, event.actor.login, + () => UserScreen(event.actor.login)), + _buildEvent(context), + ], ), ), - Padding(padding: EdgeInsets.only(left: 10)), - Icon(_buildIconData(context), - color: CupertinoColors.inactiveGray), - ], + ), + Padding(padding: EdgeInsets.only(left: 8)), + Icon( + _buildIconData(context), + color: CupertinoColors.inactiveGray, + size: 22, + ), + ], + ), + Container( + padding: EdgeInsets.only(left: 46, top: 6), + child: Text( + _buildDetail(), + overflow: TextOverflow.ellipsis, + maxLines: 3, + style: TextStyle( + color: Colors.black87, + fontSize: 15, + height: 1.2, + fontWeight: FontWeight.w300, + ), ), - Container( - padding: EdgeInsets.only(left: 42, top: 8), - child: Text(_buildComment(), - overflow: TextOverflow.ellipsis, - style: TextStyle(color: Color(0xffaaaaaa)))) - ], - ), + ) + ], ), ); } diff --git a/lib/widgets/issue_pull_request.dart b/lib/widgets/issue_pull_request.dart index 06773cd..00f9c6f 100644 --- a/lib/widgets/issue_pull_request.dart +++ b/lib/widgets/issue_pull_request.dart @@ -40,7 +40,7 @@ class _IssuePullRequestScreenState extends State { Widget _buildBody(BuildContext context) { if (payload == null) { - return Loading(); + return Loading(more: false); } List items = payload['timeline']['nodes']; diff --git a/lib/widgets/notification_item.dart b/lib/widgets/notification_item.dart index 0600116..48d9d31 100644 --- a/lib/widgets/notification_item.dart +++ b/lib/widgets/notification_item.dart @@ -46,48 +46,50 @@ class NotificationItem extends StatelessWidget { ); }, child: Container( + decoration: BoxDecoration( + border: Border(bottom: BorderSide(color: Colors.black12)), + ), child: Row( children: [ Container( padding: EdgeInsets.symmetric(horizontal: 8), child: Icon( _buildIconData(item.subject.type), - // color: CupertinoColors.inactiveGray, + color: Colors.black45, ), ), Expanded( - child: Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - // color: Colors.grey, - ))), - child: Row( - children: [ - Expanded( - child: Container( - padding: EdgeInsets.symmetric(vertical: 8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(item.subject.title, - style: TextStyle(height: 1)), - Padding(padding: EdgeInsets.only(top: 4)), - Text(TimeAgo.format(item.updatedAt), - style: TextStyle(fontSize: 12)) - ], - ), + child: Row( + children: [ + Expanded( + child: Container( + padding: EdgeInsets.symmetric(vertical: 8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + item.subject.title, + style: TextStyle(fontSize: 15), + maxLines: 3, + overflow: TextOverflow.ellipsis, + ), + Padding(padding: EdgeInsets.only(top: 8)), + Text( + TimeAgo.format(item.updatedAt), + style: TextStyle( + fontSize: 12, + color: Colors.black87, + ), + ) + ], ), ), - Container( - padding: EdgeInsets.symmetric(horizontal: 8), - child: Icon( - Octicons.check, - // color: CupertinoColors.inactiveGray, - ), - ), - ], - ), + ), + Container( + padding: EdgeInsets.symmetric(horizontal: 8), + child: Icon(Octicons.check, color: Colors.black45), + ), + ], ), ), ], diff --git a/lib/widgets/timeline_item.dart b/lib/widgets/timeline_item.dart index fbc7ecf..4c2b98e 100644 --- a/lib/widgets/timeline_item.dart +++ b/lib/widgets/timeline_item.dart @@ -65,8 +65,8 @@ class TimelineItem extends StatelessWidget { Widget _buildByType(BuildContext context) { switch (item['__typename']) { case 'IssueComment': - return Text('comment'); - // return CommentItem(item); + // return Text('comment'); + return CommentItem(item); case 'ReferencedEvent': // TODO: isCrossRepository if (item['commit'] == null) {