π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[locker] Move scanner capture widgets into their own file
laurenspriem61a50f3ee4f0
diff --git a/mobile/apps/locker/lib/ui/pages/scanner/scanner_capture_page.dart b/mobile/apps/locker/lib/ui/pages/scanner/scanner_capture_page.dartindex ec89676b60..3e542559ef 100644--- a/mobile/apps/locker/lib/ui/pages/scanner/scanner_capture_page.dart+++ b/mobile/apps/locker/lib/ui/pages/scanner/scanner_capture_page.dart@@ -15,8 +15,8 @@ import 'package:locker/services/scanner/scan_geometry.dart';import 'package:locker/services/scanner/scan_session_controller.dart';import 'package:locker/services/scanner/scanner_models.dart';import 'package:locker/ui/pages/scanner/capture_flight.dart';-import 'package:locker/ui/pages/scanner/delayed_reveal.dart';import 'package:locker/ui/pages/scanner/scan_quad_overlay.dart';+import 'package:locker/ui/pages/scanner/scanner_capture_widgets.dart';import 'package:locker/ui/pages/scanner/scanner_review_page.dart';import 'package:logging/logging.dart';@@ -357,7 +357,7 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>),target: thumbRect,targetRadius: Radii.md,- targetBorder: _PagesButton.borderWidth,+ targetBorder: ScannerPagesButton.borderWidth,);}@@ -441,7 +441,7 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>);} else if (shownPages > 0) {final page = _session.pages[shownPages - 1];- thumbnail = _ProcessedThumbnail(+ thumbnail = ScannerProcessedThumbnail(key: ValueKey(page.processedJpeg.path),page: page,);@@ -537,7 +537,7 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>Row(mainAxisAlignment: MainAxisAlignment.spaceBetween,children: [- _ChromeButton(+ ScannerChromeButton(icon: HugeIcons.strokeRoundedCancel01,onTap: () => Navigator.of(context).pop(false),tooltip: context.strings.close,@@ -545,7 +545,7 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>Row(mainAxisSize: MainAxisSize.min,children: [- _ChromeButton(+ ScannerChromeButton(icon: _torchOn? HugeIcons.strokeRoundedFlash: HugeIcons.strokeRoundedFlashOff,@@ -555,7 +555,7 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>: context.strings.scannerTorchOn,),const SizedBox(width: Spacing.sm),- _AutoToggle(+ ScannerModeToggle(active: _autoMode,onTap: _toggleAutoMode,),@@ -564,7 +564,7 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>],),const Spacer(),- _PreparingHint(+ ScannerPreparingHint(visible: !_session.isServiceReady && !_scannerInitFailed,),SizedBox(@@ -572,7 +572,7 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>child: Stack(alignment: Alignment.center,children: [- _ShutterButton(+ ScannerShutterButton(enabled:_status == _CameraStatus.ready &&!_takingPicture &&@@ -581,7 +581,7 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>),Align(alignment: Alignment.centerLeft,- child: _PagesButton(+ child: ScannerPagesButton(key: _pagesButtonKey,count: pages.count,thumbnail: pages.thumbnail,@@ -592,7 +592,7 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>),Align(alignment: Alignment.centerRight,- child: _DoneButton(+ child: ScannerDoneButton(visible: pages.count > 0,accent: colors.primary,onTap: _openReview,@@ -627,7 +627,7 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>Widget _buildPreview(ColorTokens colors) {if (_scannerInitFailed) {- return _CameraMessage(+ return ScannerCameraMessage(message: context.strings.somethingWentWrong,onRetry: _initScanner,);@@ -638,12 +638,12 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>child: CircularProgressIndicator(color: colors.specialWhite),);case _CameraStatus.permissionDenied:- return _CameraMessage(+ return ScannerCameraMessage(message: context.strings.cameraPermissionSettings,onRetry: _startCamera,);case _CameraStatus.error:- return _CameraMessage(+ return ScannerCameraMessage(message: context.strings.somethingWentWrong,onRetry: _startCamera,);@@ -685,50 +685,6 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>}}-class _ProcessedThumbnail extends StatelessWidget {- const _ProcessedThumbnail({super.key, required this.page});-- static const _inset = CaptureFlightSpec.thumbnailInset;- static const _zoom = 1 / (1 - 2 * _inset);-- final ScannedPage page;-- @override- Widget build(BuildContext context) {- return LayoutBuilder(- builder: (context, constraints) {- final box = constraints.biggest;- final aspect = page.height == 0 ? 1.0 : page.width / page.height;- final size = aspect < 1- ? Size(box.width * _zoom, box.width * _zoom / aspect)- : Size(box.height * _zoom * aspect, box.height * _zoom);- return ClipRect(- child: OverflowBox(- alignment: Alignment.topCenter,- maxWidth: double.infinity,- maxHeight: double.infinity,- child: Transform.translate(- offset: Offset(0, -size.height * _inset),- child: SizedBox.fromSize(- size: size,- child: Image(- image: ResizeImage(- FileImage(page.processedJpeg),- height:- (size.height * MediaQuery.devicePixelRatioOf(context))- .round(),- ),- fit: BoxFit.fill,- ),- ),- ),- ),- );- },- );- }-}-class _PendingCapture {_PendingCapture(this.id);@@ -747,507 +703,3 @@ class _ActiveFlight {final _PendingCapture capture;final CaptureFlightSpec spec;}--class _CameraMessage extends StatelessWidget {- const _CameraMessage({required this.message, required this.onRetry});-- final String message;- final Future<void> Function() onRetry;-- @override- Widget build(BuildContext context) {- final colors = context.componentColors;- return Center(- child: Padding(- padding: const EdgeInsets.symmetric(horizontal: Spacing.xxl),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- Text(- message,- textAlign: TextAlign.center,- style: TextStyles.body.copyWith(color: colors.specialWhite),- ),- const SizedBox(height: Spacing.xl),- ButtonComponent(- label: context.strings.retry,- size: ButtonComponentSize.small,- onTap: onRetry,- ),- ],- ),- ),- );- }-}--class _PreparingHint extends StatelessWidget {- const _PreparingHint({required this.visible});-- final bool visible;-- @override- Widget build(BuildContext context) {- final colors = context.componentColors;- return DelayedReveal(- visible: visible,- child: Padding(- padding: const EdgeInsets.only(bottom: Spacing.md),- child: Container(- padding: const EdgeInsets.symmetric(- horizontal: Spacing.md,- vertical: Spacing.sm,- ),- decoration: BoxDecoration(- color: Colors.black.withValues(alpha: 0.4),- borderRadius: BorderRadius.circular(22),- ),- child: Row(- mainAxisSize: MainAxisSize.min,- children: [- SizedBox(- width: 14,- height: 14,- child: CircularProgressIndicator(- strokeWidth: 2,- color: colors.specialWhite,- ),- ),- const SizedBox(width: Spacing.sm),- Text(- context.strings.scannerPreparing,- style: TextStyles.mini.copyWith(color: colors.specialWhite),- ),- ],- ),- ),- ),- );- }-}--class _ChromeButton extends StatelessWidget {- const _ChromeButton({required this.icon, required this.onTap, this.tooltip});-- final List<List<dynamic>> icon;- final VoidCallback? onTap;- final String? tooltip;-- @override- Widget build(BuildContext context) {- final colors = context.componentColors;- final button = GestureDetector(- onTap: onTap,- child: Container(- width: 44,- height: 44,- decoration: BoxDecoration(- color: Colors.black.withValues(alpha: 0.4),- shape: BoxShape.circle,- ),- child: Center(- child: HugeIcon(- icon: icon,- color: onTap == null- ? colors.specialWhite.withValues(alpha: 0.4)- : colors.specialWhite,- size: 22,- ),- ),- ),- );- if (tooltip == null) return button;- return Tooltip(message: tooltip!, child: button);- }-}--class _ShutterButton extends StatefulWidget {- const _ShutterButton({required this.enabled, required this.onTap});-- final bool enabled;- final Future<void> Function() onTap;-- @override- State<_ShutterButton> createState() => _ShutterButtonState();-}--class _ShutterButtonState extends State<_ShutterButton> {- bool _pressed = false;-- void _setPressed(bool pressed) {- if (_pressed != pressed) setState(() => _pressed = pressed);- }-- @override- Widget build(BuildContext context) {- final colors = context.componentColors;- final white = colors.specialWhite;- return Tooltip(- message: context.strings.scannerCapture,- child: GestureDetector(- onTapDown: widget.enabled ? (_) => _setPressed(true) : null,- onTapUp: (_) => _setPressed(false),- onTapCancel: () => _setPressed(false),- onTap: widget.enabled ? () => widget.onTap() : null,- child: AnimatedOpacity(- duration: const Duration(milliseconds: 150),- opacity: widget.enabled ? 1 : 0.5,- child: AnimatedScale(- scale: _pressed ? 0.9 : 1,- duration: _pressed ? Motion.quick : Motion.slow,- curve: _pressed ? Curves.easeOut : Curves.easeOutBack,- child: Container(- width: 76,- height: 76,- decoration: BoxDecoration(- shape: BoxShape.circle,- border: Border.all(color: white, width: 4),- ),- child: Center(- child: Container(- width: 60,- height: 60,- decoration: BoxDecoration(- shape: BoxShape.circle,- color: white,- ),- ),- ),- ),- ),- ),- ),- );- }-}--class _AutoToggle extends StatelessWidget {- const _AutoToggle({required this.active, required this.onTap});-- final bool active;- final VoidCallback onTap;-- @override- Widget build(BuildContext context) {- final colors = context.componentColors;- final labelStyle = TextStyles.mini.copyWith(color: colors.specialWhite);- return Tooltip(- message: active- ? context.strings.scannerAutoCaptureOff- : context.strings.scannerAutoCaptureOn,- child: GestureDetector(- onTap: onTap,- child: Container(- height: 44,- padding: const EdgeInsets.symmetric(horizontal: Spacing.md),- decoration: BoxDecoration(- color: Colors.black.withValues(alpha: 0.4),- borderRadius: BorderRadius.circular(22),- ),- child: Row(- mainAxisSize: MainAxisSize.min,- children: [- HugeIcon(- icon: HugeIcons.strokeRoundedCameraAutomatically01,- color: colors.specialWhite,- size: 20,- ),- const SizedBox(width: Spacing.xs),- Stack(- alignment: Alignment.center,- children: [- for (final label in [- context.strings.scannerCaptureModeAuto,- context.strings.scannerCaptureModeManual,- ])- Opacity(opacity: 0, child: Text(label, style: labelStyle)),- Text(- active- ? context.strings.scannerCaptureModeAuto- : context.strings.scannerCaptureModeManual,- style: labelStyle,- ),- ],- ),- ],- ),- ),- ),- );- }-}--class _SessionActionReveal extends StatelessWidget {- const _SessionActionReveal({- required this.visible,- required this.revealDuration,- required this.tooltip,- required this.onTap,- required this.child,- });-- static const size = 62.0;-- final bool visible;- final Duration revealDuration;- final String tooltip;- final VoidCallback onTap;- final Widget child;-- @override- Widget build(BuildContext context) {- return IgnorePointer(- ignoring: !visible,- child: AnimatedScale(- scale: visible ? 1 : 0,- duration: revealDuration,- curve: visible ? Curves.easeOutBack : Curves.easeIn,- child: Tooltip(- message: tooltip,- child: GestureDetector(- onTap: onTap,- child: SizedBox(width: size, height: size, child: child),- ),- ),- ),- );- }-}--class _PagesButton extends StatefulWidget {- const _PagesButton({- super.key,- required this.count,- required this.thumbnail,- required this.heroFile,- required this.accent,- required this.onTap,- });-- static const borderWidth = 2.0;- static const maxStackedSheets = 2;-- final int count;- final Widget? thumbnail;- final File? heroFile;- final Color accent;- final VoidCallback onTap;-- @override- State<_PagesButton> createState() => _PagesButtonState();-}--class _PagesButtonState extends State<_PagesButton>- with SingleTickerProviderStateMixin {- late final AnimationController _bounce = AnimationController(- vsync: this,- duration: const Duration(milliseconds: 320),- );- late final Animation<double> _scale = TweenSequence<double>([- TweenSequenceItem(- tween: Tween(- begin: 1.0,- end: 1.12,- ).chain(CurveTween(curve: Curves.easeOut)),- weight: 40,- ),- TweenSequenceItem(- tween: Tween(- begin: 1.12,- end: 1.0,- ).chain(CurveTween(curve: Curves.easeInOut)),- weight: 60,- ),- ]).animate(_bounce);-- Duration _switchDuration = Duration.zero;-- @override- void didUpdateWidget(_PagesButton oldWidget) {- super.didUpdateWidget(oldWidget);- if (widget.count > oldWidget.count) _bounce.forward(from: 0);- if (widget.thumbnail?.key != oldWidget.thumbnail?.key) {- _switchDuration = widget.thumbnail is CaptureSnapshotThumbnail- ? Duration.zero- : Motion.standard;- }- }-- @override- void dispose() {- _bounce.dispose();- super.dispose();- }-- static Widget _expandedLayout(Widget? current, List<Widget> previous) =>- Stack(fit: StackFit.expand, children: [...previous, ?current]);-- Widget _stackedSheet(int depth, ColorTokens colors) {- final visible = widget.count > depth;- final angle = (depth.isOdd ? -5.0 : 4.0) * math.pi / 180;- final shift = Offset(depth.isOdd ? -1 : 2, -2.0 * depth);- return Positioned.fill(- child: IgnorePointer(- child: AnimatedOpacity(- duration: Motion.standard,- opacity: visible ? 1 : 0,- child: AnimatedScale(- duration: Motion.standard,- curve: Curves.easeOutBack,- scale: visible ? 1 : 0.8,- child: Transform(- alignment: Alignment.center,- transform: Matrix4.translationValues(shift.dx, shift.dy, 0)- ..rotateZ(angle),- child: Container(- decoration: BoxDecoration(- borderRadius: BorderRadius.circular(Radii.md),- color: colors.specialWhite.withValues(- alpha: depth == 1 ? 0.85 : 0.6,- ),- boxShadow: [- BoxShadow(- color: Colors.black.withValues(alpha: 0.3),- blurRadius: 6,- ),- ],- ),- ),- ),- ),- ),- ),- );- }-- @override- Widget build(BuildContext context) {- final colors = context.componentColors;- return _SessionActionReveal(- visible: widget.count > 0,- revealDuration: Duration.zero,- tooltip: context.strings.review,- onTap: widget.onTap,- child: ScaleTransition(- scale: _scale,- child: Stack(- clipBehavior: Clip.none,- children: [- for (var depth = _PagesButton.maxStackedSheets; depth >= 1; depth--)- _stackedSheet(depth, colors),- Positioned.fill(- child: Container(- decoration: BoxDecoration(- borderRadius: BorderRadius.circular(Radii.md),- color: Colors.black.withValues(alpha: 0.4),- border: Border.all(- color: colors.specialWhite,- width: _PagesButton.borderWidth,- ),- boxShadow: [- BoxShadow(- color: Colors.black.withValues(alpha: 0.35),- blurRadius: 10,- ),- ],- ),- child: ScannerPageHero(- file: widget.heroFile,- primary: false,- child: ClipRRect(- borderRadius: BorderRadius.circular(- Radii.md - _PagesButton.borderWidth,- ),- child: AnimatedSwitcher(- duration: _switchDuration,- layoutBuilder: _expandedLayout,- child:- widget.thumbnail ??- const SizedBox.expand(key: ValueKey('empty')),- ),- ),- ),- ),- ),- if (widget.count > 0)- Positioned(- top: -Spacing.sm,- right: -Spacing.sm,- child: Container(- padding: const EdgeInsets.all(Spacing.xs),- constraints: const BoxConstraints(- minWidth: 24,- minHeight: 24,- ),- decoration: BoxDecoration(- shape: BoxShape.circle,- color: widget.accent,- border: Border.all(- color: colors.specialWhite,- width: _PagesButton.borderWidth,- ),- ),- child: Center(- child: AnimatedSwitcher(- duration: Motion.standard,- transitionBuilder: (child, animation) =>- ScaleTransition(scale: animation, child: child),- child: Text(- '${widget.count}',- key: ValueKey(widget.count),- style: TextStyles.mini.copyWith(- color: colors.specialWhite,- ),- ),- ),- ),- ),- ),- ],- ),- ),- );- }-}--class _DoneButton extends StatelessWidget {- const _DoneButton({- required this.visible,- required this.accent,- required this.onTap,- });-- final bool visible;- final Color accent;- final VoidCallback onTap;-- @override- Widget build(BuildContext context) {- final colors = context.componentColors;- return _SessionActionReveal(- visible: visible,- revealDuration: Motion.standard,- tooltip: context.strings.done,- onTap: onTap,- child: Container(- decoration: BoxDecoration(- shape: BoxShape.circle,- color: accent,- boxShadow: [- BoxShadow(- color: Colors.black.withValues(alpha: 0.35),- blurRadius: 10,- ),- ],- ),- child: Center(- child: HugeIcon(- icon: HugeIcons.strokeRoundedTick02,- color: colors.specialWhite,- size: 30,- ),- ),- ),- );- }-}diff --git a/mobile/apps/locker/lib/ui/pages/scanner/scanner_capture_widgets.dart b/mobile/apps/locker/lib/ui/pages/scanner/scanner_capture_widgets.dartnew file mode 100644index 0000000000..d86ce169aa--- /dev/null+++ b/mobile/apps/locker/lib/ui/pages/scanner/scanner_capture_widgets.dart@@ -0,0 +1,582 @@+import 'dart:io';+import 'dart:math' as math;++import 'package:ente_components/ente_components.dart';+import 'package:ente_strings/ente_strings.dart';+import 'package:flutter/material.dart';+import 'package:hugeicons/hugeicons.dart';+import 'package:locker/services/scanner/scanner_models.dart';+import 'package:locker/ui/pages/scanner/capture_flight.dart';+import 'package:locker/ui/pages/scanner/delayed_reveal.dart';+import 'package:locker/ui/pages/scanner/scanner_review_page.dart';++class ScannerProcessedThumbnail extends StatelessWidget {+ const ScannerProcessedThumbnail({super.key, required this.page});++ static const _inset = CaptureFlightTuning.thumbnailInset;+ static const _zoom = 1 / (1 - 2 * _inset);++ final ScannedPage page;++ @override+ Widget build(BuildContext context) {+ return LayoutBuilder(+ builder: (context, constraints) {+ final box = constraints.biggest;+ final aspect = page.height == 0 ? 1.0 : page.width / page.height;+ final size = aspect < 1+ ? Size(box.width * _zoom, box.width * _zoom / aspect)+ : Size(box.height * _zoom * aspect, box.height * _zoom);+ return ClipRect(+ child: OverflowBox(+ alignment: Alignment.topCenter,+ maxWidth: double.infinity,+ maxHeight: double.infinity,+ child: Transform.translate(+ offset: Offset(0, -size.height * _inset),+ child: SizedBox.fromSize(+ size: size,+ child: Image(+ image: ResizeImage(+ FileImage(page.processedJpeg),+ height:+ (size.height * MediaQuery.devicePixelRatioOf(context))+ .round(),+ ),+ fit: BoxFit.fill,+ ),+ ),+ ),+ ),+ );+ },+ );+ }+}++class ScannerCameraMessage extends StatelessWidget {+ const ScannerCameraMessage({+ super.key,+ required this.message,+ required this.onRetry,+ });++ final String message;+ final Future<void> Function() onRetry;++ @override+ Widget build(BuildContext context) {+ final colors = context.componentColors;+ return Center(+ child: Padding(+ padding: const EdgeInsets.symmetric(horizontal: Spacing.xxl),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ message,+ textAlign: TextAlign.center,+ style: TextStyles.body.copyWith(color: colors.specialWhite),+ ),+ const SizedBox(height: Spacing.xl),+ ButtonComponent(+ label: context.strings.retry,+ size: ButtonComponentSize.small,+ onTap: onRetry,+ ),+ ],+ ),+ ),+ );+ }+}++class ScannerPreparingHint extends StatelessWidget {+ const ScannerPreparingHint({super.key, required this.visible});++ final bool visible;++ @override+ Widget build(BuildContext context) {+ final colors = context.componentColors;+ return DelayedReveal(+ visible: visible,+ child: Padding(+ padding: const EdgeInsets.only(bottom: Spacing.md),+ child: Container(+ padding: const EdgeInsets.symmetric(+ horizontal: Spacing.md,+ vertical: Spacing.sm,+ ),+ decoration: BoxDecoration(+ color: Colors.black.withValues(alpha: 0.4),+ borderRadius: BorderRadius.circular(22),+ ),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ SizedBox(+ width: 14,+ height: 14,+ child: CircularProgressIndicator(+ strokeWidth: 2,+ color: colors.specialWhite,+ ),+ ),+ const SizedBox(width: Spacing.sm),+ Text(+ context.strings.scannerPreparing,+ style: TextStyles.mini.copyWith(color: colors.specialWhite),+ ),+ ],+ ),+ ),+ ),+ );+ }+}++class ScannerChromeButton extends StatelessWidget {+ const ScannerChromeButton({+ super.key,+ required this.icon,+ required this.onTap,+ this.tooltip,+ });++ final List<List<dynamic>> icon;+ final VoidCallback? onTap;+ final String? tooltip;++ @override+ Widget build(BuildContext context) {+ final colors = context.componentColors;+ final button = GestureDetector(+ onTap: onTap,+ child: Container(+ width: 44,+ height: 44,+ decoration: BoxDecoration(+ color: Colors.black.withValues(alpha: 0.4),+ shape: BoxShape.circle,+ ),+ child: Center(+ child: HugeIcon(+ icon: icon,+ color: onTap == null+ ? colors.specialWhite.withValues(alpha: 0.4)+ : colors.specialWhite,+ size: 22,+ ),+ ),+ ),+ );+ if (tooltip == null) return button;+ return Tooltip(message: tooltip!, child: button);+ }+}++class ScannerShutterButton extends StatefulWidget {+ const ScannerShutterButton({+ super.key,+ required this.enabled,+ required this.onTap,+ });++ final bool enabled;+ final Future<void> Function() onTap;++ @override+ State<ScannerShutterButton> createState() => _ScannerShutterButtonState();+}++class _ScannerShutterButtonState extends State<ScannerShutterButton> {+ bool _pressed = false;++ void _setPressed(bool pressed) {+ if (_pressed != pressed) setState(() => _pressed = pressed);+ }++ @override+ Widget build(BuildContext context) {+ final colors = context.componentColors;+ final white = colors.specialWhite;+ return Tooltip(+ message: context.strings.scannerCapture,+ child: GestureDetector(+ onTapDown: widget.enabled ? (_) => _setPressed(true) : null,+ onTapUp: (_) => _setPressed(false),+ onTapCancel: () => _setPressed(false),+ onTap: widget.enabled ? () => widget.onTap() : null,+ child: AnimatedOpacity(+ duration: const Duration(milliseconds: 150),+ opacity: widget.enabled ? 1 : 0.5,+ child: AnimatedScale(+ scale: _pressed ? 0.9 : 1,+ duration: _pressed ? Motion.quick : Motion.slow,+ curve: _pressed ? Curves.easeOut : Curves.easeOutBack,+ child: Container(+ width: 76,+ height: 76,+ decoration: BoxDecoration(+ shape: BoxShape.circle,+ border: Border.all(color: white, width: 4),+ ),+ child: Center(+ child: Container(+ width: 60,+ height: 60,+ decoration: BoxDecoration(+ shape: BoxShape.circle,+ color: white,+ ),+ ),+ ),+ ),+ ),+ ),+ ),+ );+ }+}++class ScannerModeToggle extends StatelessWidget {+ const ScannerModeToggle({+ super.key,+ required this.active,+ required this.onTap,+ });++ final bool active;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ final colors = context.componentColors;+ final labelStyle = TextStyles.mini.copyWith(color: colors.specialWhite);+ return Tooltip(+ message: active+ ? context.strings.scannerAutoCaptureOff+ : context.strings.scannerAutoCaptureOn,+ child: GestureDetector(+ onTap: onTap,+ child: Container(+ height: 44,+ padding: const EdgeInsets.symmetric(horizontal: Spacing.md),+ decoration: BoxDecoration(+ color: Colors.black.withValues(alpha: 0.4),+ borderRadius: BorderRadius.circular(22),+ ),+ child: Row(+ mainAxisSize: MainAxisSize.min,+ children: [+ HugeIcon(+ icon: HugeIcons.strokeRoundedCameraAutomatically01,+ color: colors.specialWhite,+ size: 20,+ ),+ const SizedBox(width: Spacing.xs),+ Stack(+ alignment: Alignment.center,+ children: [+ for (final label in [+ context.strings.scannerCaptureModeAuto,+ context.strings.scannerCaptureModeManual,+ ])+ Opacity(opacity: 0, child: Text(label, style: labelStyle)),+ Text(+ active+ ? context.strings.scannerCaptureModeAuto+ : context.strings.scannerCaptureModeManual,+ style: labelStyle,+ ),+ ],+ ),+ ],+ ),+ ),+ ),+ );+ }+}++class ScannerActionReveal extends StatelessWidget {+ const ScannerActionReveal({+ super.key,+ required this.visible,+ required this.revealDuration,+ required this.tooltip,+ required this.onTap,+ required this.child,+ });++ static const size = 62.0;++ final bool visible;+ final Duration revealDuration;+ final String tooltip;+ final VoidCallback onTap;+ final Widget child;++ @override+ Widget build(BuildContext context) {+ return IgnorePointer(+ ignoring: !visible,+ child: AnimatedScale(+ scale: visible ? 1 : 0,+ duration: revealDuration,+ curve: visible ? Curves.easeOutBack : Curves.easeIn,+ child: Tooltip(+ message: tooltip,+ child: GestureDetector(+ onTap: onTap,+ child: SizedBox(width: size, height: size, child: child),+ ),+ ),+ ),+ );+ }+}++class ScannerPagesButton extends StatefulWidget {+ const ScannerPagesButton({+ super.key,+ required this.count,+ required this.thumbnail,+ required this.heroFile,+ required this.accent,+ required this.onTap,+ });++ static const borderWidth = 2.0;+ static const maxStackedSheets = 2;++ final int count;+ final Widget? thumbnail;+ final File? heroFile;+ final Color accent;+ final VoidCallback onTap;++ @override+ State<ScannerPagesButton> createState() => _ScannerPagesButtonState();+}++class _ScannerPagesButtonState extends State<ScannerPagesButton>+ with SingleTickerProviderStateMixin {+ late final AnimationController _bounce = AnimationController(+ vsync: this,+ duration: const Duration(milliseconds: 320),+ );+ late final Animation<double> _scale = TweenSequence<double>([+ TweenSequenceItem(+ tween: Tween(+ begin: 1.0,+ end: 1.12,+ ).chain(CurveTween(curve: Curves.easeOut)),+ weight: 40,+ ),+ TweenSequenceItem(+ tween: Tween(+ begin: 1.12,+ end: 1.0,+ ).chain(CurveTween(curve: Curves.easeInOut)),+ weight: 60,+ ),+ ]).animate(_bounce);++ Duration _switchDuration = Duration.zero;++ @override+ void didUpdateWidget(ScannerPagesButton oldWidget) {+ super.didUpdateWidget(oldWidget);+ if (widget.count > oldWidget.count) _bounce.forward(from: 0);+ if (widget.thumbnail?.key != oldWidget.thumbnail?.key) {+ _switchDuration = widget.thumbnail is CaptureSnapshotThumbnail+ ? Duration.zero+ : Motion.standard;+ }+ }++ @override+ void dispose() {+ _bounce.dispose();+ super.dispose();+ }++ static Widget _expandedLayout(Widget? current, List<Widget> previous) =>+ Stack(fit: StackFit.expand, children: [...previous, ?current]);++ Widget _stackedSheet(int depth, ColorTokens colors) {+ final visible = widget.count > depth;+ final angle = (depth.isOdd ? -5.0 : 4.0) * math.pi / 180;+ final shift = Offset(depth.isOdd ? -1 : 2, -2.0 * depth);+ return Positioned.fill(+ child: IgnorePointer(+ child: AnimatedOpacity(+ duration: Motion.standard,+ opacity: visible ? 1 : 0,+ child: AnimatedScale(+ duration: Motion.standard,+ curve: Curves.easeOutBack,+ scale: visible ? 1 : 0.8,+ child: Transform(+ alignment: Alignment.center,+ transform: Matrix4.translationValues(shift.dx, shift.dy, 0)+ ..rotateZ(angle),+ child: Container(+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(Radii.md),+ color: colors.specialWhite.withValues(+ alpha: depth == 1 ? 0.85 : 0.6,+ ),+ boxShadow: [+ BoxShadow(+ color: Colors.black.withValues(alpha: 0.3),+ blurRadius: 6,+ ),+ ],+ ),+ ),+ ),+ ),+ ),+ ),+ );+ }++ @override+ Widget build(BuildContext context) {+ final colors = context.componentColors;+ return ScannerActionReveal(+ visible: widget.count > 0,+ revealDuration: Duration.zero,+ tooltip: context.strings.review,+ onTap: widget.onTap,+ child: ScaleTransition(+ scale: _scale,+ child: Stack(+ clipBehavior: Clip.none,+ children: [+ for (+ var depth = ScannerPagesButton.maxStackedSheets;+ depth >= 1;+ depth--+ )+ _stackedSheet(depth, colors),+ Positioned.fill(+ child: Container(+ decoration: BoxDecoration(+ borderRadius: BorderRadius.circular(Radii.md),+ color: Colors.black.withValues(alpha: 0.4),+ border: Border.all(+ color: colors.specialWhite,+ width: ScannerPagesButton.borderWidth,+ ),+ boxShadow: [+ BoxShadow(+ color: Colors.black.withValues(alpha: 0.35),+ blurRadius: 10,+ ),+ ],+ ),+ child: ScannerPageHero(+ file: widget.heroFile,+ primary: false,+ child: ClipRRect(+ borderRadius: BorderRadius.circular(+ Radii.md - ScannerPagesButton.borderWidth,+ ),+ child: AnimatedSwitcher(+ duration: _switchDuration,+ layoutBuilder: _expandedLayout,+ child:+ widget.thumbnail ??+ const SizedBox.expand(key: ValueKey('empty')),+ ),+ ),+ ),+ ),+ ),+ if (widget.count > 0)+ Positioned(+ top: -Spacing.sm,+ right: -Spacing.sm,+ child: Container(+ padding: const EdgeInsets.all(Spacing.xs),+ constraints: const BoxConstraints(+ minWidth: 24,+ minHeight: 24,+ ),+ decoration: BoxDecoration(+ shape: BoxShape.circle,+ color: widget.accent,+ border: Border.all(+ color: colors.specialWhite,+ width: ScannerPagesButton.borderWidth,+ ),+ ),+ child: Center(+ child: AnimatedSwitcher(+ duration: Motion.standard,+ transitionBuilder: (child, animation) =>+ ScaleTransition(scale: animation, child: child),+ child: Text(+ '${widget.count}',+ key: ValueKey(widget.count),+ style: TextStyles.mini.copyWith(+ color: colors.specialWhite,+ ),+ ),+ ),+ ),+ ),+ ),+ ],+ ),+ ),+ );+ }+}++class ScannerDoneButton extends StatelessWidget {+ const ScannerDoneButton({+ super.key,+ required this.visible,+ required this.accent,+ required this.onTap,+ });++ final bool visible;+ final Color accent;+ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ final colors = context.componentColors;+ return ScannerActionReveal(+ visible: visible,+ revealDuration: Motion.standard,+ tooltip: context.strings.done,+ onTap: onTap,+ child: Container(+ decoration: BoxDecoration(+ shape: BoxShape.circle,+ color: accent,+ boxShadow: [+ BoxShadow(+ color: Colors.black.withValues(alpha: 0.35),+ blurRadius: 10,+ ),+ ],+ ),+ child: Center(+ child: HugeIcon(+ icon: HugeIcons.strokeRoundedTick02,+ color: colors.specialWhite,+ size: 30,+ ),+ ),+ ),+ );+ }+}