fix: widget span for branch name

This commit is contained in:
Rongjian Zhang 2019-09-25 13:34:13 +08:00
parent bc068c20ee
commit ca11d0f0d5
2 changed files with 36 additions and 14 deletions

View File

@ -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,
),
),
);
}
}

View File

@ -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,
@ -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)