feat: add more event type
This commit is contained in:
parent
7c6c211d1c
commit
9ae00dff6d
|
@ -1,9 +1,8 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_flux/providers/event.dart';
|
||||
import 'package:git_flux/providers/notification.dart';
|
||||
import 'package:git_flux/providers/search.dart';
|
||||
import 'package:git_flux/providers/providers.dart';
|
||||
import 'package:git_flux/ios/main.dart';
|
||||
import 'package:git_flux/screens/screens.dart';
|
||||
|
||||
class App extends StatelessWidget {
|
||||
final isIos = true;
|
||||
|
@ -25,6 +24,7 @@ class App extends StatelessWidget {
|
|||
home: DefaultTextStyle(
|
||||
style: TextStyle(color: Color(0xff24292e)),
|
||||
child: IosHomePage(title: 'GitFlux'),
|
||||
// child: IssueScreen(11609, 'flutter', 'flutter'),
|
||||
),
|
||||
// theme: ThemeData(
|
||||
// textTheme: TextTheme(
|
||||
|
|
|
@ -41,16 +41,6 @@ Future queryPullRequest(int id, String owner, String name) async {
|
|||
login
|
||||
}
|
||||
}
|
||||
... on LabeledEvent {
|
||||
createdAt
|
||||
label {
|
||||
name
|
||||
url
|
||||
}
|
||||
actor {
|
||||
login
|
||||
}
|
||||
}
|
||||
... on MergedEvent {
|
||||
createdAt
|
||||
mergeRefName
|
||||
|
|
|
@ -111,8 +111,63 @@ __typename
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
... on LabeledEvent {
|
||||
createdAt
|
||||
actor {
|
||||
login
|
||||
}
|
||||
label {
|
||||
name
|
||||
color
|
||||
}
|
||||
}
|
||||
|
||||
... on UnlabeledEvent {
|
||||
createdAt
|
||||
actor {
|
||||
login
|
||||
}
|
||||
label {
|
||||
name
|
||||
color
|
||||
}
|
||||
}
|
||||
|
||||
... on MilestonedEvent {
|
||||
createdAt
|
||||
actor {
|
||||
login
|
||||
}
|
||||
milestoneTitle
|
||||
}
|
||||
|
||||
... on LockedEvent {
|
||||
createdAt
|
||||
actor {
|
||||
login
|
||||
}
|
||||
lockReason
|
||||
}
|
||||
... on UnlockedEvent {
|
||||
createdAt
|
||||
actor {
|
||||
login
|
||||
}
|
||||
}
|
||||
... on AssignedEvent {
|
||||
createdAt
|
||||
actor {
|
||||
login
|
||||
}
|
||||
user {
|
||||
login
|
||||
}
|
||||
}
|
||||
''';
|
||||
|
||||
var warning = Text('xxx', style: TextStyle(color: Colors.redAccent));
|
||||
var createWarning =
|
||||
(String text) => Text(text, style: TextStyle(color: Colors.redAccent));
|
||||
var warningSpan =
|
||||
TextSpan(text: 'xxx', style: TextStyle(color: Colors.redAccent));
|
||||
|
|
|
@ -57,7 +57,7 @@ class _IssuePullRequestScreenState extends State<IssuePullRequestScreen> {
|
|||
fontWeight: FontWeight.bold,
|
||||
height: 1.2,
|
||||
)),
|
||||
CommentItem(payload),
|
||||
// CommentItem(payload),
|
||||
// ListView.builder(
|
||||
// shrinkWrap: true,
|
||||
// itemCount: comments.length,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'dart:core';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_flux/utils/utils.dart';
|
||||
|
@ -44,10 +45,28 @@ class TimelineItem extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
TextSpan _buildLabel(item) {
|
||||
var textColor = item['label']['color'] == 'fbca04' ? null : Colors.white;
|
||||
|
||||
return TextSpan(
|
||||
text: item['label']['name'],
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
// https://github.com/flutter/flutter/issues/20430
|
||||
background: Paint()
|
||||
..color = Color(int.parse('ff' + item['label']['color'], radix: 16))
|
||||
// https://stackoverflow.com/a/52592679
|
||||
// ..strokeWidth = 16.5
|
||||
// ..style = PaintingStyle.stroke
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildByType(BuildContext context) {
|
||||
switch (item['__typename']) {
|
||||
case 'IssueComment':
|
||||
return CommentItem(item);
|
||||
return Text('comment');
|
||||
// return CommentItem(item);
|
||||
case 'ReferencedEvent':
|
||||
// TODO: isCrossRepository
|
||||
if (item['commit'] == null) {
|
||||
|
@ -104,6 +123,67 @@ class TimelineItem extends StatelessWidget {
|
|||
item['source']['number'].toString()),
|
||||
item: item,
|
||||
);
|
||||
case 'LabeledEvent':
|
||||
return _buildItem(
|
||||
actor: item['actor']['login'],
|
||||
iconData: Octicons.tag,
|
||||
textSpan: TextSpan(children: [
|
||||
TextSpan(text: ' added '),
|
||||
_buildLabel(item),
|
||||
TextSpan(text: ' label'),
|
||||
]),
|
||||
item: item,
|
||||
);
|
||||
case 'UnlabeledEvent':
|
||||
return _buildItem(
|
||||
actor: item['actor']['login'],
|
||||
iconData: Octicons.tag,
|
||||
textSpan: TextSpan(children: [
|
||||
TextSpan(text: ' removed '),
|
||||
_buildLabel(item),
|
||||
TextSpan(text: ' label'),
|
||||
]),
|
||||
item: item,
|
||||
);
|
||||
case 'MilestonedEvent':
|
||||
return _buildItem(
|
||||
actor: item['actor']['login'],
|
||||
iconData: Octicons.milestone,
|
||||
textSpan: TextSpan(children: [
|
||||
TextSpan(text: ' added this to '),
|
||||
TextSpan(text: item['milestoneTitle']),
|
||||
TextSpan(text: ' milestone'),
|
||||
]),
|
||||
item: item,
|
||||
);
|
||||
case 'LockedEvent':
|
||||
return _buildItem(
|
||||
actor: item['actor']['login'],
|
||||
iconData: Octicons.lock,
|
||||
textSpan: TextSpan(children: [
|
||||
TextSpan(text: ' locked this conversation '),
|
||||
]),
|
||||
item: item,
|
||||
);
|
||||
case 'UnlockedEvent':
|
||||
return _buildItem(
|
||||
actor: item['actor']['login'],
|
||||
iconData: Octicons.key,
|
||||
textSpan: TextSpan(children: [
|
||||
TextSpan(text: ' unlocked this conversation '),
|
||||
]),
|
||||
item: item,
|
||||
);
|
||||
case 'AssignedEvent':
|
||||
return _buildItem(
|
||||
actor: item['actor']['login'],
|
||||
iconData: Octicons.key,
|
||||
textSpan: TextSpan(children: [
|
||||
TextSpan(text: ' assigned this to '),
|
||||
TextSpan(text: item['user']['login'])
|
||||
]),
|
||||
item: item,
|
||||
);
|
||||
|
||||
//
|
||||
case 'ReviewRequestedEvent':
|
||||
|
@ -124,17 +204,6 @@ class TimelineItem extends StatelessWidget {
|
|||
textSpan: _buildReviewText(context, item),
|
||||
item: item,
|
||||
);
|
||||
case 'LabeledEvent':
|
||||
return _buildItem(
|
||||
actor: item['actor']['login'],
|
||||
iconData: Octicons.tag,
|
||||
textSpan: TextSpan(children: [
|
||||
TextSpan(text: ' added the '),
|
||||
TextSpan(text: item['label']['name']),
|
||||
TextSpan(text: 'label'),
|
||||
]),
|
||||
item: item,
|
||||
);
|
||||
case 'MergedEvent':
|
||||
return _buildItem(
|
||||
actor: item['actor']['login'],
|
||||
|
@ -170,7 +239,7 @@ class TimelineItem extends StatelessWidget {
|
|||
item: item,
|
||||
);
|
||||
default:
|
||||
return warning;
|
||||
return createWarning(item['__typename']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue