refactor: Enhance onboarding process in chat and app startup providers

- Integrated autofocus management for the composer in both chat and onboarding contexts to improve user experience.
- Added error handling for focus management to ensure smooth onboarding transitions.
- Updated modal bottom sheet handling to restore autofocus state after onboarding completion, enhancing usability across the app.
This commit is contained in:
cogwheel0
2025-10-19 21:10:10 +05:30
parent 42efbe8fc5
commit 27bfde8f95
3 changed files with 30 additions and 3 deletions

View File

@@ -190,6 +190,14 @@ class _ChatPageState extends ConsumerState<ChatPage> {
}
void _showOnboarding() {
try {
ref.read(composerAutofocusEnabledProvider.notifier).set(false);
} catch (_) {}
try {
FocusManager.instance.primaryFocus?.unfocus();
SystemChannels.textInput.invokeMethod('TextInput.hide');
} catch (_) {}
showModalBottomSheet(
context: context,
backgroundColor: Colors.transparent,
@@ -204,7 +212,12 @@ class _ChatPageState extends ConsumerState<ChatPage> {
),
child: const OnboardingSheet(),
),
);
).whenComplete(() {
if (!mounted) return;
try {
ref.read(composerAutofocusEnabledProvider.notifier).set(true);
} catch (_) {}
});
}
Future<void> _checkAndLoadDemoConversation() async {