feat(gitlab): groups screen
This commit is contained in:
parent
d7d05bc72b
commit
1c35b0b4cd
|
@ -5,6 +5,7 @@ import 'package:git_touch/models/notification.dart';
|
|||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/screens/gitea_user.dart';
|
||||
import 'package:git_touch/screens/gitlab_explore.dart';
|
||||
import 'package:git_touch/screens/gitlab_groups.dart';
|
||||
import 'package:git_touch/screens/gitlab_project.dart';
|
||||
import 'package:git_touch/screens/gitlab_todos.dart';
|
||||
import 'package:git_touch/screens/gitlab_user.dart';
|
||||
|
@ -53,6 +54,8 @@ class _HomeState extends State<Home> {
|
|||
case 0:
|
||||
return GitlabExplore();
|
||||
case 1:
|
||||
return GitlabGroups();
|
||||
case 2:
|
||||
return GitlabUserScreen(null);
|
||||
}
|
||||
break;
|
||||
|
@ -121,6 +124,10 @@ class _HomeState extends State<Home> {
|
|||
icon: Icon(Icons.explore),
|
||||
title: Text('Explore'),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.group),
|
||||
title: Text('Groups'),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.person),
|
||||
title: Text('Me'),
|
||||
|
@ -132,6 +139,10 @@ class _HomeState extends State<Home> {
|
|||
icon: Icon(Icons.explore),
|
||||
title: Text('Explore'),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.explore),
|
||||
title: Text('Groups'),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.person),
|
||||
title: Text('Me'),
|
||||
|
|
|
@ -196,6 +196,7 @@ class ThemeModel with ChangeNotifier {
|
|||
}
|
||||
|
||||
push(BuildContext context, String url, {bool replace = false}) {
|
||||
// Fimber.d(url);
|
||||
if (url.startsWith('/')) {
|
||||
return router.navigateTo(
|
||||
context,
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/models/gitlab.dart';
|
||||
import 'package:git_touch/scaffolds/list_stateful.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/widgets/user_item.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class GitlabGroups extends StatelessWidget {
|
||||
Future<ListPayload<GitlabGroup, int>> _query(BuildContext context,
|
||||
[int page = 1]) async {
|
||||
final auth = Provider.of<AuthModel>(context);
|
||||
final res = await auth.fetchGitlabWithPage('/groups?page=$page');
|
||||
return ListPayload(
|
||||
cursor: res.cursor,
|
||||
hasMore: res.hasMore,
|
||||
items: <GitlabGroup>[
|
||||
for (var v in res.data) GitlabGroup.fromJson(v),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListStatefulScaffold<GitlabGroup, int>(
|
||||
title: AppBarTitle('Explore'),
|
||||
onRefresh: () => _query(context),
|
||||
onLoadMore: (page) => _query(context, page),
|
||||
itemBuilder: (v) {
|
||||
return UserItem(
|
||||
avatarUrl: v.avatarUrl,
|
||||
login: v.path,
|
||||
bio: Text(v.description ?? ''),
|
||||
url: '/gitlab/group/${v.id}',
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
|
@ -183,9 +183,9 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||
isFork: p['isFork'],
|
||||
);
|
||||
case 1:
|
||||
return UserItem(
|
||||
return UserItem.gh(
|
||||
login: p['login'],
|
||||
name: p['name'],
|
||||
// name: p['name'],
|
||||
avatarUrl: p['avatarUrl'],
|
||||
bio: Text(p['bio'] ?? ''),
|
||||
);
|
||||
|
|
|
@ -46,9 +46,9 @@ class TrendingScreen extends StatelessWidget {
|
|||
);
|
||||
case 1:
|
||||
final item = GithubTrendingUser.fromJson(v);
|
||||
return UserItem(
|
||||
return UserItem.gh(
|
||||
login: item.username,
|
||||
name: item.name,
|
||||
// name: item.name,
|
||||
avatarUrl: item.avatar,
|
||||
bio: Row(
|
||||
children: <Widget>[
|
||||
|
|
|
@ -144,9 +144,9 @@ class UsersScreen extends StatelessWidget {
|
|||
onRefresh: () => _queryUsers(context),
|
||||
onLoadMore: (cursor) => _queryUsers(context, cursor),
|
||||
itemBuilder: (payload) {
|
||||
return UserItem(
|
||||
return UserItem.gh(
|
||||
login: payload.login,
|
||||
name: payload.name,
|
||||
// name: payload.name,
|
||||
avatarUrl: payload.avatarUrl,
|
||||
bio: _buildBio(
|
||||
context, payload.company, payload.location, payload.createdAt),
|
||||
|
|
|
@ -14,22 +14,30 @@ const userGqlChunk = '''
|
|||
|
||||
class UserItem extends StatelessWidget {
|
||||
final String login;
|
||||
final String name;
|
||||
// final String name;
|
||||
final String avatarUrl;
|
||||
final Widget bio;
|
||||
final String url;
|
||||
|
||||
UserItem.gh({
|
||||
@required this.login,
|
||||
// @required this.name,
|
||||
@required this.avatarUrl,
|
||||
@required this.bio,
|
||||
}) : url = '/$login';
|
||||
|
||||
UserItem({
|
||||
this.login,
|
||||
this.name,
|
||||
this.avatarUrl,
|
||||
this.bio,
|
||||
@required this.login,
|
||||
@required this.avatarUrl,
|
||||
@required this.bio,
|
||||
@required this.url,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
return Link(
|
||||
url: '/$login',
|
||||
url: url,
|
||||
child: Container(
|
||||
padding: CommonStyle.padding,
|
||||
child: Row(
|
||||
|
|
Loading…
Reference in New Issue