π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
auth(ui): keep next code visible with iOS text cap
lnilluv4df974d68bb9
diff --git a/mobile/apps/auth/lib/ui/code_widget.dart b/mobile/apps/auth/lib/ui/code_widget.dartindex 3a1911b64a..b315b6bef9 100644--- a/mobile/apps/auth/lib/ui/code_widget.dart+++ b/mobile/apps/auth/lib/ui/code_widget.dart@@ -371,8 +371,9 @@ class _CodeWidgetState extends State<CodeWidget> {),);if (!isIOS) return content;- final double scale =- MediaQuery.textScalerOf(context).scale(1.0).clamp(1.0, 2.0);+ final double scale = capCodeWidgetTextScaleForIOS(+ MediaQuery.textScalerOf(context).scale(1.0),+ );return MediaQuery(data:MediaQuery.of(context).copyWith(textScaler: TextScaler.linear(scale)),@@ -381,45 +382,31 @@ class _CodeWidgetState extends State<CodeWidget> {}Widget _getBottomRow(AppLocalizations l10n) {- final textScaleFactor = MediaQuery.textScalerOf(context).scale(1.0);- final isIOS = !kIsWeb && Platform.isIOS;- return LayoutBuilder(- builder: (context, constraints) {- final showNextTotp = widget.code.type.isTOTPCompatible &&- shouldShowNextTotpCode(- isIOS: isIOS,- availableWidth: constraints.maxWidth,- textScaleFactor: textScaleFactor,- isCompactMode: widget.isCompactMode,- );- return Container(- padding: const EdgeInsets.only(left: 16, right: 16),- child: Row(- mainAxisAlignment: MainAxisAlignment.start,- crossAxisAlignment: CrossAxisAlignment.end,- children: [- Expanded(- child: ValueListenableBuilder<String>(- valueListenable: _currentCode,- builder: (context, value, child) {- return Material(- type: MaterialType.transparency,- child: AutoSizeText(- _getFormattedCode(value),- style: TextStyle(- fontSize: widget.isCompactMode ? 14 : 24,- ),- maxLines: 1,- minFontSize: widget.isCompactMode ? 12 : 16,- textDirection: TextDirection.ltr,- ),- );- },- ),- ),- if (showNextTotp) ...[- const SizedBox(width: 8),- IgnorePointer(+ return Container(+ padding: const EdgeInsets.only(left: 16, right: 16),+ child: Row(+ mainAxisAlignment: MainAxisAlignment.start,+ crossAxisAlignment: CrossAxisAlignment.end,+ children: [+ Expanded(+ child: ValueListenableBuilder<String>(+ valueListenable: _currentCode,+ builder: (context, value, child) {+ return Material(+ type: MaterialType.transparency,+ child: AutoSizeText(+ _getFormattedCode(value),+ style: TextStyle(fontSize: widget.isCompactMode ? 14 : 24),+ maxLines: 1,+ textDirection: TextDirection.ltr,+ ),+ );+ },+ ),+ ),+ const SizedBox(width: 8),+ widget.code.type.isTOTPCompatible+ ? IgnorePointer(ignoring:CodeDisplayStore.instance.isSelectionModeActive.value,child: GestureDetector(@@ -452,10 +439,8 @@ class _CodeWidgetState extends State<CodeWidget> {],),),- ),- ] else if (!widget.code.type.isTOTPCompatible) ...[- const SizedBox(width: 8),- IgnorePointer(+ )+ : IgnorePointer(ignoring:CodeDisplayStore.instance.isSelectionModeActive.value,child: Column(@@ -476,11 +461,8 @@ class _CodeWidgetState extends State<CodeWidget> {],),),- ],- ],- ),- );- },+ ],+ ),);}diff --git a/mobile/apps/auth/lib/ui/code_widget_layout_utils.dart b/mobile/apps/auth/lib/ui/code_widget_layout_utils.dartindex cad170240f..25339a7da4 100644--- a/mobile/apps/auth/lib/ui/code_widget_layout_utils.dart+++ b/mobile/apps/auth/lib/ui/code_widget_layout_utils.dart@@ -1,14 +1,3 @@-bool shouldShowNextTotpCode({- required bool isIOS,- required double availableWidth,- required double textScaleFactor,- required bool isCompactMode,-}) {- if (isIOS) return true;-- final double minWidth = isCompactMode ? 230 : 320;- final double scaleAdjustedMinWidth = textScaleFactor >= 1.2- ? minWidth + (textScaleFactor - 1.2) * 140- : minWidth;- return availableWidth >= scaleAdjustedMinWidth;+double capCodeWidgetTextScaleForIOS(double textScaleFactor) {+ return textScaleFactor > 2.0 ? 2.0 : textScaleFactor;}diff --git a/mobile/apps/auth/test/ui/code_widget_layout_test.dart b/mobile/apps/auth/test/ui/code_widget_layout_test.dartindex ec2b1efad8..b3f7796901 100644--- a/mobile/apps/auth/test/ui/code_widget_layout_test.dart+++ b/mobile/apps/auth/test/ui/code_widget_layout_test.dart@@ -2,38 +2,23 @@ import 'package:ente_auth/ui/code_widget_layout_utils.dart';import 'package:flutter_test/flutter_test.dart';void main() {- group('shouldShowNextTotpCode', () {- test('returns false for constrained width and large text scale', () {- final value = shouldShowNextTotpCode(- isIOS: false,- availableWidth: 260,- textScaleFactor: 1.4,- isCompactMode: false,- );+ group('capCodeWidgetTextScaleForIOS', () {+ test('caps iOS text scale at 2.0', () {+ final value = capCodeWidgetTextScaleForIOS(3.12);- expect(value, isFalse);+ expect(value, 2.0);});- test('returns true for comfortable width', () {- final value = shouldShowNextTotpCode(- isIOS: false,- availableWidth: 420,- textScaleFactor: 1.0,- isCompactMode: false,- );+ test('preserves iOS text scale exactly at 2.0', () {+ final value = capCodeWidgetTextScaleForIOS(2.0);- expect(value, isTrue);+ expect(value, 2.0);});- test('returns true on iOS regardless of width', () {- final value = shouldShowNextTotpCode(- isIOS: true,- availableWidth: 260,- textScaleFactor: 3.12,- isCompactMode: false,- );+ test('preserves smaller iOS text scales', () {+ final value = capCodeWidgetTextScaleForIOS(0.85);- expect(value, isTrue);+ expect(value, 0.85);});});}