Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: gitee pull screen (with posting comment) * feat: GeFilesScreen, remove 'changes' prop * feat: commitScreen, commits in pullScreen * fix: commit text formatting
- Loading branch information
1 parent
fde136b
commit 92bcdaa
Showing
12 changed files
with
546 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:git_touch/models/gitee.dart'; | ||
import 'package:git_touch/scaffolds/refresh_stateful.dart'; | ||
import 'package:git_touch/utils/utils.dart'; | ||
import 'package:git_touch/widgets/action_button.dart'; | ||
import 'package:git_touch/widgets/avatar.dart'; | ||
import 'package:git_touch/widgets/files_item.dart'; | ||
import 'package:git_touch/widgets/link.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:git_touch/models/auth.dart'; | ||
import 'package:git_touch/models/theme.dart'; | ||
|
||
class GeCommitScreen extends StatelessWidget { | ||
final String owner; | ||
final String name; | ||
final String sha; | ||
GeCommitScreen(this.owner, this.name, this.sha); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final theme = context.watch<ThemeModel>(); | ||
return RefreshStatefulScaffold<GiteeCommit>( | ||
title: Text("Commit: ${sha.substring(0, 7)}"), | ||
fetch: () async { | ||
final auth = context.read<AuthModel>(); | ||
final items = await auth.fetchGitee('/repos/$owner/$name/commits/$sha'); | ||
print(GiteeCommit.fromJson(items)); | ||
return GiteeCommit.fromJson(items); | ||
}, | ||
actionBuilder: (data, _) => ActionButton( | ||
title: 'Actions', items: [...ActionItem.getUrlActions(data.htmlUrl)]), | ||
bodyBuilder: (data, _) { | ||
return Column(children: <Widget>[ | ||
Container( | ||
padding: CommonStyle.padding, | ||
child: Column( | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: <Widget>[ | ||
Link( | ||
url: '/gitee/$owner/$name', | ||
child: Row( | ||
children: <Widget>[ | ||
Avatar( | ||
url: data.author.avatarUrl, | ||
size: AvatarSize.extraSmall, | ||
), | ||
SizedBox(width: 4), | ||
Text( | ||
'$owner / $name', | ||
style: TextStyle( | ||
fontSize: 17, | ||
color: theme.palette.secondaryText, | ||
), | ||
), | ||
SizedBox(width: 4), | ||
Text( | ||
'${sha.substring(0, 7)}', | ||
style: TextStyle( | ||
fontSize: 17, | ||
color: theme.palette.tertiaryText, | ||
), | ||
), | ||
], | ||
), | ||
), | ||
SizedBox(height: 8), | ||
Text( | ||
data.commit.message, | ||
style: TextStyle( | ||
fontSize: 20, | ||
fontWeight: FontWeight.w600, | ||
), | ||
), | ||
], | ||
)), | ||
Wrap( | ||
children: data.files | ||
.map<Widget>((file) => FilesItem( | ||
filename: file.filename, | ||
additions: file.additions, | ||
deletions: file.deletions, | ||
status: file.status, | ||
patch: file.patch, | ||
)) | ||
.toList(), | ||
) | ||
]); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:git_touch/models/gitee.dart'; | ||
import 'package:git_touch/scaffolds/list_stateful.dart'; | ||
import 'package:git_touch/widgets/action_button.dart'; | ||
import 'package:git_touch/widgets/app_bar_title.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:git_touch/widgets/files_item.dart'; | ||
import 'package:git_touch/models/auth.dart'; | ||
import '../generated/l10n.dart'; | ||
|
||
class GeFilesScreen extends StatelessWidget { | ||
final String owner; | ||
final String name; | ||
final String pullNumber; | ||
GeFilesScreen(this.owner, this.name, this.pullNumber); | ||
|
||
Widget build(BuildContext context) { | ||
return ListStatefulScaffold<GiteePullFile, int>( | ||
title: AppBarTitle(S.of(context).files), | ||
actionBuilder: () { | ||
return ActionButton( | ||
title: 'Actions', | ||
items: [ | ||
...ActionItem.getUrlActions( | ||
'https://gitee.com/$owner/$name/pulls/$pullNumber/files'), | ||
], | ||
); | ||
}, | ||
fetch: (page) async { | ||
page = page ?? 1; | ||
final res = await context | ||
.read<AuthModel>() | ||
.fetchGiteeWithPage( | ||
'/repos/$owner/$name/pulls/$pullNumber/files?page=$page', | ||
) | ||
.then((v) { | ||
return [for (var file in v.data) GiteePullFile.fromJson(file)]; | ||
}); | ||
return ListPayload( | ||
cursor: page + 1, | ||
items: res, | ||
hasMore: res.isNotEmpty, | ||
); | ||
}, | ||
itemBuilder: (v) { | ||
return FilesItem( | ||
filename: v.filename, | ||
additions: int.parse(v.additions), | ||
deletions: int.parse(v.deletions), | ||
status: v.status, | ||
patch: v.patch.diff, | ||
); | ||
}, | ||
); | ||
} | ||
} |
Oops, something went wrong.