Strengthen active chat marker and fade identity tint across selection

This commit is contained in:
2026-11-07 14:34:06 +00:00
parent b7fc221360
commit cc28dcbca0
7 changed files with 49 additions and 20 deletions
@@ -76,7 +76,7 @@ class ChatCompactSidebar extends StatelessWidget {
duration: MediaQuery.disableAnimationsOf(context) duration: MediaQuery.disableAnimationsOf(context)
? Duration.zero ? Duration.zero
: const Duration(milliseconds: 200), : const Duration(milliseconds: 200),
color: color.withValues(alpha: selected ? .24 : .07), color: selected ? Colors.transparent : color.withValues(alpha: .07),
child: _button( child: _button(
context, context,
chatSessionTitle(row), chatSessionTitle(row),
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'chat_color_palette.dart';
/// A chat's colour identifies it; this animated edge identifies where it is /// A chat's colour identifies it; this animated edge identifies where it is
/// visible. The active chat has a stronger edge in both list presentations. /// visible. The active chat has a stronger edge in both list presentations.
@@ -20,7 +21,7 @@ class ChatVisibilityMarker extends StatelessWidget {
@override @override
Widget build(BuildContext context) => Semantics( Widget build(BuildContext context) => Semantics(
label: active label: visible && active
? 'Active chat' ? 'Active chat'
: visible : visible
? 'Visible chat' ? 'Visible chat'
@@ -29,12 +30,24 @@ class ChatVisibilityMarker extends StatelessWidget {
key: ValueKey('chat-visibility-$sessionId'), key: ValueKey('chat-visibility-$sessionId'),
duration: MediaQuery.disableAnimationsOf(context) duration: MediaQuery.disableAnimationsOf(context)
? Duration.zero ? Duration.zero
: const Duration(milliseconds: 200), : const Duration(milliseconds: 220),
curve: Curves.easeInOut, curve: Curves.easeInOut,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: AlignmentDirectional.centerStart,
end: AlignmentDirectional.centerEnd,
colors: [
color.withValues(
alpha: active ? (chatColorDarkSurface(context) ? .30 : .22) : 0,
),
color.withValues(alpha: active ? .06 : 0),
],
),
),
foregroundDecoration: BoxDecoration( foregroundDecoration: BoxDecoration(
border: BorderDirectional( border: BorderDirectional(
start: visible start: visible
? BorderSide(color: color, width: active ? 7 : 3) ? BorderSide(color: color, width: active ? 10 : 3)
: BorderSide.none, : BorderSide.none,
), ),
), ),
@@ -78,6 +78,7 @@ class ChatSessionRow extends StatelessWidget {
key: Key('chat-row-$id'), key: Key('chat-row-$id'),
cupertino: cupertino, cupertino: cupertino,
selected: selected, selected: selected,
selectedFill: Colors.transparent,
emphasized: unread, emphasized: unread,
divider: divider, divider: divider,
onTap: () => onOpen(session), onTap: () => onOpen(session),
+10 -2
View File
@@ -69,6 +69,7 @@ class AppListRow extends StatelessWidget {
this.selectionControl, this.selectionControl,
this.tapKey, this.tapKey,
this.selected = false, this.selected = false,
this.selectedFill,
this.emphasized = false, this.emphasized = false,
this.divider = true, this.divider = true,
this.compactWidth = kAppListRowCompactWidth, this.compactWidth = kAppListRowCompactWidth,
@@ -82,6 +83,9 @@ class AppListRow extends StatelessWidget {
/// marks the open row, so the two never read as one another. /// marks the open row, so the two never read as one another.
final Color? accent; final Color? accent;
/// Optional feature-specific selection surface, retaining selection semantics.
final Color? selectedFill;
/// Retain identity tint while a feature supplies its own visibility marker. /// Retain identity tint while a feature supplies its own visibility marker.
final bool showAccentBorder; final bool showAccentBorder;
@@ -179,12 +183,13 @@ class AppListRow extends StatelessWidget {
onLongPress: onLongPress, onLongPress: onLongPress,
selected: selected, selected: selected,
tint: tint, tint: tint,
selectedFill: selectedFill,
child: content, child: content,
) )
: Material( : Material(
key: appListRowSurfaceKey, key: appListRowSurfaceKey,
color: selected color: selected
? selectedColor(context, cupertino: false) ? selectedFill ?? selectedColor(context, cupertino: false)
: tint ?? Colors.transparent, : tint ?? Colors.transparent,
child: InkWell( child: InkWell(
key: tapKey, key: tapKey,
@@ -395,11 +400,13 @@ class _CupertinoRowSurface extends StatefulWidget {
required this.selected, required this.selected,
this.onLongPress, this.onLongPress,
this.tint, this.tint,
this.selectedFill,
required this.child, required this.child,
}); });
/// The unselected row's tint, transparent when null. /// The unselected row's tint, transparent when null.
final Color? tint; final Color? tint;
final Color? selectedFill;
final Key? tapKey; final Key? tapKey;
final VoidCallback? onTap; final VoidCallback? onTap;
@@ -423,7 +430,8 @@ class _CupertinoRowSurfaceState extends State<_CupertinoRowSurface> {
final color = _pressed final color = _pressed
? CupertinoColors.systemGrey4.resolveFrom(context) ? CupertinoColors.systemGrey4.resolveFrom(context)
: widget.selected : widget.selected
? AppListRow.selectedColor(context, cupertino: true) ? widget.selectedFill ??
AppListRow.selectedColor(context, cupertino: true)
: widget.tint ?? const Color(0x00000000); : widget.tint ?? const Color(0x00000000);
final enabled = widget.onTap != null; final enabled = widget.onTap != null;
return GestureDetector( return GestureDetector(
@@ -68,15 +68,15 @@ void main() {
final color = cupertino final color = cupertino
? tester.widget<ColoredBox>(surface).color ? tester.widget<ColoredBox>(surface).color
: tester.widget<Material>(surface).color; : tester.widget<Material>(surface).color;
expect( expect(color, const Color(0x00000000));
color, final highlight = tester.widget<AnimatedContainer>(
active find.byKey(ValueKey('chat-visibility-$id')),
? AppListRow.selectedColor(
tester.element(row),
cupertino: cupertino,
)
: const Color(0x00000000),
); );
final gradient =
(highlight.decoration as BoxDecoration).gradient!
as LinearGradient;
expect(gradient.colors.first.a > 0, active);
expect(gradient.colors.last.a > 0, active);
} }
expectRow('a', true); expectRow('a', true);
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_color_palette.dart';
import 'package:pipelines_app/features/chat/data/chat_repository.dart'; import 'package:pipelines_app/features/chat/data/chat_repository.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_controller.dart'; import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_controller.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dart'; import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dart';
@@ -207,11 +208,17 @@ void main() {
), ),
); );
final surface = tester.widget<Material>(find.byKey(appListRowSurfaceKey)); final surface = tester.widget<Material>(find.byKey(appListRowSurfaceKey));
expect(surface.color, Colors.transparent);
final highlight = tester.widget<AnimatedContainer>(
find.byKey(const ValueKey('chat-visibility-s1')),
);
final gradient =
(highlight.decoration as BoxDecoration).gradient! as LinearGradient;
expect(gradient.colors.first.a, greaterThan(gradient.colors.last.a));
final context = tester.element(find.byType(ChatSessionRow)); final context = tester.element(find.byType(ChatSessionRow));
expect( expect(
surface.color, gradient.colors.first.withValues(alpha: 1),
AppListRow.selectedColor(context, cupertino: false), chatColorShade(context, 'amber'),
reason: 'The selected fill, not the tint, marks the open row',
); );
expect(find.byKey(appListRowAccentKey), findsNothing); expect(find.byKey(appListRowAccentKey), findsNothing);
expect(find.byKey(const ValueKey('chat-visibility-s1')), findsOneWidget); expect(find.byKey(const ValueKey('chat-visibility-s1')), findsOneWidget);
@@ -79,9 +79,9 @@ void main() {
await tester.pump(); await tester.pump();
await tester.pump(const Duration(milliseconds: 100)); await tester.pump(const Duration(milliseconds: 100));
expect(edge(tester, 'on').width, greaterThan(3)); expect(edge(tester, 'on').width, greaterThan(3));
expect(edge(tester, 'on').width, lessThan(7)); expect(edge(tester, 'on').width, lessThan(10));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(edge(tester, 'on').width, 7); expect(edge(tester, 'on').width, 10);
update(() => active = false); update(() => active = false);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(edge(tester, 'on').width, 3); expect(edge(tester, 'on').width, 3);
@@ -123,7 +123,7 @@ void main() {
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byTooltip('Expand chat list'), findsOneWidget); expect(find.byTooltip('Expand chat list'), findsOneWidget);
expect(edge(tester, 'a').width, 7); expect(edge(tester, 'a').width, 10);
expect(edge(tester, 'b').width, 3); expect(edge(tester, 'b').width, 3);
expect(edge(tester, 'c').style, BorderStyle.none); expect(edge(tester, 'c').style, BorderStyle.none);
final avatars = tester final avatars = tester