mirror of
https://github.com/git-touch/git-touch
synced 2024-12-17 10:48:50 +01:00
feat: issues screen info
This commit is contained in:
parent
4ab0e4fb75
commit
bf3f077efa
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/models/settings.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/screens/issues.dart';
|
||||
import 'package:git_touch/screens/repo.dart';
|
||||
import 'package:git_touch/screens/user.dart';
|
||||
import 'package:primer/primer.dart';
|
||||
@ -91,6 +92,7 @@ class _HomeState extends State<Home> {
|
||||
}
|
||||
|
||||
_buildScreen(int index) {
|
||||
// return IssuesScreen(owner: 'flutter', name: 'flutter', isPullRequest: true);
|
||||
// return IssueScreen(number: 29, owner: 'reactjs', name: 'rfcs');
|
||||
// return IssueScreen(
|
||||
// number: 68, owner: 'reactjs', name: 'rfcs', isPullRequest: true);
|
||||
|
@ -1,13 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/settings.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/widgets/avatar.dart';
|
||||
import 'package:primer/primer.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
import '../scaffolds/list.dart';
|
||||
import '../utils/utils.dart';
|
||||
import '../widgets/link.dart';
|
||||
import '../screens/issue.dart';
|
||||
|
||||
class IssuesScreen extends StatefulWidget {
|
||||
class IssuesScreen extends StatelessWidget {
|
||||
final String owner;
|
||||
final String name;
|
||||
final bool isPullRequest;
|
||||
@ -18,23 +21,14 @@ class IssuesScreen extends StatefulWidget {
|
||||
this.isPullRequest = false,
|
||||
});
|
||||
|
||||
@override
|
||||
_IssuesScreenState createState() => _IssuesScreenState();
|
||||
}
|
||||
|
||||
class _IssuesScreenState extends State<IssuesScreen> {
|
||||
String get owner => widget.owner;
|
||||
String get name => widget.name;
|
||||
bool get isPullRequest => widget.isPullRequest;
|
||||
|
||||
Future<ListPayload> _query([String cursor]) async {
|
||||
Future<ListPayload> _query(BuildContext context, [String cursor]) async {
|
||||
var cursorChunk = cursor == null ? '' : ', after: "$cursor"';
|
||||
var resource = isPullRequest ? 'pullRequests' : 'issues';
|
||||
|
||||
var data = await Provider.of<SettingsModel>(context).query('''
|
||||
{
|
||||
repository(owner: "$owner", name: "$name") {
|
||||
$resource(states: OPEN, first: $pageSize$cursorChunk) {
|
||||
$resource(states: OPEN, orderBy: {field: CREATED_AT, direction: DESC}, first: $pageSize$cursorChunk) {
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
endCursor
|
||||
@ -43,6 +37,19 @@ class _IssuesScreenState extends State<IssuesScreen> {
|
||||
number
|
||||
title
|
||||
updatedAt
|
||||
author {
|
||||
login
|
||||
avatarUrl
|
||||
}
|
||||
labels(first: 10) {
|
||||
nodes {
|
||||
name
|
||||
color
|
||||
}
|
||||
}
|
||||
comments {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -59,9 +66,7 @@ class _IssuesScreenState extends State<IssuesScreen> {
|
||||
}
|
||||
|
||||
IconData _buildIconData() {
|
||||
return widget.isPullRequest
|
||||
? Octicons.git_pull_request
|
||||
: Octicons.issue_opened;
|
||||
return isPullRequest ? Octicons.git_pull_request : Octicons.issue_opened;
|
||||
}
|
||||
|
||||
Widget _buildItem(payload) {
|
||||
@ -75,7 +80,7 @@ class _IssuesScreenState extends State<IssuesScreen> {
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
padding: EdgeInsets.all(12),
|
||||
// color: payload.unread ? Colors.white : Colors.black12,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@ -83,15 +88,17 @@ class _IssuesScreenState extends State<IssuesScreen> {
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(right: 8, top: 4),
|
||||
child: Icon(_buildIconData(), color: Palette.green),
|
||||
Avatar(
|
||||
login: payload['author']['login'],
|
||||
url: payload['author']['avatarUrl'],
|
||||
size: 12,
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
children: join(SizedBox(height: 6), [
|
||||
// Text(
|
||||
// owner +
|
||||
// '/' +
|
||||
@ -103,20 +110,59 @@ class _IssuesScreenState extends State<IssuesScreen> {
|
||||
// Padding(padding: EdgeInsets.only(top: 4)),
|
||||
Text(
|
||||
payload['title'],
|
||||
style: TextStyle(fontSize: 15),
|
||||
style: TextStyle(
|
||||
fontSize: 16, color: PrimerColors.gray900),
|
||||
maxLines: 3,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Padding(padding: EdgeInsets.only(top: 6)),
|
||||
Text(
|
||||
payload['updatedAt'],
|
||||
Wrap(
|
||||
spacing: 2,
|
||||
runSpacing: 2,
|
||||
children:
|
||||
(payload['labels']['nodes'] as List).map((label) {
|
||||
final color = convertColor(label['color']);
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: 1, horizontal: 3),
|
||||
decoration: BoxDecoration(
|
||||
color: color,
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(2)),
|
||||
),
|
||||
child: Text(
|
||||
label['name'],
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: PrimerColors.gray900, // FIXME:
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
DefaultTextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
// fontWeight: FontWeight.w300,
|
||||
color: Colors.black54,
|
||||
fontSize: 13, color: PrimerColors.gray700),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Icon(_buildIconData(),
|
||||
color: Palette.green, size: 13),
|
||||
SizedBox(width: 4),
|
||||
Text(timeago.format(
|
||||
DateTime.parse(payload['updatedAt']))),
|
||||
if (payload['comments']['totalCount'] > 0) ...[
|
||||
Expanded(child: SizedBox()),
|
||||
Icon(Octicons.comment,
|
||||
size: 13, color: PrimerColors.gray700),
|
||||
SizedBox(width: 4),
|
||||
Text(payload['comments']['totalCount']
|
||||
.toString())
|
||||
],
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
]),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -138,7 +184,7 @@ class _IssuesScreenState extends State<IssuesScreen> {
|
||||
Widget build(BuildContext context) {
|
||||
return ListScaffold(
|
||||
title: AppBarTitle('Issues of $owner/$name'),
|
||||
onRefresh: () => _query(),
|
||||
onRefresh: () => _query(context),
|
||||
onLoadMore: (cursor) => _query(cursor),
|
||||
itemBuilder: _buildItem,
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user