2020-02-01 08:21:42 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:git_touch/models/auth.dart';
|
|
|
|
import 'package:git_touch/models/gitea.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-02-03 05:04:41 +01:00
|
|
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
2020-02-01 08:21:42 +01:00
|
|
|
|
2020-02-07 15:20:06 +01:00
|
|
|
class GtCommitsScreen extends StatelessWidget {
|
2020-02-01 08:21:42 +01:00
|
|
|
final String owner;
|
|
|
|
final String name;
|
|
|
|
// final String branch; // TODO:
|
2020-02-07 15:20:06 +01:00
|
|
|
GtCommitsScreen(this.owner, this.name);
|
2020-02-01 08:21:42 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ListStatefulScaffold<GiteaCommit, int>(
|
2021-05-16 09:16:35 +02:00
|
|
|
title: AppBarTitle(AppLocalizations.of(context)!.commits),
|
2020-10-06 14:52:40 +02:00
|
|
|
fetch: (page) async {
|
2020-10-06 05:54:35 +02:00
|
|
|
final res = await context
|
|
|
|
.read<AuthModel>()
|
|
|
|
.fetchGiteaWithPage('/repos/$owner/$name/commits', page: page);
|
2020-10-04 16:10:05 +02:00
|
|
|
return ListPayload(
|
|
|
|
cursor: res.cursor,
|
|
|
|
hasMore: res.hasMore,
|
|
|
|
items:
|
|
|
|
(res.data as List).map((v) => GiteaCommit.fromJson(v)).toList(),
|
|
|
|
);
|
|
|
|
},
|
2020-02-01 08:21:42 +01:00
|
|
|
itemBuilder: (c) {
|
|
|
|
return CommitItem(
|
2021-05-16 09:16:35 +02:00
|
|
|
author: c.author?.login ?? c.commit!.author!.name,
|
2020-02-01 08:21:42 +01:00
|
|
|
avatarUrl: null,
|
2020-04-06 07:34:14 +02:00
|
|
|
avatarLink: null,
|
2021-05-16 09:16:35 +02:00
|
|
|
createdAt: c.commit!.author!.date,
|
|
|
|
message: c.commit!.message,
|
2020-02-01 08:21:42 +01:00
|
|
|
url: c.htmlUrl,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|