mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-14 09:46:01 -07:00
Init repo
This commit is contained in:
commit
764b6034e3
566 changed files with 212335 additions and 0 deletions
33
lib/widgets/shared/pinch_poster_zoom.dart
Normal file
33
lib/widgets/shared/pinch_poster_zoom.dart
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import 'package:fladder/providers/settings/client_settings_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
class PinchPosterZoom extends ConsumerStatefulWidget {
|
||||
final Widget child;
|
||||
final Function(double difference)? scaleDifference;
|
||||
const PinchPosterZoom({required this.child, this.scaleDifference, super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<ConsumerStatefulWidget> createState() => _PinchPosterZoomState();
|
||||
}
|
||||
|
||||
class _PinchPosterZoomState extends ConsumerState<PinchPosterZoom> {
|
||||
double lastScale = 1.0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onScaleStart: (details) {
|
||||
lastScale = 1;
|
||||
},
|
||||
onScaleUpdate: (details) {
|
||||
final difference = details.scale - lastScale;
|
||||
if (ref.watch(clientSettingsProvider.select((value) => value.pinchPosterZoom))) {
|
||||
widget.scaleDifference?.call(difference);
|
||||
}
|
||||
lastScale = details.scale;
|
||||
},
|
||||
child: widget.child,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue