2018-07-05 16:08:19 +02:00
|
|
|
import '../utils.dart';
|
2019-01-22 12:41:12 +01:00
|
|
|
import '../models/event.dart';
|
2018-07-05 16:08:19 +02:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/gestures.dart';
|
|
|
|
// import '../issue.dart';
|
|
|
|
// import '../user.dart';
|
|
|
|
|
|
|
|
// class Strong extends StatelessWidget {
|
|
|
|
// final String text;
|
|
|
|
|
|
|
|
// @override
|
|
|
|
// build(context) {
|
|
|
|
// return TextSpan(
|
|
|
|
// text: text,
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontWeight: FontWeight.bold,
|
|
|
|
// color: Color(0xff24292e),
|
|
|
|
// ),
|
|
|
|
// // recognizer: recognizer,
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
class _Avatar extends StatelessWidget {
|
|
|
|
final String url;
|
|
|
|
_Avatar(this.url);
|
|
|
|
|
|
|
|
@override
|
|
|
|
build(context) {
|
|
|
|
return CircleAvatar(
|
|
|
|
backgroundImage: NetworkImage(url),
|
|
|
|
radius: 24.0,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class EventItem extends StatelessWidget {
|
|
|
|
final Event event;
|
|
|
|
EventItem(this.event);
|
|
|
|
|
2019-01-22 12:41:12 +01:00
|
|
|
Widget getEventItemByType(BuildContext context) {
|
2018-07-05 16:08:19 +02:00
|
|
|
switch (event.type) {
|
|
|
|
case 'IssuesEvent':
|
2019-01-22 12:41:12 +01:00
|
|
|
return RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
style: TextStyle(color: CupertinoColors.black),
|
|
|
|
children: [
|
|
|
|
_user(event, context),
|
|
|
|
TextSpan(text: ' ${event.payload['action']} issue '),
|
|
|
|
_strong(event.repo.name),
|
|
|
|
TextSpan(
|
|
|
|
text: '#' + event.payload['issue']['number'].toString(),
|
|
|
|
),
|
|
|
|
TextSpan(
|
|
|
|
text: event.payload['issue']['title'],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
2018-07-05 16:08:19 +02:00
|
|
|
case 'PushEvent':
|
2019-01-22 12:41:12 +01:00
|
|
|
return RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
style: TextStyle(color: CupertinoColors.black),
|
|
|
|
children: [
|
|
|
|
_user(event, context),
|
|
|
|
TextSpan(text: ' pushed to '),
|
|
|
|
TextSpan(
|
|
|
|
text: event.payload['ref'],
|
|
|
|
style: TextStyle(color: CupertinoColors.activeBlue),
|
|
|
|
),
|
|
|
|
TextSpan(text: ' in '),
|
|
|
|
_strong(event.repo.name),
|
|
|
|
TextSpan(text: '')
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
2018-07-05 16:08:19 +02:00
|
|
|
case 'PullRequestEvent':
|
2019-01-22 12:41:12 +01:00
|
|
|
return RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
style: TextStyle(color: CupertinoColors.black),
|
|
|
|
children: [
|
|
|
|
_user(event, context),
|
|
|
|
TextSpan(text: ' ${event.payload['action']} pull request '),
|
|
|
|
_strong(event.repo.name),
|
|
|
|
TextSpan(text: '#' + event.payload['number'].toString()),
|
|
|
|
TextSpan(text: event.payload['pull_request']['title'])
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
2018-07-05 16:08:19 +02:00
|
|
|
case 'WatchEvent':
|
2019-01-22 12:41:12 +01:00
|
|
|
return RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
style: TextStyle(color: CupertinoColors.black),
|
|
|
|
children: [
|
|
|
|
_user(event, context),
|
|
|
|
TextSpan(text: ' ${event.payload['action']} '),
|
|
|
|
_strong(event.repo.name),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
2018-07-05 16:08:19 +02:00
|
|
|
default:
|
2019-01-22 12:41:12 +01:00
|
|
|
return Text(
|
|
|
|
'Not implement yet',
|
|
|
|
style: TextStyle(color: CupertinoColors.destructiveRed),
|
|
|
|
);
|
2018-07-05 16:08:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
build(context) {
|
2019-01-22 12:41:12 +01:00
|
|
|
return Container(
|
|
|
|
padding: EdgeInsets.only(top: 16.0),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
top: BorderSide(width: 1.0, color: Color(0xFFFFFFFFFF)),
|
|
|
|
left: BorderSide(width: 1.0, color: Color(0xFFFFFFFFFF)),
|
|
|
|
right: BorderSide(width: 1.0, color: Color(0xFFFF000000)),
|
|
|
|
bottom: BorderSide(width: 1.0, color: Color(0xFFFF000000)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
_Avatar(event.actor.avatarUrl),
|
|
|
|
Expanded(child: getEventItemByType(context)),
|
|
|
|
],
|
|
|
|
),
|
2018-07-05 16:08:19 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TextSpan _strong(String text, [GestureRecognizer recognizer]) {
|
|
|
|
return TextSpan(
|
|
|
|
text: text,
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Color(0xff24292e),
|
|
|
|
),
|
|
|
|
recognizer: recognizer,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
TextSpan _user(Event event, context) {
|
|
|
|
return _strong(
|
2019-01-22 12:41:12 +01:00
|
|
|
event.actor.login,
|
2018-07-05 16:08:19 +02:00
|
|
|
// TapGestureRecognizer()
|
|
|
|
// ..onTap = () {
|
|
|
|
// Navigator.of(context).push(
|
|
|
|
// CupertinoPageRoute(
|
|
|
|
// builder: (context) {
|
|
|
|
// return IosUserPage(event.actor, event.avatar);
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
// );
|
|
|
|
// },
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
class IssuesEvent extends StatelessWidget {
|
|
|
|
final Event event;
|
|
|
|
IssuesEvent(this.event);
|
|
|
|
|
|
|
|
@override
|
|
|
|
build(context) {
|
|
|
|
return RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
style: TextStyle(color: CupertinoColors.black),
|
|
|
|
children: [
|
|
|
|
_user(event, context),
|
|
|
|
TextSpan(text: ' ${event.payload['action']} issue '),
|
2019-01-22 12:41:12 +01:00
|
|
|
_strong(event.repo.name),
|
2018-07-05 16:08:19 +02:00
|
|
|
TextSpan(
|
|
|
|
text: '#' + event.payload['issue']['number'].toString(),
|
|
|
|
),
|
|
|
|
TextSpan(
|
|
|
|
text: event.payload['issue']['title'],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class IssueCommentEvent extends StatelessWidget {
|
|
|
|
final Event event;
|
|
|
|
IssueCommentEvent(this.event);
|
|
|
|
|
|
|
|
@override
|
|
|
|
build(context) {
|
|
|
|
return RichText(
|
|
|
|
text: TextSpan(
|
|
|
|
style: TextStyle(color: CupertinoColors.black),
|
|
|
|
children: [
|
|
|
|
_user(event, context),
|
|
|
|
TextSpan(text: ' commented on issue '),
|
2019-01-22 12:41:12 +01:00
|
|
|
_strong(event.repo.name),
|
2018-07-05 16:08:19 +02:00
|
|
|
TextSpan(text: '#' + event.payload['issue']['number'].toString()),
|
|
|
|
TextSpan(text: event.payload['comment']['body'])
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|