Skip to content

armgit / ente

Public Imported from GitHub
0

💚 End-to-end encrypted cloud for everything.

[locker] Tidy scanner nits

laurenspriem19ecea2ada6c
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.dart
index 4c7a992a8b..b5fe470385 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
@@ -160,7 +160,8 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>
if (!mounted) return;
await controller.startImageStream(_onFrame);
if (!mounted) return;
- _torchOn = false;
+ if (_torchOn) await _applyTorch(controller, true);
+ if (!mounted) return;
setState(() {
_camera = controller;
_status = _CameraStatus.ready;
@@ -457,12 +458,17 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>
Future<void> _toggleTorch() async {
final camera = _camera;
if (camera == null) return;
- final next = !_torchOn;
+ await _applyTorch(camera, !_torchOn);
+ if (mounted) setState(() {});
+ }
+
+ Future<void> _applyTorch(CameraController camera, bool on) async {
try {
- await camera.setFlashMode(next ? FlashMode.torch : FlashMode.off);
- setState(() => _torchOn = next);
+ await camera.setFlashMode(on ? FlashMode.torch : FlashMode.off);
+ _torchOn = on;
} on CameraException catch (e) {
_logger.warning('Torch unavailable: ${e.code}');
+ _torchOn = false;
}
}
@@ -555,6 +561,9 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>
],
),
const Spacer(),
+ _PreparingHint(
+ visible: !_session.isServiceReady && !_scannerInitFailed,
+ ),
SizedBox(
height: 88,
child: Stack(
@@ -769,6 +778,56 @@ class _CameraMessage extends StatelessWidget {
}
}
+class _PreparingHint extends StatelessWidget {
+ const _PreparingHint({required this.visible});
+
+ final bool visible;
+
+ @override
+ Widget build(BuildContext context) {
+ final colors = context.componentColors;
+ return AnimatedSize(
+ duration: Motion.standard,
+ curve: Curves.easeInOut,
+ child: visible
+ ? 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,
+ ),
+ ),
+ ],
+ ),
+ ),
+ )
+ : const SizedBox.shrink(),
+ );
+ }
+}
+
class _ChromeButton extends StatelessWidget {
const _ChromeButton({required this.icon, required this.onTap, this.tooltip});
@@ -825,30 +884,36 @@ class _ShutterButtonState extends State<_ShutterButton> {
Widget build(BuildContext context) {
final colors = context.componentColors;
final white = colors.specialWhite;
- return 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),
+ 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,
+ ),
+ ),
),
),
),
diff --git a/mobile/apps/locker/lib/ui/pages/scanner/scanner_review_page.dart b/mobile/apps/locker/lib/ui/pages/scanner/scanner_review_page.dart
index 96ab3a52b1..91d90b984e 100644
--- a/mobile/apps/locker/lib/ui/pages/scanner/scanner_review_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/scanner/scanner_review_page.dart
@@ -296,6 +296,26 @@ class _ScannerReviewPageState extends State<ScannerReviewPage>
);
}
+ Widget _buildProcessingState(ColorTokens colors) {
+ return Center(
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const SizedBox(
+ width: 28,
+ height: 28,
+ child: CircularProgressIndicator(strokeWidth: 2.5),
+ ),
+ const SizedBox(height: Spacing.lg),
+ Text(
+ context.strings.scanProcessing,
+ style: TextStyles.body.copyWith(color: colors.textLighter),
+ ),
+ ],
+ ),
+ );
+ }
+
Widget _buildThumbnailStrip(
List<ScannedPage> pages,
int current,
@@ -336,7 +356,10 @@ class _ScannerReviewPageState extends State<ScannerReviewPage>
page.processedJpeg,
key: ValueKey(page.processedJpeg.path),
fit: BoxFit.cover,
- cacheHeight: 168,
+ cacheHeight:
+ (_thumbnailHeight *
+ MediaQuery.devicePixelRatioOf(context))
+ .round(),
),
),
),
@@ -380,7 +403,7 @@ class _ScannerReviewPageState extends State<ScannerReviewPage>
),
variant: IconButtonComponentVariant.unfilled,
onTap: () => Navigator.of(context).pop(false),
- tooltip: l10n.addPage,
+ tooltip: l10n.back,
),
Expanded(
child: Center(child: _buildFileNameField(colors)),
@@ -399,7 +422,7 @@ class _ScannerReviewPageState extends State<ScannerReviewPage>
),
Expanded(
child: pageCount == 0
- ? const Center(child: CircularProgressIndicator())
+ ? _buildProcessingState(colors)
: PageView.builder(
controller: _pageController,
itemCount: pageCount,
@@ -465,10 +488,20 @@ class _ScannerReviewPageState extends State<ScannerReviewPage>
),
),
const SizedBox(height: Spacing.sm),
- if (pageCount > 1) ...[
- _buildThumbnailStrip(pages, current, colors),
- const SizedBox(height: Spacing.sm),
- ],
+ AnimatedSize(
+ duration: Motion.standard,
+ curve: Curves.easeInOut,
+ alignment: Alignment.topCenter,
+ child: pageCount > 1
+ ? Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ _buildThumbnailStrip(pages, current, colors),
+ const SizedBox(height: Spacing.sm),
+ ],
+ )
+ : const SizedBox(width: double.infinity),
+ ),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
index 89e23489d4..216b1f858c 100644
--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb
+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb
@@ -526,6 +526,7 @@
"camera": "Camera",
"campingMoments": "Campfire moments",
"cancel": "Cancel",
+ "back": "Back",
"@cancel": {
"description": "Cancel button label"
},
@@ -3598,6 +3599,9 @@
"scannerNotSupportedOnDevice": "Document scanning is not supported on this device",
"scannerTorchOff": "Turn off torch",
"scannerTorchOn": "Turn on torch",
+ "scannerCapture": "Capture",
+ "scannerPreparing": "Preparing scanner…",
+ "scanProcessing": "Processing your scan…",
"scanPageOfTotal": "Page {current} of {total}",
"@scanPageOfTotal": {
"description": "Page position indicator in the document scanner review screen",