git-touch-android-ios-app/lib/screens/gl_project_activity.dart

70 lines
2.4 KiB
Dart
Raw Normal View History

2019-12-14 17:08:45 +01:00
import 'package:flutter/material.dart';
import 'package:git_touch/models/auth.dart';
import 'package:git_touch/models/gitlab.dart';
import 'package:git_touch/models/theme.dart';
import 'package:git_touch/scaffolds/list_stateful.dart';
import 'package:git_touch/utils/utils.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/avatar.dart';
import 'package:git_touch/widgets/link.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/S.dart';
2019-12-14 17:08:45 +01:00
2020-02-07 15:26:37 +01:00
class GlProjectActivityScreen extends StatelessWidget {
2019-12-14 17:08:45 +01:00
final int id;
2020-02-07 15:26:37 +01:00
GlProjectActivityScreen(this.id);
2019-12-14 17:08:45 +01:00
@override
Widget build(BuildContext context) {
final theme = Provider.of<ThemeModel>(context);
return ListStatefulScaffold<GitlabEvent, int>(
2021-05-16 09:16:35 +02:00
title: AppBarTitle(AppLocalizations.of(context)!.activity),
fetch: (page) async {
2020-10-04 16:10:05 +02:00
page = page ?? 1;
final auth = context.read<AuthModel>();
final vs = await auth.fetchGitlab('/projects/$id/events');
final events =
(vs as List).map((v) => GitlabEvent.fromJson(v)).toList();
return ListPayload(cursor: page, items: events, hasMore: false);
},
2019-12-14 17:08:45 +01:00
itemBuilder: (data) {
2021-05-16 09:16:35 +02:00
return LinkWidget(
2019-12-14 17:08:45 +01:00
url: '',
child: Container(
padding: CommonStyle.padding,
child: Row(
children: <Widget>[
2021-05-16 09:16:35 +02:00
Avatar(url: data.author!.avatarUrl),
2019-12-14 17:08:45 +01:00
SizedBox(width: 12),
Expanded(
child: Column(
children: <Widget>[
Text.rich(
TextSpan(
children: [
TextSpan(
2021-05-16 09:16:35 +02:00
text: data.author!.name,
2019-12-14 17:08:45 +01:00
style: TextStyle(
2020-01-27 08:11:51 +01:00
color: theme.palette.primary,
2019-12-14 17:08:45 +01:00
fontWeight: FontWeight.w500,
),
),
TextSpan(
2021-05-16 09:16:35 +02:00
text:
' ' + data.actionName! + data.targetType!),
2019-12-14 17:08:45 +01:00
],
),
),
2021-05-16 09:16:35 +02:00
Text(data.note!.body!)
2019-12-14 17:08:45 +01:00
],
),
),
],
),
),
);
},
);
}
}