2021-01-08 03:25:22 +01:00
|
|
|
import 'package:flutter/cupertino.dart';
|
2022-09-17 14:35:45 +02:00
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/S.dart';
|
|
|
|
import 'package:git_touch/models/auth.dart';
|
2021-01-08 03:25:22 +01:00
|
|
|
import 'package:git_touch/models/gitee.dart';
|
|
|
|
import 'package:git_touch/scaffolds/list_stateful.dart';
|
|
|
|
import 'package:git_touch/widgets/action_button.dart';
|
|
|
|
import 'package:git_touch/widgets/app_bar_title.dart';
|
|
|
|
import 'package:git_touch/widgets/files_item.dart';
|
2022-09-17 14:35:45 +02:00
|
|
|
import 'package:provider/provider.dart';
|
2021-01-08 03:25:22 +01:00
|
|
|
|
|
|
|
class GeFilesScreen extends StatelessWidget {
|
2022-09-21 18:28:21 +02:00
|
|
|
const GeFilesScreen(this.owner, this.name, this.pullNumber);
|
2021-01-08 03:25:22 +01:00
|
|
|
final String owner;
|
|
|
|
final String name;
|
|
|
|
final String pullNumber;
|
|
|
|
|
2022-09-06 18:28:12 +02:00
|
|
|
@override
|
2021-01-08 03:25:22 +01:00
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ListStatefulScaffold<GiteePullFile, int>(
|
2021-05-16 09:16:35 +02:00
|
|
|
title: AppBarTitle(AppLocalizations.of(context)!.files),
|
2021-01-08 03:25:22 +01:00
|
|
|
actionBuilder: () {
|
|
|
|
return ActionButton(
|
|
|
|
title: 'Actions',
|
|
|
|
items: [
|
|
|
|
...ActionItem.getUrlActions(
|
|
|
|
'https://gitee.com/$owner/$name/pulls/$pullNumber/files'),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
fetch: (page) async {
|
|
|
|
page = page ?? 1;
|
|
|
|
final res = await context
|
|
|
|
.read<AuthModel>()
|
|
|
|
.fetchGiteeWithPage(
|
|
|
|
'/repos/$owner/$name/pulls/$pullNumber/files?page=$page',
|
|
|
|
)
|
|
|
|
.then((v) {
|
|
|
|
return [for (var file in v.data) GiteePullFile.fromJson(file)];
|
|
|
|
});
|
|
|
|
return ListPayload(
|
|
|
|
cursor: page + 1,
|
|
|
|
items: res,
|
|
|
|
hasMore: res.isNotEmpty,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
itemBuilder: (v) {
|
|
|
|
return FilesItem(
|
|
|
|
filename: v.filename,
|
2021-05-16 09:16:35 +02:00
|
|
|
additions: int.parse(v.additions!),
|
|
|
|
deletions: int.parse(v.deletions!),
|
2021-01-08 03:25:22 +01:00
|
|
|
status: v.status,
|
2021-05-16 09:16:35 +02:00
|
|
|
patch: v.patch!.diff,
|
2021-01-08 03:25:22 +01:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|