feat: pushEvent: show commits, click to launch code compare page
This commit is contained in:
parent
2914d0c629
commit
76d8138716
|
@ -159,6 +159,9 @@ class Palette {
|
||||||
static const purple = Color(0xff6f42c1);
|
static const purple = Color(0xff6f42c1);
|
||||||
static const red = Color(0xffcb2431);
|
static const red = Color(0xffcb2431);
|
||||||
static const gray = Color(0xff959da5);
|
static const gray = Color(0xff959da5);
|
||||||
|
static const link = Color(0xff0366d6);
|
||||||
|
static const branchName = Palette.link;
|
||||||
|
static const branchBackground = Color(0xffeaf5ff);
|
||||||
}
|
}
|
||||||
|
|
||||||
// final pageSize = 5;
|
// final pageSize = 5;
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
import '../screens/issue.dart';
|
import '../screens/issue.dart';
|
||||||
import '../screens/user.dart';
|
import '../screens/user.dart';
|
||||||
import 'avatar.dart';
|
import 'avatar.dart';
|
||||||
|
import '../widgets/link.dart';
|
||||||
import '../utils/utils.dart';
|
import '../utils/utils.dart';
|
||||||
|
|
||||||
class EventPayload {
|
class EventPayload {
|
||||||
|
@ -50,6 +52,7 @@ class EventItem extends StatelessWidget {
|
||||||
@required BuildContext context,
|
@required BuildContext context,
|
||||||
@required List<TextSpan> spans,
|
@required List<TextSpan> spans,
|
||||||
String detail,
|
String detail,
|
||||||
|
Widget detailWidget,
|
||||||
IconData iconData = Octicons.octoface,
|
IconData iconData = Octicons.octoface,
|
||||||
WidgetBuilder screenBuilder,
|
WidgetBuilder screenBuilder,
|
||||||
}) {
|
}) {
|
||||||
|
@ -81,22 +84,24 @@ class EventItem extends StatelessWidget {
|
||||||
Icon(iconData, color: Colors.black45, size: 22),
|
Icon(iconData, color: Colors.black45, size: 22),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
detail == null
|
detailWidget == null
|
||||||
? Container()
|
? (detail == null
|
||||||
: Container(
|
? Container()
|
||||||
padding: EdgeInsets.only(left: 46, top: 6),
|
: Container(
|
||||||
child: Text(
|
padding: EdgeInsets.only(left: 46, top: 6),
|
||||||
detail,
|
child: Text(
|
||||||
overflow: TextOverflow.ellipsis,
|
detail,
|
||||||
maxLines: 3,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
maxLines: 3,
|
||||||
color: Colors.black87,
|
style: TextStyle(
|
||||||
fontSize: 14,
|
color: Colors.black87,
|
||||||
height: 1.2,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w300,
|
height: 1.2,
|
||||||
),
|
fontWeight: FontWeight.w300,
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
|
))
|
||||||
|
: detailWidget
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -251,19 +256,63 @@ class EventItem extends StatelessWidget {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case 'PushEvent':
|
case 'PushEvent':
|
||||||
|
int size = event.payload['size'];
|
||||||
|
String ref = event.payload['ref'];
|
||||||
|
var commitText = '$size commit' + (size == 1 ? '' : 's');
|
||||||
|
List commits = event.payload['commits'];
|
||||||
|
|
||||||
return _buildItem(
|
return _buildItem(
|
||||||
context: context,
|
context: context,
|
||||||
spans: [
|
spans: [
|
||||||
TextSpan(text: ' pushed to '),
|
TextSpan(text: ' pushed $commitText to '),
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: event.payload['ref'],
|
text: ref.replaceFirst('refs/heads/', ''),
|
||||||
style: TextStyle(color: CupertinoColors.activeBlue),
|
style: TextStyle(
|
||||||
|
color: Palette.branchName,
|
||||||
|
backgroundColor: Palette.branchBackground),
|
||||||
),
|
),
|
||||||
TextSpan(text: ' at '),
|
TextSpan(text: ' at '),
|
||||||
_buildRepo(context),
|
_buildRepo(context),
|
||||||
TextSpan(text: '')
|
TextSpan(text: '')
|
||||||
],
|
],
|
||||||
iconData: Octicons.repo_push,
|
iconData: Octicons.repo_push,
|
||||||
|
detailWidget: Container(
|
||||||
|
padding: EdgeInsets.only(left: 46, top: 6),
|
||||||
|
child: Link(
|
||||||
|
onTap: () {
|
||||||
|
launch('https://github.com/' +
|
||||||
|
event.repoFullName +
|
||||||
|
'/compare/' +
|
||||||
|
event.payload['before'] +
|
||||||
|
'...' +
|
||||||
|
event.payload['head']);
|
||||||
|
},
|
||||||
|
child: Column(
|
||||||
|
children: commits.map((commit) {
|
||||||
|
return Row(children: <Widget>[
|
||||||
|
Text(
|
||||||
|
(commit['sha'] as String).substring(0, 7),
|
||||||
|
style: TextStyle(
|
||||||
|
color: Palette.link,
|
||||||
|
fontSize: 13,
|
||||||
|
fontFamily: 'Menlo',
|
||||||
|
fontFamilyFallback: ['Menlo', 'Roboto Mono'],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(width: 6),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
commit['message'],
|
||||||
|
style: TextStyle(color: Colors.black54, fontSize: 14),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
maxLines: 1,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
case 'ReleaseEvent':
|
case 'ReleaseEvent':
|
||||||
case 'RepositoryEvent':
|
case 'RepositoryEvent':
|
||||||
|
|
Loading…
Reference in New Issue