mirror of
https://github.com/git-touch/git-touch
synced 2025-03-05 19:57:42 +01:00
feat: add users and issues search
This commit is contained in:
parent
51585f9e55
commit
cefd0bcb5c
@ -2,13 +2,9 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:git_touch/models/settings.dart';
|
import 'package:git_touch/models/settings.dart';
|
||||||
import 'package:git_touch/scaffolds/list_stateful.dart';
|
import 'package:git_touch/scaffolds/list_stateful.dart';
|
||||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||||
import 'package:git_touch/widgets/avatar.dart';
|
import 'package:git_touch/widgets/issue_item.dart';
|
||||||
import 'package:primer/primer.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:timeago/timeago.dart' as timeago;
|
|
||||||
import '../utils/utils.dart';
|
import '../utils/utils.dart';
|
||||||
import '../widgets/link.dart';
|
|
||||||
import '../screens/issue.dart';
|
|
||||||
|
|
||||||
class IssuesScreen extends StatelessWidget {
|
class IssuesScreen extends StatelessWidget {
|
||||||
final String owner;
|
final String owner;
|
||||||
@ -34,22 +30,7 @@ class IssuesScreen extends StatelessWidget {
|
|||||||
endCursor
|
endCursor
|
||||||
}
|
}
|
||||||
nodes {
|
nodes {
|
||||||
number
|
$issueGqlChunk
|
||||||
title
|
|
||||||
updatedAt
|
|
||||||
author {
|
|
||||||
login
|
|
||||||
avatarUrl
|
|
||||||
}
|
|
||||||
labels(first: 10) {
|
|
||||||
nodes {
|
|
||||||
name
|
|
||||||
color
|
|
||||||
}
|
|
||||||
}
|
|
||||||
comments {
|
|
||||||
totalCount
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,130 +46,6 @@ class IssuesScreen extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
IconData _buildIconData() {
|
|
||||||
return isPullRequest ? Octicons.git_pull_request : Octicons.issue_opened;
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildItem(payload) {
|
|
||||||
return Link(
|
|
||||||
screenBuilder: (context) {
|
|
||||||
return IssueScreen(
|
|
||||||
number: payload['number'],
|
|
||||||
owner: owner,
|
|
||||||
name: name,
|
|
||||||
isPullRequest: isPullRequest,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
padding: EdgeInsets.all(12),
|
|
||||||
// color: payload.unread ? Colors.white : Colors.black12,
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
Icon(_buildIconData(), color: Palette.green, size: 16),
|
|
||||||
SizedBox(width: 6),
|
|
||||||
Expanded(
|
|
||||||
child: Container(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: join(SizedBox(height: 8), [
|
|
||||||
// Text(
|
|
||||||
// owner +
|
|
||||||
// '/' +
|
|
||||||
// name +
|
|
||||||
// ' #' +
|
|
||||||
// payload['number'].toString(),
|
|
||||||
// style: TextStyle(fontSize: 13, color: Colors.black54),
|
|
||||||
// ),
|
|
||||||
// Padding(padding: EdgeInsets.only(top: 4)),
|
|
||||||
Text(
|
|
||||||
payload['title'] + ' (#${payload['number']})',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
color: PrimerColors.gray900,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if ((payload['labels']['nodes'] as List).isNotEmpty)
|
|
||||||
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: getFontColorByBrightness(color),
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
),
|
|
||||||
DefaultTextStyle(
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13, color: PrimerColors.gray700),
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
// FIXME: Deleted user
|
|
||||||
if (payload['author'] != null) ...[
|
|
||||||
Avatar(
|
|
||||||
login: payload['author']['login'],
|
|
||||||
url: payload['author']['avatarUrl'],
|
|
||||||
size: 8,
|
|
||||||
),
|
|
||||||
SizedBox(width: 4),
|
|
||||||
Text(
|
|
||||||
payload['author']['login'],
|
|
||||||
style: TextStyle(fontWeight: FontWeight.w500),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
Text(' opened ' +
|
|
||||||
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(numberFormat
|
|
||||||
.format(payload['comments']['totalCount']))
|
|
||||||
],
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// Column(
|
|
||||||
// children: <Widget>[
|
|
||||||
// Icon(Octicons.check, color: Colors.black45),
|
|
||||||
// Icon(Octicons.unmute, color: Colors.black45)
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListStatefulScaffold(
|
return ListStatefulScaffold(
|
||||||
@ -196,7 +53,8 @@ class IssuesScreen extends StatelessWidget {
|
|||||||
(isPullRequest ? 'Pull requests' : 'Issues') + ' of $owner/$name'),
|
(isPullRequest ? 'Pull requests' : 'Issues') + ' of $owner/$name'),
|
||||||
onRefresh: () => _query(context),
|
onRefresh: () => _query(context),
|
||||||
onLoadMore: (cursor) => _query(cursor),
|
onLoadMore: (cursor) => _query(cursor),
|
||||||
itemBuilder: _buildItem,
|
itemBuilder: (payload) =>
|
||||||
|
IssueItem(payload: payload, isPullRequest: isPullRequest),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:git_touch/models/theme.dart';
|
import 'package:git_touch/models/theme.dart';
|
||||||
import 'package:git_touch/scaffolds/single.dart';
|
import 'package:git_touch/scaffolds/tab.dart';
|
||||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||||
|
import 'package:git_touch/widgets/issue_item.dart';
|
||||||
|
import 'package:git_touch/widgets/user_item.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:git_touch/models/settings.dart';
|
import 'package:git_touch/models/settings.dart';
|
||||||
import '../utils/utils.dart';
|
import '../utils/utils.dart';
|
||||||
import 'package:git_touch/widgets/repository_item.dart';
|
import 'package:git_touch/widgets/repository_item.dart';
|
||||||
import '../widgets/loading.dart';
|
|
||||||
|
|
||||||
class SearchScreen extends StatefulWidget {
|
class SearchScreen extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
@ -15,31 +16,77 @@ class SearchScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SearchScreenState extends State<SearchScreen> {
|
class _SearchScreenState extends State<SearchScreen> {
|
||||||
int active = 0;
|
int _activeTab = 0;
|
||||||
bool loading = false;
|
bool _loading = false;
|
||||||
List repos = [];
|
List<List> _payloads = [[], [], []];
|
||||||
|
|
||||||
_onSubmitted(String value) async {
|
TextEditingController _controller;
|
||||||
|
|
||||||
|
String get _keyword => _controller.text?.trim() ?? '';
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_controller = TextEditingController();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _query() async {
|
||||||
|
if (_loading || _keyword.isEmpty) return;
|
||||||
|
|
||||||
|
var keyword = _controller.text;
|
||||||
setState(() {
|
setState(() {
|
||||||
loading = true;
|
_loading = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
// TODO: search other types
|
|
||||||
var data = await Provider.of<SettingsModel>(context).query('''
|
var data = await Provider.of<SettingsModel>(context).query('''
|
||||||
{
|
{
|
||||||
search(first: $pageSize, type: REPOSITORY, query: "$value") {
|
repository: search(first: $pageSize, type: REPOSITORY, query: "$keyword") {
|
||||||
nodes {
|
nodes {
|
||||||
... on Repository {
|
... on Repository {
|
||||||
$repoChunk
|
$repoChunk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
user: search(first: $pageSize, type: USER, query: "$keyword") {
|
||||||
|
nodes {
|
||||||
|
... on Organization {
|
||||||
|
__typename
|
||||||
|
name
|
||||||
|
avatarUrl
|
||||||
|
bio: description
|
||||||
|
login
|
||||||
|
}
|
||||||
|
... on User {
|
||||||
|
$userGqlChunk
|
||||||
|
login
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
issue: search(first: $pageSize, type: ISSUE, query: "$keyword") {
|
||||||
|
nodes {
|
||||||
|
... on PullRequest {
|
||||||
|
__typename
|
||||||
|
$issueGqlChunk
|
||||||
|
}
|
||||||
|
... on Issue {
|
||||||
|
$issueGqlChunk
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
''');
|
''');
|
||||||
repos = data['search']['nodes'];
|
_payloads[0] = data['repository']['nodes'];
|
||||||
|
_payloads[1] = data['user']['nodes'];
|
||||||
|
_payloads[2] = data['issue']['nodes'];
|
||||||
} finally {
|
} finally {
|
||||||
setState(() {
|
setState(() {
|
||||||
loading = false;
|
_loading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,30 +95,57 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||||||
switch (Provider.of<ThemeModel>(context).theme) {
|
switch (Provider.of<ThemeModel>(context).theme) {
|
||||||
case AppThemeType.cupertino:
|
case AppThemeType.cupertino:
|
||||||
return CupertinoTextField(
|
return CupertinoTextField(
|
||||||
|
controller: _controller,
|
||||||
// padding: EdgeInsets.all(10),
|
// padding: EdgeInsets.all(10),
|
||||||
placeholder: 'Type to search',
|
placeholder: 'Type to search',
|
||||||
clearButtonMode: OverlayVisibilityMode.editing,
|
clearButtonMode: OverlayVisibilityMode.editing,
|
||||||
onSubmitted: _onSubmitted,
|
onSubmitted: (_) => _query(),
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return TextField(onSubmitted: _onSubmitted);
|
return TextField(
|
||||||
|
onSubmitted: (_) => _query(),
|
||||||
|
controller: _controller,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildItem(data) {
|
||||||
|
switch (_activeTab) {
|
||||||
|
case 0:
|
||||||
|
return RepositoryItem(data);
|
||||||
|
case 1:
|
||||||
|
return UserItem.fromData(
|
||||||
|
data,
|
||||||
|
isOrganization: data['__typename'] == 'Organization',
|
||||||
|
);
|
||||||
|
case 2:
|
||||||
|
default:
|
||||||
|
return IssueItem(
|
||||||
|
payload: data, isPullRequest: data['__typename'] == 'PullRequest');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SingleScaffold(
|
return TabScaffold(
|
||||||
title: AppBarTitle('Search GitHub Repositories'),
|
title: AppBarTitle('Search GitHub Repositories'),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(padding: EdgeInsets.all(8), child: _buildInput()),
|
Container(padding: EdgeInsets.all(8), child: _buildInput()),
|
||||||
loading
|
Column(children: _payloads[_activeTab].map(_buildItem).toList())
|
||||||
? Loading()
|
|
||||||
: Column(
|
|
||||||
children: repos.map((repo) => RepositoryItem(repo)).toList(),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
activeTab: _activeTab,
|
||||||
|
onRefresh: _query,
|
||||||
|
onTabSwitch: (int index) {
|
||||||
|
setState(() {
|
||||||
|
_activeTab = index;
|
||||||
|
});
|
||||||
|
if (_payloads[_activeTab].isEmpty) {
|
||||||
|
_query();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tabs: ['Repositories', 'Users', 'Issues'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
101
lib/screens/trending_backup.dart
Normal file
101
lib/screens/trending_backup.dart
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:git_touch/scaffolds/tab.dart';
|
||||||
|
import 'package:git_touch/utils/utils.dart';
|
||||||
|
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||||
|
import 'package:git_touch/widgets/user_item.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:git_touch/widgets/repository_item.dart';
|
||||||
|
|
||||||
|
class TrendingScreen extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_TrendingScreenState createState() => _TrendingScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TrendingScreenState extends State<TrendingScreen> {
|
||||||
|
int _activeTab;
|
||||||
|
List _repoItems;
|
||||||
|
List _userItems;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
Uri get _uri => Uri.parse('https://github-trending-api.now.sh')
|
||||||
|
.resolve(_activeTab == 1 ? '/developers' : '/');
|
||||||
|
|
||||||
|
Iterable<Widget> _buildItems() {
|
||||||
|
switch (_activeTab) {
|
||||||
|
case 0:
|
||||||
|
return _userItems?.map((item) => UserItem(
|
||||||
|
item['username'],
|
||||||
|
name: item['name'],
|
||||||
|
avatarUrl: item['avatar'],
|
||||||
|
bio: '',
|
||||||
|
));
|
||||||
|
case 1:
|
||||||
|
default:
|
||||||
|
return _repoItems?.map((item) => RepositoryItem(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_refresh() async {
|
||||||
|
var res = await http.get(_uri);
|
||||||
|
var items = json.decode(res.body) as List;
|
||||||
|
setState(() {
|
||||||
|
switch (_activeTab) {
|
||||||
|
case 0:
|
||||||
|
_repoItems = items
|
||||||
|
.map((item) => {
|
||||||
|
'owner': {
|
||||||
|
'login': item['author'],
|
||||||
|
'avatarUrl': item['avatar']
|
||||||
|
},
|
||||||
|
'name': item['name'],
|
||||||
|
'description': item['description'],
|
||||||
|
'stargazers': {
|
||||||
|
'totalCount': item['stars'],
|
||||||
|
},
|
||||||
|
'forks': {
|
||||||
|
'totalCount': item['forks'],
|
||||||
|
},
|
||||||
|
'primaryLanguage': item['language'] == null
|
||||||
|
? null
|
||||||
|
: {
|
||||||
|
'name': item['language'],
|
||||||
|
'color': item['languageColor'],
|
||||||
|
},
|
||||||
|
'isPrivate': false,
|
||||||
|
'isFork': false // TODO:
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
_userItems = items;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return TabScaffold(
|
||||||
|
title: AppBarTitle('Trending'),
|
||||||
|
tabs: ['Repositories', 'Users'],
|
||||||
|
onRefresh: _refresh,
|
||||||
|
body: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: join(borderView, _buildItems()).toList(),
|
||||||
|
),
|
||||||
|
activeTab: _activeTab,
|
||||||
|
onTabSwitch: (int index) {
|
||||||
|
setState(() {
|
||||||
|
_activeTab = index;
|
||||||
|
_refresh();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
165
lib/widgets/issue_item.dart
Normal file
165
lib/widgets/issue_item.dart
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:git_touch/widgets/avatar.dart';
|
||||||
|
import 'package:primer/primer.dart';
|
||||||
|
import 'package:timeago/timeago.dart' as timeago;
|
||||||
|
import '../utils/utils.dart';
|
||||||
|
import '../widgets/link.dart';
|
||||||
|
import '../screens/issue.dart';
|
||||||
|
|
||||||
|
const issueGqlChunk = '''
|
||||||
|
number
|
||||||
|
title
|
||||||
|
updatedAt
|
||||||
|
author {
|
||||||
|
login
|
||||||
|
avatarUrl
|
||||||
|
}
|
||||||
|
repository {
|
||||||
|
owner {
|
||||||
|
login
|
||||||
|
}
|
||||||
|
name
|
||||||
|
}
|
||||||
|
labels(first: 10) {
|
||||||
|
nodes {
|
||||||
|
name
|
||||||
|
color
|
||||||
|
}
|
||||||
|
}
|
||||||
|
comments {
|
||||||
|
totalCount
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
|
||||||
|
class IssueItem extends StatelessWidget {
|
||||||
|
final payload;
|
||||||
|
final bool isPullRequest;
|
||||||
|
|
||||||
|
IssueItem({this.payload, this.isPullRequest = false});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Link(
|
||||||
|
screenBuilder: (context) {
|
||||||
|
return IssueScreen(
|
||||||
|
number: payload['number'],
|
||||||
|
owner: payload['repository']['owner']['login'],
|
||||||
|
name: payload['repository']['name'],
|
||||||
|
isPullRequest: isPullRequest,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.all(12),
|
||||||
|
// color: payload.unread ? Colors.white : Colors.black12,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
isPullRequest
|
||||||
|
? Octicons.git_pull_request
|
||||||
|
: Octicons.issue_opened,
|
||||||
|
color: Palette.green,
|
||||||
|
size: 16),
|
||||||
|
SizedBox(width: 6),
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: join(SizedBox(height: 8), [
|
||||||
|
// Text(
|
||||||
|
// owner +
|
||||||
|
// '/' +
|
||||||
|
// name +
|
||||||
|
// ' #' +
|
||||||
|
// payload['number'].toString(),
|
||||||
|
// style: TextStyle(fontSize: 13, color: Colors.black54),
|
||||||
|
// ),
|
||||||
|
// Padding(padding: EdgeInsets.only(top: 4)),
|
||||||
|
Text(
|
||||||
|
payload['title'] + ' (#${payload['number']})',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
color: PrimerColors.gray900,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if ((payload['labels']['nodes'] as List).isNotEmpty)
|
||||||
|
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: getFontColorByBrightness(color),
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
DefaultTextStyle(
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13, color: PrimerColors.gray700),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
// FIXME: Deleted user
|
||||||
|
if (payload['author'] != null) ...[
|
||||||
|
Avatar(
|
||||||
|
login: payload['author']['login'],
|
||||||
|
url: payload['author']['avatarUrl'],
|
||||||
|
size: 8,
|
||||||
|
),
|
||||||
|
SizedBox(width: 4),
|
||||||
|
Text(
|
||||||
|
payload['author']['login'],
|
||||||
|
style: TextStyle(fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
Text(' opened ' +
|
||||||
|
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(numberFormat
|
||||||
|
.format(payload['comments']['totalCount']))
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Column(
|
||||||
|
// children: <Widget>[
|
||||||
|
// Icon(Octicons.check, color: Colors.black45),
|
||||||
|
// Icon(Octicons.unmute, color: Colors.black45)
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:git_touch/screens/organization.dart';
|
||||||
import 'package:git_touch/screens/user.dart';
|
import 'package:git_touch/screens/user.dart';
|
||||||
import 'package:git_touch/widgets/avatar.dart';
|
import 'package:git_touch/widgets/avatar.dart';
|
||||||
import 'package:git_touch/widgets/link.dart';
|
import 'package:git_touch/widgets/link.dart';
|
||||||
@ -16,9 +17,22 @@ class UserItem extends StatelessWidget {
|
|||||||
final String avatarUrl;
|
final String avatarUrl;
|
||||||
final String bio;
|
final String bio;
|
||||||
final bool inUserScreen;
|
final bool inUserScreen;
|
||||||
|
final bool isOrganization;
|
||||||
|
|
||||||
UserItem(this.login,
|
UserItem(
|
||||||
{this.name, this.avatarUrl, this.bio, this.inUserScreen = false});
|
this.login, {
|
||||||
|
this.name,
|
||||||
|
this.avatarUrl,
|
||||||
|
this.bio,
|
||||||
|
this.inUserScreen = false,
|
||||||
|
this.isOrganization = false,
|
||||||
|
});
|
||||||
|
UserItem.fromData(data, {this.isOrganization = false})
|
||||||
|
: login = data['login'],
|
||||||
|
name = data['name'],
|
||||||
|
avatarUrl = data['avatarUrl'],
|
||||||
|
bio = data['bio'],
|
||||||
|
inUserScreen = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -68,7 +82,10 @@ class UserItem extends StatelessWidget {
|
|||||||
if (inUserScreen) {
|
if (inUserScreen) {
|
||||||
return widget;
|
return widget;
|
||||||
} else {
|
} else {
|
||||||
return Link(screenBuilder: (_) => UserScreen(login), child: widget);
|
return Link(
|
||||||
|
screenBuilder: (_) =>
|
||||||
|
isOrganization ? OrganizationScreen(login) : UserScreen(login),
|
||||||
|
child: widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user