- Image Viewer
This commit is contained in:
Linloir 2022-10-23 11:36:49 +08:00
parent 828fb1b5b9
commit a2e683ac2c
4 changed files with 57 additions and 17 deletions

View File

@ -1,18 +1,15 @@
/*
* @Author : Linloir
* @Date : 2022-10-14 17:04:20
* @LastEditTime : 2022-10-23 10:52:45
* @LastEditTime : 2022-10-23 11:35:10
* @Description :
*/
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tcp_client/chat/cubit/chat_cubit.dart';
import 'package:photo_view/photo_view.dart';
import 'package:tcp_client/chat/model/chat_history.dart';
import 'package:tcp_client/repositories/tcp_repository/models/tcp_request.dart';
class ImageBox extends StatelessWidget {
const ImageBox({
@ -30,13 +27,55 @@ class ImageBox extends StatelessWidget {
children: [
Container(
constraints: const BoxConstraints(maxWidth: 200, maxHeight: 150),
child: Hero(
tag: history.message.contentmd5,
child: history.preCachedImage ?? Image.memory(base64Decode(history.message.contentDecoded)),
),
),
Material(
color: Colors.transparent,
child: InkWell(
splashColor: Colors.white.withOpacity(0.1),
onTap: (){},
onTap: (){
var image = history.preCachedImage?.image ?? Image.memory(base64.decode(history.message.contentDecoded)).image;
Navigator.of(context).push(MaterialPageRoute(
builder:(context) {
return Scaffold(
body: Stack(
children: [
Positioned.fill(
child: PhotoView(
heroAttributes: PhotoViewHeroAttributes(
tag: history.message.contentmd5
),
imageProvider: image,
minScale: PhotoViewComputedScale.contained,
)
),
Positioned.fill(
child: SafeArea(
child: Align(
alignment: Alignment.topRight,
child: IconButton(
icon: Icon(
Icons.close_rounded,
shadows: [
Shadow(blurRadius: 8.0, color: Colors.white.withOpacity(0.5))
],
),
onPressed: () {
Navigator.of(context).pop();
},
),
),
),
),
],
),
);
},
));
},
)
),
]

View File

@ -1,7 +1,7 @@
/*
* @Author : Linloir
* @Date : 2022-10-10 08:04:53
* @LastEditTime : 2022-10-23 10:44:13
* @LastEditTime : 2022-10-23 11:36:04
* @Description :
*/
import 'package:flutter/gestures.dart';
@ -49,7 +49,7 @@ class SplashPage extends StatelessWidget {
return BlocProvider<InitializationCubit>(
create: (context) {
return InitializationCubit(
serverAddress: 'chat.linloir.cn',
serverAddress: '127.0.0.1',
serverPort: 20706
);
},

View File

@ -78,13 +78,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.2+1"
easy_image_viewer:
dependency: "direct main"
description:
name: easy_image_viewer
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
equatable:
dependency: "direct main"
description:
@ -291,6 +284,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.3"
photo_view:
dependency: "direct main"
description:
name: photo_view
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.14.0"
platform:
dependency: transitive
description:

View File

@ -57,7 +57,8 @@ dependencies:
easy_debounce: ^2.0.2+1
path: ^1.8.2
window_manager: ^0.2.7
easy_image_viewer: ^1.1.0
# easy_image_viewer: ^1.1.0
photo_view: ^0.14.0
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.