From e65e2800e6e52e0377e1732180730127571ebd55 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Mon, 2 Nov 2026 17:50:27 +0000 Subject: [PATCH] Enlarge viewer controls and respect safe areas --- .../actions/artifact_file_actions.dart | 8 +- .../changes/widgets/change_style.dart | 13 +- .../changes/widgets/changes_viewer.dart | 28 +- .../changes/widgets/diff_form_control.dart | 17 +- .../changes/widgets/file_diff_viewer.dart | 243 +++++++++--------- app/lib/ui/navigation/chevron_pager.dart | 20 +- .../changes/diff_presentation_test.dart | 11 +- 7 files changed, 188 insertions(+), 152 deletions(-) diff --git a/app/lib/features/artifacts/actions/artifact_file_actions.dart b/app/lib/features/artifacts/actions/artifact_file_actions.dart index d528b60b..9f4b2801 100644 --- a/app/lib/features/artifacts/actions/artifact_file_actions.dart +++ b/app/lib/features/artifacts/actions/artifact_file_actions.dart @@ -257,16 +257,18 @@ class ArtifactIconAction extends StatelessWidget { label: label, child: CupertinoButton( padding: inBar ? EdgeInsets.zero : const EdgeInsets.all(8), + minimumSize: const Size(44, 44), onPressed: onPressed, child: busy ? const CupertinoActivityIndicator(radius: 9) - : Icon(cupertinoIcon), + : Icon(cupertinoIcon, size: 30), ), ); } return IconButton( tooltip: label, - visualDensity: inBar ? null : VisualDensity.compact, + constraints: const BoxConstraints(minWidth: 48, minHeight: 48), + padding: EdgeInsets.zero, onPressed: onPressed, icon: busy ? const SizedBox( @@ -274,7 +276,7 @@ class ArtifactIconAction extends StatelessWidget { height: 18, child: CircularProgressIndicator(strokeWidth: 2), ) - : Icon(icon), + : Icon(icon, size: 28), ); } } diff --git a/app/lib/features/changes/widgets/change_style.dart b/app/lib/features/changes/widgets/change_style.dart index 370c13c5..80e4d9a5 100644 --- a/app/lib/features/changes/widgets/change_style.dart +++ b/app/lib/features/changes/widgets/change_style.dart @@ -116,11 +116,12 @@ Widget copyPatchControl( if (usesCupertino(context)) { return CupertinoButton( padding: EdgeInsets.zero, + minimumSize: const Size(44, 44), onPressed: enabled ? onPressed : null, child: Row( mainAxisSize: MainAxisSize.min, children: [ - const Icon(CupertinoIcons.doc_on_doc), + const Icon(CupertinoIcons.doc_on_doc, size: 30), const SizedBox(width: 8), Text(label), ], @@ -128,8 +129,9 @@ Widget copyPatchControl( ); } return TextButton.icon( + style: TextButton.styleFrom(minimumSize: const Size(0, 48)), onPressed: enabled ? onPressed : null, - icon: const Icon(Icons.copy_all_outlined), + icon: const Icon(Icons.copy_all_outlined, size: 28), label: Text(label), ); } @@ -143,14 +145,17 @@ Widget closeDiffControl(BuildContext context, VoidCallback onClose) { onTap: onClose, child: CupertinoButton( padding: EdgeInsets.zero, + minimumSize: const Size(44, 44), onPressed: onClose, - child: const Icon(CupertinoIcons.xmark), + child: const Icon(CupertinoIcons.xmark, size: 30), ), ); } return IconButton( + constraints: const BoxConstraints(minWidth: 48, minHeight: 48), + padding: EdgeInsets.zero, tooltip: 'Close diff', onPressed: onClose, - icon: const Icon(Icons.close), + icon: const Icon(Icons.close, size: 28), ); } diff --git a/app/lib/features/changes/widgets/changes_viewer.dart b/app/lib/features/changes/widgets/changes_viewer.dart index a3314f86..ec169e1d 100644 --- a/app/lib/features/changes/widgets/changes_viewer.dart +++ b/app/lib/features/changes/widgets/changes_viewer.dart @@ -234,19 +234,23 @@ class _ChangesViewerState extends State { child: MediaQuery.removePadding( context: context, removeBottom: true, - child: Padding( - // The inherited bottom inset belongs to the shell bar. Include it - // in this overlay's measured bar height so the pager is stacked - // above it rather than translating into a constrained layout. - padding: EdgeInsets.only( - bottom: MediaQuery.paddingOf(context).bottom, - ), + child: SafeArea( + top: false, + minimum: const EdgeInsets.symmetric(horizontal: 8), child: Padding( - padding: const EdgeInsets.all(8), - child: IntrinsicWidth( - child: GlassPill( - cupertino: usesCupertinoHost(context), - child: pager, + // The inherited bottom inset belongs to the shell bar. Include it + // in this overlay's measured bar height so the pager is stacked + // above it rather than translating into a constrained layout. + padding: EdgeInsets.only( + bottom: MediaQuery.paddingOf(context).bottom, + ), + child: Padding( + padding: const EdgeInsets.all(8), + child: IntrinsicWidth( + child: GlassPill( + cupertino: usesCupertinoHost(context), + child: pager, + ), ), ), ), diff --git a/app/lib/features/changes/widgets/diff_form_control.dart b/app/lib/features/changes/widgets/diff_form_control.dart index 7385e777..c5a76ac5 100644 --- a/app/lib/features/changes/widgets/diff_form_control.dart +++ b/app/lib/features/changes/widgets/diff_form_control.dart @@ -48,14 +48,18 @@ Widget diffFormControl( }, children: { for (final entry in diffFormLabels.entries) - entry.key: Padding( - padding: const EdgeInsets.all(6), - child: Text(entry.value), + entry.key: ConstrainedBox( + constraints: const BoxConstraints(minHeight: 44), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 6), + child: Center(child: Text(entry.value)), + ), ), }, ); } return SegmentedButton( + style: ButtonStyle(minimumSize: const WidgetStatePropertyAll(Size(0, 48))), segments: [ for (final entry in diffFormLabels.entries) ButtonSegment(value: entry.key, label: Text(entry.value)), @@ -80,6 +84,7 @@ Widget diffFormMenu( button: true, child: CupertinoButton( padding: EdgeInsets.zero, + minimumSize: const Size(44, 44), onPressed: () => showCupertinoModalPopup( context: context, builder: (sheetContext) => CupertinoActionSheet( @@ -97,13 +102,15 @@ Widget diffFormMenu( ], ), ), - child: const Icon(CupertinoIcons.ellipsis), + child: const Icon(CupertinoIcons.ellipsis, size: 30), ), ); } return IconButton( tooltip: 'Diff form', - icon: const Icon(Icons.more_vert), + constraints: const BoxConstraints(minWidth: 48, minHeight: 48), + padding: EdgeInsets.zero, + icon: const Icon(Icons.more_vert, size: 28), onPressed: () => showModalBottomSheet( context: context, showDragHandle: true, diff --git a/app/lib/features/changes/widgets/file_diff_viewer.dart b/app/lib/features/changes/widgets/file_diff_viewer.dart index 6ab86dcc..9a978e25 100644 --- a/app/lib/features/changes/widgets/file_diff_viewer.dart +++ b/app/lib/features/changes/widgets/file_diff_viewer.dart @@ -75,130 +75,136 @@ class _FileDiffViewerState extends State { final mono = nativeDiffText(base); final stat = changeStat(file.added, file.removed); final tags = changeEntryTags(file); - return ConstrainedBox( - key: const ValueKey('file-diff-viewer'), - constraints: BoxConstraints( - maxWidth: 900, - maxHeight: MediaQuery.sizeOf(context).height * 0.85, - ), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Padding( - padding: widget.floatBehindTopBar - ? withTopBarClearance( - context, - const EdgeInsets.fromLTRB(16, 12, 16, 8), - ) - : const EdgeInsets.fromLTRB(16, 12, 16, 8), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Semantics( - container: true, - header: true, - excludeSemantics: true, - label: [ - changeKindTitle(file.kind), - if (stat.isNotEmpty) stat, - if (tags.isNotEmpty) tags.join(' · '), - 'for ${file.path}', - if (file.steps.isNotEmpty) - 'changed by ${file.steps.join(' → ')}', - if (file.modeChanged && !file.binary) - 'mode ${file.beforeMode ?? ''}→' - '${file.afterMode ?? ''}', - ].join(', '), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Wrap( - spacing: 12, - runSpacing: 4, - crossAxisAlignment: WrapCrossAlignment.center, - children: [ - Text( - changeKindTitle(file.kind), - style: Theme.of(context).textTheme.titleMedium, - ), - if (stat.isNotEmpty) - ChangeStatText(stat, style: mono), - if (tags.isNotEmpty) - Text( - tags.join(' · '), - style: Theme.of(context).textTheme.bodySmall, - ), - ], - ), - const SizedBox(height: 4), - Text(file.path, style: mono), + return SafeArea( + top: false, + minimum: const EdgeInsets.symmetric(horizontal: 8), + child: ConstrainedBox( + key: const ValueKey('file-diff-viewer'), + constraints: BoxConstraints( + maxWidth: 900, + maxHeight: MediaQuery.sizeOf(context).height * 0.85, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: widget.floatBehindTopBar + ? withTopBarClearance( + context, + const EdgeInsets.fromLTRB(16, 12, 16, 8), + ) + : const EdgeInsets.fromLTRB(16, 12, 16, 8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Semantics( + container: true, + header: true, + excludeSemantics: true, + label: [ + changeKindTitle(file.kind), + if (stat.isNotEmpty) stat, + if (tags.isNotEmpty) tags.join(' · '), + 'for ${file.path}', if (file.steps.isNotEmpty) - Text( - 'changed by ${file.steps.join(' → ')}', - style: Theme.of(context).textTheme.bodySmall, - ), + 'changed by ${file.steps.join(' → ')}', if (file.modeChanged && !file.binary) - Text( - 'mode ${file.beforeMode ?? ''}→' - '${file.afterMode ?? ''}', - style: Theme.of(context).textTheme.bodySmall, + 'mode ${file.beforeMode ?? ''}→' + '${file.afterMode ?? ''}', + ].join(', '), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Wrap( + spacing: 12, + runSpacing: 4, + crossAxisAlignment: WrapCrossAlignment.center, + children: [ + Text( + changeKindTitle(file.kind), + style: Theme.of(context).textTheme.titleMedium, + ), + if (stat.isNotEmpty) + ChangeStatText(stat, style: mono), + if (tags.isNotEmpty) + Text( + tags.join(' · '), + style: Theme.of(context).textTheme.bodySmall, + ), + ], ), - ], + const SizedBox(height: 4), + Text(file.path, style: mono), + if (file.steps.isNotEmpty) + Text( + 'changed by ${file.steps.join(' → ')}', + style: Theme.of(context).textTheme.bodySmall, + ), + if (file.modeChanged && !file.binary) + Text( + 'mode ${file.beforeMode ?? ''}→' + '${file.afterMode ?? ''}', + style: Theme.of(context).textTheme.bodySmall, + ), + ], + ), ), ), - ), - ], + ], + ), ), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Wrap( - spacing: 8, - runSpacing: 8, - crossAxisAlignment: WrapCrossAlignment.center, - children: [ - if (file.hasPatch) - LayoutBuilder( - builder: (context, constraints) { - // Two native segmented-control segments cannot show both - // fixed words at 2x text on a narrow host; their menu - // shows the same labels whole, one per row. - final control = - diffFormSegmentsFit(context, constraints.maxWidth) - ? diffFormControl( - context, - form: _form, - onChanged: _selectForm, - ) - : diffFormMenu( - context, - form: _form, - onChanged: _selectForm, - ); - return control; - }, + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Wrap( + spacing: 8, + runSpacing: 8, + crossAxisAlignment: WrapCrossAlignment.center, + children: [ + if (file.hasPatch) + LayoutBuilder( + builder: (context, constraints) { + // Two native segmented-control segments cannot show both + // fixed words at 2x text on a narrow host; their menu + // shows the same labels whole, one per row. + final control = + diffFormSegmentsFit(context, constraints.maxWidth) + ? diffFormControl( + context, + form: _form, + onChanged: _selectForm, + ) + : diffFormMenu( + context, + form: _form, + onChanged: _selectForm, + ); + return control; + }, + ), + _scrollsWhenTooWide( + copyPatchControl( + context, + enabled: file.hasPatch, + copied: _copied, + onPressed: _copy, + ), ), - _scrollsWhenTooWide( - copyPatchControl( - context, - enabled: file.hasPatch, - copied: _copied, - onPressed: _copy, - ), - ), - ], + if (widget.onClose != null) + closeDiffControl(context, widget.onClose!), + ], + ), ), - ), - Divider( - height: 16, - color: cupertino - ? CupertinoColors.separator.resolveFrom(context) - : Theme.of(context).dividerColor, - ), - Flexible(child: _body(context, mono)), - ], + Divider( + height: 16, + color: cupertino + ? CupertinoColors.separator.resolveFrom(context) + : Theme.of(context).dividerColor, + ), + Flexible(child: _body(context, mono)), + ], + ), ), ); } @@ -306,8 +312,9 @@ class _FileDiffPageState extends State { : Align( alignment: AlignmentDirectional.centerEnd, heightFactor: 1, - child: Padding( - padding: const EdgeInsets.all(8), + child: SafeArea( + top: false, + minimum: const EdgeInsets.all(8), child: GlassPill(cupertino: cupertino, child: pager), ), ), diff --git a/app/lib/ui/navigation/chevron_pager.dart b/app/lib/ui/navigation/chevron_pager.dart index 895c36f3..247448be 100644 --- a/app/lib/ui/navigation/chevron_pager.dart +++ b/app/lib/ui/navigation/chevron_pager.dart @@ -48,12 +48,14 @@ class ChevronPager extends StatelessWidget { excludeSemantics: true, child: CupertinoButton( key: key, - padding: const EdgeInsets.all(8), + padding: EdgeInsets.zero, + minimumSize: const Size(44, 44), onPressed: onPressed, child: Icon( previous ? CupertinoIcons.chevron_left : CupertinoIcons.chevron_right, + size: 30, ), ), ); @@ -61,24 +63,34 @@ class ChevronPager extends StatelessWidget { return IconButton( key: key, tooltip: label, + constraints: const BoxConstraints(minWidth: 48, minHeight: 48), + padding: EdgeInsets.zero, onPressed: onPressed, - icon: Icon(previous ? Icons.chevron_left : Icons.chevron_right), + icon: Icon( + previous ? Icons.chevron_left : Icons.chevron_right, + size: 28, + ), ); } return Padding( - padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 8, 4), + // The surrounding glass pill supplies the edge gap. Keeping this row's + // horizontal padding at zero also leaves room for four 48px controls on + // a narrow phone at large text sizes. + padding: EdgeInsets.zero, child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Flexible( + fit: FlexFit.tight, child: Text( '${index + 1} of $count', key: positionKey, + style: Theme.of(context).textTheme.labelLarge, overflow: TextOverflow.ellipsis, ), ), - const SizedBox(width: 4), + const SizedBox(width: 0), chevron( key: previousKey, previous: true, diff --git a/app/test/features/changes/diff_presentation_test.dart b/app/test/features/changes/diff_presentation_test.dart index 513ef0d8..2b9604cb 100644 --- a/app/test/features/changes/diff_presentation_test.dart +++ b/app/test/features/changes/diff_presentation_test.dart @@ -428,12 +428,11 @@ void main() { ); await tester.tap(find.text('Open diff')); await tester.pumpAndSettle(); - expect( - cupertino - ? find.byType(CupertinoSlidingSegmentedControl) - : find.byType(SegmentedButton), - findsOneWidget, - ); + final control = cupertino + ? find.byType(CupertinoSlidingSegmentedControl) + : find.byType(SegmentedButton); + expect(control, findsOneWidget); + expect(tester.getSize(control).height, greaterThanOrEqualTo(44)); expect(find.text('Rendered'), findsOneWidget); expect(find.text('Raw patch'), findsOneWidget); expect(tester.takeException(), isNull);