mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 08:04:51 +01:00
refactor: using path for router
This commit is contained in:
parent
8097eb3bb4
commit
2400513007
@ -3,16 +3,21 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/models/code.dart';
|
||||
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_todos.dart';
|
||||
import 'package:git_touch/screens/gitlab_user.dart';
|
||||
import 'package:git_touch/screens/issue_form.dart';
|
||||
import 'package:git_touch/screens/issues.dart';
|
||||
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/user.dart';
|
||||
import 'package:primer/primer.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:git_touch/models/notification.dart';
|
||||
import 'package:fluro/fluro.dart';
|
||||
import 'screens/news.dart';
|
||||
import 'screens/search.dart';
|
||||
import 'screens/login.dart';
|
||||
@ -132,30 +137,30 @@ class _HomeState extends State<Home> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final authModel = Provider.of<AuthModel>(context);
|
||||
final themeModel = Provider.of<ThemeModel>(context);
|
||||
final auth = Provider.of<AuthModel>(context);
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
|
||||
final themData = ThemeData(
|
||||
brightness: themeModel.brightness,
|
||||
brightness: theme.brightness,
|
||||
primaryColor: PrimerColors.white,
|
||||
accentColor: PrimerColors.blue500,
|
||||
);
|
||||
|
||||
// TODO:
|
||||
if (!authModel.ready || !Provider.of<ThemeModel>(context).ready) {
|
||||
if (!auth.ready || !Provider.of<ThemeModel>(context).ready) {
|
||||
return MaterialApp(theme: themData, home: Scaffold(body: Text('a')));
|
||||
}
|
||||
|
||||
// Fimber.d(settings.activeLogin);
|
||||
if (authModel.activeAccount == null) {
|
||||
if (auth.activeAccount == null) {
|
||||
return MaterialApp(theme: themData, home: LoginScreen());
|
||||
}
|
||||
|
||||
switch (themeModel.theme) {
|
||||
switch (theme.theme) {
|
||||
case AppThemeType.cupertino:
|
||||
return CupertinoApp(
|
||||
theme: CupertinoThemeData(
|
||||
brightness: themeModel.brightness,
|
||||
brightness: theme.brightness,
|
||||
primaryColor: PrimerColors.blue500,
|
||||
),
|
||||
home: CupertinoTabScaffold(
|
||||
@ -223,6 +228,71 @@ void main() async {
|
||||
codeModel.init(),
|
||||
]);
|
||||
|
||||
// TODO: gitlab
|
||||
themeModel.router.define('/login', handler: Handler(
|
||||
handlerFunc: (context, params) {
|
||||
return LoginScreen();
|
||||
},
|
||||
));
|
||||
themeModel.router.define('/help/credits', handler: Handler(
|
||||
handlerFunc: (context, params) {
|
||||
return CreditsScreen();
|
||||
},
|
||||
));
|
||||
themeModel.router.define('/:login', handler: Handler(
|
||||
handlerFunc: (context, params) {
|
||||
return UserScreen(params['login'][0]);
|
||||
},
|
||||
));
|
||||
themeModel.router.define('/:owner/:name', handler: Handler(
|
||||
handlerFunc: (context, params) {
|
||||
return RepositoryScreen(params['owner'][0], params['name'][0]);
|
||||
},
|
||||
));
|
||||
themeModel.router.define('/:owner/:name/issues', handler: Handler(
|
||||
handlerFunc: (context, params) {
|
||||
return IssuesScreen(params['owner'][0], params['name'][0]);
|
||||
},
|
||||
));
|
||||
themeModel.router.define('/:owner/:name/pulls', handler: Handler(
|
||||
handlerFunc: (context, params) {
|
||||
return IssuesScreen(params['owner'][0], params['name'][0],
|
||||
isPullRequest: true);
|
||||
},
|
||||
));
|
||||
themeModel.router.define('/:owner/:name/issues/:number', handler: Handler(
|
||||
handlerFunc: (context, params) {
|
||||
return IssueScreen(params['owner'][0], params['name'][0],
|
||||
int.parse(params['number'][0]));
|
||||
},
|
||||
));
|
||||
themeModel.router.define('/:owner/:name/pulls/:number', handler: Handler(
|
||||
handlerFunc: (context, params) {
|
||||
return IssueScreen(
|
||||
params['owner'][0],
|
||||
params['name'][0],
|
||||
int.parse(params['number'][0]),
|
||||
isPullRequest: true,
|
||||
);
|
||||
},
|
||||
));
|
||||
themeModel.router.define('/:owner/:name/commits', handler: Handler(
|
||||
handlerFunc: (context, params) {
|
||||
return CommitsScreen(params['owner'][0], params['name'][0]);
|
||||
},
|
||||
));
|
||||
themeModel.router.define('/:owner/:name/blob/:ref', handler: Handler(
|
||||
handlerFunc: (context, params) {
|
||||
return ObjectScreen(
|
||||
params['owner'][0], params['name'][0], params['ref'][0]);
|
||||
},
|
||||
));
|
||||
themeModel.router.define('/:owner/:name/issues/new', handler: Handler(
|
||||
handlerFunc: (context, params) {
|
||||
return IssueFormScreen(params['owner'][0], params['name'][0]);
|
||||
},
|
||||
));
|
||||
|
||||
runApp(MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider(create: (context) => notificationModel),
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
import 'dart:async';
|
||||
import 'package:fimber/fimber.dart';
|
||||
import 'package:fluro/fluro.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/widgets/action_button.dart';
|
||||
@ -98,6 +99,8 @@ class ThemeModel with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
final router = Router();
|
||||
|
||||
Palette get palette {
|
||||
switch (brightness) {
|
||||
case Brightness.light:
|
||||
@ -149,6 +152,13 @@ class ThemeModel with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
push(BuildContext context, String path) {
|
||||
return router.navigateTo(context, path,
|
||||
transition: theme == AppThemeType.cupertino
|
||||
? TransitionType.cupertino
|
||||
: TransitionType.material);
|
||||
}
|
||||
|
||||
pushRoute(
|
||||
BuildContext context,
|
||||
WidgetBuilder builder, {
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/scaffolds/single.dart';
|
||||
import 'package:git_touch/screens/repository.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/table_view.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
@ -48,22 +47,14 @@ class CreditsScreen extends StatelessWidget {
|
||||
TableView(
|
||||
headerText: 'packages',
|
||||
items: projects.map((t) {
|
||||
return TableViewItem(
|
||||
text: Text(t.item1),
|
||||
screenBuilder: (_) {
|
||||
final repo = parseRepositoryFullName(t.item2);
|
||||
return RepositoryScreen(repo.item1, repo.item2);
|
||||
});
|
||||
return TableViewItem(text: Text(t.item1), url: t.item2);
|
||||
}),
|
||||
),
|
||||
CommonStyle.verticalGap,
|
||||
TableView(
|
||||
headerText: 'fonts',
|
||||
items: fonts.map((font) {
|
||||
return TableViewItem(
|
||||
text: Text(font),
|
||||
screenBuilder: (_) => RepositoryScreen('google', 'fonts'),
|
||||
);
|
||||
return TableViewItem(text: Text(font), url: '/google/fonts');
|
||||
}),
|
||||
),
|
||||
],
|
||||
|
@ -3,7 +3,6 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
import 'package:git_touch/models/gitlab.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/screens/gitlab_tree.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/widgets/entry_item.dart';
|
||||
@ -70,7 +69,6 @@ class GitlabProjectScreen extends StatelessWidget {
|
||||
data.forksCount,
|
||||
data.languages.keys.first,
|
||||
null,
|
||||
null,
|
||||
[],
|
||||
inRepoScreen: true),
|
||||
CommonStyle.border,
|
||||
@ -116,7 +114,7 @@ class GitlabProjectScreen extends StatelessWidget {
|
||||
TableViewItem(
|
||||
leftIconData: Octicons.code,
|
||||
text: Text('Code'),
|
||||
screenBuilder: (_) => GitlabTreeScreen(data.id),
|
||||
url: '/tree/$id',
|
||||
),
|
||||
if (data.issuesEnabled)
|
||||
TableViewItem(
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/models/gitlab.dart';
|
||||
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/screens/gitlab_blob.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/widgets/table_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -56,16 +55,16 @@ class GitlabTreeScreen extends StatelessWidget {
|
||||
return TableViewItem(
|
||||
leftWidget: _buildIcon(item),
|
||||
text: Text(item.name),
|
||||
screenBuilder: (_) {
|
||||
url: (() {
|
||||
switch (item.type) {
|
||||
case 'tree':
|
||||
return GitlabTreeScreen(id, path: item.path);
|
||||
return '/tree/$id?path=${item.path}';
|
||||
case 'blob':
|
||||
return GitlabBlobScreen(id, item.path);
|
||||
return '/blob/$id?path=${item.path}';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
},
|
||||
})(),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
@ -122,15 +122,11 @@ class ObjectScreen extends StatelessWidget {
|
||||
return TableViewItem(
|
||||
leftWidget: _buildIcon(item),
|
||||
text: Text(item.name),
|
||||
screenBuilder: (_) {
|
||||
url: (() {
|
||||
if (item.type == 'commit') return null;
|
||||
return ObjectScreen(
|
||||
owner,
|
||||
name,
|
||||
branch,
|
||||
paths: [...paths, item.name],
|
||||
);
|
||||
},
|
||||
final p = [...paths, item.name].join('/');
|
||||
return '/$owner/$name/blob/$branch?path=$p';
|
||||
})(),
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/graphql/github_repositories.dart';
|
||||
import 'package:git_touch/scaffolds/list_stateful.dart';
|
||||
import 'package:git_touch/screens/repository.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/models/auth.dart';
|
||||
@ -74,7 +73,6 @@ class RepositoriesScreen extends StatelessWidget {
|
||||
item.forks.totalCount,
|
||||
item.primaryLanguage?.name,
|
||||
item.primaryLanguage?.color,
|
||||
(_) => RepositoryScreen(item.owner.login, item.name),
|
||||
[],
|
||||
);
|
||||
});
|
||||
|
@ -12,12 +12,9 @@ import 'package:git_touch/widgets/markdown_view.dart';
|
||||
import 'package:git_touch/widgets/table_view.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/screens/commits.dart';
|
||||
import 'package:git_touch/screens/object.dart';
|
||||
import 'package:git_touch/widgets/repository_item.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
import '../widgets/entry_item.dart';
|
||||
import '../screens/issues.dart';
|
||||
import 'package:git_touch/widgets/action_button.dart';
|
||||
|
||||
class RepositoryScreen extends StatelessWidget {
|
||||
@ -134,7 +131,6 @@ class RepositoryScreen extends StatelessWidget {
|
||||
repo.forks.totalCount,
|
||||
repo.primaryLanguage?.name,
|
||||
repo.primaryLanguage?.color,
|
||||
null,
|
||||
repo.repositoryTopics.nodes,
|
||||
inRepoScreen: true),
|
||||
CommonStyle.border,
|
||||
@ -192,11 +188,7 @@ class RepositoryScreen extends StatelessWidget {
|
||||
leftIconData: Octicons.code,
|
||||
text: Text('Code'),
|
||||
rightWidget: Text(filesize(repo.diskUsage * 1000)),
|
||||
screenBuilder: (_) => ObjectScreen(
|
||||
owner,
|
||||
name,
|
||||
ref.name,
|
||||
),
|
||||
url: '/$owner/$name/blob/${ref.name}',
|
||||
),
|
||||
if (repo.hasIssuesEnabled)
|
||||
TableViewItem(
|
||||
@ -204,15 +196,14 @@ class RepositoryScreen extends StatelessWidget {
|
||||
text: Text('Issues'),
|
||||
rightWidget:
|
||||
Text(numberFormat.format(repo.issues.totalCount)),
|
||||
screenBuilder: (_) => IssuesScreen(owner, name),
|
||||
url: '/$owner/$name/issues',
|
||||
),
|
||||
TableViewItem(
|
||||
leftIconData: Octicons.git_pull_request,
|
||||
text: Text('Pull requests'),
|
||||
rightWidget:
|
||||
Text(numberFormat.format(repo.pullRequests.totalCount)),
|
||||
screenBuilder: (_) =>
|
||||
IssuesScreen(owner, name, isPullRequest: true),
|
||||
url: '/$owner/$name/pulls',
|
||||
),
|
||||
TableViewItem(
|
||||
leftIconData: Octicons.project,
|
||||
@ -238,8 +229,7 @@ class RepositoryScreen extends StatelessWidget {
|
||||
?.totalCount,
|
||||
),
|
||||
),
|
||||
screenBuilder: (_) =>
|
||||
CommitsScreen(owner, name, branch: branch),
|
||||
url: '/$owner/$name/commits',
|
||||
),
|
||||
if (repo.refs != null)
|
||||
TableViewItem(
|
||||
|
@ -2,9 +2,6 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/scaffolds/single.dart';
|
||||
import 'package:git_touch/screens/credits.dart';
|
||||
import 'package:git_touch/screens/issue_form.dart';
|
||||
import 'package:git_touch/screens/repository.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@ -30,7 +27,7 @@ class SettingsScreen extends StatelessWidget {
|
||||
TableView(headerText: 'ACCOUNTS', items: [
|
||||
TableViewItem(
|
||||
text: Text('Switch to another account'),
|
||||
screenBuilder: (_) => LoginScreen(),
|
||||
url: '/login',
|
||||
),
|
||||
]),
|
||||
CommonStyle.verticalGap,
|
||||
@ -60,18 +57,10 @@ class SettingsScreen extends StatelessWidget {
|
||||
]),
|
||||
CommonStyle.verticalGap,
|
||||
TableView(headerText: 'ABOUT', items: [
|
||||
TableViewItem(text: Text('Source Code'), url: '/pd4d10/git-touch'),
|
||||
TableViewItem(
|
||||
text: Text('Source Code'),
|
||||
screenBuilder: (_) => RepositoryScreen('pd4d10', 'git-touch'),
|
||||
),
|
||||
TableViewItem(
|
||||
text: Text('Feedback'),
|
||||
screenBuilder: (_) => IssueFormScreen('pd4d10', 'git-touch'),
|
||||
),
|
||||
TableViewItem(
|
||||
text: Text('Credits'),
|
||||
screenBuilder: (_) => CreditsScreen(),
|
||||
),
|
||||
text: Text('Feedback'), url: '/pd4d10/git-touch/issues/new'),
|
||||
TableViewItem(text: Text('Credits'), url: '/help/credits'),
|
||||
TableViewItem(
|
||||
text: Text('Rate This App'),
|
||||
onTap: () {
|
||||
|
@ -2,7 +2,6 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/github.dart';
|
||||
import 'package:git_touch/scaffolds/tab_stateful.dart';
|
||||
import 'package:git_touch/screens/repository.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/widgets/user_item.dart';
|
||||
@ -39,7 +38,6 @@ class TrendingScreen extends StatelessWidget {
|
||||
item.forks ?? 0,
|
||||
item.language,
|
||||
item.languageColor,
|
||||
(_) => RepositoryScreen(item.author, item.name),
|
||||
[],
|
||||
);
|
||||
case 1:
|
||||
|
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/screens/user.dart';
|
||||
import 'package:git_touch/widgets/border_view.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:primer/primer.dart';
|
||||
@ -59,7 +58,7 @@ void nextTick(Function callback, [int milliseconds = 0]) {
|
||||
TextSpan createLinkSpan(
|
||||
BuildContext context,
|
||||
String text,
|
||||
Widget Function(BuildContext) builder,
|
||||
String url,
|
||||
) {
|
||||
return TextSpan(
|
||||
text: text,
|
||||
@ -69,13 +68,13 @@ TextSpan createLinkSpan(
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
Provider.of<ThemeModel>(context).pushRoute(context, builder);
|
||||
Provider.of<ThemeModel>(context).push(context, url);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
TextSpan createUserSpan(BuildContext context, String login) {
|
||||
return createLinkSpan(context, login, (_) => UserScreen(login));
|
||||
return createLinkSpan(context, login, '/$login');
|
||||
}
|
||||
|
||||
Tuple2<String, String> parseRepositoryFullName(String fullName) {
|
||||
|
@ -1,8 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/screens/issue.dart';
|
||||
import 'package:git_touch/screens/repository.dart';
|
||||
import 'package:git_touch/screens/user.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
@ -32,23 +29,24 @@ class ActionItem {
|
||||
ActionItem.user(String login)
|
||||
: text = '@$login',
|
||||
onPress = ((context) {
|
||||
Provider.of<ThemeModel>(context)
|
||||
.pushRoute(context, (_) => UserScreen(login));
|
||||
Provider.of<ThemeModel>(context).push(context, '/$login');
|
||||
});
|
||||
ActionItem.repository(String owner, String name)
|
||||
: text = '$owner/$name',
|
||||
onPress = ((context) {
|
||||
Provider.of<ThemeModel>(context)
|
||||
.pushRoute(context, (_) => RepositoryScreen(owner, name));
|
||||
Provider.of<ThemeModel>(context).push(context, '/$owner/$name');
|
||||
});
|
||||
ActionItem.issue(String owner, String name, int number,
|
||||
{isPullRequest = false})
|
||||
ActionItem.issue(String owner, String name, int number)
|
||||
: text = '$owner/$name #$number',
|
||||
onPress = ((context) {
|
||||
Provider.of<ThemeModel>(context).pushRoute(
|
||||
context,
|
||||
(_) => IssueScreen(owner, name, number,
|
||||
isPullRequest: isPullRequest));
|
||||
Provider.of<ThemeModel>(context)
|
||||
.push(context, '/$owner/$name/issues/$number');
|
||||
});
|
||||
ActionItem.pullRequest(String owner, String name, int number)
|
||||
: text = '$owner/$name #$number',
|
||||
onPress = ((context) {
|
||||
Provider.of<ThemeModel>(context)
|
||||
.push(context, '/$owner/$name/pulls/$number');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/screens/user.dart';
|
||||
import 'package:git_touch/widgets/markdown_view.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
@ -47,8 +46,8 @@ class CommentItem extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
Row(children: <Widget>[
|
||||
Link(
|
||||
url: '/' + payload['author']['login'],
|
||||
child: Avatar.medium(url: payload['author']['avatarUrl']),
|
||||
screenBuilder: (_) => UserScreen(payload['author']['login']),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Expanded(
|
||||
|
@ -2,12 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:git_touch/models/github.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/screens/repository.dart';
|
||||
import 'package:git_touch/widgets/action_button.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
import '../screens/issue.dart';
|
||||
import '../screens/user.dart';
|
||||
import 'avatar.dart';
|
||||
import '../widgets/link.dart';
|
||||
import '../utils/utils.dart';
|
||||
@ -43,7 +40,6 @@ class EventItem extends StatelessWidget {
|
||||
String detail,
|
||||
Widget detailWidget,
|
||||
IconData iconData = Octicons.octoface,
|
||||
WidgetBuilder screenBuilder,
|
||||
String url,
|
||||
List<ActionItem> actionItems,
|
||||
}) {
|
||||
@ -55,7 +51,6 @@ class EventItem extends StatelessWidget {
|
||||
}
|
||||
|
||||
return Link(
|
||||
screenBuilder: screenBuilder,
|
||||
url: url,
|
||||
child: Container(
|
||||
padding: CommonStyle.padding,
|
||||
@ -66,8 +61,8 @@ class EventItem extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Link(
|
||||
url: '/' + event.actor.login,
|
||||
child: Avatar.medium(url: event.actor.avatarUrl),
|
||||
screenBuilder: (_) => UserScreen(event.actor.login),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
Expanded(
|
||||
@ -170,7 +165,7 @@ class EventItem extends StatelessWidget {
|
||||
_buildRepo(theme),
|
||||
],
|
||||
iconData: Octicons.repo_forked,
|
||||
screenBuilder: (_) => RepositoryScreen(forkeeOwner, forkeeName),
|
||||
url: '/$forkeeOwner/$forkeeName',
|
||||
actionItems: [
|
||||
..._getUserActions([event.actor.login, forkeeOwner]),
|
||||
ActionItem.repository(forkeeOwner, forkeeName),
|
||||
@ -201,16 +196,11 @@ class EventItem extends StatelessWidget {
|
||||
],
|
||||
detail: event.payload['comment']['body'],
|
||||
iconData: Octicons.comment_discussion,
|
||||
screenBuilder: (_) => IssueScreen(
|
||||
event.repoOwner,
|
||||
event.repoName,
|
||||
number,
|
||||
isPullRequest: isPullRequest,
|
||||
),
|
||||
url:
|
||||
'/${event.repoOwner}/${event.repoName}/${isPullRequest ? 'pulls' : 'issues'}/$number',
|
||||
actionItems: [
|
||||
..._getUserActions([event.actor.login, event.repoOwner]),
|
||||
ActionItem.issue(event.repoOwner, event.repoName, number,
|
||||
isPullRequest: isPullRequest),
|
||||
ActionItem.pullRequest(event.repoOwner, event.repoName, number),
|
||||
],
|
||||
);
|
||||
case 'IssuesEvent':
|
||||
@ -227,8 +217,7 @@ class EventItem extends StatelessWidget {
|
||||
],
|
||||
iconData: Octicons.issue_opened,
|
||||
detail: event.payload['issue']['title'],
|
||||
screenBuilder: (_) =>
|
||||
IssueScreen(event.repoOwner, event.repoName, number),
|
||||
url: '/${event.repoOwner}/${event.repoName}/issues/$number',
|
||||
actionItems: [
|
||||
..._getUserActions([event.actor.login, event.repoOwner]),
|
||||
ActionItem.repository(event.repoOwner, event.repoName),
|
||||
@ -263,17 +252,11 @@ class EventItem extends StatelessWidget {
|
||||
],
|
||||
iconData: Octicons.git_pull_request,
|
||||
detail: event.payload['pull_request']['title'],
|
||||
screenBuilder: (_) => IssueScreen(
|
||||
event.repoOwner,
|
||||
event.repoName,
|
||||
number,
|
||||
isPullRequest: true,
|
||||
),
|
||||
url: '/${event.repoOwner}/${event.repoName}/pulls/$number',
|
||||
actionItems: [
|
||||
..._getUserActions([event.actor.login, event.repoOwner]),
|
||||
ActionItem.repository(event.repoOwner, event.repoName),
|
||||
ActionItem.issue(event.repoOwner, event.repoName, number,
|
||||
isPullRequest: true),
|
||||
ActionItem.pullRequest(event.repoOwner, event.repoName, number),
|
||||
],
|
||||
);
|
||||
case 'PullRequestReviewEvent':
|
||||
@ -291,17 +274,11 @@ class EventItem extends StatelessWidget {
|
||||
_buildRepo(theme),
|
||||
],
|
||||
detail: event.payload['comment']['body'],
|
||||
screenBuilder: (_) => IssueScreen(
|
||||
event.repoOwner,
|
||||
event.repoName,
|
||||
number,
|
||||
isPullRequest: true,
|
||||
),
|
||||
url: '/${event.repoOwner}/${event.repoName}/pulls/$number',
|
||||
actionItems: [
|
||||
..._getUserActions([event.actor.login, event.repoOwner]),
|
||||
ActionItem.repository(event.repoOwner, event.repoName),
|
||||
ActionItem.issue(event.repoOwner, event.repoName, number,
|
||||
isPullRequest: true),
|
||||
ActionItem.pullRequest(event.repoOwner, event.repoName, number),
|
||||
],
|
||||
);
|
||||
case 'PushEvent':
|
||||
@ -365,8 +342,7 @@ class EventItem extends StatelessWidget {
|
||||
context: context,
|
||||
spans: [TextSpan(text: ' starred '), _buildRepo(theme)],
|
||||
iconData: Octicons.star,
|
||||
screenBuilder: (_) =>
|
||||
RepositoryScreen(event.repoOwner, event.repoName),
|
||||
url: '/${event.repoOwner}/${event.repoName}',
|
||||
actionItems: [
|
||||
..._getUserActions([event.actor.login, event.repoOwner]),
|
||||
ActionItem.repository(event.repoOwner, event.repoName),
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/screens/user.dart';
|
||||
import 'package:git_touch/widgets/avatar.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
@ -123,10 +122,9 @@ class IssueItem extends StatelessWidget {
|
||||
// FIXME: Deleted user
|
||||
if (payload['author'] != null) ...[
|
||||
Link(
|
||||
url: '/' + payload['author']['login'],
|
||||
child: Avatar.extraSmall(
|
||||
url: payload['author']['avatarUrl']),
|
||||
screenBuilder: (_) =>
|
||||
UserScreen(payload['author']['login']),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
|
@ -27,7 +27,11 @@ class Link extends StatelessWidget {
|
||||
return Provider.of<ThemeModel>(context).pushRoute(context, screenBuilder);
|
||||
}
|
||||
if (url != null) {
|
||||
launchUrl(url);
|
||||
if (url.startsWith('/')) {
|
||||
Provider.of<ThemeModel>(context).push(context, url);
|
||||
} else {
|
||||
launchUrl(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,6 @@ import 'package:git_touch/graphql/github_user.dart';
|
||||
import 'package:git_touch/models/gitea.dart';
|
||||
import 'package:git_touch/models/gitlab.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/screens/gitlab_project.dart';
|
||||
import 'package:git_touch/screens/repository.dart';
|
||||
import 'package:git_touch/widgets/action_button.dart';
|
||||
import 'package:git_touch/widgets/avatar.dart';
|
||||
import 'package:primer/primer.dart';
|
||||
@ -46,7 +44,6 @@ class RepositoryItem extends StatelessWidget {
|
||||
final int forkCount;
|
||||
final String primaryLanguageName;
|
||||
final String primaryLanguageColor;
|
||||
final Widget Function(BuildContext context) screenBuilder;
|
||||
final bool inRepoScreen;
|
||||
final Iterable<GithubRepositoryRepositoryTopic> topics;
|
||||
|
||||
@ -60,7 +57,6 @@ class RepositoryItem extends StatelessWidget {
|
||||
this.forkCount,
|
||||
this.primaryLanguageName,
|
||||
this.primaryLanguageColor,
|
||||
this.screenBuilder,
|
||||
this.topics,
|
||||
{this.inRepoScreen = false});
|
||||
|
||||
@ -78,8 +74,6 @@ class RepositoryItem extends StatelessWidget {
|
||||
this.primaryLanguageColor = payload['primaryLanguage'] == null
|
||||
? null
|
||||
: payload['primaryLanguage']['color'],
|
||||
this.screenBuilder = ((_) =>
|
||||
RepositoryScreen(payload['owner']['login'], payload['name'])),
|
||||
this.topics = [];
|
||||
|
||||
RepositoryItem.github(GithubUserRepository payload,
|
||||
@ -93,8 +87,6 @@ class RepositoryItem extends StatelessWidget {
|
||||
this.forkCount = payload.forks.totalCount,
|
||||
this.primaryLanguageName = payload.primaryLanguage?.name,
|
||||
this.primaryLanguageColor = payload.primaryLanguage?.color,
|
||||
this.screenBuilder =
|
||||
((_) => RepositoryScreen(payload.owner.login, payload.name)),
|
||||
this.topics = []; // TODO:
|
||||
// this.topics = payload['repositoryTopics'] == null
|
||||
// ? []
|
||||
@ -123,7 +115,6 @@ class RepositoryItem extends StatelessWidget {
|
||||
this.forkCount = payload.forksCount,
|
||||
this.primaryLanguageName = null,
|
||||
this.primaryLanguageColor = null,
|
||||
this.screenBuilder = ((_) => GitlabProjectScreen(payload.id)),
|
||||
this.topics = [];
|
||||
|
||||
RepositoryItem.gitea(GiteaRepository payload, {this.inRepoScreen = false})
|
||||
@ -136,7 +127,6 @@ class RepositoryItem extends StatelessWidget {
|
||||
this.forkCount = payload.forksCount,
|
||||
this.primaryLanguageName = null,
|
||||
this.primaryLanguageColor = null,
|
||||
this.screenBuilder = ((_) => RepositoryScreen('', '')), // TODO:
|
||||
this.topics = [];
|
||||
|
||||
static IconData _buildIconData(payload) {
|
||||
@ -153,9 +143,9 @@ class RepositoryItem extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
|
||||
// TODO: text style
|
||||
// TODO: text style inRepoScreen
|
||||
return Link(
|
||||
screenBuilder: inRepoScreen ? null : screenBuilder,
|
||||
url: '/$owner/$name',
|
||||
onLongPress: () async {
|
||||
await Provider.of<ThemeModel>(context).showActions(context, [
|
||||
ActionItem.user(owner),
|
||||
|
@ -31,7 +31,6 @@ class TableViewItem {
|
||||
final Widget rightWidget;
|
||||
final void Function() onTap;
|
||||
final String url;
|
||||
final WidgetBuilder screenBuilder;
|
||||
final bool hideRightChevron;
|
||||
|
||||
TableViewItem({
|
||||
@ -41,7 +40,6 @@ class TableViewItem {
|
||||
this.rightWidget,
|
||||
this.onTap,
|
||||
this.url,
|
||||
this.screenBuilder,
|
||||
this.hideRightChevron = false,
|
||||
}) : assert(leftIconData == null || leftWidget == null);
|
||||
}
|
||||
@ -104,9 +102,7 @@ class TableView extends StatelessWidget {
|
||||
),
|
||||
SizedBox(width: 6)
|
||||
],
|
||||
if ((item.onTap != null ||
|
||||
item.screenBuilder != null ||
|
||||
item.url != null) &&
|
||||
if ((item.onTap != null || item.url != null) &&
|
||||
!item.hideRightChevron)
|
||||
Icon(CupertinoIcons.right_chevron,
|
||||
size: 20, color: themeModel.palette.tertiaryText)
|
||||
@ -118,12 +114,7 @@ class TableView extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
|
||||
return Link(
|
||||
onTap: item.onTap,
|
||||
screenBuilder: item.screenBuilder,
|
||||
url: item.url,
|
||||
child: widget,
|
||||
);
|
||||
return Link(onTap: item.onTap, url: item.url, child: widget);
|
||||
}).toList()),
|
||||
CommonStyle.border,
|
||||
],
|
||||
|
@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/screens/user.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
|
||||
class TextContainsOrganization extends StatelessWidget {
|
||||
@ -22,8 +21,8 @@ class TextContainsOrganization extends StatelessWidget {
|
||||
if (chunks[index].isNotEmpty) {
|
||||
spans.add(TextSpan(text: chunks[index]));
|
||||
}
|
||||
spans.add(createLinkSpan(
|
||||
context, orgs[index], (_) => UserScreen(orgs[index].substring(1))));
|
||||
spans.add(
|
||||
createLinkSpan(context, orgs[index], '/' + orgs[index].substring(1)));
|
||||
}
|
||||
if (chunks.last.isNotEmpty) {
|
||||
spans.add(TextSpan(text: chunks.last));
|
||||
|
@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/screens/user.dart';
|
||||
import 'package:git_touch/utils/utils.dart';
|
||||
import 'package:git_touch/widgets/avatar.dart';
|
||||
import 'package:git_touch/widgets/link.dart';
|
||||
@ -41,7 +40,7 @@ class UserItem extends StatelessWidget {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
|
||||
return Link(
|
||||
screenBuilder: inUserScreen ? null : (_) => UserScreen(login),
|
||||
url: '/$login',
|
||||
child: Container(
|
||||
padding: CommonStyle.padding,
|
||||
child: Row(
|
||||
|
@ -1,7 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import '../screens/user.dart';
|
||||
import 'link.dart';
|
||||
import 'package:git_touch/widgets/link.dart';
|
||||
|
||||
final style = TextStyle(fontWeight: FontWeight.w600);
|
||||
|
||||
@ -13,7 +11,7 @@ class UserName extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Link(
|
||||
screenBuilder: (_) => UserScreen(login),
|
||||
url: '/$login',
|
||||
child: Container(
|
||||
// padding: EdgeInsets.all(2),
|
||||
decoration: BoxDecoration(
|
||||
|
@ -40,6 +40,7 @@ dependencies:
|
||||
gql: ^0.11.1
|
||||
artemis: ^2.1.2
|
||||
gql_link: ^0.2.0
|
||||
fluro: ^1.5.1
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
|
Loading…
x
Reference in New Issue
Block a user