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

chore: github prefix for routes (#89)

closes #88
This commit is contained in:
Shreyas Thirumalai 2020-05-12 21:01:30 +05:30 committed by GitHub
parent 8f5dafd2d0
commit 7a11dca621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 47 additions and 50 deletions

View File

@ -63,7 +63,7 @@ class CommonRouter {
}
class GithubRouter {
static const prefix = ''; // TODO: '/github';
static const prefix = '/github';
static final routes = [
GithubRouter.user,
GithubRouter.repo,

View File

@ -55,7 +55,7 @@ class GhCommitsScreen extends StatelessWidget {
return CommitItem(
url: payload.url,
avatarUrl: payload.author?.avatarUrl,
avatarLink: login == null ? null : '/$login',
avatarLink: login == null ? null : '/github/$login',
message: payload.messageHeadline,
author: login ?? payload.author.name,
createdAt: payload.committedDate,

View File

@ -24,7 +24,6 @@ class GhComparisonScreen extends StatelessWidget {
'/repos/$owner/$name/compare/$before...$head',
convert: (vs) => GithubComparisonItem.fromJson(vs),
);
print('/repos/$owner/$name/compare/$before...$head');
return res.files;
},
actionBuilder: (v, _) {

View File

@ -1,14 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:git_touch/models/github.dart';
import 'package:git_touch/models/notification.dart';
import 'package:git_touch/scaffolds/list_stateful.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/contributor_item.dart';
import 'package:github/github.dart';
import 'package:provider/provider.dart';
import 'package:git_touch/widgets/event_item.dart';
import 'package:git_touch/models/auth.dart';
class GhContributorsScreen extends StatelessWidget {
@ -41,7 +37,7 @@ class GhContributorsScreen extends StatelessWidget {
avatarUrl: v.avatarUrl,
commits: v.contributions,
login: v.login,
url: '/$login?tab=contributors',
url: '/github/$login?tab=contributors',
);
},
);

View File

@ -509,7 +509,7 @@ fragment ReactableParts on Reactable {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Link(
url: '/$owner/$name',
url: '/github/$owner/$name',
child: Row(
children: <Widget>[
Avatar(
@ -587,7 +587,7 @@ fragment ReactableParts on Reactable {
],
),
),
url: '/$owner/$name/pull/$number/files',
url: '/github/$owner/$name/pull/$number/files',
),
CommonStyle.border,
],

View File

@ -75,7 +75,7 @@ class _GhIssueFormScreenState extends State<GhIssueFormScreen> {
jsonDecode(response.body) as Map<String, dynamic>);
await theme.push(
context,
'/${widget.owner}/${widget.name}/issues/${res.number}',
'/github/${widget.owner}/${widget.name}/issues/${res.number}',
replace: true,
);
},

View File

@ -37,7 +37,7 @@ class GhIssuesScreen extends StatelessWidget {
title: AppBarTitle('Issues'),
actionBuilder: () => ActionEntry(
iconData: Octicons.plus,
url: '/$owner/$name/issues/new',
url: '/github/$owner/$name/issues/new',
),
onRefresh: () => _query(context),
onLoadMore: (cursor) => _query(context, cursor),
@ -55,7 +55,7 @@ class GhIssuesScreen extends StatelessWidget {
MyLabel(name: label.name, cssColor: label.color)
]),
url:
'/${p.repository.owner.login}/${p.repository.name}/issues/${p.number}',
'/github/${p.repository.owner.login}/${p.repository.name}/issues/${p.number}',
),
);
}

View File

@ -58,7 +58,7 @@ class GhObjectScreen extends StatelessWidget {
items: data.tree.map((v) {
// if (item.type == 'commit') return null;
final uri = Uri(
path: '/$owner/$name/blob/$ref',
path: '/github/$owner/$name/blob/$ref',
queryParameters: {
'path': v.path,
...(v.downloadUrl == null ? {} : {'raw': v.downloadUrl}),

View File

@ -50,7 +50,7 @@ class GhPullsScreen extends StatelessWidget {
MyLabel(name: label.name, cssColor: label.color)
]),
url:
'/${p.repository.owner.login}/${p.repository.name}/pull/${p.number}',
'/github/${p.repository.owner.login}/${p.repository.name}/pull/${p.number}',
),
);
}

View File

@ -115,7 +115,7 @@ class GhRepoScreen extends StatelessWidget {
children: <Widget>[
RepoHeader(
avatarUrl: repo.owner.avatarUrl,
avatarLink: '/${repo.owner.login}',
avatarLink: '/github/${repo.owner.login}',
name: repo.name,
owner: repo.owner.login,
description: repo.description,
@ -240,12 +240,12 @@ class GhRepoScreen extends StatelessWidget {
EntryItem(
count: repo.watchers.totalCount,
text: 'Watchers',
url: '/$owner/$name/watchers',
url: '/github/$owner/$name/watchers',
),
EntryItem(
count: repo.stargazers.totalCount,
text: 'Stars',
url: '/$owner/$name/stargazers',
url: '/github/$owner/$name/stargazers',
),
EntryItem(
count: repo.forks.totalCount,
@ -276,7 +276,7 @@ class GhRepoScreen extends StatelessWidget {
(license == null ? '' : '$license') +
filesize(repo.diskUsage * 1000),
),
url: '/$owner/$name/blob/${ref.name}',
url: '/github/$owner/$name/blob/${ref.name}',
),
if (repo.hasIssuesEnabled)
TableViewItem(
@ -284,14 +284,14 @@ class GhRepoScreen extends StatelessWidget {
text: Text('Issues'),
rightWidget:
Text(numberFormat.format(repo.issues.totalCount)),
url: '/$owner/$name/issues',
url: '/github/$owner/$name/issues',
),
TableViewItem(
leftIconData: Octicons.git_pull_request,
text: Text('Pull requests'),
rightWidget:
Text(numberFormat.format(repo.pullRequests.totalCount)),
url: '/$owner/$name/pulls',
url: '/github/$owner/$name/pulls',
),
TableViewItem(
leftIconData: Octicons.history,
@ -300,7 +300,7 @@ class GhRepoScreen extends StatelessWidget {
.history
?.totalCount
.toString()),
url: '/$owner/$name/commits',
url: '/github/$owner/$name/commits',
),
if (ref != null) ...[
if (repo.refs != null)
@ -323,7 +323,8 @@ class GhRepoScreen extends StatelessWidget {
.toList(),
onClose: (ref) {
if (ref != branch) {
theme.push(context, '/$owner/$name?ref=$ref',
theme.push(
context, '/github/$owner/$name?ref=$ref',
replace: true);
}
},
@ -336,7 +337,7 @@ class GhRepoScreen extends StatelessWidget {
leftIconData: Octicons.organization,
text: Text('Contributors'),
rightWidget: Text(contributorsCount),
url: '/$owner/$name/contributors',
url: '/github/$owner/$name/contributors',
)
],
),

View File

@ -199,7 +199,7 @@ class _GhSearchScreenState extends State<GhSearchScreen> {
number: p['number'],
title: p['title'],
updatedAt: DateTime.parse(p['updatedAt']),
url: Uri.parse(p['url']).path,
url: '/github' + Uri.parse(p['url']).path,
isPr: p['__typename'] == 'PullRequest',
);
}

View File

@ -51,7 +51,7 @@ class GhTrendingScreen extends StatelessWidget {
// name: v.name,
avatarUrl: v.avatar,
bio: Link(
url: '/${v.username}/${v.repo.name}',
url: '/github/${v.username}/${v.repo.name}',
child: Row(
children: <Widget>[
Icon(

View File

@ -97,22 +97,22 @@ class GhUserScreen extends StatelessWidget {
EntryItem(
count: p.repositories.totalCount,
text: 'Repositories',
url: '/$login?tab=repositories',
url: '/github/$login?tab=repositories',
),
EntryItem(
count: p.starredRepositories.totalCount,
text: 'Stars',
url: '/$login?tab=stars',
url: '/github/$login?tab=stars',
),
EntryItem(
count: p.followers.totalCount,
text: 'Followers',
url: '/$login?tab=followers',
url: '/github/$login?tab=followers',
),
EntryItem(
count: p.following.totalCount,
text: 'Following',
url: '/$login?tab=following',
url: '/github/$login?tab=following',
),
]),
CommonStyle.border,
@ -155,7 +155,7 @@ class GhUserScreen extends StatelessWidget {
TableViewItem(
leftIconData: Octicons.home,
text: Text('Organizations'),
url: '/$login?tab=organizations',
url: '/github/$login?tab=organizations',
),
if (isNotNullOrEmpty(p.company))
TableViewItem(
@ -241,12 +241,12 @@ class GhUserScreen extends StatelessWidget {
EntryItem(
count: p.pinnableItems.totalCount,
text: 'Repositories',
url: '/${p.login}?tab=orgrepo',
url: '/github/${p.login}?tab=orgrepo',
),
EntryItem(
count: p.membersWithRole.totalCount,
text: 'Members',
url: '/${p.login}?tab=people',
url: '/github/${p.login}?tab=people',
),
]),
TableView(

View File

@ -38,7 +38,7 @@ class GhUserOrganizationScreen extends StatelessWidget {
return UserOrganizationItem(
avatarUrl: v.avatarUrl,
login: v.login,
url: '/$login',
url: '/github/$login',
description: v.description,
);
},

View File

@ -63,7 +63,7 @@ class GithubAvatar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Avatar(url: url, size: size, linkUrl: '/$login');
return Avatar(url: url, size: size, linkUrl: '/github/$login');
}
}
@ -83,7 +83,7 @@ class GitlabAvatar extends StatelessWidget {
return Avatar(
url: url,
size: size,
linkUrl: '/user/$id',
linkUrl: '/gitlab/user/$id',
);
}
}

View File

@ -29,13 +29,13 @@ class EventItem extends StatelessWidget {
InlineSpan _buildRepo(BuildContext context, [String fullName]) {
final name = fullName ?? e.repo.name;
return _buildLinkSpan(context, name, '/$name');
return _buildLinkSpan(context, name, '/github/$name');
}
InlineSpan _buildIssue(BuildContext context, int number,
{bool isPullRequest = false}) {
return _buildLinkSpan(context, '#$number',
'/${e.repoOwner}/${e.repoName}/${isPullRequest ? 'pull' : 'issues'}/$number');
'/github/${e.repoOwner}/${e.repoName}/${isPullRequest ? 'pull' : 'issues'}/$number');
}
Widget _buildItem({
@ -52,7 +52,8 @@ class EventItem extends StatelessWidget {
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Avatar(url: e.actor.avatarUrl, linkUrl: '/' + e.actor.login),
Avatar(
url: e.actor.avatarUrl, linkUrl: '/github/' + e.actor.login),
SizedBox(width: 10),
Expanded(
child: Column(
@ -65,8 +66,8 @@ class EventItem extends StatelessWidget {
color: theme.palette.text,
),
children: [
_buildLinkSpan(
context, e.actor.login, '/${e.actor.login}'),
_buildLinkSpan(context, e.actor.login,
'/github/${e.actor.login}'),
...spans,
],
),
@ -110,7 +111,7 @@ class EventItem extends StatelessWidget {
final theme = Provider.of<ThemeModel>(context);
return Link(
url:
'/${e.repoOwner}/${e.repoName}/compare/${e.payload.before}/${e.payload.head}',
'/github/${e.repoOwner}/${e.repoName}/compare/${e.payload.before}/${e.payload.head}',
child: Container(
padding: EdgeInsets.all(12),
decoration: BoxDecoration(
@ -186,7 +187,7 @@ class EventItem extends StatelessWidget {
return Link(
url:
'/${e.repoOwner}/${e.repoName}/${isPullRequest ? 'pull' : 'issues'}/${issue.number}',
'/github/${e.repoOwner}/${e.repoName}/${isPullRequest ? 'pull' : 'issues'}/${issue.number}',
child: Container(
padding: EdgeInsets.all(12),
decoration: BoxDecoration(

View File

@ -102,14 +102,14 @@ class _NotificationItemState extends State<NotificationItem> {
final fullName = payload.repository.fullName;
switch (payload.subject.type) {
case 'Issue':
return '/$fullName/issues/${payload.subject.number}';
return '/github/$fullName/issues/${payload.subject.number}';
case 'PullRequest':
return '/$fullName/pull/${payload.subject.number}';
return '/github/$fullName/pull/${payload.subject.number}';
case 'Release':
return 'https://github.com/$fullName/releases';
case 'Commit':
case 'CheckSuite':
return '/$fullName';
return '/github/$fullName';
default:
return null;
}

View File

@ -84,8 +84,8 @@ class RepositoryItem extends StatelessWidget {
@required bool isPrivate,
@required bool isFork,
}) : iconData = _buildIconData(isPrivate, isFork),
avatarLink = '/$owner',
url = '/$owner/$name';
avatarLink = '/github/$owner',
url = '/github/$owner/$name';
static IconData _buildIconData(bool isPrivate, bool isFork) {
if (isPrivate == true) return Octicons.lock;

View File

@ -24,7 +24,7 @@ class UserItem extends StatelessWidget {
// @required this.name,
@required this.avatarUrl,
@required this.bio,
}) : url = '/$login';
}) : url = '/github/$login';
UserItem({
@required this.login,

View File

@ -12,7 +12,7 @@ class UserName extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
return Link(
url: '/$login',
url: '/github/$login',
child: Container(
// padding: EdgeInsets.all(2),
decoration: BoxDecoration(