From 5bed73e658fe96b72049e595c3904f0cd036b644 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Sat, 31 Oct 2026 03:22:52 +0000 Subject: [PATCH] fix(app): polish glass diff and pipeline controls --- .../changes/widgets/change_style.dart | 5 +- .../features/changes/widgets/patch_view.dart | 60 +------------------ .../widgets/pipeline_list_panel.dart | 2 +- .../ui/adaptive/floating_destination_bar.dart | 3 + app/lib/ui/adaptive/glass_pill.dart | 10 ++-- app/lib/ui/adaptive/segmented_bar_pieces.dart | 1 + .../changes/diff_presentation_test.dart | 19 +++--- .../pipeline_scope_control_test.dart | 21 +++++++ app/test/ui/adaptive/segmented_bar_test.dart | 26 ++++++++ 9 files changed, 76 insertions(+), 71 deletions(-) diff --git a/app/lib/features/changes/widgets/change_style.dart b/app/lib/features/changes/widgets/change_style.dart index 60a3690f..cd318b88 100644 --- a/app/lib/features/changes/widgets/change_style.dart +++ b/app/lib/features/changes/widgets/change_style.dart @@ -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( diff --git a/app/lib/features/changes/widgets/patch_view.dart b/app/lib/features/changes/widgets/patch_view.dart index dc4039bb..8d8bbb13 100644 --- a/app/lib/features/changes/widgets/patch_view.dart +++ b/app/lib/features/changes/widgets/patch_view.dart @@ -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}); diff --git a/app/lib/features/pipelines/widgets/pipeline_list_panel.dart b/app/lib/features/pipelines/widgets/pipeline_list_panel.dart index ff4040dc..531b590e 100644 --- a/app/lib/features/pipelines/widgets/pipeline_list_panel.dart +++ b/app/lib/features/pipelines/widgets/pipeline_list_panel.dart @@ -76,7 +76,7 @@ class PipelineListPanel extends StatelessWidget { kPipelineListInset, 4, ), - child: SizedBox(width: double.infinity, child: control), + child: Align(alignment: AlignmentDirectional.centerStart, child: control), ); } diff --git a/app/lib/ui/adaptive/floating_destination_bar.dart b/app/lib/ui/adaptive/floating_destination_bar.dart index 056fa948..9089ffc2 100644 --- a/app/lib/ui/adaptive/floating_destination_bar.dart +++ b/app/lib/ui/adaptive/floating_destination_bar.dart @@ -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, diff --git a/app/lib/ui/adaptive/glass_pill.dart b/app/lib/ui/adaptive/glass_pill.dart index c568576c..f42bfd3b 100644 --- a/app/lib/ui/adaptive/glass_pill.dart +++ b/app/lib/ui/adaptive/glass_pill.dart @@ -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, ), ); diff --git a/app/lib/ui/adaptive/segmented_bar_pieces.dart b/app/lib/ui/adaptive/segmented_bar_pieces.dart index 4cab46eb..6056c628 100644 --- a/app/lib/ui/adaptive/segmented_bar_pieces.dart +++ b/app/lib/ui/adaptive/segmented_bar_pieces.dart @@ -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); diff --git a/app/test/features/changes/diff_presentation_test.dart b/app/test/features/changes/diff_presentation_test.dart index 7971e200..3509c3a8 100644 --- a/app/test/features/changes/diff_presentation_test.dart +++ b/app/test/features/changes/diff_presentation_test.dart @@ -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', ( diff --git a/app/test/features/pipelines/pipeline_scope_control_test.dart b/app/test/features/pipelines/pipeline_scope_control_test.dart index 507bc569..9167cfa8 100644 --- a/app/test/features/pipelines/pipeline_scope_control_test.dart +++ b/app/test/features/pipelines/pipeline_scope_control_test.dart @@ -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), + ); + }); } diff --git a/app/test/ui/adaptive/segmented_bar_test.dart b/app/test/ui/adaptive/segmented_bar_test.dart index 9510f944..80c9873b 100644 --- a/app/test/ui/adaptive/segmented_bar_test.dart +++ b/app/test/ui/adaptive/segmented_bar_test.dart @@ -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(find.text('Title')).style?.fontWeight, + FontWeight.w600, + ); + } + }); }