git-touch-android-ios-app/lib/widgets/notification_item.dart

96 lines
2.7 KiB
Dart
Raw Normal View History

2019-01-30 07:46:18 +01:00
import 'dart:core';
import 'package:flutter/material.dart' hide Notification;
import 'package:flutter/cupertino.dart' hide Notification;
2019-01-31 07:37:25 +01:00
import '../utils/utils.dart';
import 'link.dart';
2019-01-30 07:46:18 +01:00
class NotificationItem extends StatelessWidget {
const NotificationItem({
Key key,
@required this.item,
}) : super(key: key);
final Notification item;
Widget _buildRoute(Notification item) {
String type = item.subject.type;
switch (type) {
case 'Issue':
case 'PullRequest':
// return IssueScreen(item.repository.);
default:
// throw new Exception('Unhandled notification type: $type');
return Text('test');
2019-01-30 07:46:18 +01:00
}
}
IconData _buildIconData(String type) {
switch (type) {
case 'Issue':
return Octicons.issue_opened;
// color: Color.fromRGBO(0x28, 0xa7, 0x45, 1),
case 'PullRequest':
return Octicons.git_pull_request;
// color: Color.fromRGBO(0x6f, 0x42, 0xc1, 1),
default:
return Octicons.person;
2019-01-30 07:46:18 +01:00
}
}
@override
Widget build(BuildContext context) {
2019-01-31 07:37:25 +01:00
return Link(
onTap: () {
Navigator.of(context).push(
CupertinoPageRoute(builder: (context) => _buildRoute(item)),
);
},
child: Row(
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(horizontal: 8),
child: Icon(
_buildIconData(item.subject.type),
color: Colors.black45,
2019-01-31 07:37:25 +01:00
),
),
Expanded(
child: Row(
children: <Widget>[
Expanded(
child: Container(
padding: EdgeInsets.symmetric(vertical: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
item.subject.title,
style: TextStyle(fontSize: 15),
maxLines: 3,
overflow: TextOverflow.ellipsis,
),
Padding(padding: EdgeInsets.only(top: 8)),
Text(
TimeAgo.format(item.updatedAt),
style: TextStyle(
fontSize: 12,
color: Colors.black87,
2019-02-02 17:28:51 +01:00
),
)
],
2019-01-31 07:37:25 +01:00
),
2019-02-02 17:28:51 +01:00
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 8),
child: Icon(Octicons.check, color: Colors.black45),
),
],
2019-01-31 07:37:25 +01:00
),
),
],
2019-01-30 07:46:18 +01:00
),
);
}
}