Skip to content

armgit / ente

Public Imported from GitHub
0

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

[locker] Show scanner arming on the detected quad

laurenspriemf1b27ba6f83e
diff --git a/mobile/apps/locker/lib/services/scanner/auto_capture_controller.dart b/mobile/apps/locker/lib/services/scanner/auto_capture_controller.dart
index efc830c211..0f06516104 100644
--- a/mobile/apps/locker/lib/services/scanner/auto_capture_controller.dart
+++ b/mobile/apps/locker/lib/services/scanner/auto_capture_controller.dart
@@ -4,7 +4,7 @@ import 'package:locker/services/scanner/scanner_models.dart';
enum AutoCaptureState { searching, arming, cooldown }
class AutoCaptureController {
- static const armHold = Duration(milliseconds: 1200);
+ static const armHold = Duration(milliseconds: 2500);
static const armGrace = Duration(milliseconds: 250);
diff --git a/mobile/apps/locker/lib/ui/pages/scanner/scan_quad_overlay.dart b/mobile/apps/locker/lib/ui/pages/scanner/scan_quad_overlay.dart
index b585ca2f74..665b3fcc8a 100644
--- a/mobile/apps/locker/lib/ui/pages/scanner/scan_quad_overlay.dart
+++ b/mobile/apps/locker/lib/ui/pages/scanner/scan_quad_overlay.dart
@@ -4,7 +4,12 @@ import 'package:locker/services/scanner/scan_geometry.dart';
import 'package:locker/services/scanner/scanner_models.dart';
class ScanQuadOverlay extends StatefulWidget {
- const ScanQuadOverlay({super.key, required this.quad, required this.color});
+ const ScanQuadOverlay({
+ super.key,
+ required this.quad,
+ required this.color,
+ this.armingProgress = 0,
+ });
static const double _smoothing = 0.15;
@@ -12,6 +17,7 @@ class ScanQuadOverlay extends StatefulWidget {
final ScanQuad? quad;
final Color color;
+ final double armingProgress;
@override
State<ScanQuadOverlay> createState() => _ScanQuadOverlayState();
@@ -56,17 +62,28 @@ class _ScanQuadOverlayState extends State<ScanQuadOverlay>
return IgnorePointer(
child: CustomPaint(
size: Size.infinite,
- painter: _QuadPainter(quad: _displayed, color: widget.color),
+ painter: _QuadPainter(
+ quad: _displayed,
+ color: widget.color,
+ armingProgress: widget.armingProgress,
+ ),
),
);
}
}
class _QuadPainter extends CustomPainter {
- const _QuadPainter({required this.quad, required this.color});
+ const _QuadPainter({
+ required this.quad,
+ required this.color,
+ required this.armingProgress,
+ });
+
+ static const _armedTint = 0.45;
final ScanQuad? quad;
final Color color;
+ final double armingProgress;
@override
void paint(Canvas canvas, Size size) {
@@ -77,23 +94,52 @@ class _QuadPainter extends CustomPainter {
Offset(c.dx * size.width, c.dy * size.height),
];
final path = Path()..addPolygon(points, true);
- canvas.drawPath(
- path,
- Paint()
- ..color = color.withValues(alpha: 0.16)
- ..style = PaintingStyle.fill,
- );
- canvas.drawPath(
- path,
- Paint()
- ..color = color
- ..style = PaintingStyle.stroke
- ..strokeWidth = 4
- ..strokeJoin = StrokeJoin.round,
- );
+ final progress = armingProgress.clamp(0.0, 1.0);
+ final lit = Color.lerp(color, Colors.white, _armedTint)!;
+ if (progress > 0) {
+ canvas
+ ..drawPath(
+ path,
+ Paint()
+ ..color = color.withValues(alpha: 0.35 + 0.4 * progress)
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 18 + 18 * progress
+ ..strokeJoin = StrokeJoin.round
+ ..maskFilter = MaskFilter.blur(
+ BlurStyle.normal,
+ 14 + 16 * progress,
+ ),
+ )
+ ..drawPath(
+ path,
+ Paint()
+ ..color = lit.withValues(alpha: 0.45 + 0.55 * progress)
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 7 + 5 * progress
+ ..strokeJoin = StrokeJoin.round
+ ..maskFilter = MaskFilter.blur(BlurStyle.normal, 3 + 4 * progress),
+ );
+ }
+ canvas
+ ..drawPath(
+ path,
+ Paint()
+ ..color = color.withValues(alpha: 0.16)
+ ..style = PaintingStyle.fill,
+ )
+ ..drawPath(
+ path,
+ Paint()
+ ..color = Color.lerp(color, lit, progress)!
+ ..style = PaintingStyle.stroke
+ ..strokeWidth = 4
+ ..strokeJoin = StrokeJoin.round,
+ );
}
@override
bool shouldRepaint(_QuadPainter oldDelegate) =>
- oldDelegate.quad != quad || oldDelegate.color != color;
+ oldDelegate.quad != quad ||
+ oldDelegate.color != color ||
+ oldDelegate.armingProgress != armingProgress;
}