iOS navigation fixes: deep-link pop fallback + back-button PopScope
- notification_service: use GoRouter.go (not push) for terminal states (session_closing, session_expired) so the nav stack doesn't linger behind deep-linked screens - chat_screen: PopScope + canPop fallback in client_app so iOS back gestures fall back to /home when there is nothing to pop
This commit is contained in:
@@ -74,6 +74,14 @@ class _ChatScreenState extends ConsumerState<ChatScreen> {
|
||||
_scrollToBottom();
|
||||
}
|
||||
|
||||
void _exitChat() {
|
||||
if (context.canPop()) {
|
||||
context.pop();
|
||||
} else {
|
||||
context.go('/home');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final chatState = ref.watch(chatProvider);
|
||||
@@ -112,34 +120,40 @@ class _ChatScreenState extends ConsumerState<ChatScreen> {
|
||||
}
|
||||
});
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: Colors.black,
|
||||
elevation: 0.5,
|
||||
centerTitle: true,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.chevron_left, size: 28),
|
||||
onPressed: () => context.pop(),
|
||||
),
|
||||
title: Text(widget.mitraName),
|
||||
actions: [
|
||||
if (chatState is ChatConnectedData && chatState.remainingSeconds != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'${chatState.remainingSeconds}s',
|
||||
style: TextStyle(
|
||||
color: chatState.remainingSeconds! < 30 ? Colors.red : Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvokedWithResult: (didPop, _) {
|
||||
if (!didPop) _exitChat();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: Colors.black,
|
||||
elevation: 0.5,
|
||||
centerTitle: true,
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.chevron_left, size: 28),
|
||||
onPressed: _exitChat,
|
||||
),
|
||||
title: Text(widget.mitraName),
|
||||
actions: [
|
||||
if (chatState is ChatConnectedData && chatState.remainingSeconds != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'${chatState.remainingSeconds}s',
|
||||
style: TextStyle(
|
||||
color: chatState.remainingSeconds! < 30 ? Colors.red : Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
body: _buildBody(chatState, closureState),
|
||||
),
|
||||
body: _buildBody(chatState, closureState),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user