Enlarge viewer controls and respect safe areas

This commit is contained in:
2026-11-02 17:50:27 +00:00
parent e2ba091f7d
commit e65e2800e6
7 changed files with 188 additions and 152 deletions
@@ -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),
);
}
@@ -234,19 +234,23 @@ class _ChangesViewerState extends State<ChangesViewer> {
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,
),
),
),
),
@@ -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<DiffForm>(
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<void>(
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<void>(
context: context,
showDragHandle: true,
@@ -75,130 +75,136 @@ class _FileDiffViewerState extends State<FileDiffViewer> {
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<FileDiffPage> {
: 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),
),
),