Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions lib/app/app_navigator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,27 @@ class AppChatPageRoute<T> extends PageRoute<T>
if (AppMotion.isReduced(context) && !_fullPageBackSwipeActive) {
return child;
}
final leaving = _fullPageBackSwipeActive;
final leaving =
_fullPageBackSwipeActive ||
animation.status == AnimationStatus.reverse ||
animation.status == AnimationStatus.dismissed;
if (leaving) {
final effectiveAnimation = popGestureInProgress
? animation
: CurvedAnimation(
parent: animation,
curve: AppMotion.standard,
reverseCurve: AppMotion.accelerate,
reverseCurve: AppMotion.standard.flipped,
);
final slide = SlideTransition(
position: Tween<Offset>(
begin: const Offset(1, 0),
end: Offset.zero,
).animate(effectiveAnimation),
transformHitTests: false,
child: child,
);
if (!_fullPageBackSwipeActive) return slide;
return Stack(
fit: StackFit.expand,
children: [
Expand All @@ -220,14 +232,7 @@ class AppChatPageRoute<T> extends PageRoute<T>
child: ColoredBox(color: Color(0xFF000000)),
),
),
SlideTransition(
position: Tween<Offset>(
begin: const Offset(1, 0),
end: Offset.zero,
).animate(effectiveAnimation),
transformHitTests: false,
child: child,
),
slide,
],
);
}
Expand Down
12 changes: 9 additions & 3 deletions test/full_page_back_swipe_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ void main() {
expect(tester.takeException(), isNull);
});

testWidgets('ordinary pop keeps the compact non-interactive transition', (
testWidgets('ordinary pop slides the conversation across the full viewport', (
tester,
) async {
final harness = await _pumpRouteHarness(tester);
Expand All @@ -402,8 +402,14 @@ void main() {
await tester.pump(const Duration(milliseconds: 90));

final chatLeft = tester.getTopLeft(find.byKey(_chatKey)).dx;
expect(chatLeft, greaterThan(0));
expect(chatLeft, lessThan(30));
expect(chatLeft, greaterThan(180));
expect(chatLeft, lessThan(390));
final revealedColor = await _pixelAt(
tester,
harness,
const Offset(24, 420),
);
_expectColorClose(revealedColor, _previousColor);

await tester.pumpAndSettle();
expect(harness.observer.popCount, 1);
Expand Down
46 changes: 46 additions & 0 deletions test/main_tab_motion_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:mithka/chat/chat_view.dart';
import 'package:mithka/chats/archived_chats_view.dart';
import 'package:mithka/chats/chat_list_view.dart';
import 'package:mithka/chats/search_view.dart';
import 'package:mithka/components/app_icons.dart';
import 'package:mithka/components/drawer_controller.dart' as dc;
import 'package:mithka/contacts/contacts_view.dart';
import 'package:mithka/l10n/app_locale_controller.dart';
Expand Down Expand Up @@ -598,6 +599,51 @@ void main() {
debugDefaultTargetPlatformOverride = null;
}
});

testWidgets(
'phone chat back button slides the conversation out across the viewport',
(tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
try {
await _setSurfaceSize(tester, const Size(390, 844));
await _pumpMainShell(tester);
final deepLinks = ChatDeepLinkController.shared;

deepLinks.openChat(chatId: 41, title: 'Mobile chat', messageId: 410);
await tester.pump();
await tester.pump();
await tester.pump(const Duration(milliseconds: 350));
_discardMissingTdlibErrors(tester);

final chatView = find.byType(ChatView);
expect(chatView, findsOneWidget);
expect(tester.getTopLeft(chatView).dx, closeTo(0, 0.5));

final backButton = find.descendant(
of: chatView,
matching: find.byIcon(HeroAppIcons.chevronLeft.data),
);
expect(backButton, findsOneWidget);
await tester.tap(backButton);
await tester.pump();
await tester.pump(const Duration(milliseconds: 90));
_discardMissingTdlibErrors(tester);

final midPopLeft = tester.getTopLeft(chatView).dx;
expect(midPopLeft, greaterThan(180));
expect(midPopLeft, lessThan(390));

await tester.pump(const Duration(milliseconds: 240));
await tester.pump();
_discardMissingTdlibErrors(tester);
expect(chatView, findsNothing);
expect(find.byType(ChatListView), findsOneWidget);
await _disposeShell(tester);
} finally {
debugDefaultTargetPlatformOverride = null;
}
},
);
}

void _discardMissingTdlibErrors(WidgetTester tester) {
Expand Down
Loading