feat(app): P0 batch 1 — photo viewer zoom, camera lifecycle, image memory management
P0-2 查看器缩放:InteractiveViewer(5x max,放大后平移,1x 时穿透到 PageView 滑动切页) P0-3 相机后台释放:WidgetsBindingObserver——paused 时 dispose(省电+ 隐私指示灯),resumed 时重开(沿用前后摄/闪光灯偏好) P0-6 图片内存管理:PhotoThumbnail 加 maxCacheWidth 参数——网格/列表 缩略图限制解码宽度(600/400px),查看器大图不限 397/397 全绿、analyze 0 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ class PhotoThumbnail extends StatelessWidget {
|
||||
required this.url,
|
||||
required this.aspectRatio,
|
||||
this.fit = BoxFit.cover,
|
||||
this.maxCacheWidth,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@@ -27,6 +28,11 @@ class PhotoThumbnail extends StatelessWidget {
|
||||
/// 图片适配(默认 cover 裁切;大图查看用 contain)。
|
||||
final BoxFit fit;
|
||||
|
||||
/// 解码宽度上限(P0-6 内存管理):网格/列表传入,限制 Image.network
|
||||
/// 实际解码的像素宽度——防止 4000px 原图全量解码导致 OOM。
|
||||
/// null = 不限制(查看器大图等需要完整分辨率的场景)。
|
||||
final int? maxCacheWidth;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (url == null) {
|
||||
@@ -40,6 +46,8 @@ class PhotoThumbnail extends StatelessWidget {
|
||||
child: Image.network(
|
||||
url!,
|
||||
fit: fit,
|
||||
// P0-6:限制解码宽度(网格缩略图无需全量分辨率)。
|
||||
cacheWidth: maxCacheWidth,
|
||||
// 帧 ready 前显示中性占位(不是 spinner):布局稳定优先。
|
||||
frameBuilder: (context, child, frame, wasSynchronouslyLoaded) =>
|
||||
wasSynchronouslyLoaded || frame != null
|
||||
|
||||
Reference in New Issue
Block a user