Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[locker] Redesign scanner capture page controls

laurenspriemadc82813171c
diff --git a/mobile/apps/locker/lib/ui/pages/save_page.dart b/mobile/apps/locker/lib/ui/pages/save_page.dart
index f521793364..58b028f3ce 100644
--- a/mobile/apps/locker/lib/ui/pages/save_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/save_page.dart
@@ -4,6 +4,7 @@ import 'dart:io';
import "package:ente_components/ente_components.dart";
import 'package:ente_strings/ente_strings.dart';
import 'package:ente_ui/utils/toast_util.dart';
+import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:hugeicons/hugeicons.dart';
import 'package:locker/ui/pages/account_credentials_page.dart';
@@ -27,7 +28,7 @@ class SaveOption {
final String description;
}
-const bool docScannerEnabled = false;
+const bool docScannerEnabled = kDebugMode;
List<SaveOption> saveOptions(BuildContext context) {
final l10n = context.strings;
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 716827ceb7..c941962013 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
@@ -323,51 +323,64 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>
onTap: () => Navigator.of(context).pop(false),
tooltip: context.strings.close,
),
- _ChromeButton(
- icon: _torchOn
- ? HugeIcons.strokeRoundedFlash
- : HugeIcons.strokeRoundedFlashOff,
- onTap: _camera == null ? null : _toggleTorch,
- tooltip: _torchOn
- ? context.strings.scannerTorchOff
- : context.strings.scannerTorchOn,
+ Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ _ChromeButton(
+ icon: _torchOn
+ ? HugeIcons.strokeRoundedFlash
+ : HugeIcons.strokeRoundedFlashOff,
+ onTap: _camera == null ? null : _toggleTorch,
+ tooltip: _torchOn
+ ? context.strings.scannerTorchOff
+ : context.strings.scannerTorchOn,
+ ),
+ const SizedBox(width: Spacing.sm),
+ _AutoToggle(
+ active: _autoMode,
+ onTap: _toggleAutoMode,
+ ),
+ ],
),
],
),
const Spacer(),
SizedBox(
height: 88,
- child: Stack(
- alignment: Alignment.center,
- children: [
- _ShutterButton(
- enabled:
- _status == _CameraStatus.ready &&
- !_takingPicture &&
- _session.isServiceReady,
- armingProgress: _autoMode ? _autoCapture.progress : 0,
- armingColor: colors.primary,
- onTap: _capture,
- ),
- Align(
- alignment: Alignment.centerLeft,
- child: _AutoToggle(
- active: _autoMode,
- onTap: _toggleAutoMode,
+ child: ListenableBuilder(
+ listenable: _session,
+ builder: (context, _) => Stack(
+ alignment: Alignment.center,
+ children: [
+ _ShutterButton(
+ enabled:
+ _status == _CameraStatus.ready &&
+ !_takingPicture &&
+ _session.isServiceReady,
+ armingProgress: _autoMode
+ ? _autoCapture.progress
+ : 0,
+ armingColor: colors.primary,
+ onTap: _capture,
),
- ),
- Align(
- alignment: Alignment.centerRight,
- child: ListenableBuilder(
- listenable: _session,
- builder: (context, _) => _DoneButton(
+ Align(
+ alignment: Alignment.centerLeft,
+ child: _PagesButton(
session: _session,
accent: colors.primary,
onTap: _openReview,
),
),
- ),
- ],
+ Align(
+ alignment: Alignment.centerRight,
+ child: _DoneButton(
+ session: _session,
+ accent: colors.primary,
+ onTap: _openReview,
+ ),
+ ),
+ ],
+ ),
),
),
],
@@ -411,15 +424,18 @@ class _ScannerCapturePageState extends State<ScannerCapturePage>
return Center(
child: AspectRatio(
aspectRatio: 1 / camera.value.aspectRatio,
- child: Stack(
- fit: StackFit.expand,
- children: [
- CameraPreview(camera),
- ScanQuadOverlay(
- quad: _takingPicture ? null : _stableQuad,
- color: colors.primary,
- ),
- ],
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(Radii.sheet),
+ child: Stack(
+ fit: StackFit.expand,
+ children: [
+ CameraPreview(camera),
+ ScanQuadOverlay(
+ quad: _takingPicture ? null : _stableQuad,
+ color: colors.primary,
+ ),
+ ],
+ ),
),
),
);
@@ -636,20 +652,23 @@ class _AutoToggle extends StatelessWidget {
}
}
-class _DoneButton extends StatelessWidget {
- const _DoneButton({
+class _SessionActionReveal extends StatelessWidget {
+ const _SessionActionReveal({
required this.session,
- required this.accent,
+ required this.tooltip,
required this.onTap,
+ required this.child,
});
+ static const size = 62.0;
+
final ScanSessionController session;
- final Color accent;
+ final String tooltip;
final VoidCallback onTap;
+ final Widget child;
@override
Widget build(BuildContext context) {
- final colors = context.componentColors;
final visible = session.pageCount > 0 || session.isProcessing;
return IgnorePointer(
ignoring: !visible,
@@ -658,68 +677,153 @@ class _DoneButton extends StatelessWidget {
duration: Motion.standard,
curve: visible ? Curves.easeOutBack : Curves.easeIn,
child: Tooltip(
- message: context.strings.done,
+ message: tooltip,
child: GestureDetector(
onTap: onTap,
- child: SizedBox(
- width: 62,
- height: 62,
- child: Stack(
- clipBehavior: Clip.none,
- children: [
- Positioned.fill(
- child: Container(
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: accent,
- boxShadow: [
- BoxShadow(
- color: Colors.black.withValues(alpha: 0.35),
- blurRadius: 10,
- ),
- ],
- ),
- child: Center(
- child: session.isProcessing
- ? SizedBox(
- width: 24,
- height: 24,
- child: CircularProgressIndicator(
- strokeWidth: 2.5,
- color: colors.specialWhite,
- ),
- )
- : HugeIcon(
- icon: HugeIcons.strokeRoundedTick02,
- color: colors.specialWhite,
- size: 30,
- ),
- ),
- ),
+ child: SizedBox(width: size, height: size, child: child),
+ ),
+ ),
+ ),
+ );
+ }
+}
+
+class _PagesButton extends StatelessWidget {
+ const _PagesButton({
+ required this.session,
+ required this.accent,
+ required this.onTap,
+ });
+
+ static const _borderWidth = 2.0;
+
+ final ScanSessionController session;
+ final Color accent;
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ final colors = context.componentColors;
+ final page = session.lastPage;
+ return _SessionActionReveal(
+ session: session,
+ tooltip: context.strings.review,
+ onTap: onTap,
+ child: Stack(
+ clipBehavior: Clip.none,
+ children: [
+ 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: _borderWidth,
+ ),
+ boxShadow: [
+ BoxShadow(
+ color: Colors.black.withValues(alpha: 0.35),
+ blurRadius: 10,
),
- if (session.pageCount > 0)
- Positioned(
- top: -4,
- right: -4,
- child: Container(
- padding: const EdgeInsets.all(Spacing.xs),
- constraints: const BoxConstraints(minWidth: 22),
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: colors.specialWhite,
- ),
- child: Center(
- child: Text(
- '${session.pageCount}',
- style: TextStyles.mini.copyWith(color: accent),
+ ],
+ ),
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(Radii.md - _borderWidth),
+ child: page == null
+ ? Center(
+ child: SizedBox(
+ width: 24,
+ height: 24,
+ child: CircularProgressIndicator(
+ strokeWidth: 2.5,
+ color: colors.specialWhite,
),
),
+ )
+ : Image.file(
+ page.processedJpeg,
+ key: ValueKey(page.processedJpeg.path),
+ fit: BoxFit.cover,
+ alignment: Alignment.topCenter,
+ cacheHeight: (_SessionActionReveal.size * 3).round(),
),
- ),
- ],
),
),
),
+ if (session.pageCount > 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: accent,
+ border: Border.all(
+ color: colors.specialWhite,
+ width: _borderWidth,
+ ),
+ ),
+ child: Center(
+ child: Text(
+ '${session.pageCount}',
+ style: TextStyles.mini.copyWith(color: colors.specialWhite),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
+
+class _DoneButton extends StatelessWidget {
+ const _DoneButton({
+ required this.session,
+ required this.accent,
+ required this.onTap,
+ });
+
+ final ScanSessionController session;
+ final Color accent;
+ final VoidCallback onTap;
+
+ @override
+ Widget build(BuildContext context) {
+ final colors = context.componentColors;
+ return _SessionActionReveal(
+ session: session,
+ 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: session.isProcessing
+ ? SizedBox(
+ width: 24,
+ height: 24,
+ child: CircularProgressIndicator(
+ strokeWidth: 2.5,
+ color: colors.specialWhite,
+ ),
+ )
+ : HugeIcon(
+ icon: HugeIcons.strokeRoundedTick02,
+ color: colors.specialWhite,
+ size: 30,
+ ),
),
),
);