1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-17 10:48:50 +01:00

fix: current branch name

This commit is contained in:
Rongjian Zhang 2019-09-23 19:51:49 +08:00
parent b07b25fca0
commit 89786c307e

View File

@ -37,7 +37,6 @@ class RepositoryScreen extends StatelessWidget {
get _branchQueryChunk => get _branchQueryChunk =>
branch == null ? 'defaultBranchRef' : 'ref(qualifiedName: "$branch")'; branch == null ? 'defaultBranchRef' : 'ref(qualifiedName: "$branch")';
get _branchName => branch ?? 'master';
get branchInfoKey => branch == null ? 'defaultBranchRef' : 'ref'; get branchInfoKey => branch == null ? 'defaultBranchRef' : 'ref';
Future queryRepo(BuildContext context) async { Future queryRepo(BuildContext context) async {
@ -284,7 +283,7 @@ class RepositoryScreen extends StatelessWidget {
TableView( TableView(
hasIcon: true, hasIcon: true,
items: [ items: [
if (payload[branchInfoKey] != null) if (payload[branchInfoKey] != null) ...[
TableViewItem( TableViewItem(
leftIconData: Octicons.history, leftIconData: Octicons.history,
text: Text('Commits'), text: Text('Commits'),
@ -293,31 +292,33 @@ class RepositoryScreen extends StatelessWidget {
screenBuilder: (_) => screenBuilder: (_) =>
CommitsScreen(owner, name, branch: branch), CommitsScreen(owner, name, branch: branch),
), ),
if (payload['refs'] != null) if (payload['refs'] != null)
TableViewItem( TableViewItem(
leftIconData: Octicons.git_branch, leftIconData: Octicons.git_branch,
text: Text('Branches'), text: Text('Branches'),
rightWidget: Text(_branchName + rightWidget: Text(payload[branchInfoKey]['name'] +
'' + '' +
numberFormat.format(payload['refs']['totalCount'])), numberFormat.format(payload['refs']['totalCount'])),
onTap: () async { onTap: () async {
var result = await Provider.of<ThemeModel>(context) // FIXME: Show all branches
.showDialogOptions( var result = await Provider.of<ThemeModel>(context)
context, .showDialogOptions(
(payload['refs']['nodes'] as List) context,
.map((b) => DialogOption( (payload['refs']['nodes'] as List)
value: b['name'] as String, .map((b) => DialogOption(
widget: Text(b['name'] as String))) value: b['name'] as String,
.toList()); widget: Text(b['name'] as String)))
.toList());
if (result != null) { if (result != null) {
Provider.of<ThemeModel>(context).pushReplacementRoute( Provider.of<ThemeModel>(context).pushReplacementRoute(
context, context,
(_) => (_) => RepositoryScreen(owner, name,
RepositoryScreen(owner, name, branch: result)); branch: result));
} }
}, },
), ),
],
TableViewItem( TableViewItem(
leftIconData: Octicons.law, leftIconData: Octicons.law,
text: Text('License'), text: Text('License'),