2019-11-01 18:12:17 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:git_touch/models/auth.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/screens/gitlab/issue.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-11-01 18:12:17 +01:00
|
|
|
return RefreshStatefulScaffold(
|
|
|
|
title: Text('Todos'),
|
|
|
|
fetchData: () {
|
|
|
|
return Provider.of<AuthModel>(context).fetchGitlab('/todos');
|
|
|
|
},
|
2019-11-02 13:54:23 +01:00
|
|
|
bodyBuilder: (data, _) {
|
2019-11-01 18:12:17 +01:00
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
2019-11-02 13:54:23 +01:00
|
|
|
children: (data as List).map((item) {
|
2019-11-01 18:12:17 +01:00
|
|
|
return Link(
|
|
|
|
screenBuilder: (_) => GitlabIssueScreen(
|
|
|
|
item['target']['project_id'], item['target']['iid'],
|
|
|
|
isMr: item['target_type'] == 'MergeRequest'),
|
|
|
|
child: Container(
|
|
|
|
padding: CommonStyle.padding,
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Avatar.medium(
|
|
|
|
url: item['author']['avatar_url'],
|
|
|
|
),
|
|
|
|
SizedBox(width: 12),
|
|
|
|
Expanded(
|
|
|
|
child: Text.rich(
|
|
|
|
TextSpan(
|
|
|
|
children: [
|
|
|
|
TextSpan(
|
|
|
|
text: item['author']['name'],
|
|
|
|
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: ' ' +
|
|
|
|
item['action_name'] +
|
|
|
|
' you ' +
|
|
|
|
item['target_type'] +
|
|
|
|
' ' +
|
|
|
|
item['project']['path_with_namespace'] +
|
|
|
|
' ' +
|
|
|
|
item['target']['iid'].toString(),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}).toList(),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|