Resize chat list into compact rail and animate visible chat markers
This commit is contained in:
@@ -66,16 +66,15 @@ Future<void> _pump(
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Finder _accent(String id) => find.descendant(
|
||||
of: find.byKey(Key('chat-row-$id')),
|
||||
matching: find.byKey(appListRowAccentKey),
|
||||
Finder _accent(String id) => find.byWidgetPredicate(
|
||||
(widget) =>
|
||||
widget is AppListRow &&
|
||||
widget.key == Key('chat-row-$id') &&
|
||||
widget.accent != null,
|
||||
);
|
||||
|
||||
Color _accentColor(WidgetTester tester, String id) {
|
||||
final box = tester.widget<DecoratedBox>(_accent(id));
|
||||
final border = (box.decoration as BoxDecoration).border as BorderDirectional;
|
||||
return border.start.color;
|
||||
}
|
||||
Color _accentColor(WidgetTester tester, String id) =>
|
||||
tester.widget<AppListRow>(_accent(id)).accent!;
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
@@ -214,7 +213,8 @@ void main() {
|
||||
AppListRow.selectedColor(context, cupertino: false),
|
||||
reason: 'The selected fill, not the tint, marks the open row',
|
||||
);
|
||||
expect(find.byKey(appListRowAccentKey), findsOneWidget);
|
||||
expect(find.byKey(appListRowAccentKey), findsNothing);
|
||||
expect(find.byKey(const ValueKey('chat-visibility-s1')), findsOneWidget);
|
||||
});
|
||||
|
||||
group('controller', () {
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import 'package:pipelines_app/features/chat/data/chat_repository.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_compact_sidebar.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_body.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_controller.dart';
|
||||
import 'chat_test_harness.dart' show MemoryChatSessionLocalStore;
|
||||
import 'fake_chat_gateway.dart';
|
||||
|
||||
BorderSide edge(WidgetTester tester, String id) {
|
||||
final box = tester.widget<DecoratedBox>(
|
||||
find
|
||||
.descendant(
|
||||
of: find.byKey(ValueKey('chat-visibility-$id')),
|
||||
matching: find.byWidgetPredicate(
|
||||
(widget) =>
|
||||
widget is DecoratedBox &&
|
||||
widget.position == DecorationPosition.foreground,
|
||||
),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
return ((box.decoration as BoxDecoration).border as BorderDirectional).start;
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'only visible chats have an edge; active edge widens continuously',
|
||||
(tester) async {
|
||||
tester.platformDispatcher.accessibilityFeaturesTestValue =
|
||||
const FakeAccessibilityFeatures(disableAnimations: false);
|
||||
addTearDown(
|
||||
tester.platformDispatcher.clearAccessibilityFeaturesTestValue,
|
||||
);
|
||||
var active = false;
|
||||
late StateSetter update;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
update = setState;
|
||||
return Column(
|
||||
children: [
|
||||
ChatSessionRow(
|
||||
selected: true,
|
||||
session: const {
|
||||
'id': 'off',
|
||||
'title': 'Not visible',
|
||||
'color': 'teal',
|
||||
},
|
||||
onOpen: (_) {},
|
||||
onAction: (_) {},
|
||||
),
|
||||
ChatSessionRow(
|
||||
session: const {
|
||||
'id': 'on',
|
||||
'title': 'Visible',
|
||||
'color': 'red',
|
||||
},
|
||||
visible: true,
|
||||
selected: active,
|
||||
onOpen: (_) {},
|
||||
onAction: (_) {},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(edge(tester, 'off').style, BorderStyle.none);
|
||||
expect(edge(tester, 'on').width, 3);
|
||||
expect(find.byKey(appListRowAccentKey), findsNothing);
|
||||
update(() => active = true);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
expect(edge(tester, 'on').width, greaterThan(3));
|
||||
expect(edge(tester, 'on').width, lessThan(7));
|
||||
await tester.pumpAndSettle();
|
||||
expect(edge(tester, 'on').width, 7);
|
||||
update(() => active = false);
|
||||
await tester.pumpAndSettle();
|
||||
expect(edge(tester, 'on').width, 3);
|
||||
},
|
||||
);
|
||||
testWidgets('compact chats keep identity colours and visible/active edges', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = FakeChatGateway()
|
||||
..sessionsHandler = () async => {
|
||||
'chat_sessions': [
|
||||
{'id': 'a', 'title': 'Amber', 'color': 'red'},
|
||||
{'id': 'b', 'title': 'Beta', 'color': 'teal'},
|
||||
{'id': 'c', 'title': 'Charlie', 'color': 'blue'},
|
||||
],
|
||||
};
|
||||
addTearDown(gateway.pushed.close);
|
||||
final controller = ChatSessionsController(
|
||||
ChatRepository(gateway),
|
||||
localStore: MemoryChatSessionLocalStore(),
|
||||
);
|
||||
addTearDown(controller.dispose);
|
||||
await controller.refresh();
|
||||
final folds = ChatSectionFolds();
|
||||
addTearDown(folds.dispose);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: ChatCompactSidebar(
|
||||
controller: controller,
|
||||
folds: folds,
|
||||
activeSessionId: 'a',
|
||||
visibleSessionIds: const {'a', 'b'},
|
||||
onOpen: (_) {},
|
||||
onExpand: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byTooltip('Expand chat list'), findsOneWidget);
|
||||
expect(edge(tester, 'a').width, 7);
|
||||
expect(edge(tester, 'b').width, 3);
|
||||
expect(edge(tester, 'c').style, BorderStyle.none);
|
||||
final avatars = tester
|
||||
.widgetList<CircleAvatar>(find.byType(CircleAvatar))
|
||||
.toList();
|
||||
expect(avatars, hasLength(3));
|
||||
expect(avatars.map((a) => a.foregroundColor).toSet(), hasLength(3));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user