Skip to content

armgit / ente

Public Imported from GitHub
0

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

Replace dot ripple with scan+pulse animation for OCR processing

Amrithesh Kakkoth Entef7692faacff3
diff --git a/mobile/apps/photos/android/app/build.gradle b/mobile/apps/photos/android/app/build.gradle
index 6e7336dd31..0da8a38d8f 100644
--- a/mobile/apps/photos/android/app/build.gradle
+++ b/mobile/apps/photos/android/app/build.gradle
@@ -107,6 +107,13 @@ android {
}
}
+ packagingOptions {
+ pickFirst 'lib/arm64-v8a/libc++_shared.so'
+ pickFirst 'lib/armeabi-v7a/libc++_shared.so'
+ pickFirst 'lib/x86/libc++_shared.so'
+ pickFirst 'lib/x86_64/libc++_shared.so'
+ }
+
buildTypes {
release {
signingConfig signingConfigs.release
diff --git a/mobile/apps/photos/lib/states/detail_page_state.dart b/mobile/apps/photos/lib/states/detail_page_state.dart
index 793e081a8b..09fec51922 100644
--- a/mobile/apps/photos/lib/states/detail_page_state.dart
+++ b/mobile/apps/photos/lib/states/detail_page_state.dart
@@ -95,5 +95,6 @@ class InheritedDetailPageState extends InheritedWidget {
oldWidget.enableFullScreenNotifier != enableFullScreenNotifier ||
oldWidget.isInSharedCollectionNotifier != isInSharedCollectionNotifier ||
oldWidget.showingThumbnailFallbackNotifier !=
- showingThumbnailFallbackNotifier;
+ showingThumbnailFallbackNotifier ||
+ oldWidget.isZoomedNotifier != isZoomedNotifier;
}
diff --git a/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart b/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
index 6098c529a7..4b4645fa65 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
@@ -31,7 +31,6 @@ import "package:photos/ui/viewer/file/inline_text_detection.dart";
import "package:photos/ui/viewer/file/panorama_viewer_screen.dart";
import "package:photos/ui/viewer/file/qr_code_detection_helper.dart";
import "package:photos/ui/viewer/file/qr_code_highlight_overlay.dart";
-import "package:photos/ui/viewer/file/text_detection_overlay_button.dart";
import 'package:photos/ui/viewer/gallery/gallery.dart';
import 'package:photos/utils/dialog_util.dart';
import 'package:photos/utils/file_util.dart';
@@ -269,13 +268,7 @@ class _BodyState extends State<_Body> {
isGuestView: isGuestView,
);
}
- return TextDetectionOverlayButton(
- file: _files![selectedIndex],
- enableFullScreenNotifier:
- InheritedDetailPageState.of(context)
- .enableFullScreenNotifier,
- isGuestView: isGuestView,
- );
+ return const SizedBox.shrink();
},
),
if (_qrHelper != null)
diff --git a/mobile/apps/photos/lib/ui/viewer/file/image_animation_demo.dart b/mobile/apps/photos/lib/ui/viewer/file/image_animation_demo.dart
new file mode 100644
index 0000000000..b8cfad8e35
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/viewer/file/image_animation_demo.dart
@@ -0,0 +1,524 @@
+import "dart:math" as math;
+import "dart:ui" as ui;
+
+import "package:flutter/material.dart";
+
+void main() {
+ runApp(
+ const MaterialApp(
+ debugShowCheckedModeBanner: false,
+ home: ImageAnimationDemo(),
+ ),
+ );
+}
+
+// ─────────────────────────────────────────────────────────────────────────────
+// Demo page with animation switcher
+// ─────────────────────────────────────────────────────────────────────────────
+
+/// Demo page showcasing two image-overlay animation styles:
+/// dot-grid ripple and scan-line with radial pulse.
+class ImageAnimationDemo extends StatefulWidget {
+ const ImageAnimationDemo({super.key});
+
+ @override
+ State<ImageAnimationDemo> createState() => _ImageAnimationDemoState();
+}
+
+class _ImageAnimationDemoState extends State<ImageAnimationDemo> {
+ bool _useScanPulse = false;
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ backgroundColor: Colors.black,
+ body: SafeArea(
+ child: Column(
+ children: [
+ const SizedBox(height: 16),
+ _buildSwitcher(),
+ const SizedBox(height: 24),
+ Expanded(
+ child: Center(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: AspectRatio(
+ aspectRatio: 3 / 2,
+ child: ClipRRect(
+ borderRadius: BorderRadius.circular(8),
+ child: _buildContent(),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+
+ Widget _buildSwitcher() {
+ Widget tab(String label, bool active, VoidCallback onTap) {
+ return GestureDetector(
+ onTap: onTap,
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
+ decoration: BoxDecoration(
+ color: active
+ ? Colors.white.withValues(alpha: 0.12)
+ : Colors.transparent,
+ borderRadius: BorderRadius.circular(6),
+ ),
+ child: Text(
+ label,
+ style: TextStyle(
+ color: Colors.white.withValues(alpha: active ? 0.9 : 0.5),
+ fontSize: 14,
+ fontWeight: active ? FontWeight.w600 : FontWeight.w400,
+ ),
+ ),
+ ),
+ );
+ }
+
+ return Container(
+ decoration: BoxDecoration(
+ color: Colors.white.withValues(alpha: 0.08),
+ borderRadius: BorderRadius.circular(8),
+ ),
+ padding: const EdgeInsets.all(4),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ tab(
+ "Dot grid",
+ !_useScanPulse,
+ () => setState(() => _useScanPulse = false),
+ ),
+ const SizedBox(width: 4),
+ tab(
+ "Scan + pulse",
+ _useScanPulse,
+ () => setState(() => _useScanPulse = true),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget _buildContent() {
+ return Stack(
+ fit: StackFit.expand,
+ children: [
+ // Placeholder image background
+ Container(
+ color: const Color(0xFF1A1A1A),
+ child: Center(
+ child: Icon(
+ Icons.landscape,
+ size: 64,
+ color: Colors.white.withValues(alpha: 0.3),
+ ),
+ ),
+ ),
+ // Dark overlay
+ ColoredBox(color: Colors.black.withValues(alpha: 0.15)),
+ // Breathe effect (scan+pulse mode only)
+ if (_useScanPulse) const _BreatheOverlay(),
+ // Animation overlay
+ IgnorePointer(
+ child: AnimatedSwitcher(
+ duration: const Duration(milliseconds: 300),
+ child: _useScanPulse
+ ? const ScanPulseOverlay(key: ValueKey("scan"))
+ : const DotGridOverlay(key: ValueKey("dots")),
+ ),
+ ),
+ ],
+ );
+ }
+}
+
+// ─────────────────────────────────────────────────────────────────────────────
+// Animation A: Dot grid overlay
+// ─────────────────────────────────────────────────────────────────────────────
+
+/// A 24Γ—16 grid of dots that pulse outward from the center in a ripple pattern.
+class DotGridOverlay extends StatefulWidget {
+ const DotGridOverlay({super.key});
+
+ @override
+ State<DotGridOverlay> createState() => _DotGridOverlayState();
+}
+
+class _DotGridOverlayState extends State<DotGridOverlay>
+ with SingleTickerProviderStateMixin {
+ late final AnimationController _controller;
+
+ @override
+ void initState() {
+ super.initState();
+ _controller = AnimationController(
+ vsync: this,
+ duration: const Duration(milliseconds: 2500),
+ )..repeat();
+ }
+
+ @override
+ void dispose() {
+ _controller.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return AnimatedBuilder(
+ animation: _controller,
+ builder: (context, _) {
+ return CustomPaint(
+ painter: _DotGridPainter(progress: _controller.value),
+ size: Size.infinite,
+ );
+ },
+ );
+ }
+}
+
+class _DotGridPainter extends CustomPainter {
+ static const int _cols = 24;
+ static const int _rows = 16;
+ // sqrt(50^2 + 50^2) β€” max distance from center in percentage space.
+ static const double _maxDist = 70.710678;
+
+ final double progress;
+
+ _DotGridPainter({required this.progress});
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ for (int r = 0; r < _rows; r++) {
+ for (int c = 0; c < _cols; c++) {
+ // Pixel position for drawing
+ final double x = ((c + 0.5) / _cols) * size.width;
+ final double y = ((r + 0.5) / _rows) * size.height;
+
+ // Distance in percentage space (0-100) from center for delay
+ final double dx = ((c + 0.5) / _cols) * 100 - 50;
+ final double dy = ((r + 0.5) / _rows) * 100 - 50;
+ final double dist = math.sqrt(dx * dx + dy * dy);
+
+ // Delay: (dist / maxDist) * 1.8s, normalized to cycle: * (1.8 / 2.5)
+ final double delay = (dist / _maxDist) * 0.72;
+
+ double phase = (progress - delay) % 1.0;
+ if (phase < 0) phase += 1.0;
+
+ // Ping-pong with ease-in-out within each half
+ double t;
+ if (phase < 0.5) {
+ t = _easeInOut(phase * 2);
+ } else {
+ t = _easeInOut((1.0 - phase) * 2);
+ }
+
+ if (t < 0.01) continue;
+
+ // CSS: scale(0)β†’scale(1)β†’scale(0), opacity 0β†’0.5β†’0
+ final double radius = 1.5 * t;
+ final double opacity = 0.5 * t;
+
+ final paint = Paint()..color = Color.fromRGBO(255, 255, 255, opacity);
+ canvas.drawCircle(Offset(x, y), radius, paint);
+ }
+ }
+ }
+
+ static double _easeInOut(double t) {
+ return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
+ }
+
+ @override
+ bool shouldRepaint(_DotGridPainter oldDelegate) =>
+ oldDelegate.progress != progress;
+}
+
+// ─────────────────────────────────────────────────────────────────────────────
+// Animation B: Scan line + radial pulse + edge glow
+// ─────────────────────────────────────────────────────────────────────────────
+
+/// Composite overlay with a scanning line, radial pulse, and edge glow.
+class ScanPulseOverlay extends StatefulWidget {
+ const ScanPulseOverlay({super.key});
+
+ @override
+ State<ScanPulseOverlay> createState() => _ScanPulseOverlayState();
+}
+
+class _ScanPulseOverlayState extends State<ScanPulseOverlay>
+ with TickerProviderStateMixin {
+ late final AnimationController _scanController;
+ late final AnimationController _pulseController;
+ late final AnimationController _glowController;
+
+ @override
+ void initState() {
+ super.initState();
+ _scanController = AnimationController(
+ vsync: this,
+ duration: const Duration(milliseconds: 4000),
+ )..repeat();
+ _pulseController = AnimationController(
+ vsync: this,
+ duration: const Duration(milliseconds: 4000),
+ )..repeat();
+ _glowController = AnimationController(
+ vsync: this,
+ duration: const Duration(milliseconds: 3500),
+ )..repeat();
+ }
+
+ @override
+ void dispose() {
+ _scanController.dispose();
+ _pulseController.dispose();
+ _glowController.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Stack(
+ fit: StackFit.expand,
+ children: [
+ AnimatedBuilder(
+ animation: _scanController,
+ builder: (context, _) => CustomPaint(
+ painter: _ScanLinePainter(progress: _scanController.value),
+ size: Size.infinite,
+ ),
+ ),
+ AnimatedBuilder(
+ animation: _pulseController,
+ builder: (context, _) => CustomPaint(
+ painter: _RadialPulsePainter(progress: _pulseController.value),
+ size: Size.infinite,
+ ),
+ ),
+ AnimatedBuilder(
+ animation: _glowController,
+ builder: (context, _) => CustomPaint(
+ painter: _EdgeGlowPainter(progress: _glowController.value),
+ size: Size.infinite,
+ ),
+ ),
+ ],
+ );
+ }
+}
+
+// ─────────────────────────────────────────────────────────────────────────────
+// Scan line painter
+// ─────────────────────────────────────────────────────────────────────────────
+
+/// Horizontal gradient line that sweeps from top to bottom.
+class _ScanLinePainter extends CustomPainter {
+ final double progress;
+
+ _ScanLinePainter({required this.progress});
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ // Position with ease-in-out: -2px β†’ size.height
+ final double easedPos = _easeInOut(progress);
+ final double y = -2.0 + (size.height + 2.0) * easedPos;
+
+ // Opacity: fade in 0–5%, full 5–95%, fade out 95–100%
+ double opacity;
+ if (progress < 0.05) {
+ opacity = progress / 0.05;
+ } else if (progress > 0.95) {
+ opacity = (1.0 - progress) / 0.05;
+ } else {
+ opacity = 1.0;
+ }
+
+ // Glow behind the line
+ final glowPaint = Paint()
+ ..color = Color.fromRGBO(255, 220, 180, 0.1 * opacity)
+ ..maskFilter = const MaskFilter.blur(BlurStyle.normal, 20);
+ canvas.drawRect(
+ Rect.fromCenter(
+ center: Offset(size.width / 2, y + 1),
+ width: size.width + 12,
+ height: 14,
+ ),
+ glowPaint,
+ );
+
+ // Main scan line with horizontal gradient
+ final lineRect = Rect.fromLTWH(0, y, size.width, 2);
+ final gradient = ui.Gradient.linear(
+ Offset(0, y),
+ Offset(size.width, y),
+ [
+ Colors.transparent,
+ Color.fromRGBO(255, 220, 180, 0.5 * opacity),
+ Color.fromRGBO(255, 255, 255, 0.4 * opacity),
+ Color.fromRGBO(255, 220, 180, 0.5 * opacity),
+ Colors.transparent,
+ ],
+ [0.0, 0.25, 0.5, 0.75, 1.0],
+ );
+ final linePaint = Paint()..shader = gradient;
+ canvas.drawRRect(
+ RRect.fromRectAndRadius(lineRect, const Radius.circular(1)),
+ linePaint,
+ );
+ }
+
+ static double _easeInOut(double t) {
+ return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
+ }
+
+ @override
+ bool shouldRepaint(_ScanLinePainter oldDelegate) =>
+ oldDelegate.progress != progress;
+}
+
+// ─────────────────────────────────────────────────────────────────────────────
+// Radial pulse painter
+// ─────────────────────────────────────────────────────────────────────────────
+
+/// Radial gradient that breathes from the center, scaling 0.6β†’1β†’0.6.
+class _RadialPulsePainter extends CustomPainter {
+ final double progress;
+
+ _RadialPulsePainter({required this.progress});
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ // Ping-pong with ease-in-out: scale 0.6β†’1β†’0.6, opacity 0β†’1β†’0
+ double t;
+ if (progress < 0.5) {
+ t = _easeInOut(progress * 2);
+ } else {
+ t = _easeInOut((1.0 - progress) * 2);
+ }
+
+ final center = Offset(size.width / 2, size.height / 2);
+ final scale = 0.6 + 0.4 * t;
+ final double maxDim = math.max(size.width, size.height) * 0.6 * scale;
+
+ final gradient = ui.Gradient.radial(
+ center,
+ maxDim,
+ [Color.fromRGBO(255, 240, 210, 0.08 * t), Colors.transparent],
+ [0.0, 0.6],
+ );
+ final paint = Paint()..shader = gradient;
+ canvas.drawRect(Offset.zero & size, paint);
+ }
+
+ static double _easeInOut(double t) {
+ return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
+ }
+
+ @override
+ bool shouldRepaint(_RadialPulsePainter oldDelegate) =>
+ oldDelegate.progress != progress;
+}
+
+// ─────────────────────────────────────────────────────────────────────────────
+// Edge glow painter (simulates CSS inset box-shadow)
+// ─────────────────────────────────────────────────────────────────────────────
+
+/// Pulsing inset glow around the edges, simulating CSS inset box-shadow.
+class _EdgeGlowPainter extends CustomPainter {
+ final double progress;
+
+ _EdgeGlowPainter({required this.progress});
+
+ @override
+ void paint(Canvas canvas, Size size) {
+ // Ping-pong with ease-in-out
+ double t;
+ if (progress < 0.5) {
+ t = _easeInOut(progress * 2);
+ } else {
+ t = _easeInOut((1.0 - progress) * 2);
+ }
+
+ final double blur = 40.0 + 20.0 * t;
+ final double alpha = 0.02 + 0.05 * t;
+ final color = Color.fromRGBO(255, 220, 180, alpha);
+
+ // Draw thick stroked rect clipped to bounds β†’ inset glow effect
+ canvas.save();
+ canvas.clipRRect(
+ RRect.fromRectAndRadius(Offset.zero & size, const Radius.circular(2)),
+ );
+ final paint = Paint()
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = blur * 2
+ ..color = color
+ ..maskFilter = MaskFilter.blur(BlurStyle.normal, blur);
+ canvas.drawRRect(
+ RRect.fromRectAndRadius(Offset.zero & size, const Radius.circular(2)),
+ paint,
+ );
+ canvas.restore();
+ }
+
+ static double _easeInOut(double t) {
+ return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
+ }
+
+ @override
+ bool shouldRepaint(_EdgeGlowPainter oldDelegate) =>
+ oldDelegate.progress != progress;
+}
+
+// ─────────────────────────────────────────────────────────────────────────────
+// Breathe overlay β€” subtle brightness dimming for scan+pulse mode
+// ─────────────────────────────────────────────────────────────────────────────
+
+/// Simulates CSS `filter: brightness(0.92)` by overlaying a pulsing dark tint.
+class _BreatheOverlay extends StatefulWidget {
+ const _BreatheOverlay();
+
+ @override
+ State<_BreatheOverlay> createState() => _BreatheOverlayState();
+}
+
+class _BreatheOverlayState extends State<_BreatheOverlay>
+ with SingleTickerProviderStateMixin {
+ late final AnimationController _controller;
+
+ @override
+ void initState() {
+ super.initState();
+ _controller = AnimationController(
+ vsync: this,
+ duration: const Duration(milliseconds: 3000),
+ )..repeat();
+ }
+
+ @override
+ void dispose() {
+ _controller.dispose();
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return AnimatedBuilder(
+ animation: _controller,
+ builder: (context, _) {
+ // Brightness: 1.0 β†’ 0.92 β†’ 1.0 (darken by up to 8%)
+ final double darken = math.sin(_controller.value * math.pi) * 0.08;
+ return ColoredBox(color: Colors.black.withValues(alpha: darken));
+ },
+ );
+ }
+}
diff --git a/mobile/apps/photos/lib/ui/viewer/file/inline_text_detection.dart b/mobile/apps/photos/lib/ui/viewer/file/inline_text_detection.dart
index 51f1b69691..1e8c0bb4df 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/inline_text_detection.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/inline_text_detection.dart
@@ -11,6 +11,7 @@ import "package:photos/models/file/file.dart";
import "package:photos/models/file/file_type.dart";
import "package:photos/models/file/trash_file.dart";
import "package:photos/states/detail_page_state.dart";
+import "package:photos/ui/viewer/file/image_animation_demo.dart";
import "package:photos/utils/file_util.dart";
/// Inline text detection widget that mimics Apple's Live Text behavior:
@@ -47,7 +48,6 @@ class _InlineTextDetectionState extends State<InlineTextDetection> {
String? _localFilePath;
int _requestId = 0;
bool _overlayActive = false;
- Timer? _activationTimer;
bool _userTriggered = false;
Offset? _pendingLongPressPosition;
@@ -68,13 +68,11 @@ class _InlineTextDetectionState extends State<InlineTextDetection> {
@override
void dispose() {
- _activationTimer?.cancel();
_detectorController.dispose();
super.dispose();
}
void _resetState() {
- _activationTimer?.cancel();
setState(() {
_localFilePath = null;
_overlayActive = false;
@@ -129,7 +127,7 @@ class _InlineTextDetectionState extends State<InlineTextDetection> {
setState(() {
_localFilePath = cached.localPath;
});
- if (cached.hasText) _activateOrSchedule(requestId);
+ if (cached.hasText) _activateOverlay();
return;
}
@@ -146,11 +144,19 @@ class _InlineTextDetectionState extends State<InlineTextDetection> {
_logger.info("running hasText check");
bool hasText = false;
try {
- hasText = await _mobileOcr.hasText(imagePath: localFile.path);
+ hasText = await _mobileOcr
+ .hasText(imagePath: localFile.path)
+ .timeout(const Duration(seconds: 5));
_logger.info("hasText result: $hasText");
} catch (error, stackTrace) {
- _logger.warning("hasText error: $error");
- _logger.severe("Failed to run hasText", error, stackTrace);
+ // On error or timeout, optimistically assume text may be present
+ // so the full detection pipeline can make the final determination.
+ hasText = true;
+ _logger.warning(
+ "hasText failed, falling back to optimistic",
+ error,
+ stackTrace,
+ );
}
if (!mounted || requestId != _requestId) return;
@@ -165,9 +171,7 @@ class _InlineTextDetectionState extends State<InlineTextDetection> {
_localFilePath = result.localPath;
});
- // If text found, activate immediately if user already long pressed,
- // otherwise schedule activation after 1 second delay.
- if (hasText) _activateOrSchedule(requestId);
+ if (hasText) _activateOverlay();
} catch (error, stackTrace) {
_logger.severe("Text detection pre-check failed", error, stackTrace);
if (!mounted || requestId != _requestId) return;
@@ -175,30 +179,14 @@ class _InlineTextDetectionState extends State<InlineTextDetection> {
}
}
- void _activateOrSchedule(int requestId) {
- if (_userTriggered) {
- // User already long pressed β€” skip delay, activate immediately
- setState(() {
- _overlayActive = true;
- });
- } else {
- _scheduleActivation(requestId);
- }
- }
-
- void _scheduleActivation(int requestId) {
- _activationTimer?.cancel();
- _activationTimer = Timer(const Duration(seconds: 1), () {
- if (!mounted || requestId != _requestId) return;
- setState(() {
- _overlayActive = true;
- });
+ void _activateOverlay() {
+ setState(() {
+ _overlayActive = true;
});
}
void _handleLongPress(LongPressStartDetails details) {
if (_overlayActive) return; // Already active, let overlay handle it
- _activationTimer?.cancel();
setState(() {
_userTriggered = true;
_pendingLongPressPosition = details.globalPosition;
@@ -218,8 +206,8 @@ class _InlineTextDetectionState extends State<InlineTextDetection> {
return const SizedBox.shrink();
}
- final isZoomedNotifier = InheritedDetailPageState.maybeOf(context)
- ?.isZoomedNotifier;
+ final isZoomedNotifier =
+ InheritedDetailPageState.maybeOf(context)?.isZoomedNotifier;
// During the wait period (hasText passed but 1s timer hasn't fired),
// show a transparent gesture layer to capture long press.
@@ -257,31 +245,48 @@ class _InlineTextDetectionState extends State<InlineTextDetection> {
Widget _buildInlineOverlay(BuildContext context) {
final l10n = context.l10n;
- return TextDetectorWidget(
- key: ValueKey("ocr_$_localFilePath"),
- imagePath: _localFilePath!,
- autoDetect: !_userTriggered,
- backgroundColor: Colors.transparent,
- showUnselectedBoundaries: true,
- overlayOnly: true,
- showProcessingOverlay: false,
- showEditorHint: false,
- initialInteractionPosition: _pendingLongPressPosition,
- controller: _detectorController,
- strings: TextDetectorStrings(
- processingOverlayMessage: l10n.ocrProcessingOverlayMessage,
- selectionHint: l10n.ocrSelectionHint,
- noTextDetected: l10n.ocrNoTextDetected,
- retryButtonLabel: l10n.ocrRetryButtonLabel,
- modelsNetworkRequiredError: l10n.ocrModelsNetworkRequiredError,
- modelsPrepareFailed: l10n.ocrModelsPrepareFailed,
- imageNotFoundError: l10n.ocrImageNotFoundError,
- imageDecodeFailedError: l10n.ocrImageDecodeFailedError,
- genericDetectError: l10n.ocrGenericDetectError,
- ),
- onTextCopied: (text) {
- HapticFeedback.lightImpact();
- },
+ return Stack(
+ fit: StackFit.expand,
+ children: [
+ TextDetectorWidget(
+ key: ValueKey("ocr_$_localFilePath"),
+ imagePath: _localFilePath!,
+ autoDetect: !_userTriggered,
+ backgroundColor: Colors.transparent,
+ showUnselectedBoundaries: true,
+ overlayOnly: true,
+ showProcessingOverlay: false,
+ showEditorHint: false,
+ initialInteractionPosition: _pendingLongPressPosition,
+ controller: _detectorController,
+ strings: TextDetectorStrings(
+ processingOverlayMessage: l10n.ocrProcessingOverlayMessage,
+ selectionHint: l10n.ocrSelectionHint,
+ noTextDetected: l10n.ocrNoTextDetected,
+ retryButtonLabel: l10n.ocrRetryButtonLabel,
+ modelsNetworkRequiredError: l10n.ocrModelsNetworkRequiredError,
+ modelsPrepareFailed: l10n.ocrModelsPrepareFailed,
+ imageNotFoundError: l10n.ocrImageNotFoundError,
+ imageDecodeFailedError: l10n.ocrImageDecodeFailedError,
+ genericDetectError: l10n.ocrGenericDetectError,
+ ),
+ onTextCopied: (text) {
+ HapticFeedback.lightImpact();
+ },
+ ),
+ ListenableBuilder(
+ listenable: _detectorController,
+ builder: (context, _) {
+ if (_detectorController.isProcessing &&
+ !_detectorController.hasSelectableText) {
+ return const IgnorePointer(
+ child: ScanPulseOverlay(),
+ );
+ }
+ return const SizedBox.shrink();
+ },
+ ),
+ ],
);
}
}
diff --git a/mobile/apps/photos/pubspec.lock b/mobile/apps/photos/pubspec.lock
index 2e3a03b3b5..454bf2c119 100644
--- a/mobile/apps/photos/pubspec.lock
+++ b/mobile/apps/photos/pubspec.lock
@@ -1800,8 +1800,8 @@ packages:
dependency: "direct main"
description:
path: "."
- ref: "6238cb84476694c8d613f88a2da554ea9fdd103e"
- resolved-ref: "6238cb84476694c8d613f88a2da554ea9fdd103e"
+ ref: c550d52
+ resolved-ref: c550d5256d99ca8a411f6aed3e0da2db738d98df
url: "https://github.com/ente-io/mobile_ocr"
source: git
version: "1.0.0"
diff --git a/mobile/apps/photos/pubspec.yaml b/mobile/apps/photos/pubspec.yaml
index bcf3c87493..16aecac0ec 100644
--- a/mobile/apps/photos/pubspec.yaml
+++ b/mobile/apps/photos/pubspec.yaml
@@ -155,7 +155,7 @@ dependencies:
mobile_ocr:
git:
url: https://github.com/ente-io/mobile_ocr
- ref: 6238cb84476694c8d613f88a2da554ea9fdd103e
+ ref: c550d52
modal_bottom_sheet: ^3.0.0
motionphoto:
git: "https://github.com/ente-io/motionphoto.git"