mirror of
https://github.com/git-touch/git-touch
synced 2024-12-16 10:20:55 +01:00
refactor: push router
This commit is contained in:
parent
24eea80b66
commit
151ca1fbaa
@ -13,6 +13,7 @@ import 'package:git_touch/screens/notification.dart';
|
||||
import 'package:git_touch/screens/object.dart';
|
||||
import 'package:git_touch/screens/repository.dart';
|
||||
import 'package:git_touch/screens/repositories.dart';
|
||||
import 'package:git_touch/screens/settings.dart';
|
||||
import 'package:git_touch/screens/user.dart';
|
||||
import 'package:primer/primer.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@ -234,6 +235,11 @@ void main() async {
|
||||
return LoginScreen();
|
||||
},
|
||||
));
|
||||
themeModel.router.define('/settings', handler: Handler(
|
||||
handlerFunc: (context, params) {
|
||||
return SettingsScreen();
|
||||
},
|
||||
));
|
||||
themeModel.router.define('/help/credits', handler: Handler(
|
||||
handlerFunc: (context, params) {
|
||||
return CreditsScreen();
|
||||
|
@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/scaffolds/list_stateful.dart';
|
||||
import 'package:git_touch/screens/issue_form.dart';
|
||||
import 'package:git_touch/widgets/action_entry.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/widgets/issue_item.dart';
|
||||
@ -52,9 +51,8 @@ class IssuesScreen extends StatelessWidget {
|
||||
actionBuilder: () => ActionEntry(
|
||||
iconData: Octicons.plus,
|
||||
onTap: () {
|
||||
Provider.of<ThemeModel>(context).pushRoute(
|
||||
context, (_) => IssueFormScreen(owner, name),
|
||||
fullscreenDialog: true);
|
||||
Provider.of<ThemeModel>(context)
|
||||
.push(context, '/$owner/$name/issues/new');
|
||||
}),
|
||||
onRefresh: () => _query(context),
|
||||
onLoadMore: (cursor) => _query(context, cursor),
|
||||
|
@ -3,7 +3,6 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/graphql/github_user.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/screens/settings.dart';
|
||||
import 'package:git_touch/screens/users.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/action_entry.dart';
|
||||
@ -270,9 +269,7 @@ class UserScreen extends StatelessWidget {
|
||||
return ActionEntry(
|
||||
iconData: Icons.settings,
|
||||
onTap: () {
|
||||
Provider.of<ThemeModel>(context).pushRoute(
|
||||
context, (_) => SettingsScreen(),
|
||||
fullscreenDialog: true);
|
||||
Provider.of<ThemeModel>(context).push(context, '/settings');
|
||||
},
|
||||
);
|
||||
} else {
|
||||
|
@ -37,9 +37,10 @@ class Avatar extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
Provider.of<ThemeModel>(context).pushRoute(
|
||||
context, (_) => ImageViewScreen(url),
|
||||
fullscreenDialog: true);
|
||||
// TODO:
|
||||
// Provider.of<ThemeModel>(context).pushRoute(
|
||||
// context, (_) => ImageViewScreen(url),
|
||||
// fullscreenDialog: true);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ class EntryItem extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
screenBuilder: screenBuilder,
|
||||
url: url,
|
||||
),
|
||||
);
|
||||
|
@ -5,7 +5,6 @@ import 'package:provider/provider.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
import '../utils/utils.dart';
|
||||
import '../widgets/link.dart';
|
||||
import '../screens/issue.dart';
|
||||
|
||||
const issueGqlChunk = '''
|
||||
number
|
||||
@ -43,14 +42,8 @@ class IssueItem extends StatelessWidget {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
|
||||
return Link(
|
||||
screenBuilder: (context) {
|
||||
return IssueScreen(
|
||||
payload['repository']['owner']['login'] as String,
|
||||
payload['repository']['name'] as String,
|
||||
payload['number'] as int,
|
||||
isPullRequest: isPullRequest,
|
||||
);
|
||||
},
|
||||
url:
|
||||
'/${payload['repository']['owner']['login']}/${payload['repository']['name']}/${isPullRequest ? 'pulls' : 'issues'}/${payload['number']}',
|
||||
child: Container(
|
||||
padding: CommonStyle.padding,
|
||||
// color: payload.unread ? Colors.white : Colors.black12,
|
||||
|
@ -102,15 +102,9 @@ class _NotificationItemState extends State<NotificationItem> {
|
||||
switch (payload.type) {
|
||||
case 'Issue':
|
||||
case 'PullRequest':
|
||||
Provider.of<ThemeModel>(context).pushRoute(
|
||||
context,
|
||||
(_) => IssueScreen(
|
||||
payload.owner,
|
||||
payload.name,
|
||||
payload.number,
|
||||
isPullRequest: payload.type == 'PullRequest',
|
||||
));
|
||||
|
||||
final resource = payload.type == 'PullRequest' ? 'pulls' : 'issues';
|
||||
Provider.of<ThemeModel>(context).push(context,
|
||||
'/${payload.owner}/${payload.name}/$resource/${payload.number}');
|
||||
break;
|
||||
case 'Release':
|
||||
launchUrl(
|
||||
|
Loading…
Reference in New Issue
Block a user