1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-24 23:01:18 +01:00
git-touch-android-ios-app/lib/screens/gitlab_todos.dart

70 lines
2.5 KiB
Dart
Raw Normal View History

2019-11-01 18:12:17 +01:00
import 'package:flutter/material.dart';
import 'package:git_touch/models/auth.dart';
2019-12-04 15:00:39 +01:00
import 'package:git_touch/models/gitlab.dart';
2019-11-08 11:29:08 +01:00
import 'package:git_touch/models/theme.dart';
2019-11-01 18:12:17 +01:00
import 'package:git_touch/scaffolds/refresh_stateful.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/avatar.dart';
import 'package:git_touch/widgets/link.dart';
import 'package:provider/provider.dart';
class GitlabTodosScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
2019-11-08 11:29:08 +01:00
final theme = Provider.of<ThemeModel>(context);
2019-12-04 15:00:39 +01:00
return RefreshStatefulScaffold<Iterable<GitlabTodo>>(
2019-11-01 18:12:17 +01:00
title: Text('Todos'),
2019-12-04 15:00:39 +01:00
fetchData: () async {
final vs = await Provider.of<AuthModel>(context).fetchGitlab('/todos');
return (vs as List).map((v) => GitlabTodo.fromJson(v));
2019-11-01 18:12:17 +01:00
},
2019-11-02 13:54:23 +01:00
bodyBuilder: (data, _) {
2019-11-01 18:12:17 +01:00
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
2019-12-04 15:00:39 +01:00
children: data.map((item) {
2019-11-01 18:12:17 +01:00
return Link(
url:
2019-12-14 17:08:12 +01:00
'/projects/${item.target.projectId}/${item.targetType == 'MergeRequest' ? 'merge_requests' : 'issue'}/${item.target.iid}',
2019-11-01 18:12:17 +01:00
child: Container(
padding: CommonStyle.padding,
child: Row(
children: <Widget>[
2019-12-04 15:00:39 +01:00
Avatar.medium(url: item.author.avatarUrl),
2019-11-01 18:12:17 +01:00
SizedBox(width: 12),
Expanded(
child: Text.rich(
TextSpan(
children: [
TextSpan(
2019-12-04 15:00:39 +01:00
text: item.author.name,
2019-11-01 18:12:17 +01:00
style: TextStyle(
2019-11-08 11:29:08 +01:00
color: theme.palette.primary,
2019-11-01 18:12:17 +01:00
fontWeight: FontWeight.w500,
),
),
TextSpan(
text: ' ' +
2019-12-04 15:00:39 +01:00
item.actionName +
2019-11-01 18:12:17 +01:00
' you ' +
2019-12-04 15:00:39 +01:00
item.targetType +
2019-11-01 18:12:17 +01:00
' ' +
2019-12-04 15:00:39 +01:00
item.project.pathWithNamespace +
2019-11-01 18:12:17 +01:00
' ' +
2019-12-04 15:00:39 +01:00
item.target.iid.toString(),
2019-11-01 18:12:17 +01:00
),
],
),
),
),
],
),
),
);
}).toList(),
);
},
);
}
}