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:
@@ -14,6 +14,7 @@ import '../services/background_streaming_handler.dart';
|
|||||||
import '../services/persistent_streaming_service.dart';
|
import '../services/persistent_streaming_service.dart';
|
||||||
import '../services/socket_service.dart';
|
import '../services/socket_service.dart';
|
||||||
import '../../features/onboarding/views/onboarding_sheet.dart';
|
import '../../features/onboarding/views/onboarding_sheet.dart';
|
||||||
|
import '../../features/chat/providers/chat_providers.dart';
|
||||||
import '../../shared/theme/theme_extensions.dart';
|
import '../../shared/theme/theme_extensions.dart';
|
||||||
import '../services/connectivity_service.dart';
|
import '../services/connectivity_service.dart';
|
||||||
import '../utils/debug_logger.dart';
|
import '../utils/debug_logger.dart';
|
||||||
@@ -534,8 +535,16 @@ Future<void> _maybeShowOnboarding(Ref ref) async {
|
|||||||
final navContext = NavigationService.navigatorKey.currentContext;
|
final navContext = NavigationService.navigatorKey.currentContext;
|
||||||
if (navContext == null) return;
|
if (navContext == null) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
ref.read(composerAutofocusEnabledProvider.notifier).set(false);
|
||||||
|
} catch (_) {}
|
||||||
|
try {
|
||||||
|
FocusManager.instance.primaryFocus?.unfocus();
|
||||||
|
SystemChannels.textInput.invokeMethod('TextInput.hide');
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
// Show onboarding sheet
|
// Show onboarding sheet
|
||||||
showModalBottomSheet(
|
final sheetFuture = showModalBottomSheet(
|
||||||
context: navContext,
|
context: navContext,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
isScrollControlled: true,
|
isScrollControlled: true,
|
||||||
@@ -550,6 +559,11 @@ Future<void> _maybeShowOnboarding(Ref ref) async {
|
|||||||
child: const OnboardingSheet(),
|
child: const OnboardingSheet(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
sheetFuture.whenComplete(() {
|
||||||
|
try {
|
||||||
|
ref.read(composerAutofocusEnabledProvider.notifier).set(true);
|
||||||
|
} catch (_) {}
|
||||||
|
});
|
||||||
|
|
||||||
await storage.setOnboardingSeen(true);
|
await storage.setOnboardingSeen(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -190,6 +190,14 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _showOnboarding() {
|
void _showOnboarding() {
|
||||||
|
try {
|
||||||
|
ref.read(composerAutofocusEnabledProvider.notifier).set(false);
|
||||||
|
} catch (_) {}
|
||||||
|
try {
|
||||||
|
FocusManager.instance.primaryFocus?.unfocus();
|
||||||
|
SystemChannels.textInput.invokeMethod('TextInput.hide');
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
@@ -204,7 +212,12 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
|||||||
),
|
),
|
||||||
child: const OnboardingSheet(),
|
child: const OnboardingSheet(),
|
||||||
),
|
),
|
||||||
);
|
).whenComplete(() {
|
||||||
|
if (!mounted) return;
|
||||||
|
try {
|
||||||
|
ref.read(composerAutofocusEnabledProvider.notifier).set(true);
|
||||||
|
} catch (_) {}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _checkAndLoadDemoConversation() async {
|
Future<void> _checkAndLoadDemoConversation() async {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class ConduitThemeExtension extends ThemeExtension<ConduitThemeExtension> {
|
|||||||
Color get inputBorderFocused => surfaces.ring;
|
Color get inputBorderFocused => surfaces.ring;
|
||||||
Color get inputText => tokens.neutralOnSurface;
|
Color get inputText => tokens.neutralOnSurface;
|
||||||
Color get inputPlaceholder =>
|
Color get inputPlaceholder =>
|
||||||
isDark ? tokens.neutralTone80 : tokens.neutralTone60;
|
isDark ? tokens.neutralTone60 : tokens.neutralTone60;
|
||||||
Color get inputError => tokens.statusError60;
|
Color get inputError => tokens.statusError60;
|
||||||
|
|
||||||
Color get cardBackground => surfaces.card;
|
Color get cardBackground => surfaces.card;
|
||||||
|
|||||||
Reference in New Issue
Block a user