f7b5958d64
A chat's colour is picked from its row menu (Colour...), a long-press or the chat information sheet. The list shows it as a leading bar, a faint row tint and a coloured avatar; the open chat shows a faint wash under its top bar. Shades are Cupertino's dynamic system colours and Material swatches tuned per brightness. Changes from other devices apply live. Ctrl+1...Ctrl+9 open the Nth item of the open tab's list (chats, runs, pipelines) in on-screen order, also while typing. Starred chats are sorted by name, case-insensitively, as one alphabetical group.
71 lines
2.2 KiB
Dart
71 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
|
import 'package:pipelines_app/shell/destination.dart';
|
|
import 'package:pipelines_app/shell/shell_list_shortcuts.dart';
|
|
|
|
void main() {
|
|
testWidgets('Ctrl+1…9 reach only the open tab\'s list; other chords pass', (
|
|
tester,
|
|
) async {
|
|
final opened = <(AppDestination, int)>[];
|
|
final field = FocusNode();
|
|
addTearDown(field.dispose);
|
|
Widget list(AppDestination destination) => ShellListShortcut(
|
|
onOpenIndex: (index) {
|
|
if (index > 4) return false;
|
|
opened.add((destination, index));
|
|
return true;
|
|
},
|
|
child: TextField(focusNode: field),
|
|
);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: AdaptiveShell(
|
|
destination: AppDestination.runs,
|
|
destinationBodies: {
|
|
AppDestination.runs: (_) => list(AppDestination.runs),
|
|
AppDestination.pipelines: (_) => list(AppDestination.pipelines),
|
|
},
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
field.requestFocus();
|
|
await tester.pump();
|
|
|
|
Future<void> press(
|
|
LogicalKeyboardKey key, {
|
|
List<LogicalKeyboardKey> held = const [LogicalKeyboardKey.controlLeft],
|
|
}) async {
|
|
for (final modifier in held) {
|
|
await tester.sendKeyDownEvent(modifier);
|
|
}
|
|
await tester.sendKeyEvent(key);
|
|
for (final modifier in held.reversed) {
|
|
await tester.sendKeyUpEvent(modifier);
|
|
}
|
|
await tester.pump();
|
|
}
|
|
|
|
await press(LogicalKeyboardKey.digit1);
|
|
await press(LogicalKeyboardKey.digit5);
|
|
expect(opened, [(AppDestination.runs, 0), (AppDestination.runs, 4)]);
|
|
|
|
opened.clear();
|
|
await press(
|
|
LogicalKeyboardKey.digit2,
|
|
held: [LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.shiftLeft],
|
|
);
|
|
await press(
|
|
LogicalKeyboardKey.digit2,
|
|
held: [LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.metaLeft],
|
|
);
|
|
await press(LogicalKeyboardKey.digit2, held: const []);
|
|
await press(LogicalKeyboardKey.digit0);
|
|
expect(opened, isEmpty);
|
|
expect(field.hasFocus, isTrue);
|
|
});
|
|
}
|