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

69 lines
2.3 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 '../generated/l10n.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>(
title: AppBarTitle(S.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) {
return Link(
url: '',
child: Container(
padding: CommonStyle.padding,
child: Row(
children: <Widget>[
2019-12-22 04:11:13 +01: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(
text: data.author.name,
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(
text: ' ' + data.actionName + data.targetType),
],
),
),
Text(data.note.body)
],
),
),
],
),
),
);
},
);
}
}