2019-12-11 23:58:25 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:git_touch/models/auth.dart';
|
|
|
|
import 'package:git_touch/models/gitlab.dart';
|
|
|
|
import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
2019-12-15 00:08:12 +08:00
|
|
|
import 'package:git_touch/utils/utils.dart';
|
2020-01-30 14:51:22 +08:00
|
|
|
import 'package:git_touch/widgets/action_entry.dart';
|
2019-12-11 23:58:25 +08:00
|
|
|
import 'package:git_touch/widgets/app_bar_title.dart';
|
|
|
|
import 'package:git_touch/widgets/blob_view.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
2020-02-07 22:26:37 +08:00
|
|
|
class GlBlobScreen extends StatelessWidget {
|
2019-12-11 23:58:25 +08:00
|
|
|
final int id;
|
2020-02-02 10:58:42 +08:00
|
|
|
final String ref;
|
2019-12-11 23:58:25 +08:00
|
|
|
final String path;
|
2020-02-07 22:26:37 +08:00
|
|
|
GlBlobScreen(this.id, this.ref, {this.path});
|
2019-12-11 23:58:25 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return RefreshStatefulScaffold<GitlabBlob>(
|
2020-01-29 12:42:36 +08:00
|
|
|
title: AppBarTitle(path ?? ''),
|
2020-10-06 20:52:40 +08:00
|
|
|
fetch: () async {
|
2020-10-04 20:37:23 +08:00
|
|
|
final auth = context.read<AuthModel>();
|
|
|
|
final res = await auth.fetchGitlab(
|
2020-02-02 10:58:42 +08:00
|
|
|
'/projects/$id/repository/files/${path.urlencode}?ref=$ref');
|
2019-12-11 23:58:25 +08:00
|
|
|
return GitlabBlob.fromJson(res);
|
|
|
|
},
|
2021-02-14 22:17:22 +08:00
|
|
|
action: ActionEntry(iconData: Ionicons.cog, url: '/choose-code-theme'),
|
2019-12-11 23:58:25 +08:00
|
|
|
bodyBuilder: (data, _) {
|
2020-01-30 14:06:25 +08:00
|
|
|
return BlobView(path, base64Text: data.content);
|
2019-12-11 23:58:25 +08:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|