diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 909bb46..121f300 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -8,8 +8,7 @@ import 'package:git_touch/screens/user.dart'; import 'package:intl/intl.dart'; import 'package:primer/primer.dart'; import 'package:provider/provider.dart'; -export 'package:flutter_vector_icons/flutter_vector_icons.dart' hide Octicons; -export 'package:primer/primer.dart' show Octicons; +export 'package:flutter_vector_icons/flutter_vector_icons.dart'; final monospaceFont = Platform.isIOS ? 'Menlo' : 'monospace'; // FIXME: @@ -164,3 +163,33 @@ String getBranchQueryKey(String branch, {bool withParams = false}) { if (branch == null) return 'defaultBranchRef'; return 'ref' + (withParams ? '(qualifiedName: "$branch")' : ''); } + +// TODO: Primer +class PrimerBranchName extends StatelessWidget { + final String name; + + PrimerBranchName(this.name); + + static const branchBgColor = Color(0xffeaf5ff); + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.symmetric(vertical: 2, horizontal: 4), + height: 16, + decoration: BoxDecoration( + color: branchBgColor, + borderRadius: BorderRadius.all(Radius.circular(3)), + ), + child: Text( + name, + style: TextStyle( + color: PrimerColors.blue500, + fontSize: 12, + height: 1, + fontFamily: monospaceFont, + ), + ), + ); + } +} diff --git a/lib/widgets/event_item.dart b/lib/widgets/event_item.dart index d9ddfcc..5a038fc 100644 --- a/lib/widgets/event_item.dart +++ b/lib/widgets/event_item.dart @@ -56,7 +56,7 @@ class EventItem extends StatelessWidget { Widget _buildItem({ @required BuildContext context, - @required List spans, + @required List spans, String detail, Widget detailWidget, IconData iconData = Octicons.octoface, @@ -287,22 +287,15 @@ class EventItem extends StatelessWidget { ), ); case 'PushEvent': - String ref = event.payload['ref']; - List commits = event.payload['commits']; + var ref = event.payload['ref'] as String; + var commits = event.payload['commits'] as List; return _buildItem( context: context, spans: [ TextSpan(text: ' pushed to '), - // TODO: Use primer widgets - TextSpan( - text: ref.replaceFirst('refs/heads/', ''), - style: TextStyle( - color: PrimerColors.blue500, - fontSize: 14, - backgroundColor: Color(0xffeaf5ff), - fontFamily: monospaceFont, - ), + WidgetSpan( + child: PrimerBranchName(ref.replaceFirst('refs/heads/', '')), ), TextSpan(text: ' at '), _buildRepo(context)