1
0
mirror of https://github.com/git-touch/git-touch synced 2025-01-31 16:14:49 +01:00

refactor: add gh prefix

This commit is contained in:
Rongjian Zhang 2020-02-07 14:17:05 +08:00
parent c62e8e950e
commit a3b617f7fc
19 changed files with 159 additions and 159 deletions

View File

@ -14,13 +14,13 @@ import 'package:git_touch/screens/gitlab_project.dart';
import 'package:git_touch/screens/gitlab_todos.dart';
import 'package:git_touch/screens/gitlab_user.dart';
import 'package:git_touch/screens/login.dart';
import 'package:git_touch/screens/notification.dart';
import 'package:git_touch/screens/user.dart';
import 'package:git_touch/screens/gh_notification.dart';
import 'package:git_touch/screens/gh_user.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:provider/provider.dart';
import 'package:git_touch/screens/news.dart';
import 'package:git_touch/screens/search.dart';
import 'package:git_touch/screens/trending.dart';
import 'package:git_touch/screens/gh_news.dart';
import 'package:git_touch/screens/gh_search.dart';
import 'package:git_touch/screens/gh_trending.dart';
class Home extends StatefulWidget {
@override
@ -42,15 +42,15 @@ class _HomeState extends State<Home> {
case PlatformType.github:
switch (index) {
case 0:
return NewsScreen();
return GhNewsScreen();
case 1:
return NotificationScreen();
return GhNotificationScreen();
case 2:
return TrendingScreen();
return GhTrendingScreen();
case 3:
return SearchScreen();
return GhSearchScreen();
case 4:
return UserScreen(null);
return GhUserScreen(null);
}
break;
case PlatformType.gitlab:

View File

@ -4,7 +4,7 @@ import 'package:git_touch/screens/bb_object.dart';
import 'package:git_touch/screens/bb_repo.dart';
import 'package:git_touch/screens/bb_user.dart';
import 'package:git_touch/screens/code_theme.dart';
import 'package:git_touch/screens/commits.dart';
import 'package:git_touch/screens/gh_commits.dart';
import 'package:git_touch/screens/gitea_commits.dart';
import 'package:git_touch/screens/gitea_issues.dart';
import 'package:git_touch/screens/gitea_object.dart';
@ -21,17 +21,17 @@ import 'package:git_touch/screens/gitlab_merge_requests.dart';
import 'package:git_touch/screens/gitlab_project.dart';
import 'package:git_touch/screens/gitlab_tree.dart';
import 'package:git_touch/screens/gitlab_user.dart';
import 'package:git_touch/screens/issue.dart';
import 'package:git_touch/screens/issue_form.dart';
import 'package:git_touch/screens/issues.dart';
import 'package:git_touch/screens/gh_issue.dart';
import 'package:git_touch/screens/gh_issue_form.dart';
import 'package:git_touch/screens/gh_issues.dart';
import 'package:git_touch/screens/login.dart';
import 'package:git_touch/screens/object.dart';
import 'package:git_touch/screens/pulls.dart';
import 'package:git_touch/screens/repositories.dart';
import 'package:git_touch/screens/repository.dart';
import 'package:git_touch/screens/gh_object.dart';
import 'package:git_touch/screens/gh_pulls.dart';
import 'package:git_touch/screens/gh_repos.dart';
import 'package:git_touch/screens/gh_repo.dart';
import 'package:git_touch/screens/settings.dart';
import 'package:git_touch/screens/user.dart';
import 'package:git_touch/screens/users.dart';
import 'package:git_touch/screens/gh_user.dart';
import 'package:git_touch/screens/gh_users.dart';
class RouterScreen {
String path;
@ -74,47 +74,47 @@ class GithubRouter {
final tab = p['tab']?.first;
switch (tab) {
case 'followers':
return UsersScreen(login, UsersScreenType.follower);
return GhUsersScreen(login, UsersScreenType.follower);
case 'following':
return UsersScreen(login, UsersScreenType.following);
return GhUsersScreen(login, UsersScreenType.following);
case 'people':
return UsersScreen(login, UsersScreenType.member);
return GhUsersScreen(login, UsersScreenType.member);
case 'stars':
return RepositoriesScreen.stars(login);
return GhReposScreen.stars(login);
case 'repositories':
return RepositoriesScreen(login);
return GhReposScreen(login);
default:
return UserScreen(login);
return GhUserScreen(login);
}
});
static final repo = RouterScreen('/:owner/:name', (_, p) {
if (p['ref'] == null) {
return RepositoryScreen(p['owner'].first, p['name'].first);
return GhRepoScreen(p['owner'].first, p['name'].first);
} else {
return RepositoryScreen(p['owner'].first, p['name'].first,
return GhRepoScreen(p['owner'].first, p['name'].first,
branch: p['ref'].first);
}
});
static final issueAdd = RouterScreen('/:owner/:name/issues/new', (_, p) {
return IssueFormScreen(p['owner'].first, p['name'].first);
return GhIssueFormScreen(p['owner'].first, p['name'].first);
});
static final issues = RouterScreen('/:owner/:name/issues',
(context, p) => IssuesScreen(p['owner'].first, p['name'].first));
(context, p) => GhIssuesScreen(p['owner'].first, p['name'].first));
static final pulls = RouterScreen('/:owner/:name/pulls',
(context, p) => PullsScreen(p['owner'].first, p['name'].first));
(context, p) => GhPullsScreen(p['owner'].first, p['name'].first));
static final issue = RouterScreen(
'/:owner/:name/issues/:number',
(context, p) => IssueScreen(
(context, p) => GhIssueScreen(
p['owner'].first, p['name'].first, int.parse(p['number'].first)));
static final pull = RouterScreen(
'/:owner/:name/pull/:number',
(context, p) => IssueScreen(
(context, p) => GhIssueScreen(
p['owner'].first, p['name'].first, int.parse(p['number'].first),
isPullRequest: true));
static final commits = RouterScreen('/:owner/:name/commits',
(context, p) => CommitsScreen(p['owner'].first, p['name'].first));
(context, p) => GhCommitsScreen(p['owner'].first, p['name'].first));
static final object = RouterScreen('/:owner/:name/blob/:ref', (_, p) {
return ObjectScreen(
return GhObjectScreen(
p['owner'].first,
p['name'].first,
p['ref'].first,
@ -123,11 +123,11 @@ class GithubRouter {
);
});
static final stargazers = RouterScreen('/:owner/:name/stargazers', (_, p) {
return UsersScreen(p['owner'].first, UsersScreenType.star,
return GhUsersScreen(p['owner'].first, UsersScreenType.star,
repoName: p['name'].first);
});
static final watchers = RouterScreen('/:owner/:name/watchers', (_, p) {
return UsersScreen(p['owner'].first, UsersScreenType.watch,
return GhUsersScreen(p['owner'].first, UsersScreenType.watch,
repoName: p['name'].first);
});
}

View File

@ -1,69 +1,69 @@
import 'package:flutter/material.dart';
import 'package:git_touch/models/theme.dart';
import 'package:git_touch/scaffolds/single.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/table_view.dart';
import 'package:launch_review/launch_review.dart';
import 'package:package_info/package_info.dart';
import 'package:provider/provider.dart';
// import 'package:flutter/material.dart';
// import 'package:git_touch/models/theme.dart';
// import 'package:git_touch/scaffolds/single.dart';
// import 'package:git_touch/widgets/app_bar_title.dart';
// import 'package:git_touch/widgets/table_view.dart';
// import 'package:launch_review/launch_review.dart';
// import 'package:package_info/package_info.dart';
// import 'package:provider/provider.dart';
/// Unused
class AboutScreen extends StatefulWidget {
@override
_AboutScreenState createState() => _AboutScreenState();
}
// /// Unused
// class AboutScreen extends StatefulWidget {
// @override
// _AboutScreenState createState() => _AboutScreenState();
// }
class _AboutScreenState extends State<AboutScreen> {
var _version = '';
// class _AboutScreenState extends State<AboutScreen> {
// var _version = '';
@override
void initState() {
super.initState();
PackageInfo.fromPlatform().then((info) {
setState(() {
_version = info.version;
});
});
}
// @override
// void initState() {
// super.initState();
// PackageInfo.fromPlatform().then((info) {
// setState(() {
// _version = info.version;
// });
// });
// }
@override
Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
return SingleScaffold(
title: AppBarTitle('About'),
body: Column(
children: <Widget>[
SizedBox(height: 32),
ClipRRect(
borderRadius: BorderRadius.circular(24),
child: Image.asset(
'images/icon.png',
width: 96,
),
),
SizedBox(height: 12),
Text(
'GitTouch',
style: TextStyle(fontSize: 20, color: theme.palette.text),
),
SizedBox(height: 48),
TableView(items: [
TableViewItem(text: Text('Version'), rightWidget: Text(_version)),
TableViewItem(text: Text('Source Code'), url: '/pd4d10/git-touch'),
TableViewItem(
text: Text('Feedback'), url: '/pd4d10/git-touch/issues/new'),
TableViewItem(
text: Text('Rate This App'),
onTap: () {
LaunchReview.launch(
androidAppId: 'io.github.pd4d10.gittouch',
iOSAppId: '1452042346',
);
},
),
]),
],
),
);
}
}
// @override
// Widget build(BuildContext context) {
// final theme = Provider.of<ThemeModel>(context);
// return SingleScaffold(
// title: AppBarTitle('About'),
// body: Column(
// children: <Widget>[
// SizedBox(height: 32),
// ClipRRect(
// borderRadius: BorderRadius.circular(24),
// child: Image.asset(
// 'images/icon.png',
// width: 96,
// ),
// ),
// SizedBox(height: 12),
// Text(
// 'GitTouch',
// style: TextStyle(fontSize: 20, color: theme.palette.text),
// ),
// SizedBox(height: 48),
// TableView(items: [
// TableViewItem(text: Text('Version'), rightWidget: Text(_version)),
// TableViewItem(text: Text('Source Code'), url: '/pd4d10/git-touch'),
// TableViewItem(
// text: Text('Feedback'), url: '/pd4d10/git-touch/issues/new'),
// TableViewItem(
// text: Text('Rate This App'),
// onTap: () {
// LaunchReview.launch(
// androidAppId: 'io.github.pd4d10.gittouch',
// iOSAppId: '1452042346',
// );
// },
// ),
// ]),
// ],
// ),
// );
// }
// }

View File

@ -7,11 +7,11 @@ import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/commit_item.dart';
import 'package:provider/provider.dart';
class CommitsScreen extends StatelessWidget {
class GhCommitsScreen extends StatelessWidget {
final String owner;
final String name;
final String branch;
CommitsScreen(this.owner, this.name, {this.branch});
GhCommitsScreen(this.owner, this.name, {this.branch});
Future<ListPayload<GhCommitsCommit, String>> _query(BuildContext context,
[String cursor]) async {

View File

@ -23,19 +23,20 @@ $key: reactions(content: $key) {
}).join('\n');
/// Screen for issue and pull request
class IssueScreen extends StatefulWidget {
class GhIssueScreen extends StatefulWidget {
final String owner;
final String name;
final int number;
final bool isPullRequest;
IssueScreen(this.owner, this.name, this.number, {this.isPullRequest = false});
GhIssueScreen(this.owner, this.name, this.number,
{this.isPullRequest = false});
@override
_IssueScreenState createState() => _IssueScreenState();
_GhIssueScreenState createState() => _GhIssueScreenState();
}
class _IssueScreenState extends State<IssueScreen> {
class _GhIssueScreenState extends State<GhIssueScreen> {
String get owner => widget.owner;
String get name => widget.name;
int get number => widget.number;

View File

@ -7,16 +7,16 @@ import 'package:git_touch/scaffolds/common.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:provider/provider.dart';
class IssueFormScreen extends StatefulWidget {
class GhIssueFormScreen extends StatefulWidget {
final String owner;
final String name;
IssueFormScreen(this.owner, this.name);
GhIssueFormScreen(this.owner, this.name);
@override
_IssueFormScreenState createState() => _IssueFormScreenState();
_GhIssueFormScreenState createState() => _GhIssueFormScreenState();
}
class _IssueFormScreenState extends State<IssueFormScreen> {
class _GhIssueFormScreenState extends State<GhIssueFormScreen> {
var _title = '';
var _body = '';

View File

@ -9,10 +9,10 @@ import 'package:git_touch/widgets/issue_item.dart';
import 'package:git_touch/widgets/label.dart';
import 'package:provider/provider.dart';
class IssuesScreen extends StatelessWidget {
class GhIssuesScreen extends StatelessWidget {
final String owner;
final String name;
IssuesScreen(this.owner, this.name);
GhIssuesScreen(this.owner, this.name);
Future<ListPayload<GhIssuesIssue, String>> _query(BuildContext context,
[String cursor]) async {

View File

@ -11,12 +11,12 @@ import 'package:provider/provider.dart';
import '../widgets/event_item.dart';
import 'package:git_touch/models/auth.dart';
class NewsScreen extends StatefulWidget {
class GhNewsScreen extends StatefulWidget {
@override
NewsScreenState createState() => NewsScreenState();
GhNewsScreenState createState() => GhNewsScreenState();
}
class NewsScreenState extends State<NewsScreen> {
class GhNewsScreenState extends State<GhNewsScreen> {
@override
initState() {
super.initState();

View File

@ -13,12 +13,12 @@ import '../widgets/list_group.dart';
import '../widgets/empty.dart';
import '../utils/utils.dart';
class NotificationScreen extends StatefulWidget {
class GhNotificationScreen extends StatefulWidget {
@override
NotificationScreenState createState() => NotificationScreenState();
GhNotificationScreenState createState() => GhNotificationScreenState();
}
class NotificationScreenState extends State<NotificationScreen> {
class GhNotificationScreenState extends State<GhNotificationScreen> {
Future<Map<String, NotificationGroup>> fetchNotifications(int index) async {
List items = await Provider.of<AuthModel>(context).getWithCredentials(
'/notifications?all=${index == 2}&participating=${index == 1}');

View File

@ -10,13 +10,13 @@ import 'package:git_touch/models/auth.dart';
import 'package:provider/provider.dart';
import 'package:git_touch/utils/utils.dart';
class ObjectScreen extends StatelessWidget {
class GhObjectScreen extends StatelessWidget {
final String owner;
final String name;
final String ref;
final String path;
final String raw;
ObjectScreen(this.owner, this.name, this.ref, {this.path, this.raw});
GhObjectScreen(this.owner, this.name, this.ref, {this.path, this.raw});
@override
Widget build(BuildContext context) {

View File

@ -7,10 +7,10 @@ import 'package:git_touch/widgets/issue_item.dart';
import 'package:git_touch/widgets/label.dart';
import 'package:provider/provider.dart';
class PullsScreen extends StatelessWidget {
class GhPullsScreen extends StatelessWidget {
final String owner;
final String name;
PullsScreen(this.owner, this.name);
GhPullsScreen(this.owner, this.name);
Future<ListPayload<GhPullsPullRequest, String>> _query(BuildContext context,
[String cursor]) async {

View File

@ -17,11 +17,11 @@ import 'package:git_touch/models/theme.dart';
import 'package:tuple/tuple.dart';
import 'package:git_touch/widgets/action_button.dart';
class RepositoryScreen extends StatelessWidget {
class GhRepoScreen extends StatelessWidget {
final String owner;
final String name;
final String branch;
RepositoryScreen(this.owner, this.name, {this.branch});
GhRepoScreen(this.owner, this.name, {this.branch});
Future<GhRepoRepository> _query(BuildContext context) async {
var res = await Provider.of<AuthModel>(context).gqlClient.execute(

View File

@ -7,15 +7,15 @@ import 'package:provider/provider.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:timeago/timeago.dart' as timeago;
class RepositoriesScreen extends StatelessWidget {
class GhReposScreen extends StatelessWidget {
final String owner;
final String title;
final bool isStar;
RepositoriesScreen(this.owner)
GhReposScreen(this.owner)
: title = 'Repositories',
isStar = false;
RepositoriesScreen.stars(this.owner)
GhReposScreen.stars(this.owner)
: title = 'Stars',
isStar = true;

View File

@ -12,12 +12,12 @@ import 'package:git_touch/models/auth.dart';
import 'package:git_touch/widgets/repository_item.dart';
import 'package:timeago/timeago.dart' as timeago;
class SearchScreen extends StatefulWidget {
class GhSearchScreen extends StatefulWidget {
@override
_SearchScreenState createState() => _SearchScreenState();
_GhSearchScreenState createState() => _GhSearchScreenState();
}
class _SearchScreenState extends State<SearchScreen> {
class _GhSearchScreenState extends State<GhSearchScreen> {
int _activeTab = 0;
bool _loading = false;
List<List> _payloads = [[], [], []];

View File

@ -10,7 +10,7 @@ import 'package:http/http.dart' as http;
import 'package:git_touch/widgets/repository_item.dart';
import 'package:provider/provider.dart';
class TrendingScreen extends StatelessWidget {
class GhTrendingScreen extends StatelessWidget {
Widget build(BuildContext context) {
return TabStatefulScaffold<Iterable>(
title: AppBarTitle('Trending'),

View File

@ -16,9 +16,9 @@ import 'package:git_touch/widgets/user_header.dart';
import 'package:provider/provider.dart';
import 'package:git_touch/widgets/action_button.dart';
class UserScreen extends StatelessWidget {
class GhUserScreen extends StatelessWidget {
final String login;
UserScreen(this.login);
GhUserScreen(this.login);
bool get isViewer => login == null;
Iterable<Widget> _buildPinnedItems(Iterable<GhUserRepository> pinnedItems,

View File

@ -16,12 +16,12 @@ enum UsersScreenType {
star,
}
class UsersScreen extends StatelessWidget {
class GhUsersScreen extends StatelessWidget {
final String login;
final String repoName;
final UsersScreenType type;
UsersScreen(this.login, this.type, {this.repoName = ''});
GhUsersScreen(this.login, this.type, {this.repoName = ''});
String get _title {
switch (type) {

View File

@ -1,25 +1,25 @@
import 'package:flutter/material.dart';
import 'package:git_touch/models/theme.dart';
import 'package:git_touch/scaffolds/common.dart';
import 'package:photo_view/photo_view.dart';
import 'package:provider/provider.dart';
// import 'package:flutter/material.dart';
// import 'package:git_touch/models/theme.dart';
// import 'package:git_touch/scaffolds/common.dart';
// import 'package:photo_view/photo_view.dart';
// import 'package:provider/provider.dart';
class ImageViewScreen extends StatelessWidget {
final String url;
final Widget title;
// class ImageViewScreen extends StatelessWidget {
// final String url;
// final Widget title;
ImageViewScreen(this.url, {this.title = const Text('Image')});
// ImageViewScreen(this.url, {this.title = const Text('Image')});
@override
Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
// @override
// Widget build(BuildContext context) {
// final theme = Provider.of<ThemeModel>(context);
return CommonScaffold(
title: title,
body: PhotoView(
imageProvider: NetworkImage(url),
backgroundDecoration: BoxDecoration(color: theme.palette.background),
),
);
}
}
// return CommonScaffold(
// title: title,
// body: PhotoView(
// imageProvider: NetworkImage(url),
// backgroundDecoration: BoxDecoration(color: theme.palette.background),
// ),
// );
// }
// }

View File

@ -5,7 +5,6 @@ import 'package:git_touch/models/theme.dart';
import 'package:git_touch/scaffolds/single.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/action_button.dart';
import 'package:git_touch/widgets/action_entry.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/text_field.dart';
import 'package:provider/provider.dart';