1
0
mirror of https://github.com/git-touch/git-touch synced 2025-02-13 10:00:43 +01:00

36 lines
1.2 KiB
Dart
Raw Normal View History

2022-09-17 20:35:45 +08:00
import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/S.dart';
2020-11-01 23:23:03 +08:00
import 'package:git_touch/models/auth.dart';
import 'package:git_touch/models/gitee.dart';
import 'package:git_touch/scaffolds/refresh_stateful.dart';
2021-02-14 22:17:22 +08:00
import 'package:git_touch/utils/utils.dart';
2020-11-01 23:23:03 +08:00
import 'package:git_touch/widgets/action_entry.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/blob_view.dart';
import 'package:provider/provider.dart';
class GeBlobScreen extends StatelessWidget {
2022-09-22 00:28:21 +08:00
const GeBlobScreen(this.owner, this.name, this.sha, this.path);
2020-11-01 23:23:03 +08:00
final String owner;
final String name;
final String sha;
final String path;
@override
Widget build(BuildContext context) {
2021-05-16 15:16:35 +08:00
return RefreshStatefulScaffold<String?>(
title: AppBarTitle(AppLocalizations.of(context)!.file),
2020-11-01 23:23:03 +08:00
fetch: () async {
final auth = context.read<AuthModel>();
final res = await auth.fetchGitee('/repos/$owner/$name/git/blobs/$sha');
return GiteeBlob.fromJson(res).content;
},
2022-09-17 20:35:45 +08:00
action:
const ActionEntry(iconData: Ionicons.cog, url: '/choose-code-theme'),
2020-11-01 23:23:03 +08:00
bodyBuilder: (content, _) {
return BlobView(path, base64Text: content);
},
);
}
}