mirror of
https://github.com/git-touch/git-touch
synced 2025-03-05 19:57:42 +01:00
feat: add view owner action at repo screen
This commit is contained in:
parent
3055c29e7b
commit
83c22bda9a
@ -7,6 +7,7 @@ import 'package:nanoid/nanoid.dart';
|
|||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
// import 'package:flutter/services.dart';
|
// import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
// import '../utils/utils.dart';
|
// import '../utils/utils.dart';
|
||||||
import '../utils/constants.dart';
|
import '../utils/constants.dart';
|
||||||
@ -357,6 +358,26 @@ class SettingsProviderState extends State<SettingsProvider> {
|
|||||||
return true;
|
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;
|
String randomString;
|
||||||
|
|
||||||
generateRandomString() {
|
generateRandomString() {
|
||||||
|
@ -9,6 +9,7 @@ import '../scaffolds/refresh.dart';
|
|||||||
import '../widgets/repo_item.dart';
|
import '../widgets/repo_item.dart';
|
||||||
import '../widgets/entry_item.dart';
|
import '../widgets/entry_item.dart';
|
||||||
import '../screens/issues.dart';
|
import '../screens/issues.dart';
|
||||||
|
import '../screens/user.dart';
|
||||||
import '../widgets/action.dart';
|
import '../widgets/action.dart';
|
||||||
|
|
||||||
class RepoScreen extends StatefulWidget {
|
class RepoScreen extends StatefulWidget {
|
||||||
@ -22,8 +23,8 @@ class RepoScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _RepoScreenState extends State<RepoScreen> {
|
class _RepoScreenState extends State<RepoScreen> {
|
||||||
get owner => widget.owner;
|
String get owner => widget.owner;
|
||||||
get name => widget.name;
|
String get name => widget.name;
|
||||||
|
|
||||||
Future queryRepo(BuildContext context) async {
|
Future queryRepo(BuildContext context) async {
|
||||||
var data = await SettingsProvider.of(context).query('''
|
var data = await SettingsProvider.of(context).query('''
|
||||||
@ -31,6 +32,7 @@ class _RepoScreenState extends State<RepoScreen> {
|
|||||||
repository(owner: "$owner", name: "$name") {
|
repository(owner: "$owner", name: "$name") {
|
||||||
id
|
id
|
||||||
owner {
|
owner {
|
||||||
|
__typename
|
||||||
login
|
login
|
||||||
}
|
}
|
||||||
name
|
name
|
||||||
@ -89,6 +91,24 @@ class _RepoScreenState extends State<RepoScreen> {
|
|||||||
var payload = data[0];
|
var payload = data[0];
|
||||||
|
|
||||||
return ActionButton(title: 'Repository Actions', actions: [
|
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(
|
Action(
|
||||||
text: payload['viewerHasStarred'] ? 'Unstar' : 'Star',
|
text: payload['viewerHasStarred'] ? 'Unstar' : 'Star',
|
||||||
onPress: () async {
|
onPress: () async {
|
||||||
|
@ -31,19 +31,11 @@ class Link extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (screenBuilder != null) {
|
if (screenBuilder != null) {
|
||||||
switch (theme) {
|
SettingsProvider.of(context).pushRoute(
|
||||||
case ThemeMap.cupertino:
|
context: context,
|
||||||
Navigator.of(context).push(CupertinoPageRoute(
|
|
||||||
builder: screenBuilder,
|
builder: screenBuilder,
|
||||||
fullscreenDialog: fullscreenDialog,
|
fullscreenDialog: fullscreenDialog,
|
||||||
));
|
);
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Navigator.of(context).push(MaterialPageRoute(
|
|
||||||
builder: screenBuilder,
|
|
||||||
fullscreenDialog: fullscreenDialog,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user