api update and flutter update
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'core/constants/app_constants.dart';
|
||||
import 'core/network/api_client.dart';
|
||||
import 'core/storage/secure_storage.dart';
|
||||
import 'core/services/tts_service.dart';
|
||||
import 'core/services/stt_service.dart';
|
||||
import 'core/services/voice_command_handler.dart';
|
||||
import 'core/services/haptic_service.dart';
|
||||
|
||||
final sl = GetIt.instance;
|
||||
|
||||
Future<void> initDependencies() async {
|
||||
// ── Core singletons ──────────────────────────────────────────────────────
|
||||
sl.registerLazySingleton<SecureStorage>(() => SecureStorage());
|
||||
sl.registerLazySingleton<ApiClient>(() => ApiClient(sl<SecureStorage>()));
|
||||
|
||||
sl.registerLazySingleton<TtsService>(() => TtsService());
|
||||
sl.registerLazySingleton<SttService>(() => SttService());
|
||||
sl.registerLazySingleton<HapticService>(() => HapticService());
|
||||
sl.registerLazySingleton<VoiceCommandHandler>(
|
||||
() => VoiceCommandHandler(sl<SttService>(), sl<TtsService>()),
|
||||
);
|
||||
|
||||
// ── Init ApiClient if serverUrl already saved ─────────────────────────────
|
||||
final serverUrl = await AppConstants.getServerUrl();
|
||||
if (serverUrl != null && serverUrl.isNotEmpty) {
|
||||
await sl<ApiClient>().init(serverUrl);
|
||||
}
|
||||
|
||||
// ── Init TTS ──────────────────────────────────────────────────────────────
|
||||
await sl<TtsService>().init();
|
||||
|
||||
// ── Init STT ──────────────────────────────────────────────────────────────
|
||||
await sl<SttService>().init();
|
||||
sl<VoiceCommandHandler>().loadDefaultCommands();
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'core/storage/secure_storage.dart';
|
||||
import 'core/constants/app_constants.dart';
|
||||
import 'injection_container.dart';
|
||||
|
||||
// Auth
|
||||
import 'features/server_connect/presentation/screens/server_connect_screen.dart';
|
||||
import 'features/auth/presentation/screens/splash_screen.dart';
|
||||
import 'features/auth/presentation/screens/login_screen.dart';
|
||||
import 'features/auth/presentation/screens/register_screen.dart';
|
||||
|
||||
// User shell + screens
|
||||
import 'shared/widgets/user_shell.dart';
|
||||
import 'features/walk_guide/presentation/screens/walk_guide_screen.dart';
|
||||
import 'features/sos/presentation/screens/sos_screen.dart';
|
||||
import 'features/activity_log/presentation/screens/activity_log_screen.dart';
|
||||
import 'features/notifications/presentation/screens/notification_screen.dart';
|
||||
import 'features/navigation_mode/presentation/screens/navigation_mode_screen.dart';
|
||||
import 'features/settings/presentation/screens/user_settings_screen.dart';
|
||||
|
||||
// Guardian shell + screens
|
||||
import 'shared/widgets/guardian_shell.dart';
|
||||
import 'features/guardian/presentation/screens/guardian_dashboard_screen.dart';
|
||||
import 'features/guardian/presentation/screens/guardian_map_screen.dart';
|
||||
import 'features/guardian/presentation/screens/guardian_activity_log_screen.dart';
|
||||
import 'features/guardian/presentation/screens/guardian_send_notif_screen.dart';
|
||||
import 'features/guardian/presentation/screens/guardian_ai_config_screen.dart';
|
||||
import 'features/guardian/presentation/screens/guardian_voice_cmd_screen.dart';
|
||||
import 'features/guardian/presentation/screens/guardian_shortcut_screen.dart';
|
||||
import 'features/guardian/presentation/screens/guardian_geofence_screen.dart';
|
||||
import 'features/pairing/presentation/screens/guardian_pairing_screen.dart';
|
||||
import 'features/pairing/presentation/screens/user_pairing_screen.dart';
|
||||
|
||||
// Call
|
||||
import 'features/call/presentation/screens/call_screen.dart';
|
||||
import 'features/call/presentation/screens/incoming_call_screen.dart';
|
||||
|
||||
final GoRouter appRouter = GoRouter(
|
||||
initialLocation: '/splash',
|
||||
redirect: (context, state) async {
|
||||
final serverUrl = await AppConstants.getServerUrl();
|
||||
final path = state.matchedLocation;
|
||||
|
||||
// 1. No server URL → must go to server-connect
|
||||
if (serverUrl == null || serverUrl.isEmpty) {
|
||||
if (path != '/server-connect') return '/server-connect';
|
||||
return null;
|
||||
}
|
||||
|
||||
// 2. Already on server-connect but has URL → splash
|
||||
if (path == '/server-connect') return '/splash';
|
||||
|
||||
return null;
|
||||
},
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/server-connect',
|
||||
builder: (context, state) => const ServerConnectScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/splash',
|
||||
builder: (context, state) => const SplashScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/login',
|
||||
builder: (context, state) => const LoginScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/register',
|
||||
builder: (context, state) => const RegisterScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/incoming-call',
|
||||
builder: (context, state) => const IncomingCallScreen(),
|
||||
),
|
||||
|
||||
// ── USER SHELL ──────────────────────────────────────────────────────────
|
||||
ShellRoute(
|
||||
builder: (context, state, child) => UserShell(child: child),
|
||||
routes: [
|
||||
GoRoute(path: '/user/walkguide', builder: (c, s) => const WalkGuideScreen()),
|
||||
GoRoute(path: '/user/sos', builder: (c, s) => const SosScreen()),
|
||||
GoRoute(path: '/user/activity', builder: (c, s) => const ActivityLogScreen()),
|
||||
GoRoute(path: '/user/notifications',builder: (c, s) => const NotificationScreen()),
|
||||
GoRoute(path: '/user/navigation', builder: (c, s) => const NavigationModeScreen()),
|
||||
GoRoute(path: '/user/settings', builder: (c, s) => const UserSettingsScreen()),
|
||||
GoRoute(path: '/user/pairing', builder: (c, s) => const UserPairingScreen()),
|
||||
GoRoute(path: '/user/call', builder: (c, s) => const CallScreen()),
|
||||
],
|
||||
),
|
||||
|
||||
// ── GUARDIAN SHELL ──────────────────────────────────────────────────────
|
||||
ShellRoute(
|
||||
builder: (context, state, child) => GuardianShell(child: child),
|
||||
routes: [
|
||||
GoRoute(path: '/guardian/dashboard', builder: (c, s) => const GuardianDashboardScreen()),
|
||||
GoRoute(path: '/guardian/map', builder: (c, s) => const GuardianMapScreen()),
|
||||
GoRoute(path: '/guardian/logs', builder: (c, s) => const GuardianActivityLogScreen()),
|
||||
GoRoute(path: '/guardian/send-notif', builder: (c, s) => const GuardianSendNotifScreen()),
|
||||
GoRoute(path: '/guardian/ai-config', builder: (c, s) => const GuardianAiConfigScreen()),
|
||||
GoRoute(path: '/guardian/voice-cmd', builder: (c, s) => const GuardianVoiceCmdScreen()),
|
||||
GoRoute(path: '/guardian/shortcuts', builder: (c, s) => const GuardianShortcutScreen()),
|
||||
GoRoute(path: '/guardian/geofence', builder: (c, s) => const GuardianGeofenceScreen()),
|
||||
GoRoute(path: '/guardian/pairing', builder: (c, s) => const GuardianPairingScreen()),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
Reference in New Issue
Block a user