mirror of
https://github.com/git-touch/git-touch
synced 2025-01-31 16:14:49 +01:00
feat: use image view in object screen
This commit is contained in:
parent
ed07ff086f
commit
3e3e3d1251
@ -2,15 +2,16 @@ import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/scaffolds/common.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
|
||||
class ImageView extends StatelessWidget {
|
||||
class ImageViewScreen extends StatelessWidget {
|
||||
final String url;
|
||||
final Widget title;
|
||||
|
||||
ImageView(this.url);
|
||||
ImageViewScreen(this.url, {this.title = const Text('Image')});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CommonScaffold(
|
||||
title: Text('Image'),
|
||||
title: title,
|
||||
body: PhotoView(
|
||||
imageProvider: NetworkImage(url),
|
||||
backgroundDecoration: BoxDecoration(color: Colors.white),
|
@ -7,6 +7,7 @@ import 'package:git_touch/scaffolds/refresh_stateful.dart';
|
||||
import 'package:git_touch/screens/code_theme.dart';
|
||||
import 'package:git_touch/widgets/action_entry.dart';
|
||||
import 'package:git_touch/widgets/app_bar_title.dart';
|
||||
import 'package:git_touch/screens/image_view.dart';
|
||||
import 'package:git_touch/widgets/markdown_view.dart';
|
||||
import 'package:git_touch/widgets/table_view.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
@ -120,13 +121,6 @@ class ObjectScreen extends StatelessWidget {
|
||||
padding: CommonStyle.padding,
|
||||
child: MarkdownView(payload['text']),
|
||||
);
|
||||
case 'png':
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
case 'gif':
|
||||
case 'webp':
|
||||
// TODO: All image types
|
||||
return Image.network(rawUrl);
|
||||
case 'svg':
|
||||
return SvgPicture.network(rawUrl);
|
||||
default:
|
||||
@ -147,6 +141,12 @@ class ObjectScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: All image types
|
||||
if (type == 'blob' &&
|
||||
['png', 'jpg', 'jpeg', 'gif', 'webp'].contains(_extname)) {
|
||||
return ImageViewScreen(rawUrl, title: Text(paths.last));
|
||||
}
|
||||
|
||||
return RefreshStatefulScaffold(
|
||||
title: AppBarTitle(_path.isEmpty ? 'Files' : _path),
|
||||
fetchData: () async {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:git_touch/models/theme.dart';
|
||||
import 'package:git_touch/widgets/image_view.dart';
|
||||
import 'package:git_touch/screens/image_view.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class Avatar extends StatelessWidget {
|
||||
@ -37,8 +37,9 @@ class Avatar extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
Provider.of<ThemeModel>(context)
|
||||
.pushRoute(context, (_) => ImageView(url), fullscreenDialog: true);
|
||||
Provider.of<ThemeModel>(context).pushRoute(
|
||||
context, (_) => ImageViewScreen(url),
|
||||
fullscreenDialog: true);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user