mirror of
https://github.com/git-touch/git-touch
synced 2025-03-13 01:30:09 +01:00
improvement: gitlab todo
This commit is contained in:
parent
e80881db17
commit
38fe9caf8d
1
.gitignore
vendored
1
.gitignore
vendored
@ -74,3 +74,4 @@
|
||||
|
||||
pubspec.lock
|
||||
.flutter-plugins-dependencies
|
||||
generated_plugin_registrant.dart
|
||||
|
@ -9,6 +9,54 @@ import 'package:git_touch/widgets/link.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class GitlabTodosScreen extends StatelessWidget {
|
||||
InlineSpan _buildActor(BuildContext context, GitlabTodo p) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
return TextSpan(
|
||||
text: p.author.name,
|
||||
style: TextStyle(color: theme.palette.primary),
|
||||
);
|
||||
}
|
||||
|
||||
InlineSpan _buildIssue(BuildContext context, GitlabTodo p) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
return TextSpan(
|
||||
text: '${p.project.pathWithNamespace}!${p.target.iid}',
|
||||
style: TextStyle(color: theme.palette.primary),
|
||||
);
|
||||
}
|
||||
|
||||
Iterable<InlineSpan> _buildItem(BuildContext context, GitlabTodo p) {
|
||||
switch (p.actionName) {
|
||||
case 'mentioned':
|
||||
return [
|
||||
_buildActor(context, p),
|
||||
TextSpan(text: ' mentioned you on ${p.targetType} '),
|
||||
_buildIssue(context, p),
|
||||
];
|
||||
case 'build_failed':
|
||||
return [
|
||||
TextSpan(text: ' the build failed for ${p.targetType} '),
|
||||
_buildIssue(context, p),
|
||||
];
|
||||
case 'directly_addressed':
|
||||
return [
|
||||
_buildActor(context, p),
|
||||
TextSpan(text: ' directly addressed you ${p.targetType} '),
|
||||
_buildIssue(context, p),
|
||||
];
|
||||
case 'assigned':
|
||||
return [
|
||||
_buildActor(context, p),
|
||||
TextSpan(text: ' directly addressed you ${p.targetType} '),
|
||||
_buildIssue(context, p),
|
||||
];
|
||||
default:
|
||||
return [
|
||||
TextSpan(text: ' action type ${p.actionName} not implemented yet')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Provider.of<ThemeModel>(context);
|
||||
@ -30,29 +78,16 @@ class GitlabTodosScreen extends StatelessWidget {
|
||||
padding: CommonStyle.padding,
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Avatar(url: item.author.avatarUrl),
|
||||
GitlabAvatar(
|
||||
url: item.author.avatarUrl, id: item.author.id),
|
||||
SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text.rich(
|
||||
TextSpan(
|
||||
style: TextStyle(
|
||||
color: theme.palette.text, fontSize: 17),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: item.author.name,
|
||||
style: TextStyle(
|
||||
color: theme.palette.primary,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: ' ' +
|
||||
item.actionName +
|
||||
' you ' +
|
||||
item.targetType +
|
||||
' ' +
|
||||
item.project.pathWithNamespace +
|
||||
' ' +
|
||||
item.target.iid.toString(),
|
||||
),
|
||||
..._buildItem(context, item),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -13,18 +13,20 @@ class Avatar extends StatelessWidget {
|
||||
final String url;
|
||||
final double size;
|
||||
final String linkUrl;
|
||||
final BorderRadius borderRadius;
|
||||
|
||||
Avatar({
|
||||
@required this.url,
|
||||
this.size = AvatarSize.medium,
|
||||
this.linkUrl,
|
||||
this.borderRadius,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
borderRadius: borderRadius ?? BorderRadius.circular(4),
|
||||
child: FadeInImage.assetNetwork(
|
||||
placeholder: 'images/avatar.png',
|
||||
image: url ?? 'images/avatar.png',
|
||||
@ -66,12 +68,17 @@ class GitlabAvatar extends StatelessWidget {
|
||||
|
||||
GitlabAvatar({
|
||||
@required this.url,
|
||||
@required this.id,
|
||||
this.size = AvatarSize.medium,
|
||||
this.id,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Avatar(url: url, size: size, linkUrl: '/user/$id');
|
||||
return Avatar(
|
||||
url: url,
|
||||
size: size,
|
||||
linkUrl: '/user/$id',
|
||||
borderRadius: BorderRadius.circular(size / 2),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user