Add opposing arc swap animation for chat quick switch
This commit is contained in:
@@ -159,51 +159,63 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('card stack cycles all added panes and settles reduced motion', (
|
||||
tester,
|
||||
) async {
|
||||
phone(tester);
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
await QuickSwitchAnimationController.instance.setAnimation(
|
||||
QuickSwitchAnimation.cardStack,
|
||||
);
|
||||
addTearDown(
|
||||
() => QuickSwitchAnimationController.instance.setAnimation(
|
||||
QuickSwitchAnimation.tape,
|
||||
),
|
||||
);
|
||||
final controller = ChatWorkspaceController()..open('a');
|
||||
for (final id in ['b', 'c']) {
|
||||
controller.splitActive(id, ChatSplitAxis.horizontal);
|
||||
}
|
||||
await tester.pumpWidget(_host(controller));
|
||||
await tester.pumpAndSettle();
|
||||
final states = {
|
||||
for (final id in ['a', 'b', 'c'])
|
||||
id: tester.state<_DraftState>(
|
||||
find.byKey(ValueKey(id), skipOffstage: false),
|
||||
),
|
||||
};
|
||||
for (final id in ['a', 'b', 'c', 'a']) {
|
||||
final pane = controller.panes.firstWhere((p) => p.sessionId == id);
|
||||
await tester.tap(find.byKey(ValueKey('chat-peek-${pane.id}')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.activePane!.sessionId, id);
|
||||
for (final entry in states.entries) {
|
||||
expect(
|
||||
tester.state(find.byKey(ValueKey(entry.key), skipOffstage: false)),
|
||||
same(entry.value),
|
||||
for (final ringStyle in [
|
||||
QuickSwitchAnimation.cardStack,
|
||||
QuickSwitchAnimation.arcSwap,
|
||||
]) {
|
||||
testWidgets(
|
||||
'${ringStyle.name} cycles all added panes and settles reduced motion',
|
||||
(tester) async {
|
||||
phone(tester);
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
await QuickSwitchAnimationController.instance.setAnimation(ringStyle);
|
||||
addTearDown(
|
||||
() => QuickSwitchAnimationController.instance.setAnimation(
|
||||
QuickSwitchAnimation.tape,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
await tester.pumpWidget(_host(controller, reduced: true));
|
||||
controller.activate(
|
||||
controller.panes.firstWhere((p) => p.sessionId == 'b').id,
|
||||
final controller = ChatWorkspaceController()..open('a');
|
||||
for (final id in ['b', 'c']) {
|
||||
controller.splitActive(id, ChatSplitAxis.horizontal);
|
||||
}
|
||||
await tester.pumpWidget(_host(controller));
|
||||
await tester.pumpAndSettle();
|
||||
final states = {
|
||||
for (final id in ['a', 'b', 'c'])
|
||||
id: tester.state<_DraftState>(
|
||||
find.byKey(ValueKey(id), skipOffstage: false),
|
||||
),
|
||||
};
|
||||
controller.resizeMobilePeek(.12);
|
||||
for (final entry in states.entries) {
|
||||
entry.value.controller.text = 'Draft ${entry.key}';
|
||||
}
|
||||
for (final id in ['a', 'b', 'c', 'a']) {
|
||||
final pane = controller.panes.firstWhere((p) => p.sessionId == id);
|
||||
await tester.tap(find.byKey(ValueKey('chat-peek-${pane.id}')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.activePane!.sessionId, id);
|
||||
for (final entry in states.entries) {
|
||||
expect(
|
||||
tester.state(
|
||||
find.byKey(ValueKey(entry.key), skipOffstage: false),
|
||||
),
|
||||
same(entry.value),
|
||||
);
|
||||
expect(entry.value.controller.text, 'Draft ${entry.key}');
|
||||
}
|
||||
expect(controller.mobilePeekFraction, .12);
|
||||
}
|
||||
await tester.pumpWidget(_host(controller, reduced: true));
|
||||
controller.activate(
|
||||
controller.panes.firstWhere((p) => p.sessionId == 'b').id,
|
||||
);
|
||||
await tester.pump();
|
||||
expect(tester.getRect(rect(controller.activePaneId!)).top, 0);
|
||||
expect(find.byKey(const ValueKey('chat-swap-exit')), findsNothing);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
controller.dispose();
|
||||
},
|
||||
);
|
||||
await tester.pump();
|
||||
expect(tester.getRect(rect(controller.activePaneId!)).top, 0);
|
||||
expect(find.byKey(const ValueKey('chat-swap-exit')), findsNothing);
|
||||
await tester.pumpWidget(const SizedBox());
|
||||
controller.dispose();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(workspace.controller.activePaneId, isNot(active));
|
||||
expect(tester.binding.transientCallbackCount, 0);
|
||||
await tester.pumpWidget(_host(QuickSwitchAnimation.swap));
|
||||
await tester.pumpWidget(_host(QuickSwitchAnimation.arcSwap));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.widget<ChatWorkspace>(find.byType(ChatWorkspace)).controller,
|
||||
@@ -35,7 +35,7 @@ void main() {
|
||||
);
|
||||
expect(
|
||||
tester.widget<ChatWorkspace>(find.byType(ChatWorkspace)).animationStyle,
|
||||
QuickSwitchAnimation.swap,
|
||||
QuickSwitchAnimation.arcSwap,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user