1
0
mirror of https://github.com/git-touch/git-touch synced 2025-01-31 08:04:51 +01:00

refactor: view images

This commit is contained in:
Rongjian Zhang 2019-09-29 13:53:03 +08:00
parent 3a1877859a
commit 2c64179715
2 changed files with 7 additions and 27 deletions

View File

@ -1,19 +0,0 @@
import 'package:flutter/material.dart';
import 'package:git_touch/scaffolds/single.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
class ImageView extends StatelessWidget {
final ImageProvider imageProvider;
ImageView(this.imageProvider);
@override
Widget build(BuildContext context) {
return SingleScaffold(
title: AppBarTitle('Image preview'),
body: Container(
child: Image(image: imageProvider),
),
);
}
}

View File

@ -4,10 +4,8 @@ import 'package:git_touch/models/code.dart';
import 'package:git_touch/models/theme.dart';
import 'package:git_touch/scaffolds/refresh_stateful.dart';
import 'package:git_touch/screens/code_theme.dart';
import 'package:git_touch/screens/image_view.dart';
import 'package:git_touch/widgets/action_entry.dart';
import 'package:git_touch/widgets/app_bar_title.dart';
import 'package:git_touch/widgets/link.dart';
import 'package:git_touch/widgets/markdown_view.dart';
import 'package:git_touch/widgets/table_view.dart';
import 'package:path/path.dart' as path;
@ -99,12 +97,6 @@ class ObjectScreen extends StatelessWidget {
text: Text(item['name']),
screenBuilder: (_) {
if (item['type'] == 'commit') return null;
// TODO: All image types
var ext = path.extension(item['name']);
if (ext.isNotEmpty) ext = ext.substring(1);
if (['png', 'jpg', 'jpeg', 'gif', 'webp'].contains(ext)) {
return ImageView(NetworkImage('$rawUrl/' + item['name']));
}
return ObjectScreen(
name: name,
owner: owner,
@ -127,6 +119,13 @@ class ObjectScreen extends StatelessWidget {
padding: const EdgeInsets.all(12),
child: MarkdownView(payload['text']),
);
case 'png':
case 'jpg':
case 'jpeg':
case 'gif':
case 'webp':
// TODO: All image types
return Image.network(rawUrl);
default:
return SingleChildScrollView(
scrollDirection: Axis.horizontal,