mirror of
https://github.com/git-touch/git-touch
synced 2024-12-15 09:56:15 +01:00
feat(gitea): add status screen
This commit is contained in:
parent
99b2b795d1
commit
e3a4b2c091
@ -20,6 +20,7 @@ import 'package:git_touch/screens/gt_object.dart';
|
||||
import 'package:git_touch/screens/gt_orgs.dart';
|
||||
import 'package:git_touch/screens/gt_repo.dart';
|
||||
import 'package:git_touch/screens/gt_repos.dart';
|
||||
import 'package:git_touch/screens/gt_status.dart';
|
||||
import 'package:git_touch/screens/gt_user.dart';
|
||||
import 'package:git_touch/screens/gl_blob.dart';
|
||||
import 'package:git_touch/screens/gl_commits.dart';
|
||||
@ -264,6 +265,7 @@ class GitlabRouter {
|
||||
class GiteaRouter {
|
||||
static const prefix = '/gitea';
|
||||
static final routes = [
|
||||
GiteaRouter.status,
|
||||
GiteaRouter.user,
|
||||
GiteaRouter.repo,
|
||||
GiteaRouter.object,
|
||||
@ -274,6 +276,8 @@ class GiteaRouter {
|
||||
GiteaRouter.issues,
|
||||
GiteaRouter.pulls,
|
||||
];
|
||||
static final status =
|
||||
RouterScreen('/status', (context, parameters) => GtStatusScreen());
|
||||
static final user = RouterScreen('/:login', (context, p) {
|
||||
final login = p['login'].first;
|
||||
final tab = p['tab']?.first;
|
||||
|
36
lib/screens/gt_status.dart
Normal file
36
lib/screens/gt_status.dart
Normal file
@ -0,0 +1,36 @@
|
||||
import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/widgets/blob_view.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class GtStatusScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RefreshStatefulScaffold<String>(
|
||||
title: Text('Gitea status'),
|
||||
fetchData: () async {
|
||||
final auth = context.read<AuthModel>();
|
||||
final res = await Future.wait([
|
||||
auth.fetchGitea('/version'),
|
||||
auth.fetchGitea('/settings/attachment'),
|
||||
auth.fetchGitea('/settings/api'),
|
||||
auth.fetchGitea('/settings/repository'),
|
||||
auth.fetchGitea('/settings/ui'),
|
||||
]);
|
||||
return JsonEncoder.withIndent(' ').convert({
|
||||
...res[0],
|
||||
'attachment': res[1],
|
||||
'api': res[2],
|
||||
'repository': res[3],
|
||||
'ui': res[4],
|
||||
});
|
||||
},
|
||||
bodyBuilder: (jsonStr, _) {
|
||||
return BlobView('0.json', text: jsonStr);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -129,6 +129,17 @@ class GtUserScreen extends StatelessWidget {
|
||||
]),
|
||||
ContributionWidget(weeks: p.userHeatmap),
|
||||
CommonStyle.border,
|
||||
TableView(
|
||||
hasIcon: true,
|
||||
items: [
|
||||
TableViewItem(
|
||||
leftIconData: Octicons.home,
|
||||
text: Text('Organizations'),
|
||||
url: '/gitea/$login?tab=organizations',
|
||||
),
|
||||
],
|
||||
),
|
||||
CommonStyle.border,
|
||||
Column(
|
||||
children: <Widget>[
|
||||
for (var v in p.userRepos)
|
||||
@ -145,17 +156,6 @@ class GtUserScreen extends StatelessWidget {
|
||||
)
|
||||
],
|
||||
),
|
||||
CommonStyle.border,
|
||||
TableView(
|
||||
hasIcon: true,
|
||||
items: [
|
||||
TableViewItem(
|
||||
leftIconData: Octicons.home,
|
||||
text: Text('Organizations'),
|
||||
url: '/gitea/$login?tab=organizations',
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
} else if (p.org != null) {
|
||||
|
@ -19,18 +19,6 @@ class SettingsScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SettingsScreenState extends State<SettingsScreen> {
|
||||
var _version = '';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
PackageInfo.fromPlatform().then((info) {
|
||||
setState(() {
|
||||
_version = info.version;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildRightWidget(BuildContext context, bool checked) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
if (!checked) return null;
|
||||
@ -60,6 +48,18 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
'https://github.com/settings/connections/applications/$clientId',
|
||||
rightWidget: Text(auth.activeAccount.login),
|
||||
),
|
||||
if (auth.activeAccount.platform == PlatformType.gitea)
|
||||
TableViewItem(
|
||||
leftIconData: Octicons.info,
|
||||
text: Text('Gitea'),
|
||||
url: '/gitea/status',
|
||||
rightWidget: FutureBuilder<String>(
|
||||
future: auth.fetchGitea('/version').then((v) => v['version']),
|
||||
builder: (context, snapshot) {
|
||||
return Text(snapshot.data ?? '');
|
||||
},
|
||||
),
|
||||
)
|
||||
]),
|
||||
CommonStyle.verticalGap,
|
||||
TableView(headerText: 'theme', items: [
|
||||
@ -143,7 +143,15 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
]),
|
||||
CommonStyle.verticalGap,
|
||||
TableView(headerText: 'about', items: [
|
||||
TableViewItem(text: Text('Version'), rightWidget: Text(_version)),
|
||||
TableViewItem(
|
||||
text: Text('Version'),
|
||||
rightWidget: FutureBuilder<String>(
|
||||
future:
|
||||
PackageInfo.fromPlatform().then((info) => info.version),
|
||||
builder: (context, snapshot) {
|
||||
return Text(snapshot.data ?? '');
|
||||
},
|
||||
)),
|
||||
TableViewItem(
|
||||
text: Text('Source Code'),
|
||||
rightWidget: Text('pd4d10/git-touch'),
|
||||
|
Loading…
Reference in New Issue
Block a user