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

53 lines
1.6 KiB
Dart
Raw Normal View History

2022-09-20 20:00:03 +02:00
import 'package:antd_mobile/antd_mobile.dart';
import 'package:flutter/cupertino.dart';
2022-09-17 14:35:45 +02:00
import 'package:flutter/widgets.dart';
2022-09-11 19:54:07 +02:00
import 'package:flutter_gen/gen_l10n/S.dart';
import 'package:git_touch/models/auth.dart';
import 'package:git_touch/scaffolds/refresh_stateful.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/object_tree.dart';
import 'package:gql_github/gist.data.gql.dart';
import 'package:gql_github/gist.req.gql.dart';
import 'package:provider/provider.dart';
class GhGistsFilesScreen extends StatelessWidget {
2022-09-21 18:28:21 +02:00
const GhGistsFilesScreen(this.login, this.id);
final String id;
final String login;
@override
Widget build(BuildContext context) {
2021-05-16 09:16:35 +02:00
return RefreshStatefulScaffold<GGistData_user_gist?>(
title: AppBarTitle(AppLocalizations.of(context)!.files),
fetch: () async {
final req = GGistReq((b) => b
..vars.login = login
..vars.name = id);
2022-09-30 21:49:56 +02:00
final res =
2022-10-01 19:26:34 +02:00
await context.read<AuthModel>().ghGqlClient.request(req).first;
2021-05-16 09:16:35 +02:00
final gist = res.data!.user!.gist;
return gist;
},
bodyBuilder: (payload, _) {
2022-09-20 20:00:03 +02:00
return AntList(
2022-09-22 17:37:06 +02:00
children: payload!.files!.map((v) {
final uri = Uri(
path: '/github/$login/gists/$id/${v.name}',
queryParameters: {
'content': v.text,
},
).toString();
2022-09-13 17:52:35 +02:00
return createObjectTreeItem(
url: uri,
type: 'file',
name: v.name ?? '',
downloadUrl: null,
size: v.size,
);
2022-09-20 20:00:03 +02:00
}).toList(),
);
},
);
}
}