2020-10-17 14:46:47 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:git_touch/models/auth.dart';
|
|
|
|
import 'package:git_touch/models/gitee.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-10-17 14:46:47 +02:00
|
|
|
|
|
|
|
class GeCommitsScreen extends StatelessWidget {
|
|
|
|
final String owner;
|
|
|
|
final String name;
|
2021-05-16 09:16:35 +02:00
|
|
|
final String? branch;
|
2021-01-09 17:52:45 +01:00
|
|
|
GeCommitsScreen(this.owner, this.name, {this.branch});
|
2020-10-17 14:46:47 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ListStatefulScaffold<GiteeCommit, int>(
|
2021-05-16 09:16:35 +02:00
|
|
|
title: AppBarTitle(AppLocalizations.of(context)!.commits),
|
2020-10-17 14:46:47 +02:00
|
|
|
fetch: (page) async {
|
2021-01-09 17:52:45 +01:00
|
|
|
final res = await context.read<AuthModel>().fetchGiteeWithPage(
|
|
|
|
'/repos/$owner/$name/commits?sha=$branch',
|
|
|
|
page: page);
|
2020-10-17 14:46:47 +02:00
|
|
|
return ListPayload(
|
|
|
|
cursor: res.cursor,
|
|
|
|
hasMore: res.hasMore,
|
|
|
|
items: [for (var v in res.data) GiteeCommit.fromJson(v)],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemBuilder: (c) {
|
|
|
|
return CommitItem(
|
2021-05-16 09:16:35 +02:00
|
|
|
author: c.commit!.author!.name,
|
|
|
|
avatarUrl: c.author!.avatarUrl,
|
|
|
|
avatarLink: '/gitee/${c.author!.login}',
|
|
|
|
createdAt: c.commit!.author!.date,
|
|
|
|
message: c.commit!.message,
|
2021-01-08 03:25:22 +01:00
|
|
|
url: '/gitee/$owner/$name/commits/${c.sha}',
|
2020-10-17 14:46:47 +02:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|