Remove Cupertino chat workspace branches
Keep the app's Material-only chat workspace path while retaining public cupertino parameters for callers. Narrow the affected widget tests to the supported Material host.
This commit is contained in:
@@ -338,9 +338,7 @@ mixin _ChatScreenWorkspace on State<ChatScreen> {
|
||||
context,
|
||||
chatSessionColor(_rowFor(pane.sessionId)),
|
||||
) ??
|
||||
(chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary)
|
||||
Theme.of(context).colorScheme.primary
|
||||
: Colors.transparent;
|
||||
return Semantics(
|
||||
selected: active,
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
/// Covers a chat beside the stage too narrow to use: its colour and title,
|
||||
/// running down the column. A press brings that chat to center stage. The
|
||||
/// retained chat underneath keeps its state.
|
||||
@@ -22,20 +19,13 @@ class ChatCenterStageStrip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final accent =
|
||||
color ??
|
||||
(cupertino ? CupertinoTheme.of(context).primaryColor : scheme.primary);
|
||||
final accent = color ?? scheme.primary;
|
||||
final background = Color.alphaBlend(
|
||||
accent.withValues(alpha: .12),
|
||||
cupertino
|
||||
? CupertinoColors.secondarySystemBackground.resolveFrom(context)
|
||||
: scheme.surfaceContainer,
|
||||
scheme.surfaceContainer,
|
||||
);
|
||||
final style = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.titleSmall;
|
||||
final style = Theme.of(context).textTheme.titleSmall;
|
||||
final label = Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Column(
|
||||
@@ -62,25 +52,17 @@ class ChatCenterStageStrip extends StatelessWidget {
|
||||
label: 'Show $title on center stage',
|
||||
excludeSemantics: true,
|
||||
onTap: onSelected,
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
color: background,
|
||||
borderRadius: BorderRadius.zero,
|
||||
onPressed: onSelected,
|
||||
child: SizedBox.expand(child: label),
|
||||
)
|
||||
: Tooltip(
|
||||
message: title,
|
||||
excludeFromSemantics: true,
|
||||
child: Material(
|
||||
color: background,
|
||||
child: InkWell(
|
||||
onTap: onSelected,
|
||||
child: SizedBox.expand(child: label),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Tooltip(
|
||||
message: title,
|
||||
excludeFromSemantics: true,
|
||||
child: Material(
|
||||
color: background,
|
||||
child: InkWell(
|
||||
onTap: onSelected,
|
||||
child: SizedBox.expand(child: label),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import 'chat_workspace_pane_scope.dart';
|
||||
|
||||
/// "Move up/down/left/right" for a tiled pane's actions (More) menu. A move
|
||||
/// swaps the pane with the one across that edge. A direction with no pane is
|
||||
/// disabled in the Material menu (and left out of a Cupertino action sheet).
|
||||
/// Nothing is offered when the panes are not tiled (one pane, or a phone).
|
||||
/// disabled in the menu. Nothing is offered when the panes are not tiled (one
|
||||
/// pane, or a phone).
|
||||
List<Widget> chatPaneMoveActions(
|
||||
ChatWorkspacePaneScope? scope, {
|
||||
required void Function(String targetPaneId) onMove,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
/// A named, explicit switch action above the inactive transcript. It occupies
|
||||
/// space rather than obscuring the small chat's readable content.
|
||||
@@ -17,20 +15,11 @@ class ChatPeekHeader extends StatelessWidget {
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final compact = constraints.maxHeight < 44;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final textStyle = cupertino
|
||||
? (compact
|
||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle
|
||||
: CupertinoTheme.of(context).textTheme.textStyle)
|
||||
: (compact
|
||||
? Theme.of(context).textTheme.labelMedium
|
||||
: Theme.of(context).textTheme.labelLarge);
|
||||
final foreground = cupertino
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurface;
|
||||
final background = cupertino
|
||||
? CupertinoColors.secondarySystemBackground.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainer;
|
||||
final textStyle = compact
|
||||
? Theme.of(context).textTheme.labelMedium
|
||||
: Theme.of(context).textTheme.labelLarge;
|
||||
final foreground = Theme.of(context).colorScheme.onSurface;
|
||||
final background = Theme.of(context).colorScheme.surfaceContainer;
|
||||
final content = Row(
|
||||
children: [
|
||||
Expanded(
|
||||
@@ -44,34 +33,23 @@ class ChatPeekHeader extends StatelessWidget {
|
||||
const SizedBox(width: 8),
|
||||
Text('Switch', style: textStyle?.copyWith(color: foreground)),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
cupertino ? CupertinoIcons.arrow_up : Icons.arrow_upward,
|
||||
color: foreground,
|
||||
size: 18,
|
||||
),
|
||||
Icon(Icons.arrow_upward, color: foreground, size: 18),
|
||||
],
|
||||
);
|
||||
return ColoredBox(
|
||||
color: background,
|
||||
child: Tooltip(
|
||||
message: 'Switch to $title',
|
||||
child: cupertino
|
||||
? CupertinoButton(
|
||||
minimumSize: const Size(0, 44),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
onPressed: onActivate,
|
||||
child: content,
|
||||
)
|
||||
: TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
minimumSize: const Size(0, 44),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
shape: const RoundedRectangleBorder(),
|
||||
),
|
||||
onPressed: onActivate,
|
||||
child: content,
|
||||
),
|
||||
child: TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
minimumSize: const Size(0, 44),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
shape: const RoundedRectangleBorder(),
|
||||
),
|
||||
onPressed: onActivate,
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/motion/quick_switch_effect.dart';
|
||||
import 'chat_pane_switch_motion.dart';
|
||||
|
||||
@@ -24,12 +22,8 @@ class ChatSwitchCard extends StatelessWidget {
|
||||
motion.isAnimating ? motion.progress : 1,
|
||||
outgoing: outgoing,
|
||||
);
|
||||
final shadow = usesCupertinoHost(context)
|
||||
? CupertinoColors.black
|
||||
: Theme.of(context).shadowColor;
|
||||
final surface = usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
||||
: Theme.of(context).colorScheme.surface;
|
||||
final shadow = Theme.of(context).shadowColor;
|
||||
final surface = Theme.of(context).colorScheme.surface;
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) => Opacity(
|
||||
opacity: pose.opacity,
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/semantics.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'chat_workspace_controller.dart';
|
||||
import '../../../ui/adaptive/resize_grip.dart';
|
||||
import 'chat_workspace_geometry.dart';
|
||||
@@ -50,9 +48,7 @@ class _ChatWorkspaceDividerState extends State<ChatWorkspaceDivider> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final verticalLine = _horizontal;
|
||||
final color = usesCupertinoHost(context)
|
||||
? CupertinoColors.separator.resolveFrom(context)
|
||||
: Theme.of(context).dividerColor;
|
||||
final color = Theme.of(context).dividerColor;
|
||||
return Semantics(
|
||||
identifier: 'chat-divider-${widget.geometry.split.id}',
|
||||
label: 'Resize chat panes ${_horizontal ? 'horizontally' : 'vertically'}',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../ui/motion/motion.dart';
|
||||
import '../../../ui/motion/surface_visibility.dart';
|
||||
@@ -78,23 +78,16 @@ class _ChatWorkspaceEntranceState extends State<ChatWorkspaceEntrance>
|
||||
),
|
||||
),
|
||||
);
|
||||
final transition = widget.cupertino
|
||||
? CupertinoPageTransition(
|
||||
primaryRouteAnimation: _controller,
|
||||
secondaryRouteAnimation: const AlwaysStoppedAnimation(0),
|
||||
linearTransition: false,
|
||||
child: content,
|
||||
)
|
||||
: FadeTransition(
|
||||
opacity: _curve,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 0.08),
|
||||
end: Offset.zero,
|
||||
).animate(_curve),
|
||||
child: content,
|
||||
),
|
||||
);
|
||||
final transition = FadeTransition(
|
||||
opacity: _curve,
|
||||
child: SlideTransition(
|
||||
position: Tween<Offset>(
|
||||
begin: const Offset(0, 0.08),
|
||||
end: Offset.zero,
|
||||
).animate(_curve),
|
||||
child: content,
|
||||
),
|
||||
);
|
||||
return AnimatedBuilder(
|
||||
animation: _controller,
|
||||
child: transition,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'chat_center_stage_motion.dart';
|
||||
import 'chat_center_stage_strip.dart';
|
||||
import 'chat_mobile_panes.dart';
|
||||
@@ -130,11 +128,7 @@ Widget chatWorkspaceSurface({
|
||||
clipBehavior: Clip.hardEdge,
|
||||
children: [
|
||||
if (mobile != null)
|
||||
ColoredBox(
|
||||
color: usesCupertinoHost(context)
|
||||
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
||||
: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
ColoredBox(color: Theme.of(context).colorScheme.surface),
|
||||
picture,
|
||||
for (final pane in livePanes)
|
||||
if (motion.isTape ||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -34,61 +33,53 @@ class _Gateway extends FakeChatGateway {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'a pushed phone chat stays read and preserves underlying list chrome ($cupertino)',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
final gateway = _Gateway()..history = (_) async => chatPage([]);
|
||||
addTearDown(gateway.close);
|
||||
final bar = ShellBarRegistry();
|
||||
addTearDown(bar.dispose);
|
||||
final selected = ValueNotifier<String?>('s1');
|
||||
addTearDown(selected.dispose);
|
||||
final screen = ShellBarScope(
|
||||
registry: bar,
|
||||
destination: AppDestination.chat,
|
||||
child: ValueListenableBuilder<String?>(
|
||||
valueListenable: selected,
|
||||
builder: (_, id, _) => ChatScreen(
|
||||
gateway: gateway,
|
||||
initialSessionId: id,
|
||||
onBack: () => selected.value = null,
|
||||
),
|
||||
testWidgets(
|
||||
'a pushed phone chat stays read and preserves underlying list chrome',
|
||||
(tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
final gateway = _Gateway()..history = (_) async => chatPage([]);
|
||||
addTearDown(gateway.close);
|
||||
final bar = ShellBarRegistry();
|
||||
addTearDown(bar.dispose);
|
||||
final selected = ValueNotifier<String?>('s1');
|
||||
addTearDown(selected.dispose);
|
||||
final screen = ShellBarScope(
|
||||
registry: bar,
|
||||
destination: AppDestination.chat,
|
||||
child: ValueListenableBuilder<String?>(
|
||||
valueListenable: selected,
|
||||
builder: (_, id, _) => ChatScreen(
|
||||
gateway: gateway,
|
||||
initialSessionId: id,
|
||||
onBack: () => selected.value = null,
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
|
||||
: MaterialApp(home: Scaffold(body: screen)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
final list = tester.widget<ChatSessionsScreen>(
|
||||
find.byType(ChatSessionsScreen, skipOffstage: false),
|
||||
);
|
||||
final controller = list.controller!;
|
||||
expect(controller.activeSessionId, 's1');
|
||||
expect(bar.specFor(AppDestination.chat)?.actions, isNotEmpty);
|
||||
gateway.emitEvent(chatTextFrame('New live answer', session: 's1'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.sessions.where(controller.isUnseen), isEmpty);
|
||||
gateway.emitEvent(chatTextFrame('Different answer', session: 's2'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
controller.sessions
|
||||
.where(controller.isUnseen)
|
||||
.map((row) => row['id']),
|
||||
['s2'],
|
||||
);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.activeSessionId, isNull);
|
||||
expect(find.text('Open conversation'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: screen)));
|
||||
await tester.pumpAndSettle();
|
||||
final list = tester.widget<ChatSessionsScreen>(
|
||||
find.byType(ChatSessionsScreen, skipOffstage: false),
|
||||
);
|
||||
final controller = list.controller!;
|
||||
expect(controller.activeSessionId, 's1');
|
||||
expect(bar.specFor(AppDestination.chat)?.actions, isNotEmpty);
|
||||
gateway.emitEvent(chatTextFrame('New live answer', session: 's1'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.sessions.where(controller.isUnseen), isEmpty);
|
||||
gateway.emitEvent(chatTextFrame('Different answer', session: 's2'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
controller.sessions.where(controller.isUnseen).map((row) => row['id']),
|
||||
['s2'],
|
||||
);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.activeSessionId, isNull);
|
||||
expect(find.text('Open conversation'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -192,6 +192,13 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(widthOf(tester, 'three'), 950);
|
||||
expect(find.byType(ChatCenterStageStrip), findsNWidgets(2));
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(ChatCenterStageStrip).first,
|
||||
matching: find.byType(InkWell),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('draft'), findsOneWidget);
|
||||
|
||||
stage.value = false;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_mobile_panes.dart';
|
||||
@@ -36,54 +35,48 @@ class _ThreadState extends State<_Thread> {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final height in [32.0, 48.0]) {
|
||||
testWidgets(
|
||||
'peek title and switch fit $height height at 2x ($cupertino)',
|
||||
(tester) async {
|
||||
var activated = 0;
|
||||
Size? bodySize;
|
||||
final viewport = MediaQuery(
|
||||
data: const MediaQueryData(textScaler: TextScaler.linear(2)),
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: SizedBox(
|
||||
width: 320,
|
||||
height: height,
|
||||
child: ChatMobilePaneViewport(
|
||||
peek: true,
|
||||
active: false,
|
||||
barReveal: const AlwaysStoppedAnimation(0),
|
||||
onActivate: () => activated++,
|
||||
label: 'A long working project name',
|
||||
paneId: 'first',
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
bodySize = constraints.biggest;
|
||||
return const SizedBox.expand();
|
||||
},
|
||||
),
|
||||
),
|
||||
for (final height in [32.0, 48.0]) {
|
||||
testWidgets('peek title and switch fit $height height at 2x', (
|
||||
tester,
|
||||
) async {
|
||||
var activated = 0;
|
||||
Size? bodySize;
|
||||
final viewport = MediaQuery(
|
||||
data: const MediaQueryData(textScaler: TextScaler.linear(2)),
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: SizedBox(
|
||||
width: 320,
|
||||
height: height,
|
||||
child: ChatMobilePaneViewport(
|
||||
peek: true,
|
||||
active: false,
|
||||
barReveal: const AlwaysStoppedAnimation(0),
|
||||
onActivate: () => activated++,
|
||||
label: 'A long working project name',
|
||||
paneId: 'first',
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
bodySize = constraints.biggest;
|
||||
return const SizedBox.expand();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: viewport))
|
||||
: MaterialApp(home: Scaffold(body: viewport)),
|
||||
);
|
||||
expect(find.text('A long working project name'), findsOneWidget);
|
||||
expect(find.text('Switch'), findsOneWidget);
|
||||
final headerSize = tester.getSize(find.byType(ChatPeekHeader));
|
||||
expect(headerSize.height, lessThanOrEqualTo(height));
|
||||
expect(bodySize!.height, closeTo(height - headerSize.height, .01));
|
||||
await tester.tap(find.text('Switch'));
|
||||
await tester.pump();
|
||||
expect(activated, 1);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: viewport)));
|
||||
expect(find.text('A long working project name'), findsOneWidget);
|
||||
expect(find.text('Switch'), findsOneWidget);
|
||||
expect(find.byType(TextButton), findsOneWidget);
|
||||
final headerSize = tester.getSize(find.byType(ChatPeekHeader));
|
||||
expect(headerSize.height, lessThanOrEqualTo(height));
|
||||
expect(bodySize!.height, closeTo(height - headerSize.height, .01));
|
||||
await tester.tap(find.text('Switch'));
|
||||
await tester.pump();
|
||||
expect(activated, 1);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
testWidgets('peek header reserves real body space and keeps reading state', (
|
||||
tester,
|
||||
|
||||
@@ -3,56 +3,47 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/workspace/chat_workspace_entrance.dart';
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('retained entrance moves the same child ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
tester.platformDispatcher.accessibilityFeaturesTestValue =
|
||||
const FakeAccessibilityFeatures(disableAnimations: false);
|
||||
addTearDown(
|
||||
tester.platformDispatcher.clearAccessibilityFeaturesTestValue,
|
||||
);
|
||||
final childKey = GlobalKey();
|
||||
final child = TextField(key: childKey);
|
||||
Widget host(bool visible, {bool reduced = false}) => MaterialApp(
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(disableAnimations: reduced),
|
||||
child: SizedBox.expand(
|
||||
child: ChatWorkspaceEntrance(
|
||||
visible: visible,
|
||||
cupertino: cupertino,
|
||||
child: Material(child: child),
|
||||
),
|
||||
testWidgets('retained entrance moves the same child', (tester) async {
|
||||
tester.platformDispatcher.accessibilityFeaturesTestValue =
|
||||
const FakeAccessibilityFeatures(disableAnimations: false);
|
||||
addTearDown(tester.platformDispatcher.clearAccessibilityFeaturesTestValue);
|
||||
final childKey = GlobalKey();
|
||||
final child = TextField(key: childKey);
|
||||
Widget host(bool visible, {bool reduced = false}) => MaterialApp(
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(disableAnimations: reduced),
|
||||
child: SizedBox.expand(
|
||||
child: ChatWorkspaceEntrance(
|
||||
visible: visible,
|
||||
cupertino: false,
|
||||
child: Material(child: child),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(host(false));
|
||||
final element = childKey.currentContext;
|
||||
final state = childKey.currentState;
|
||||
expect(find.byKey(childKey), findsNothing);
|
||||
await tester.pumpWidget(host(true));
|
||||
final start = tester.getTopLeft(find.byKey(childKey));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 80));
|
||||
final middle = tester.getTopLeft(find.byKey(childKey));
|
||||
await tester.pumpAndSettle();
|
||||
final end = tester.getTopLeft(find.byKey(childKey));
|
||||
expect(cupertino ? middle.dx : middle.dy, greaterThan(0));
|
||||
expect(
|
||||
cupertino ? middle.dx : middle.dy,
|
||||
lessThan(cupertino ? start.dx : start.dy),
|
||||
);
|
||||
expect(end, Offset.zero);
|
||||
expect(childKey.currentContext, same(element));
|
||||
expect(childKey.currentState, same(state));
|
||||
await tester.enterText(find.byType(TextField), 'Retained draft');
|
||||
await tester.pumpWidget(host(false));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(host(true, reduced: true));
|
||||
expect(tester.getTopLeft(find.byKey(childKey)), Offset.zero);
|
||||
expect(find.text('Retained draft'), findsOneWidget);
|
||||
expect(childKey.currentState, same(state));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(host(false));
|
||||
final element = childKey.currentContext;
|
||||
final state = childKey.currentState;
|
||||
expect(find.byKey(childKey), findsNothing);
|
||||
await tester.pumpWidget(host(true));
|
||||
final start = tester.getTopLeft(find.byKey(childKey));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 80));
|
||||
final middle = tester.getTopLeft(find.byKey(childKey));
|
||||
await tester.pumpAndSettle();
|
||||
final end = tester.getTopLeft(find.byKey(childKey));
|
||||
expect(middle.dy, greaterThan(0));
|
||||
expect(middle.dy, lessThan(start.dy));
|
||||
expect(end, Offset.zero);
|
||||
expect(childKey.currentContext, same(element));
|
||||
expect(childKey.currentState, same(state));
|
||||
await tester.enterText(find.byType(TextField), 'Retained draft');
|
||||
await tester.pumpWidget(host(false));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pumpWidget(host(true, reduced: true));
|
||||
expect(tester.getTopLeft(find.byKey(childKey)), Offset.zero);
|
||||
expect(find.text('Retained draft'), findsOneWidget);
|
||||
expect(childKey.currentState, same(state));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user