use extended_image
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:extended_image/extended_image.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
@ -32,10 +33,6 @@ class _ImageDetailState extends ConsumerState<ImageDetail> {
|
|||||||
// double dx=0;
|
// double dx=0;
|
||||||
double _scale = 1;
|
double _scale = 1;
|
||||||
|
|
||||||
Offset offsetBeforeDrag = const Offset(0, 0);
|
|
||||||
Offset origin = const Offset(0, 0);
|
|
||||||
double ox = 0;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
String id = GoRouterState.of(context).queryParams["id"] ?? "";
|
String id = GoRouterState.of(context).queryParams["id"] ?? "";
|
||||||
@ -48,95 +45,27 @@ class _ImageDetailState extends ConsumerState<ImageDetail> {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
children: [
|
children: [
|
||||||
Positioned(
|
Positioned(
|
||||||
// left: dx,
|
child: FutureBuilder(
|
||||||
|
future: loadImage(id),
|
||||||
child: GestureDetector(
|
builder: (context, snapshot) {
|
||||||
onTapDown: (TapDownDetails details) {
|
if (snapshot.hasData) {
|
||||||
print("tap start");
|
return ClipRect(
|
||||||
print(details.globalPosition.dx);
|
child: SizedBox(
|
||||||
offsetBeforeDrag = details.globalPosition;
|
width: double.infinity,
|
||||||
},
|
height: double.infinity,
|
||||||
child: Draggable(
|
child: ExtendedImage.network(
|
||||||
onDragUpdate: (details) {
|
"${dio.options.baseUrl}/image/${snapshot.data?.file_path}",
|
||||||
print("on drag update");
|
mode: ExtendedImageMode.gesture,
|
||||||
print(details.globalPosition.dx - offsetBeforeDrag.dx);
|
// scale: 3,
|
||||||
// print(details.localPosition - offsetBeforeDrag);
|
),
|
||||||
// print(offsetBeforeDrag.dx - details.localPosition.dx);
|
));
|
||||||
// print(offsetBeforeDrag.dy - details.localPosition.dy);
|
} else if (snapshot.hasError) {
|
||||||
//
|
return ErrorWidget("13");
|
||||||
setState(() {
|
}
|
||||||
origin = (offsetBeforeDrag - details.localPosition);
|
return const Center(
|
||||||
// /
|
child: CircularProgressIndicator(),
|
||||||
// (_scale - 1);
|
);
|
||||||
});
|
})),
|
||||||
},
|
|
||||||
feedback: const SizedBox(),
|
|
||||||
child: FutureBuilder(
|
|
||||||
future: loadImage(id),
|
|
||||||
builder: (BuildContext context, snapshot) {
|
|
||||||
if (snapshot.hasData) {
|
|
||||||
// return ClipRect(
|
|
||||||
// child: SizedBox(
|
|
||||||
// width: double.infinity,
|
|
||||||
// height: double.infinity,
|
|
||||||
// child: Transform.scale(
|
|
||||||
// origin: Offset(0, 0),
|
|
||||||
// scale: _scale,
|
|
||||||
// child: Image.network(
|
|
||||||
// "${dio.options.baseUrl}/image/${snapshot.data?.file_path}",
|
|
||||||
// loadingBuilder: (BuildContext context, child,
|
|
||||||
// loadingProgress) {
|
|
||||||
// if (loadingProgress == null) {
|
|
||||||
// return child;
|
|
||||||
// }
|
|
||||||
// return Center(
|
|
||||||
// child: CircularProgressIndicator(
|
|
||||||
// value: loadingProgress.expectedTotalBytes !=
|
|
||||||
// null
|
|
||||||
// ? loadingProgress
|
|
||||||
// .cumulativeBytesLoaded /
|
|
||||||
// loadingProgress.expectedTotalBytes!
|
|
||||||
// : null,
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// }),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
return Image.network(
|
|
||||||
"${dio.options.baseUrl}/image/${snapshot.data?.file_path}",
|
|
||||||
loadingBuilder:
|
|
||||||
(BuildContext context, child, loadingProgress) {
|
|
||||||
if (loadingProgress == null) {
|
|
||||||
return ClipRect(
|
|
||||||
child: SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
height: double.infinity,
|
|
||||||
child: Transform.scale(
|
|
||||||
origin: Offset(166, 0),
|
|
||||||
scale: _scale,
|
|
||||||
child: child),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Center(
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
value: loadingProgress.expectedTotalBytes != null
|
|
||||||
? loadingProgress.cumulativeBytesLoaded /
|
|
||||||
loadingProgress.expectedTotalBytes!
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
} else if (snapshot.hasError) {
|
|
||||||
print(snapshot.error);
|
|
||||||
return ErrorWidget("err");
|
|
||||||
}
|
|
||||||
return CircularProgressIndicator();
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 10,
|
bottom: 10,
|
||||||
child: Card(
|
child: Card(
|
||||||
@ -156,31 +85,16 @@ class _ImageDetailState extends ConsumerState<ImageDetail> {
|
|||||||
},
|
},
|
||||||
icon: const Icon(Icons.delete)),
|
icon: const Icon(Icons.delete)),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: _scale > 0.2
|
onPressed: _scale > 0.2 ? () {} : null,
|
||||||
? () {
|
|
||||||
setState(() {
|
|
||||||
_scale -= 1;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
icon: const Icon(Icons.remove_circle_outline)),
|
icon: const Icon(Icons.remove_circle_outline)),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: _scale < 10
|
onPressed: _scale < 10 ? () {} : null,
|
||||||
? () {
|
|
||||||
setState(() {
|
|
||||||
_scale += 1;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
icon: const Icon(Icons.add_circle_outline)),
|
icon: const Icon(Icons.add_circle_outline)),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {});
|
||||||
// _scale += 0.1;
|
|
||||||
ox += 100 / 2;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.chevron_left)),
|
icon: const Icon(Icons.menu_rounded)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -27,8 +27,8 @@ class MyMaterialRouterConfig {
|
|||||||
GoRoute(
|
GoRoute(
|
||||||
path: "/",
|
path: "/",
|
||||||
name: "相册",
|
name: "相册",
|
||||||
builder: (BuildContext context, GoRouterState state) =>
|
pageBuilder: (BuildContext context, GoRouterState state) =>
|
||||||
const Gallery(),
|
const NoTransitionPage(child: Gallery()),
|
||||||
redirect: (BuildContext context, GoRouterState state) {
|
redirect: (BuildContext context, GoRouterState state) {
|
||||||
if (token == null || token.isEmpty) {
|
if (token == null || token.isEmpty) {
|
||||||
return '/login';
|
return '/login';
|
||||||
@ -45,8 +45,8 @@ class MyMaterialRouterConfig {
|
|||||||
GoRoute(
|
GoRoute(
|
||||||
path: "/profile",
|
path: "/profile",
|
||||||
name: "个人资料",
|
name: "个人资料",
|
||||||
builder: (BuildContext context, GoRouterState state) =>
|
pageBuilder: (BuildContext context, GoRouterState state) =>
|
||||||
const Profile()),
|
const NoTransitionPage(child: Profile())),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
import FlutterMacOS
|
import FlutterMacOS
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
import path_provider_foundation
|
||||||
import screen_retriever
|
import screen_retriever
|
||||||
import shared_preferences_foundation
|
import shared_preferences_foundation
|
||||||
import tray_manager
|
import tray_manager
|
||||||
@ -12,6 +13,7 @@ import url_launcher_macos
|
|||||||
import window_manager
|
import window_manager
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
|
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||||
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
|
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
|
||||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin"))
|
TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin"))
|
||||||
|
56
pubspec.lock
56
pubspec.lock
@ -217,6 +217,22 @@ packages:
|
|||||||
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.6"
|
version: "4.0.6"
|
||||||
|
extended_image:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: extended_image
|
||||||
|
sha256: "6494c5728d0a8216fafcda7a4125f7a6da3d510ab00677a630d01dbb1125da96"
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "7.0.1"
|
||||||
|
extended_image_library:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: extended_image_library
|
||||||
|
sha256: b1de389378589e4dffb3564d782373238f19064037458092c49b3043b2791b2b
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "3.4.1"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -365,6 +381,22 @@ packages:
|
|||||||
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.2.0"
|
||||||
|
http:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: http
|
||||||
|
sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482"
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "0.13.5"
|
||||||
|
http_client_helper:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: http_client_helper
|
||||||
|
sha256: "1f32359bd07a064ad256d1f84ae5f973f69bc972e7287223fa198abe1d969c28"
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.3"
|
||||||
http_multi_server:
|
http_multi_server:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -509,6 +541,30 @@ packages:
|
|||||||
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.2"
|
version: "1.8.2"
|
||||||
|
path_provider:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider
|
||||||
|
sha256: dcea5feb97d8abf90cab9e9030b497fb7c3cbf26b7a1fe9e3ef7dcb0a1ddec95
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.12"
|
||||||
|
path_provider_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_android
|
||||||
|
sha256: a776c088d671b27f6e3aa8881d64b87b3e80201c64e8869b811325de7a76c15e
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.22"
|
||||||
|
path_provider_foundation:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_provider_foundation
|
||||||
|
sha256: "62a68e7e1c6c459f9289859e2fae58290c981ce21d1697faf54910fe1faa4c74"
|
||||||
|
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.1"
|
||||||
path_provider_linux:
|
path_provider_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -50,6 +50,7 @@ dependencies:
|
|||||||
http_parser: ^4.0.2
|
http_parser: ^4.0.2
|
||||||
mime: ^1.0.4
|
mime: ^1.0.4
|
||||||
context_menus: ^1.0.2
|
context_menus: ^1.0.2
|
||||||
|
extended_image: ^7.0.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Reference in New Issue
Block a user