1
0
mirror of https://github.com/git-touch/git-touch synced 2024-12-16 18:28:51 +01:00

feat: open image view on avatar tap

This commit is contained in:
Rongjian Zhang 2019-11-02 21:44:26 +08:00
parent 79febd275b
commit ed07ff086f
3 changed files with 39 additions and 9 deletions

View File

@ -1,4 +1,7 @@
import 'package:flutter/material.dart';
import 'package:git_touch/models/theme.dart';
import 'package:git_touch/widgets/image_view.dart';
import 'package:provider/provider.dart';
class Avatar extends StatelessWidget {
final String url;
@ -21,16 +24,22 @@ class Avatar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ClipRRect(
borderRadius: BorderRadius.circular(4),
child: FadeInImage.assetNetwork(
placeholder: 'images/octoface.png',
image: url,
width: size,
height: size,
fadeInDuration: Duration(milliseconds: 200),
fadeOutDuration: Duration(milliseconds: 100),
return GestureDetector(
child: ClipRRect(
borderRadius: BorderRadius.circular(4),
child: FadeInImage.assetNetwork(
placeholder: 'images/octoface.png',
image: url,
width: size,
height: size,
fadeInDuration: Duration(milliseconds: 200),
fadeOutDuration: Duration(milliseconds: 100),
),
),
onTap: () {
Provider.of<ThemeModel>(context)
.pushRoute(context, (_) => ImageView(url), fullscreenDialog: true);
},
);
}
}

View File

@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
import 'package:git_touch/scaffolds/common.dart';
import 'package:photo_view/photo_view.dart';
class ImageView extends StatelessWidget {
final String url;
ImageView(this.url);
@override
Widget build(BuildContext context) {
return CommonScaffold(
title: Text('Image'),
body: PhotoView(
imageProvider: NetworkImage(url),
backgroundDecoration: BoxDecoration(color: Colors.white),
),
);
}
}

View File

@ -36,6 +36,7 @@ dependencies:
tuple: ^1.0.2
uri: ^0.11.3
fimber: ^0.3.2
photo_view: ^0.7.0
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.