1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-14 01:15:12 +01:00

feat: add view owner action at repo screen

This commit is contained in:
Rongjian Zhang 2019-03-10 21:53:35 +08:00
parent 3055c29e7b
commit 83c22bda9a
3 changed files with 48 additions and 15 deletions

View File

@ -7,6 +7,7 @@ import 'package:nanoid/nanoid.dart';
import 'package:url_launcher/url_launcher.dart';
// import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:shared_preferences/shared_preferences.dart';
// import '../utils/utils.dart';
import '../utils/constants.dart';
@ -357,6 +358,26 @@ class SettingsProviderState extends State<SettingsProvider> {
return true;
}
void pushRoute({
@required BuildContext context,
@required WidgetBuilder builder,
bool fullscreenDialog = false,
}) {
switch (theme) {
case ThemeMap.cupertino:
Navigator.of(context).push(CupertinoPageRoute(
builder: builder,
fullscreenDialog: fullscreenDialog,
));
break;
default:
Navigator.of(context).push(MaterialPageRoute(
builder: builder,
fullscreenDialog: fullscreenDialog,
));
}
}
String randomString;
generateRandomString() {

View File

@ -9,6 +9,7 @@ import '../scaffolds/refresh.dart';
import '../widgets/repo_item.dart';
import '../widgets/entry_item.dart';
import '../screens/issues.dart';
import '../screens/user.dart';
import '../widgets/action.dart';
class RepoScreen extends StatefulWidget {
@ -22,8 +23,8 @@ class RepoScreen extends StatefulWidget {
}
class _RepoScreenState extends State<RepoScreen> {
get owner => widget.owner;
get name => widget.name;
String get owner => widget.owner;
String get name => widget.name;
Future queryRepo(BuildContext context) async {
var data = await SettingsProvider.of(context).query('''
@ -31,6 +32,7 @@ class _RepoScreenState extends State<RepoScreen> {
repository(owner: "$owner", name: "$name") {
id
owner {
__typename
login
}
name
@ -89,6 +91,24 @@ class _RepoScreenState extends State<RepoScreen> {
var payload = data[0];
return ActionButton(title: 'Repository Actions', actions: [
Action(
text: 'View @$owner',
onPress: () {
WidgetBuilder builder;
switch (payload['owner']['__typename']) {
case 'Organization':
// TODO:
break;
case 'User':
builder = (_) => UserScreen(owner);
break;
}
SettingsProvider.of(context)
.pushRoute(context: context, builder: builder);
},
),
Action(
text: payload['viewerHasStarred'] ? 'Unstar' : 'Star',
onPress: () async {

View File

@ -31,19 +31,11 @@ class Link extends StatelessWidget {
}
if (screenBuilder != null) {
switch (theme) {
case ThemeMap.cupertino:
Navigator.of(context).push(CupertinoPageRoute(
builder: screenBuilder,
fullscreenDialog: fullscreenDialog,
));
break;
default:
Navigator.of(context).push(MaterialPageRoute(
builder: screenBuilder,
fullscreenDialog: fullscreenDialog,
));
}
SettingsProvider.of(context).pushRoute(
context: context,
builder: screenBuilder,
fullscreenDialog: fullscreenDialog,
);
}
if (url != null) {