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
@@ -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),
),
),