Skip to content

Commit

Permalink
fix: widget span for branch name
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Sep 25, 2019
1 parent bc068c2 commit ca11d0f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
33 changes: 31 additions & 2 deletions lib/utils/utils.dart
Expand Up @@ -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:

Expand Down Expand Up @@ -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,
),
),
);
}
}
17 changes: 5 additions & 12 deletions lib/widgets/event_item.dart
Expand Up @@ -56,7 +56,7 @@ class EventItem extends StatelessWidget {

Widget _buildItem({
@required BuildContext context,
@required List<TextSpan> spans,
@required List<InlineSpan> spans,
String detail,
Widget detailWidget,
IconData iconData = Octicons.octoface,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ca11d0f

Please sign in to comment.