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

improvment: drop screen builder for link

This commit is contained in:
Rongjian Zhang 2019-12-13 11:02:05 +08:00
parent 151ca1fbaa
commit 032be3b8f3
4 changed files with 18 additions and 16 deletions

View File

@ -5,6 +5,7 @@ import 'package:git_touch/models/auth.dart';
import 'package:git_touch/models/theme.dart';
import 'package:git_touch/screens/commits.dart';
import 'package:git_touch/screens/credits.dart';
import 'package:git_touch/screens/gitlab_issue.dart';
import 'package:git_touch/screens/gitlab_todos.dart';
import 'package:git_touch/screens/gitlab_user.dart';
import 'package:git_touch/screens/issue_form.dart';
@ -229,7 +230,7 @@ void main() async {
codeModel.init(),
]);
// TODO: gitlab
// github
themeModel.router.define('/login', handler: Handler(
handlerFunc: (context, params) {
return LoginScreen();
@ -309,6 +310,14 @@ void main() async {
},
));
// gitlab
themeModel.router.define('/project/:id/issue/:iid', handler: Handler(
handlerFunc: (context, params) {
return GitlabIssueScreen(
int.parse(['id'].first), int.parse(params['iid'].first));
},
));
runApp(MultiProvider(
providers: [
ChangeNotifierProvider(create: (context) => notificationModel),

View File

@ -3,7 +3,6 @@ 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/screens/gitlab_issue.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/avatar.dart';
import 'package:git_touch/widgets/link.dart';
@ -25,9 +24,8 @@ class GitlabTodosScreen extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: data.map((item) {
return Link(
screenBuilder: (_) => GitlabIssueScreen(
item.target.projectId, item.target.iid,
isMr: item.targetType == 'MergeRequest'),
url:
'/project/${item.target.projectId}/${item.targetType == 'MergeRequest' ? 'merge_requests' : 'issue'}/${item.target.iid}',
child: Container(
padding: CommonStyle.padding,
child: Row(

View File

@ -5,7 +5,6 @@ import 'package:git_touch/graphql/github_object.dart';
import 'package:git_touch/models/code.dart';
import 'package:git_touch/models/theme.dart';
import 'package:git_touch/scaffolds/refresh_stateful.dart';
import 'package:git_touch/screens/code_theme.dart';
import 'package:git_touch/widgets/action_entry.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/markdown_view.dart';
@ -102,10 +101,11 @@ class ObjectScreen extends StatelessWidget {
return ActionEntry(
iconData: Octicons.settings,
onTap: () {
if (data != null) {
Provider.of<ThemeModel>(context).pushRoute(
context, (_) => CodeThemeScreen(blob.text, _language));
}
// TODO:
// if (data != null) {
// Provider.of<ThemeModel>(context).pushRoute(
// context, (_) => CodeThemeScreen(blob.text, _language));
// }
},
);
default:

View File

@ -7,25 +7,20 @@ import 'package:git_touch/models/theme.dart';
class Link extends StatelessWidget {
final Widget child;
final String url;
final WidgetBuilder screenBuilder;
final Function onTap;
final VoidCallback onLongPress;
Link({
this.child,
this.url,
this.screenBuilder,
this.onTap,
this.onLongPress,
}) : assert(screenBuilder == null || url == null);
});
void _onTap(BuildContext context) {
if (onTap != null) {
return onTap();
}
if (screenBuilder != null) {
return Provider.of<ThemeModel>(context).pushRoute(context, screenBuilder);
}
if (url != null) {
if (url.startsWith('/')) {
Provider.of<ThemeModel>(context).push(context, url);