2020-01-28 15:10:44 +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/scaffolds/list_stateful.dart';
|
|
|
|
import 'package:git_touch/widgets/app_bar_title.dart';
|
|
|
|
import 'package:git_touch/widgets/commit_item.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
2021-01-05 10:25:19 +01:00
|
|
|
import '../generated/l10n.dart';
|
2020-01-28 15:10:44 +01:00
|
|
|
|
2020-02-07 15:26:37 +01:00
|
|
|
class GlCommitsScreen extends StatelessWidget {
|
2020-01-28 15:10:44 +01:00
|
|
|
final String id;
|
2020-02-01 06:37:44 +01:00
|
|
|
final String prefix;
|
2020-01-28 15:10:44 +01:00
|
|
|
// final String branch; // TODO:
|
2020-02-07 15:26:37 +01:00
|
|
|
GlCommitsScreen(this.id, {this.prefix});
|
2020-01-28 15:10:44 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ListStatefulScaffold<GitlabCommit, int>(
|
2021-01-05 10:25:19 +01:00
|
|
|
title: AppBarTitle(S.of(context).commits),
|
2020-10-06 14:52:40 +02:00
|
|
|
fetch: (page) async {
|
2020-10-04 16:10:05 +02:00
|
|
|
page = page ?? 1;
|
|
|
|
final auth = context.read<AuthModel>();
|
|
|
|
final res = await auth
|
|
|
|
.fetchGitlabWithPage('/projects/$id/repository/commits?page=$page');
|
|
|
|
return ListPayload(
|
|
|
|
cursor: res.cursor,
|
|
|
|
hasMore: res.hasMore,
|
|
|
|
items:
|
|
|
|
(res.data as List).map((v) => GitlabCommit.fromJson(v)).toList(),
|
|
|
|
);
|
|
|
|
},
|
2020-01-28 15:10:44 +01:00
|
|
|
itemBuilder: (c) {
|
|
|
|
return CommitItem(
|
|
|
|
author: c.authorName,
|
|
|
|
avatarUrl: null,
|
2020-04-06 07:34:14 +02:00
|
|
|
avatarLink: null,
|
2020-01-28 15:10:44 +01:00
|
|
|
createdAt: c.createdAt,
|
|
|
|
message: c.message,
|
2020-02-01 06:37:44 +01:00
|
|
|
url: '$prefix/commit/${c.id}', // TODO:
|
2020-04-06 07:34:14 +02:00
|
|
|
// url: '/gitlab/projects/$id/commit/${c.id}', // TODO:
|
2020-01-28 15:10:44 +01:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|