mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 16:14:49 +01:00
feat(gitlab): settings entry
This commit is contained in:
parent
1d90a3959c
commit
65e45f6b7f
@ -49,6 +49,7 @@ class GiteaUserScreen extends StatelessWidget {
|
||||
description: v.description,
|
||||
starCount: v.starsCount,
|
||||
forkCount: v.forksCount,
|
||||
url: '', // TODO:
|
||||
)
|
||||
],
|
||||
)
|
||||
|
@ -1,7 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/models/gitlab.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/widgets/action_entry.dart';
|
||||
import 'package:git_touch/widgets/repository_item.dart';
|
||||
import 'package:git_touch/widgets/user_item.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@ -15,8 +18,8 @@ final gitlabUserRouter = RouterScreen(
|
||||
|
||||
class GitlabUserScreen extends StatelessWidget {
|
||||
final int id;
|
||||
|
||||
GitlabUserScreen(this.id);
|
||||
bool get isViewer => id == null;
|
||||
|
||||
static _getGitlabIcon(String visibility) {
|
||||
switch (visibility) {
|
||||
@ -35,18 +38,27 @@ class GitlabUserScreen extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return RefreshStatefulScaffold<
|
||||
Tuple2<GitlabUser, Iterable<GitlabUserProject>>>(
|
||||
title: Text('User'),
|
||||
title: Text(isViewer ? 'Me' : 'User'),
|
||||
fetchData: () async {
|
||||
final auth = Provider.of<AuthModel>(context);
|
||||
|
||||
final v0 = await auth.fetchGitlab('/users/$id');
|
||||
final _id = id ?? auth.activeAccount.gitlabId;
|
||||
final v0 = await auth.fetchGitlab('/users/$_id');
|
||||
final user = GitlabUser.fromJson(v0);
|
||||
final v1 = await auth.fetchGitlab('/users/$id/projects');
|
||||
final v1 = await auth.fetchGitlab('/users/$_id/projects');
|
||||
final projects =
|
||||
(v1 as List).map((v) => GitlabUserProject.fromJson(v)).toList();
|
||||
|
||||
return Tuple2(user, projects);
|
||||
},
|
||||
action: isViewer
|
||||
? ActionEntry(
|
||||
iconData: Icons.settings,
|
||||
onTap: () {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
theme.push(context, '/settings');
|
||||
},
|
||||
)
|
||||
: null,
|
||||
bodyBuilder: (data, _) {
|
||||
final user = data.item1;
|
||||
final projects = data.item2;
|
||||
@ -69,6 +81,7 @@ class GitlabUserScreen extends StatelessWidget {
|
||||
description: v.description,
|
||||
starCount: v.starCount,
|
||||
forkCount: v.forksCount,
|
||||
url: '/gitlab/projects/${v.id}',
|
||||
)
|
||||
],
|
||||
)
|
||||
|
@ -58,12 +58,13 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
url: '/login',
|
||||
rightWidget: Text(auth.activeAccount.login),
|
||||
),
|
||||
TableViewItem(
|
||||
text: Text('Review Permissions'),
|
||||
url:
|
||||
'https://github.com/settings/connections/applications/$clientId',
|
||||
rightWidget: Text(auth.activeAccount.login),
|
||||
),
|
||||
if (auth.activeAccount.platform == PlatformType.github)
|
||||
TableViewItem(
|
||||
text: Text('Review Permissions'),
|
||||
url:
|
||||
'https://github.com/settings/connections/applications/$clientId',
|
||||
rightWidget: Text(auth.activeAccount.login),
|
||||
),
|
||||
]),
|
||||
CommonStyle.verticalGap,
|
||||
TableView(headerText: 'theme', items: [
|
||||
@ -124,7 +125,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
TableViewItem(
|
||||
text: Text('Submit an issue'),
|
||||
rightWidget: Text('pd4d10/git-touch'),
|
||||
url: '/pd4d10/git-touch/issues/new',
|
||||
url: (auth.activeAccount.platform == PlatformType.github
|
||||
? ''
|
||||
: 'https://github.com') +
|
||||
'/pd4d10/git-touch/issues/new',
|
||||
),
|
||||
TableViewItem(
|
||||
text: Text('Rate This App'),
|
||||
@ -148,7 +152,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
TableViewItem(
|
||||
text: Text('Source Code'),
|
||||
rightWidget: Text('pd4d10/git-touch'),
|
||||
url: '/pd4d10/git-touch',
|
||||
url: (auth.activeAccount.platform == PlatformType.github
|
||||
? ''
|
||||
: 'https://github.com') +
|
||||
'/pd4d10/git-touch',
|
||||
),
|
||||
])
|
||||
],
|
||||
|
@ -17,6 +17,7 @@ class RepositoryItem extends StatelessWidget {
|
||||
final String primaryLanguageName;
|
||||
final String primaryLanguageColor;
|
||||
final String note;
|
||||
final String url;
|
||||
|
||||
RepositoryItem({
|
||||
@required this.owner,
|
||||
@ -29,6 +30,7 @@ class RepositoryItem extends StatelessWidget {
|
||||
this.primaryLanguageColor,
|
||||
this.note,
|
||||
this.iconData,
|
||||
@required this.url,
|
||||
});
|
||||
|
||||
RepositoryItem.gh({
|
||||
@ -43,7 +45,8 @@ class RepositoryItem extends StatelessWidget {
|
||||
this.note,
|
||||
@required bool isPrivate,
|
||||
@required bool isFork,
|
||||
}) : this.iconData = _buildIconData(isPrivate, isFork);
|
||||
}) : this.iconData = _buildIconData(isPrivate, isFork),
|
||||
this.url = '$owner/$name';
|
||||
|
||||
static IconData _buildIconData(bool isPrivate, bool isFork) {
|
||||
if (isPrivate == true) return Octicons.lock;
|
||||
@ -55,7 +58,7 @@ class RepositoryItem extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
return Link(
|
||||
url: '/$owner/$name',
|
||||
url: url,
|
||||
child: Container(
|
||||
padding: CommonStyle.padding,
|
||||
child: Row(
|
||||
|
Loading…
x
Reference in New Issue
Block a user