fix(app): polish glass diff and pipeline controls

This commit is contained in:
2026-10-31 03:22:52 +00:00
parent 3641083bcc
commit 5bed73e658
9 changed files with 76 additions and 71 deletions
@@ -6,8 +6,9 @@ import 'diff_form_control.dart';
export 'diff_form_control.dart';
/// Patch text inherits the host's typography without a diff-specific font.
TextStyle nativeDiffText(TextStyle base) => base;
/// Patch columns use the bundled fixed-width face so gutters and markers align.
TextStyle nativeDiffText(TextStyle base) =>
base.copyWith(fontFamily: 'RobotoMono');
/// Keep Material-derived metadata roles readable inside a Cupertino host.
ThemeData hostTextTheme(BuildContext context) => ThemeData(
@@ -18,24 +18,15 @@ class PatchView extends StatelessWidget {
Widget build(BuildContext context) {
final parsed = file.parsedPatch;
final base = nativeDiffText(DefaultTextStyle.of(context).style);
final stat = changeStat(parsed.added, parsed.removed);
return Semantics(
container: true,
label: 'Rendered diff for ${file.path}',
value: stat.isEmpty ? noLineChangesMessage : stat,
value: changeStat(parsed.added, parsed.removed).isEmpty
? noLineChangesMessage
: changeStat(parsed.added, parsed.removed),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: ExcludeSemantics(
child: _StatLine(
added: parsed.added,
removed: parsed.removed,
base: base,
),
),
),
if (file.truncated)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
@@ -54,51 +45,6 @@ class PatchView extends StatelessWidget {
}
}
/// `+N` in the add colour and `-M` in the remove colour, or the honest note when
/// the patch records no changed line.
class _StatLine extends StatelessWidget {
const _StatLine({
required this.added,
required this.removed,
required this.base,
});
final int added;
final int removed;
final TextStyle base;
@override
Widget build(BuildContext context) {
if (added == 0 && removed == 0) {
return Text(
noLineChangesMessage,
style: base.copyWith(color: mutedColor(context)),
);
}
return Text.rich(
TextSpan(
children: [
if (added > 0)
TextSpan(
text: '+$added',
style: base.copyWith(
color: diffLineColors(context, ChangeLineKind.add).text,
),
),
if (added > 0 && removed > 0) TextSpan(text: ' ', style: base),
if (removed > 0)
TextSpan(
text: '-$removed',
style: base.copyWith(
color: diffLineColors(context, ChangeLineKind.remove).text,
),
),
],
),
);
}
}
class _HunkView extends StatelessWidget {
const _HunkView({required this.hunk});
@@ -76,7 +76,7 @@ class PipelineListPanel extends StatelessWidget {
kPipelineListInset,
4,
),
child: SizedBox(width: double.infinity, child: control),
child: Align(alignment: AlignmentDirectional.centerStart, child: control),
);
}
@@ -184,6 +184,9 @@ class FloatingDestinationBar extends StatelessWidget {
child: CupertinoTabBar(
backgroundColor: CupertinoColors.transparent,
border: null,
// Secondary-label translucency over glass falls below text contrast
// requirements. The host label role remains readable in both themes.
inactiveColor: CupertinoColors.label.resolveFrom(context),
iconSize: 24,
height: cupertinoHeight,
currentIndex: currentIndex,
+6 -4
View File
@@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
/// A frosted-glass piece floating over content: the content behind is
/// blurred inside the piece's [shape], under a translucent fill in the host's
/// raised surface role (Material `surfaceContainerHigh`, Cupertino
/// `systemGrey6`) and a hairline border.
/// `systemGrey5`) and a hairline border.
///
/// Under the system's high-contrast setting the fill is solid and nothing is
/// blurred. The Cupertino piece uses no Material widget; the Material piece
@@ -34,7 +34,7 @@ class GlassPill extends StatelessWidget {
static const double blurSigma = 16;
/// How much of the fill covers the blurred content.
static const double fillOpacity = 0.72;
static const double fillOpacity = 0.84;
@override
Widget build(BuildContext context) {
@@ -42,7 +42,9 @@ class GlassPill extends StatelessWidget {
final Color base;
final Color edge;
if (cupertino) {
base = CupertinoColors.systemGrey6.resolveFrom(context);
// Grey 5 stays visibly raised over both the black dark canvas and the
// white light canvas; Grey 6 disappears into either one when blurred.
base = CupertinoColors.systemGrey5.resolveFrom(context);
edge = CupertinoColors.separator.resolveFrom(context);
} else {
final scheme = Theme.of(context).colorScheme;
@@ -52,7 +54,7 @@ class GlassPill extends StatelessWidget {
final color = fill ?? (solid ? base : base.withValues(alpha: fillOpacity));
final border = shape.copyWith(
side: BorderSide(
color: solid ? edge : edge.withValues(alpha: edge.a * 0.5),
color: solid ? edge : edge.withValues(alpha: edge.a * 0.8),
width: 0.5,
),
);
@@ -128,6 +128,7 @@ class SegmentedTitlePill extends StatelessWidget {
final theme = Theme.of(context);
titleStyle = (theme.textTheme.titleSmall ?? const TextStyle()).copyWith(
color: foreground ?? theme.colorScheme.onSurface,
fontWeight: FontWeight.w600,
);
subtitleStyle = (theme.textTheme.labelSmall ?? const TextStyle())
.copyWith(color: foreground ?? theme.colorScheme.onSurfaceVariant);
@@ -76,13 +76,10 @@ void _expectWholeLabel(WidgetTester tester, Finder finder, String label) {
}
void main() {
test(
'patch typography preserves the native host style without overrides',
() {
const native = TextStyle(fontSize: 19, fontFamily: 'host-font');
expect(nativeDiffText(native), same(native));
},
);
test('patch typography uses the bundled fixed-width font', () {
const native = TextStyle(fontSize: 19, fontFamily: 'host-font');
expect(nativeDiffText(native), native.copyWith(fontFamily: 'RobotoMono'));
});
testWidgets(
'light and dark themes give additions and removals distinct hues',
@@ -164,6 +161,14 @@ void main() {
final added = spans.firstWhere((span) => span.text == '+2');
final removed = spans.firstWhere((span) => span.text == '-2');
expect(added.style!.color, isNot(removed.style!.color));
expect(
find.byWidgetPredicate((widget) {
if (widget is! RichText || widget.text is! TextSpan) return false;
return (widget.text as TextSpan).toPlainText() == '+2 -2';
}),
findsOneWidget,
reason: 'the file header is the only visible line-count summary',
);
});
testWidgets('the raw view scrolls long lines instead of wrapping them', (
@@ -41,4 +41,25 @@ void main() {
);
}
}
testWidgets('wide scope control hugs its labels', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: SizedBox(
width: 500,
child: Align(
alignment: AlignmentDirectional.centerStart,
child: PipelineScopeControl(scheduled: false, onSelected: (_) {}),
),
),
),
),
);
expect(
tester.getSize(find.byKey(const Key('pipeline-scope'))).width,
lessThan(500),
);
});
}
@@ -191,4 +191,30 @@ void main() {
await tester.pumpWidget(app(true));
expect(find.byType(BackdropFilter), findsNothing);
});
testWidgets('Material and Cupertino titles use semibold text', (
tester,
) async {
for (final cupertino in [false, true]) {
await tester.pumpWidget(
cupertino
? const CupertinoApp(
home: CupertinoPageScaffold(
navigationBar: SegmentedBar(cupertino: true, title: 'Title'),
child: SizedBox.expand(),
),
)
: const MaterialApp(
home: Scaffold(
appBar: SegmentedBar(cupertino: false, title: 'Title'),
body: SizedBox.expand(),
),
),
);
expect(
tester.widget<Text>(find.text('Title')).style?.fontWeight,
FontWeight.w600,
);
}
});
}