chore: bump dart sdk to 3.8 (#20355)

* chore: bump dart sdk to 3.8

* chore: make build

* make pigeon

* chore: format files

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
shenlong
2025-07-29 00:34:03 +05:30
committed by GitHub
parent 9b3718120b
commit e52b9d15b5
643 changed files with 32561 additions and 35292 deletions
+36 -64
View File
@@ -15,9 +15,7 @@ export 'src/photo_view_scale_state.dart';
export 'src/utils/photo_view_hero_attributes.dart';
typedef PhotoViewControllerCallback = PhotoViewControllerBase Function();
typedef PhotoViewControllerCallbackBuilder = void Function(
PhotoViewControllerCallback photoViewMethod,
);
typedef PhotoViewControllerCallbackBuilder = void Function(PhotoViewControllerCallback photoViewMethod);
/// A [StatefulWidget] that contains all the photo view rendering elements.
///
@@ -269,8 +267,8 @@ class PhotoView extends StatefulWidget {
this.disableScaleGestures,
this.errorBuilder,
this.enablePanAlways,
}) : child = null,
childSize = null;
}) : child = null,
childSize = null;
/// Creates a widget that displays a zoomable child.
///
@@ -310,12 +308,12 @@ class PhotoView extends StatefulWidget {
this.disableScaleGestures,
this.disableGestures,
this.enablePanAlways,
}) : semanticLabel = null,
errorBuilder = null,
imageProvider = null,
gaplessPlayback = false,
loadingBuilder = null,
index = 0;
}) : semanticLabel = null,
errorBuilder = null,
imageProvider = null,
gaplessPlayback = false,
loadingBuilder = null,
index = 0;
/// Given a [imageProvider] it resolves into an zoomable image widget using. It
/// is required
@@ -543,10 +541,7 @@ class _PhotoViewState extends State<PhotoView> with AutomaticKeepAliveClientMixi
Widget build(BuildContext context) {
super.build(context);
return LayoutBuilder(
builder: (
BuildContext context,
BoxConstraints constraints,
) {
builder: (BuildContext context, BoxConstraints constraints) {
final computedOuterSize = widget.customSize ?? constraints.biggest;
final backgroundDecoration = widget.backgroundDecoration ?? const BoxDecoration(color: Colors.black);
@@ -623,72 +618,49 @@ class _PhotoViewState extends State<PhotoView> with AutomaticKeepAliveClientMixi
/// The default [ScaleStateCycle]
PhotoViewScaleState defaultScaleStateCycle(PhotoViewScaleState actual) => switch (actual) {
PhotoViewScaleState.initial => PhotoViewScaleState.covering,
PhotoViewScaleState.covering => PhotoViewScaleState.originalSize,
PhotoViewScaleState.originalSize => PhotoViewScaleState.initial,
PhotoViewScaleState.zoomedIn || PhotoViewScaleState.zoomedOut => PhotoViewScaleState.initial,
};
PhotoViewScaleState.initial => PhotoViewScaleState.covering,
PhotoViewScaleState.covering => PhotoViewScaleState.originalSize,
PhotoViewScaleState.originalSize => PhotoViewScaleState.initial,
PhotoViewScaleState.zoomedIn || PhotoViewScaleState.zoomedOut => PhotoViewScaleState.initial,
};
/// A type definition for a [Function] that receives the actual [PhotoViewScaleState] and returns the next one
/// It is used internally to walk in the "doubletap gesture cycle".
/// It is passed to [PhotoView.scaleStateCycle]
typedef ScaleStateCycle = PhotoViewScaleState Function(
PhotoViewScaleState actual,
);
typedef ScaleStateCycle = PhotoViewScaleState Function(PhotoViewScaleState actual);
/// A type definition for a callback when the user taps up the photoview region
typedef PhotoViewImageTapUpCallback = Function(
BuildContext context,
TapUpDetails details,
PhotoViewControllerValue controllerValue,
);
typedef PhotoViewImageTapUpCallback =
Function(BuildContext context, TapUpDetails details, PhotoViewControllerValue controllerValue);
/// A type definition for a callback when the user taps down the photoview region
typedef PhotoViewImageTapDownCallback = Function(
BuildContext context,
TapDownDetails details,
PhotoViewControllerValue controllerValue,
);
typedef PhotoViewImageTapDownCallback =
Function(BuildContext context, TapDownDetails details, PhotoViewControllerValue controllerValue);
/// A type definition for a callback when the user drags up
typedef PhotoViewImageDragStartCallback = Function(
BuildContext context,
DragStartDetails details,
PhotoViewControllerBase controllerValue,
PhotoViewScaleStateController scaleStateController,
);
typedef PhotoViewImageDragStartCallback =
Function(
BuildContext context,
DragStartDetails details,
PhotoViewControllerBase controllerValue,
PhotoViewScaleStateController scaleStateController,
);
/// A type definition for a callback when the user drags
typedef PhotoViewImageDragUpdateCallback = Function(
BuildContext context,
DragUpdateDetails details,
PhotoViewControllerValue controllerValue,
);
typedef PhotoViewImageDragUpdateCallback =
Function(BuildContext context, DragUpdateDetails details, PhotoViewControllerValue controllerValue);
/// A type definition for a callback when the user taps down the photoview region
typedef PhotoViewImageDragEndCallback = Function(
BuildContext context,
DragEndDetails details,
PhotoViewControllerValue controllerValue,
);
typedef PhotoViewImageDragEndCallback =
Function(BuildContext context, DragEndDetails details, PhotoViewControllerValue controllerValue);
/// A type definition for a callback when a user finished scale
typedef PhotoViewImageScaleEndCallback = Function(
BuildContext context,
ScaleEndDetails details,
PhotoViewControllerValue controllerValue,
);
typedef PhotoViewImageScaleEndCallback =
Function(BuildContext context, ScaleEndDetails details, PhotoViewControllerValue controllerValue);
/// A type definition for a callback when the user long press start
typedef PhotoViewImageLongPressStartCallback = Function(
BuildContext context,
LongPressStartDetails details,
PhotoViewControllerValue controllerValue,
);
typedef PhotoViewImageLongPressStartCallback =
Function(BuildContext context, LongPressStartDetails details, PhotoViewControllerValue controllerValue);
/// A type definition for a callback to show a widget while the image is loading, a [ImageChunkEvent] is passed to inform progress
typedef LoadingBuilder = Widget Function(
BuildContext context,
ImageChunkEvent? event,
int index,
);
typedef LoadingBuilder = Widget Function(BuildContext context, ImageChunkEvent? event, int index);
@@ -20,16 +20,10 @@ import 'package:immich_mobile/widgets/photo_view/src/photo_view_scale_state.dart
import 'package:immich_mobile/widgets/photo_view/src/utils/photo_view_hero_attributes.dart';
/// A type definition for a [Function] that receives a index after a page change in [PhotoViewGallery]
typedef PhotoViewGalleryPageChangedCallback = void Function(
int index,
PhotoViewControllerBase? controller,
);
typedef PhotoViewGalleryPageChangedCallback = void Function(int index, PhotoViewControllerBase? controller);
/// A type definition for a [Function] that defines a page in [PhotoViewGallery.build]
typedef PhotoViewGalleryBuilder = PhotoViewGalleryPageOptions Function(
BuildContext context,
int index,
);
typedef PhotoViewGalleryBuilder = PhotoViewGalleryPageOptions Function(BuildContext context, int index);
/// A [StatefulWidget] that shows multiple [PhotoView] widgets in a [PageView]
///
@@ -126,8 +120,8 @@ class PhotoViewGallery extends StatefulWidget {
this.customSize,
this.allowImplicitScrolling = false,
this.enablePanAlways = false,
}) : itemCount = null,
builder = null;
}) : itemCount = null,
builder = null;
/// Construct a gallery with dynamic items.
///
@@ -151,9 +145,9 @@ class PhotoViewGallery extends StatefulWidget {
this.customSize,
this.allowImplicitScrolling = false,
this.enablePanAlways = false,
}) : pageOptions = null,
assert(itemCount != null),
assert(builder != null);
}) : pageOptions = null,
assert(itemCount != null),
assert(builder != null);
/// A list of options to describe the items in the gallery
final List<PhotoViewGalleryPageOptions>? pageOptions;
@@ -340,15 +334,10 @@ class _PhotoViewGalleryState extends State<PhotoViewGallery> {
heroAttributes: pageOption.heroAttributes,
);
return ClipRect(
child: photoView,
);
return ClipRect(child: photoView);
}
PhotoViewGalleryPageOptions _buildPageOption(
BuildContext context,
int index,
) {
PhotoViewGalleryPageOptions _buildPageOption(BuildContext context, int index) {
if (widget._isBuilder) {
return widget.builder!(context, index);
}
@@ -386,9 +375,9 @@ class PhotoViewGalleryPageOptions {
this.disableScaleGestures,
this.disableGestures,
this.errorBuilder,
}) : child = null,
childSize = null,
assert(imageProvider != null);
}) : child = null,
childSize = null,
assert(imageProvider != null);
const PhotoViewGalleryPageOptions.customChild({
this.key,
@@ -415,8 +404,8 @@ class PhotoViewGalleryPageOptions {
this.filterQuality,
this.disableScaleGestures,
this.disableGestures,
}) : errorBuilder = null,
imageProvider = null;
}) : errorBuilder = null,
imageProvider = null;
final Key? key;
@@ -72,12 +72,7 @@ abstract class PhotoViewControllerBase<T extends PhotoViewControllerValue> {
Offset? rotationFocusPoint;
/// Update multiple fields of the state with only one update streamed.
void updateMultiple({
Offset? position,
double? scale,
double? rotation,
Offset? rotationFocusPoint,
});
void updateMultiple({Offset? position, double? scale, double? rotation, Offset? rotationFocusPoint});
}
/// The state value stored and streamed by [PhotoViewController].
@@ -122,19 +117,16 @@ class PhotoViewControllerValue {
/// For details of fields and methods, check [PhotoViewControllerBase].
///
class PhotoViewController implements PhotoViewControllerBase<PhotoViewControllerValue> {
PhotoViewController({
Offset initialPosition = Offset.zero,
double initialRotation = 0.0,
double? initialScale,
}) : _valueNotifier = IgnorableValueNotifier(
PhotoViewControllerValue(
position: initialPosition,
rotation: initialRotation,
scale: initialScale,
rotationFocusPoint: null,
),
PhotoViewController({Offset initialPosition = Offset.zero, double initialRotation = 0.0, double? initialScale})
: _valueNotifier = IgnorableValueNotifier(
PhotoViewControllerValue(
position: initialPosition,
rotation: initialRotation,
scale: initialScale,
rotationFocusPoint: null,
),
super() {
),
super() {
initial = value;
prevValue = initial;
@@ -299,12 +291,7 @@ class PhotoViewController implements PhotoViewControllerBase<PhotoViewController
Offset? get rotationFocusPoint => value.rotationFocusPoint;
@override
void updateMultiple({
Offset? position,
double? scale,
double? rotation,
Offset? rotationFocusPoint,
}) {
void updateMultiple({Offset? position, double? scale, double? rotation, Offset? rotationFocusPoint}) {
prevValue = value;
value = PhotoViewControllerValue(
position: position ?? value.position,
@@ -35,23 +35,15 @@ mixin PhotoViewControllerDelegate on State<PhotoViewCore> {
controller.setScaleInvisibly(scale);
return;
}
final double prevScale = controller.scale ??
getScaleForScaleState(
scaleStateController.prevScaleState,
scaleBoundaries,
);
final double prevScale =
controller.scale ?? getScaleForScaleState(scaleStateController.prevScaleState, scaleBoundaries);
final double nextScale = getScaleForScaleState(
scaleStateController.scaleState,
scaleBoundaries,
);
final double nextScale = getScaleForScaleState(scaleStateController.scaleState, scaleBoundaries);
_animateScale!(prevScale, nextScale);
}
void addAnimateOnScaleStateUpdate(
void Function(double prevScale, double nextScale) animateScale,
) {
void addAnimateOnScaleStateUpdate(void Function(double prevScale, double nextScale) animateScale) {
_animateScale = animateScale;
}
@@ -62,8 +54,9 @@ mixin PhotoViewControllerDelegate on State<PhotoViewCore> {
if (controller.scale == controller.prevValue.scale) {
return;
}
final PhotoViewScaleState newScaleState =
(scale > scaleBoundaries.initialScale) ? PhotoViewScaleState.zoomedIn : PhotoViewScaleState.zoomedOut;
final PhotoViewScaleState newScaleState = (scale > scaleBoundaries.initialScale)
? PhotoViewScaleState.zoomedIn
: PhotoViewScaleState.zoomedOut;
scaleStateController.setInvisibly(newScaleState);
}
@@ -76,10 +69,7 @@ mixin PhotoViewControllerDelegate on State<PhotoViewCore> {
final scaleExistsOnController = controller.scale != null;
if (needsRecalc || !scaleExistsOnController) {
final newScale = getScaleForScaleState(
scaleStateController.scaleState,
scaleBoundaries,
);
final newScale = getScaleForScaleState(scaleStateController.scaleState, scaleBoundaries);
markNeedsScaleRecalc = false;
scale = newScale;
return newScale;
@@ -89,12 +79,7 @@ mixin PhotoViewControllerDelegate on State<PhotoViewCore> {
set scale(double scale) => controller.setScaleInvisibly(scale);
void updateMultiple({
Offset? position,
double? scale,
double? rotation,
Offset? rotationFocusPoint,
}) {
void updateMultiple({Offset? position, double? scale, double? rotation, Offset? rotationFocusPoint}) {
controller.updateMultiple(
position: position,
scale: scale,
@@ -106,8 +91,9 @@ mixin PhotoViewControllerDelegate on State<PhotoViewCore> {
PhotoViewScaleState getScaleStateFromNewScale(double newScale) {
PhotoViewScaleState newScaleState = PhotoViewScaleState.initial;
if (scale != scaleBoundaries.initialScale) {
newScaleState =
(newScale > scaleBoundaries.initialScale) ? PhotoViewScaleState.zoomedIn : PhotoViewScaleState.zoomedOut;
newScaleState = (newScale > scaleBoundaries.initialScale)
? PhotoViewScaleState.zoomedIn
: PhotoViewScaleState.zoomedOut;
}
return newScaleState;
}
@@ -115,8 +101,9 @@ mixin PhotoViewControllerDelegate on State<PhotoViewCore> {
void updateScaleStateFromNewScale(double newScale) {
PhotoViewScaleState newScaleState = PhotoViewScaleState.initial;
if (scale != scaleBoundaries.initialScale) {
newScaleState =
(newScale > scaleBoundaries.initialScale) ? PhotoViewScaleState.zoomedIn : PhotoViewScaleState.zoomedOut;
newScaleState = (newScale > scaleBoundaries.initialScale)
? PhotoViewScaleState.zoomedIn
: PhotoViewScaleState.zoomedOut;
}
scaleStateController.setInvisibly(newScaleState);
}
@@ -127,10 +114,7 @@ mixin PhotoViewControllerDelegate on State<PhotoViewCore> {
scaleStateController.scaleState = scaleStateCycle(scaleState);
return;
}
final double originalScale = getScaleForScaleState(
scaleState,
scaleBoundaries,
);
final double originalScale = getScaleForScaleState(scaleState, scaleBoundaries);
double prevScale = originalScale;
PhotoViewScaleState prevScaleState = scaleState;
@@ -19,8 +19,9 @@ typedef ScaleStateListener = void Function(double prevScale, double nextScale);
/// The updates should be done via [scaleState] setter and the updated listened via [outputScaleStateStream]
///
class PhotoViewScaleStateController {
late final IgnorableValueNotifier<PhotoViewScaleState> _scaleStateNotifier =
IgnorableValueNotifier(PhotoViewScaleState.initial)..addListener(_scaleStateChangeListener);
late final IgnorableValueNotifier<PhotoViewScaleState> _scaleStateNotifier = IgnorableValueNotifier(
PhotoViewScaleState.initial,
)..addListener(_scaleStateChangeListener);
final StreamController<PhotoViewScaleState> _outputScaleStateCtrl = StreamController<PhotoViewScaleState>.broadcast()
..sink.add(PhotoViewScaleState.initial);
@@ -18,9 +18,7 @@ import 'package:immich_mobile/widgets/photo_view/src/core/photo_view_gesture_det
import 'package:immich_mobile/widgets/photo_view/src/core/photo_view_hit_corners.dart';
import 'package:immich_mobile/widgets/photo_view/src/utils/photo_view_utils.dart';
const _defaultDecoration = BoxDecoration(
color: Color.fromRGBO(0, 0, 0, 1.0),
);
const _defaultDecoration = BoxDecoration(color: Color.fromRGBO(0, 0, 0, 1.0));
/// Internal widget in which controls all animations lifecycle, core responses
/// to user gestures, updates to the controller state and mounts the entire PhotoView Layout
@@ -77,9 +75,9 @@ class PhotoViewCore extends StatefulWidget {
required this.disableGestures,
required this.disableScaleGestures,
required this.enablePanAlways,
}) : semanticLabel = null,
imageProvider = null,
gaplessPlayback = false;
}) : semanticLabel = null,
imageProvider = null,
gaplessPlayback = false;
final Decoration? backgroundDecoration;
final ImageProvider? imageProvider;
@@ -163,9 +161,9 @@ class PhotoViewCoreState extends State<PhotoViewCore>
}
bool _shouldAllowPanRotate() => switch (scaleStateController.scaleState) {
PhotoViewScaleState.zoomedIn => scaleStateController.hasZoomedOutManually,
_ => true,
};
PhotoViewScaleState.zoomedIn => scaleStateController.hasZoomedOutManually,
_ => true,
};
void onScaleUpdate(ScaleUpdateDetails details) {
final double newScale = _scaleBefore! * details.scale;
@@ -206,10 +204,7 @@ class PhotoViewCoreState extends State<PhotoViewCore>
if (s > maxScale) {
final double scaleComebackRatio = maxScale / s;
animateScale(s, maxScale);
final Offset clampedPosition = clampPosition(
position: p * scaleComebackRatio,
scale: maxScale,
);
final Offset clampedPosition = clampPosition(position: p * scaleComebackRatio, scale: maxScale);
animatePosition(p, clampedPosition);
return;
}
@@ -218,13 +213,7 @@ class PhotoViewCoreState extends State<PhotoViewCore>
if (s < minScale) {
final double scaleComebackRatio = minScale / s;
animateScale(s, minScale);
animatePosition(
p,
clampPosition(
position: p * scaleComebackRatio,
scale: minScale,
),
);
animatePosition(p, clampPosition(position: p * scaleComebackRatio, scale: minScale));
return;
}
// get magnitude from gesture velocity
@@ -233,10 +222,7 @@ class PhotoViewCoreState extends State<PhotoViewCore>
// animate velocity only if there is no scale change and a significant magnitude
if (_scaleBefore! / s == 1.0 && magnitude >= 400.0) {
final Offset direction = details.velocity.pixelsPerSecond / magnitude;
animatePosition(
p,
clampPosition(position: p + direction * 100.0),
);
animatePosition(p, clampPosition(position: p + direction * 100.0));
}
}
@@ -248,10 +234,7 @@ class PhotoViewCoreState extends State<PhotoViewCore>
if (!mounted) {
return;
}
_scaleAnimation = Tween<double>(
begin: from,
end: to,
).animate(_scaleAnimationController);
_scaleAnimation = Tween<double>(begin: from, end: to).animate(_scaleAnimationController);
_scaleAnimationController
..value = 0.0
..fling(velocity: 0.4);
@@ -355,10 +338,7 @@ class PhotoViewCoreState extends State<PhotoViewCore>
return StreamBuilder(
stream: controller.outputStateStream,
initialData: controller.prevValue,
builder: (
BuildContext context,
AsyncSnapshot<PhotoViewControllerValue> snapshot,
) {
builder: (BuildContext context, AsyncSnapshot<PhotoViewControllerValue> snapshot) {
if (snapshot.hasData) {
final PhotoViewControllerValue value = snapshot.data!;
final useImageScale = widget.filterQuality != FilterQuality.none;
@@ -371,11 +351,7 @@ class PhotoViewCoreState extends State<PhotoViewCore>
..rotateZ(value.rotation);
final Widget customChildLayout = CustomSingleChildLayout(
delegate: _CenterWithOriginalSizeDelegate(
scaleBoundaries.childSize,
basePosition,
useImageScale,
),
delegate: _CenterWithOriginalSizeDelegate(scaleBoundaries.childSize, basePosition, useImageScale),
child: _buildHero(_buildChild()),
);
@@ -383,11 +359,7 @@ class PhotoViewCoreState extends State<PhotoViewCore>
constraints: widget.tightMode ? BoxConstraints.tight(scaleBoundaries.childSize * scale) : null,
decoration: widget.backgroundDecoration ?? _defaultDecoration,
child: Center(
child: Transform(
transform: matrix,
alignment: basePosition,
child: customChildLayout,
),
child: Transform(transform: matrix, alignment: basePosition, child: customChildLayout),
),
);
@@ -402,28 +374,20 @@ class PhotoViewCoreState extends State<PhotoViewCore>
onScaleUpdate: widget.disableScaleGestures ? null : onScaleUpdate,
onScaleEnd: widget.disableScaleGestures ? null : onScaleEnd,
onDragStart: widget.onDragStart != null
? (details) => widget.onDragStart!(
context,
details,
widget.controller,
widget.scaleStateController,
)
? (details) => widget.onDragStart!(context, details, widget.controller, widget.scaleStateController)
: null,
onDragEnd: widget.onDragEnd != null
? (details) => widget.onDragEnd!(context, details, widget.controller.value)
: null,
onDragUpdate: widget.onDragUpdate != null
? (details) => widget.onDragUpdate!(
context,
details,
widget.controller.value,
)
? (details) => widget.onDragUpdate!(context, details, widget.controller.value)
: null,
hitDetector: this,
onTapUp: widget.onTapUp != null ? (details) => widget.onTapUp!(context, details, value) : null,
onTapDown: widget.onTapDown != null ? (details) => widget.onTapDown!(context, details, value) : null,
onLongPressStart:
widget.onLongPressStart != null ? (details) => widget.onLongPressStart!(context, details, value) : null,
onLongPressStart: widget.onLongPressStart != null
? (details) => widget.onLongPressStart!(context, details, value)
: null,
child: child,
);
} else {
@@ -462,11 +426,7 @@ class PhotoViewCoreState extends State<PhotoViewCore>
}
class _CenterWithOriginalSizeDelegate extends SingleChildLayoutDelegate {
const _CenterWithOriginalSizeDelegate(
this.subjectSize,
this.basePosition,
this.useImageScale,
);
const _CenterWithOriginalSizeDelegate(this.subjectSize, this.basePosition, this.useImageScale);
final Size subjectSize;
final Alignment basePosition;
@@ -103,15 +103,13 @@ class PhotoViewGestureDetector extends StatelessWidget {
);
gestures[LongPressGestureRecognizer] = GestureRecognizerFactoryWithHandlers<LongPressGestureRecognizer>(
() => LongPressGestureRecognizer(debugOwner: this), (LongPressGestureRecognizer instance) {
instance.onLongPressStart = onLongPressStart;
});
return RawGestureDetector(
behavior: behavior,
gestures: gestures,
child: child,
() => LongPressGestureRecognizer(debugOwner: this),
(LongPressGestureRecognizer instance) {
instance.onLongPressStart = onLongPressStart;
},
);
return RawGestureDetector(behavior: behavior, gestures: gestures, child: child);
}
}
@@ -241,16 +239,11 @@ class PhotoViewGestureRecognizer extends ScaleGestureRecognizer {
/// );
/// ```
class PhotoViewGestureDetectorScope extends InheritedWidget {
const PhotoViewGestureDetectorScope({
super.key,
this.axis,
this.touchSlopFactor = .2,
required super.child,
});
const PhotoViewGestureDetectorScope({super.key, this.axis, this.touchSlopFactor = .2, required super.child});
static PhotoViewGestureDetectorScope? of(BuildContext context) {
final PhotoViewGestureDetectorScope? scope =
context.dependOnInheritedWidgetOfExactType<PhotoViewGestureDetectorScope>();
final PhotoViewGestureDetectorScope? scope = context
.dependOnInheritedWidgetOfExactType<PhotoViewGestureDetectorScope>();
return scope;
}
@@ -273,10 +266,7 @@ class PhotoViewGestureDetectorScope extends InheritedWidget {
// we cannot change that, but we can prevent the scrollable from panning until this threshold is reached
// and let other recognizers accept the gesture instead
class PhotoViewPageViewScrollPhysics extends ScrollPhysics {
const PhotoViewPageViewScrollPhysics({
this.touchSlopFactor = 0.1,
super.parent,
});
const PhotoViewPageViewScrollPhysics({this.touchSlopFactor = 0.1, super.parent});
// in [0, 1]
// 0: most reactive but will not let PhotoView recognizers accept gestures
@@ -285,10 +275,7 @@ class PhotoViewPageViewScrollPhysics extends ScrollPhysics {
@override
PhotoViewPageViewScrollPhysics applyTo(ScrollPhysics? ancestor) {
return PhotoViewPageViewScrollPhysics(
touchSlopFactor: touchSlopFactor,
parent: buildParent(ancestor),
);
return PhotoViewPageViewScrollPhysics(touchSlopFactor: touchSlopFactor, parent: buildParent(ancestor));
}
@override
@@ -25,10 +25,7 @@ mixin HitCornersDetector on PhotoViewControllerDelegate {
return HitCorners(y <= cornersY.min, y >= cornersY.max);
}
bool _shouldMoveAxis(
HitCorners hitCorners,
double mainAxisMove,
) {
bool _shouldMoveAxis(HitCorners hitCorners, double mainAxisMove) {
if (mainAxisMove == 0) {
return false;
}
@@ -9,13 +9,7 @@ class PhotoViewDefaultError extends StatelessWidget {
Widget build(BuildContext context) {
return DecoratedBox(
decoration: decoration,
child: Center(
child: Icon(
Icons.broken_image,
color: Colors.grey[400],
size: 40.0,
),
),
child: Center(child: Icon(Icons.broken_image, color: Colors.grey[400], size: 40.0)),
);
}
}
@@ -32,11 +26,7 @@ class PhotoViewDefaultLoading extends StatelessWidget {
final value = loadedBytes != null && expectedBytes != null ? loadedBytes / expectedBytes : null;
return Center(
child: SizedBox(
width: 20.0,
height: 20.0,
child: CircularProgressIndicator(value: value),
),
child: SizedBox(width: 20.0, height: 20.0, child: CircularProgressIndicator(value: value)),
);
}
}
@@ -109,9 +109,7 @@ class _ImageWrapperState extends State<ImageWrapper> {
// retrieve image from the provider
void _resolveImage() {
final ImageStream newStream = widget.imageProvider.resolve(
const ImageConfiguration(),
);
final ImageStream newStream = widget.imageProvider.resolve(const ImageConfiguration());
_updateSourceStream(newStream);
}
@@ -125,10 +123,7 @@ class _ImageWrapperState extends State<ImageWrapper> {
void handleImageFrame(ImageInfo info, bool synchronousCall) {
setupCB() {
_imageSize = Size(
info.image.width.toDouble(),
info.image.height.toDouble(),
);
_imageSize = Size(info.image.width.toDouble(), info.image.height.toDouble());
_loading = false;
_imageInfo = _imageInfo;
@@ -154,11 +149,7 @@ class _ImageWrapperState extends State<ImageWrapper> {
}());
}
_imageStreamListener = ImageStreamListener(
handleImageFrame,
onChunk: handleImageChunk,
onError: handleError,
);
_imageStreamListener = ImageStreamListener(handleImageFrame, onChunk: handleImageChunk, onError: handleError);
return _imageStreamListener!;
}
@@ -227,20 +218,14 @@ class _ImageWrapperState extends State<ImageWrapper> {
return widget.loadingBuilder!(context, _loadingProgress, widget.index);
}
return PhotoViewDefaultLoading(
event: _loadingProgress,
);
return PhotoViewDefaultLoading(event: _loadingProgress);
}
Widget _buildError(
BuildContext context,
) {
Widget _buildError(BuildContext context) {
if (widget.errorBuilder != null) {
return widget.errorBuilder!(context, _lastException!, _lastStack);
}
return PhotoViewDefaultError(
decoration: widget.backgroundDecoration,
);
return PhotoViewDefaultError(decoration: widget.backgroundDecoration);
}
}
@@ -58,11 +58,7 @@ class IgnorableChangeNotifier extends ChangeNotifier {
}
} catch (exception, stack) {
FlutterError.reportError(
FlutterErrorDetails(
exception: exception,
stack: stack,
library: 'Photoview library',
),
FlutterErrorDetails(exception: exception, stack: stack, library: 'Photoview library'),
);
}
}
@@ -5,22 +5,15 @@ import "package:immich_mobile/widgets/photo_view/src/photo_view_computed_scale.d
import 'package:immich_mobile/widgets/photo_view/src/photo_view_scale_state.dart';
/// Given a [PhotoViewScaleState], returns a scale value considering [scaleBoundaries].
double getScaleForScaleState(
PhotoViewScaleState scaleState,
ScaleBoundaries scaleBoundaries,
) {
double getScaleForScaleState(PhotoViewScaleState scaleState, ScaleBoundaries scaleBoundaries) {
return switch (scaleState) {
PhotoViewScaleState.initial ||
PhotoViewScaleState.zoomedIn ||
PhotoViewScaleState.zoomedOut =>
_clampSize(scaleBoundaries.initialScale, scaleBoundaries),
PhotoViewScaleState.zoomedOut => _clampSize(scaleBoundaries.initialScale, scaleBoundaries),
PhotoViewScaleState.covering => _clampSize(
_scaleForCovering(
scaleBoundaries.outerSize,
scaleBoundaries.childSize,
),
scaleBoundaries,
),
_scaleForCovering(scaleBoundaries.outerSize, scaleBoundaries.childSize),
scaleBoundaries,
),
PhotoViewScaleState.originalSize => _clampSize(1.0, scaleBoundaries),
};
}
@@ -28,13 +21,7 @@ double getScaleForScaleState(
/// Internal class to wraps custom scale boundaries (min, max and initial)
/// Also, stores values regarding the two sizes: the container and the child.
class ScaleBoundaries {
const ScaleBoundaries(
this._minScale,
this._maxScale,
this._initialScale,
this.outerSize,
this.childSize,
);
const ScaleBoundaries(this._minScale, this._maxScale, this._initialScale, this.outerSize, this.childSize);
final dynamic _minScale;
final dynamic _maxScale;