mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 08:04:51 +01:00
feat(gitea): org screen
This commit is contained in:
parent
336ff4960e
commit
f0e447fd84
@ -4,6 +4,7 @@ import 'package:git_touch/screens/commits.dart';
|
||||
import 'package:git_touch/screens/gitea_commits.dart';
|
||||
import 'package:git_touch/screens/gitea_issues.dart';
|
||||
import 'package:git_touch/screens/gitea_object.dart';
|
||||
import 'package:git_touch/screens/gitea_org.dart';
|
||||
import 'package:git_touch/screens/gitea_repo.dart';
|
||||
import 'package:git_touch/screens/gitea_user.dart';
|
||||
import 'package:git_touch/screens/gitlab_blob.dart';
|
||||
@ -203,7 +204,9 @@ class GiteaRouter {
|
||||
];
|
||||
static final user = RouterScreen(
|
||||
'/:login',
|
||||
(context, params) => GiteaUserScreen(params['login'].first),
|
||||
(context, params) => params['org'].first == '1'
|
||||
? GiteaOrgScreen(params['login'].first)
|
||||
: GiteaUserScreen(params['login'].first),
|
||||
);
|
||||
static final repo = RouterScreen(
|
||||
'/:owner/:name',
|
||||
|
67
lib/screens/gitea_org.dart
Normal file
67
lib/screens/gitea_org.dart
Normal file
@ -0,0 +1,67 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/models/gitea.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/repository_item.dart';
|
||||
import 'package:git_touch/widgets/user_header.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
|
||||
class GiteaOrgScreen extends StatelessWidget {
|
||||
final String login;
|
||||
GiteaOrgScreen(this.login);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RefreshStatefulScaffold<Tuple2<GiteaOrg, List<GiteaRepository>>>(
|
||||
title: Text(login),
|
||||
fetchData: () async {
|
||||
final auth = Provider.of<AuthModel>(context);
|
||||
final res = await Future.wait([
|
||||
auth.fetchGitea('/orgs/$login'),
|
||||
auth.fetchGitea('/orgs/$login/repos'),
|
||||
]);
|
||||
return Tuple2(
|
||||
GiteaOrg.fromJson(res[0]),
|
||||
[for (var v in res[1]) GiteaRepository.fromJson(v)],
|
||||
);
|
||||
},
|
||||
bodyBuilder: (data, _) {
|
||||
final org = data.item1;
|
||||
final repos = data.item2;
|
||||
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
UserHeader(
|
||||
login: org.username,
|
||||
avatarUrl: org.avatarUrl,
|
||||
name: org.fullName,
|
||||
createdAt: null,
|
||||
bio: org.description,
|
||||
),
|
||||
CommonStyle.border,
|
||||
Column(
|
||||
children: <Widget>[
|
||||
for (var v in repos)
|
||||
RepositoryItem(
|
||||
owner: v.owner.login,
|
||||
avatarUrl: v.owner.avatarUrl,
|
||||
name: v.name,
|
||||
description: v.description,
|
||||
starCount: v.starsCount,
|
||||
forkCount: v.forksCount,
|
||||
note: 'Updated ${timeago.format(v.updatedAt)}',
|
||||
url: '/gitea/${v.owner.login}/${v.name}',
|
||||
avatarLink: '/gitea/${v.owner.login}',
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ class GiteaOrgsScreen extends StatelessWidget {
|
||||
avatarUrl: v.avatarUrl,
|
||||
login: v.username,
|
||||
bio: Text(v.description ?? ''),
|
||||
url: '',
|
||||
url: '/gitea/${v.username}?org=1',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user