π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[auth] Fix progress bar (#4564)
Neeraj Gupta543411254b2b
diff --git a/auth/lib/ui/code_timer_progress.dart b/auth/lib/ui/code_timer_progress.dartindex ea62860268..520a18d76c 100644--- a/auth/lib/ui/code_timer_progress.dart+++ b/auth/lib/ui/code_timer_progress.dart@@ -22,9 +22,6 @@ class _CodeTimerProgressState extends State<CodeTimerProgress> {late final ValueNotifier<double> _progress;late final int _periodInMicros;- // Cache the start time to avoid repeated system calls- late final int _startMicros;-// Reduce update frequencyfinal int _updateIntervalMs =(Platform.isAndroid || Platform.isIOS) ? 16 : 500; // approximately 60 FPS@@ -34,9 +31,8 @@ class _CodeTimerProgressState extends State<CodeTimerProgress> {super.initState();_periodInMicros = widget.period * 1000000;_progress = ValueNotifier<double>(0.0);- _startMicros = DateTime.now().microsecondsSinceEpoch;+ _updateTimeRemaining(DateTime.now().microsecondsSinceEpoch);- // Use a Timer instead of a Ticker_timer = Timer.periodic(Duration(milliseconds: _updateIntervalMs), (timer) {final now = DateTime.now().microsecondsSinceEpoch;_updateTimeRemaining(now);@@ -45,11 +41,20 @@ class _CodeTimerProgressState extends State<CodeTimerProgress> {void _updateTimeRemaining(int currentMicros) {// More efficient time calculation using modulo- final elapsed = (currentMicros - _startMicros) % _periodInMicros;+ final elapsed = (currentMicros) % _periodInMicros;final timeRemaining = _periodInMicros - elapsed;_progress.value = timeRemaining / _periodInMicros;}+ @override+ void didUpdateWidget(covariant CodeTimerProgress oldWidget) {+ super.didUpdateWidget(oldWidget);+ if (oldWidget.period != widget.period) {+ _periodInMicros = widget.period * 1000000;+ _updateTimeRemaining(DateTime.now().microsecondsSinceEpoch);+ }+ }+@overridevoid dispose() {_timer.cancel();