1
0
mirror of https://github.com/git-touch/git-touch synced 2025-02-01 08:26:53 +01:00

70 lines
2.5 KiB
Dart
Raw Normal View History

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