restuctured flow
parent
518ab82814
commit
c8674f6bf0
@ -0,0 +1,19 @@
|
|||||||
|
import 'package:get_it/get_it.dart';
|
||||||
|
import 'package:test_sa/modules/cx_module/chat/services/signalr_service.dart';
|
||||||
|
/// Global service locator instance
|
||||||
|
final getIt = GetIt.instance;
|
||||||
|
/// Setup dependency injection
|
||||||
|
Future<void> setupServiceLocator() async {
|
||||||
|
// SignalR Service - ONLY ONE instance for the entire app
|
||||||
|
getIt.registerLazySingleton<SignalRService>(
|
||||||
|
() => SignalRService(),
|
||||||
|
);
|
||||||
|
print('✅ [DI] Service locator initialized');
|
||||||
|
print(' - SignalRService registered as singleton (hashCode: ${getIt<SignalRService>().hashCode})');
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> resetServices() async {
|
||||||
|
await getIt<SignalRService>().reset();
|
||||||
|
print('✅ [DI] All services reset');
|
||||||
|
}
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,111 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:test_sa/modules/cx_module/chat/services/call_manager.dart';
|
||||||
|
import 'package:test_sa/modules/cx_module/chat/services/signalr_service.dart';
|
||||||
|
|
||||||
|
/// App-level initialization service
|
||||||
|
/// Handles initialization of core services like SignalR and CallManager
|
||||||
|
class AppInitializationService {
|
||||||
|
static final AppInitializationService _instance = AppInitializationService._internal();
|
||||||
|
factory AppInitializationService() => _instance;
|
||||||
|
AppInitializationService._internal();
|
||||||
|
|
||||||
|
bool _isInitialized = false;
|
||||||
|
bool get isInitialized => _isInitialized;
|
||||||
|
|
||||||
|
/// Initialize SignalR and CallManager after user login
|
||||||
|
/// This should be called from the landing page after successful login
|
||||||
|
Future<void> initializeAfterLogin({
|
||||||
|
required String userId,
|
||||||
|
required String authToken,
|
||||||
|
required String employeeNumber,
|
||||||
|
String? conversationId,
|
||||||
|
String? moduleId,
|
||||||
|
String? referenceId,
|
||||||
|
}) async {
|
||||||
|
if (_isInitialized) {
|
||||||
|
log('⚠️ [APP INIT] Already initialized, skipping...', name: 'AppInitializationService');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
log('═══════════════════════════════════════════', name: 'AppInitializationService');
|
||||||
|
log('🚀 [APP INIT] Starting app initialization...', name: 'AppInitializationService');
|
||||||
|
log(' User ID: $userId', name: 'AppInitializationService');
|
||||||
|
log(' Employee Number: $employeeNumber', name: 'AppInitializationService');
|
||||||
|
log('═══════════════════════════════════════════', name: 'AppInitializationService');
|
||||||
|
|
||||||
|
// Step 1: Initialize SignalR Service
|
||||||
|
log('🔌 [APP INIT] Step 1: Initializing SignalR Service...', name: 'AppInitializationService');
|
||||||
|
final signalRService = SignalRService();
|
||||||
|
|
||||||
|
final connected = await signalRService.initialize(
|
||||||
|
userId: userId,
|
||||||
|
authToken: authToken,
|
||||||
|
conversationId: conversationId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!connected) {
|
||||||
|
throw Exception('Failed to initialize SignalR connection');
|
||||||
|
}
|
||||||
|
log('✅ [APP INIT] SignalR Service initialized', name: 'AppInitializationService');
|
||||||
|
log(' Connection State: ${signalRService.connectionState}', name: 'AppInitializationService');
|
||||||
|
log(' Connection ID: ${signalRService.connectionId ?? "NULL"}', name: 'AppInitializationService');
|
||||||
|
|
||||||
|
// Step 2: Initialize CallManager
|
||||||
|
log('📞 [APP INIT] Step 2: Initializing CallManager...', name: 'AppInitializationService');
|
||||||
|
await CallManager().initialize(
|
||||||
|
userId: userId,
|
||||||
|
authToken: authToken,
|
||||||
|
conversationId: conversationId,
|
||||||
|
moduleId: moduleId,
|
||||||
|
referenceId: referenceId,
|
||||||
|
employeeNumber: employeeNumber,
|
||||||
|
);
|
||||||
|
log('✅ [APP INIT] CallManager initialized', name: 'AppInitializationService');
|
||||||
|
|
||||||
|
_isInitialized = true;
|
||||||
|
|
||||||
|
log('═══════════════════════════════════════════', name: 'AppInitializationService');
|
||||||
|
log('✅ [APP INIT] App initialization complete!', name: 'AppInitializationService');
|
||||||
|
log(' ✅ SignalR Service: Ready', name: 'AppInitializationService');
|
||||||
|
log(' ✅ CallManager: Ready', name: 'AppInitializationService');
|
||||||
|
log(' ✅ WebRTC: Will initialize on first call', name: 'AppInitializationService');
|
||||||
|
log('═══════════════════════════════════════════', name: 'AppInitializationService');
|
||||||
|
|
||||||
|
} catch (e, stackTrace) {
|
||||||
|
log('❌ [APP INIT] Initialization failed: $e',
|
||||||
|
name: 'AppInitializationService', error: e, stackTrace: stackTrace);
|
||||||
|
_isInitialized = false;
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reset initialization state (for logout)
|
||||||
|
Future<void> reset() async {
|
||||||
|
log('🔄 [APP INIT] Resetting app initialization...', name: 'AppInitializationService');
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Reset CallManager
|
||||||
|
await CallManager().reset();
|
||||||
|
|
||||||
|
// Disconnect SignalR
|
||||||
|
await SignalRService().disconnect();
|
||||||
|
|
||||||
|
_isInitialized = false;
|
||||||
|
|
||||||
|
log('✅ [APP INIT] Reset complete', name: 'AppInitializationService');
|
||||||
|
} catch (e) {
|
||||||
|
log('⚠️ [APP INIT] Error during reset: $e', name: 'AppInitializationService');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if services are ready for calling
|
||||||
|
bool areServicesReady() {
|
||||||
|
final signalRConnected = SignalRService().isConnected;
|
||||||
|
final callManagerInitialized = CallManager().isCallInProgress || _isInitialized;
|
||||||
|
|
||||||
|
return signalRConnected && _isInitialized;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -1,176 +0,0 @@
|
|||||||
name: test_sa
|
|
||||||
description: medical app to manage medical devices issues
|
|
||||||
|
|
||||||
# The following line prevents the package from being accidentally published to
|
|
||||||
# pub.dev using `flutter pub publish`. This is preferred for private packages.
|
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|
||||||
|
|
||||||
# The following defines the version and build number for your application.
|
|
||||||
# A version number is three numbers separated by dots, like 1.2.43
|
|
||||||
# followed by an optional build number separated by a +.
|
|
||||||
# Both the version and the builder number may be overridden in flutter
|
|
||||||
# build by specifying --build-name and --build-number, respectively.
|
|
||||||
# In Android, build-name is used as versionName while build-number used as versionCode.
|
|
||||||
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
|
|
||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
|
||||||
# Read more about iOS versioning at
|
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
|
||||||
version: 1.7.8+44
|
|
||||||
|
|
||||||
environment:
|
|
||||||
sdk: ">=3.5.0 <4.0.0"
|
|
||||||
|
|
||||||
#localization_dir: assets\translations
|
|
||||||
|
|
||||||
# Dependencies specify other packages that your package needs in order to work.
|
|
||||||
# To automatically upgrade your package dependencies to the latest versions
|
|
||||||
# consider running `flutter pub upgrade --major-versions`. Alternatively,
|
|
||||||
# dependencies can be manually updated by changing the version numbers below to
|
|
||||||
# the latest version available on pub.dev. To see which dependencies have newer
|
|
||||||
# versions available, run `flutter pub outdated`.
|
|
||||||
dependencies:
|
|
||||||
flutter:
|
|
||||||
sdk: flutter
|
|
||||||
flutter_localizations:
|
|
||||||
sdk: flutter
|
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
|
||||||
cupertino_icons: ^1.0.5
|
|
||||||
font_awesome_flutter: ^10.12.0
|
|
||||||
http: ^1.6.0
|
|
||||||
provider: ^6.1.5+1
|
|
||||||
shared_preferences: ^2.5.4
|
|
||||||
fluttertoast: ^9.0.0
|
|
||||||
image_picker: ^1.2.1
|
|
||||||
url_launcher: ^6.3.2
|
|
||||||
flutter_launcher_icons: ^0.14.4
|
|
||||||
package_info_plus: ^8.3.1
|
|
||||||
share_plus: ^10.1.4
|
|
||||||
flutter_local_notifications: ^17.2.4
|
|
||||||
cached_network_image: ^3.4.1
|
|
||||||
carousel_slider: ^5.1.2
|
|
||||||
intl: ^0.20.2
|
|
||||||
nfc_manager: ^4.2.1
|
|
||||||
flutter_typeahead: ^5.2.0
|
|
||||||
speech_to_text: ^7.3.0
|
|
||||||
firebase_core: ^3.15.2
|
|
||||||
firebase_messaging: ^15.2.10
|
|
||||||
qr_code_scanner_plus: ^2.1.1
|
|
||||||
flutter_sound: ^9.30.0
|
|
||||||
permission_handler: ^11.4.0
|
|
||||||
rive: ^0.14.4
|
|
||||||
another_flushbar: ^1.12.32
|
|
||||||
pinput: ^6.0.2
|
|
||||||
audioplayers: ^6.6.0
|
|
||||||
mobile_scanner: ^7.2.0
|
|
||||||
|
|
||||||
flare_flutter:
|
|
||||||
git:
|
|
||||||
url: https://github.com/mbfakourii/Flare-Flutter.git
|
|
||||||
path: flare_flutter
|
|
||||||
ref: remove_hashValues
|
|
||||||
|
|
||||||
signature: ^5.5.0
|
|
||||||
flutter_svg: ^2.2.3
|
|
||||||
file_picker: ^10.3.10
|
|
||||||
record_mp3_plus: ^1.4.1
|
|
||||||
path_provider: ^2.1.5
|
|
||||||
open_file: ^3.5.11
|
|
||||||
localization: ^2.1.0
|
|
||||||
dotted_border: ^2.1.0
|
|
||||||
lottie: ^3.3.2
|
|
||||||
shimmer: ^3.0.0
|
|
||||||
date_picker_timeline: ^1.2.6
|
|
||||||
flutter_advanced_switch: ^3.0.1
|
|
||||||
table_calendar: ^3.0.8
|
|
||||||
image_cropper: ^8.1.0
|
|
||||||
flutter_timezone: ^3.0.1
|
|
||||||
device_calendar: ^4.3.3
|
|
||||||
pie_chart: ^5.4.0
|
|
||||||
|
|
||||||
badges: ^3.1.1
|
|
||||||
# buttons_tabbar: ^1.1.2
|
|
||||||
flutter_custom_month_picker: ^0.1.3
|
|
||||||
local_auth: ^2.3.0
|
|
||||||
google_api_availability: ^5.0.1
|
|
||||||
huawei_push: ^6.14.0+300
|
|
||||||
huawei_location: ^6.16.0+300
|
|
||||||
geolocator: ^9.0.2
|
|
||||||
wifi_iot: ^0.3.19+2
|
|
||||||
just_audio: ^0.9.46
|
|
||||||
safe_device: ^1.3.8
|
|
||||||
toggle_switch: ^2.3.0
|
|
||||||
tree_view_flutter: ^1.0.2
|
|
||||||
audio_waveforms: ^1.3.0
|
|
||||||
signalr_netcore: ^1.4.4
|
|
||||||
ellipsized_text: ^2.0.0
|
|
||||||
local_auth_darwin: ^1.4.0
|
|
||||||
haptic_feedback: ^0.6.4+3
|
|
||||||
sn_progress_dialog: ^1.2.0
|
|
||||||
flutter_webrtc: ^1.5.2
|
|
||||||
flutter_callkit_incoming: ^3.1.3
|
|
||||||
uuid: ^4.5.3
|
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
|
||||||
flutter_test:
|
|
||||||
sdk: flutter
|
|
||||||
dependency_overrides:
|
|
||||||
sqflite_android: 2.4.1
|
|
||||||
win32: ^5.5.4
|
|
||||||
flutter_lints: ^2.0.0
|
|
||||||
|
|
||||||
flutter_icons:
|
|
||||||
ios: true
|
|
||||||
android: true
|
|
||||||
image_path_ios: "assets/images/app_logo.jpg"
|
|
||||||
image_path_android: "assets/images/app_logo.jpg"
|
|
||||||
|
|
||||||
# The following section is specific to Flutter.
|
|
||||||
flutter:
|
|
||||||
config:
|
|
||||||
enable-swift-package-manager: false
|
|
||||||
# The following line ensures that the Material Icons font is
|
|
||||||
# included with your application, so that you can use the icons in
|
|
||||||
# the material Icons class.
|
|
||||||
generate: true
|
|
||||||
uses-material-design: true
|
|
||||||
assets:
|
|
||||||
- assets/
|
|
||||||
- assets/audio/
|
|
||||||
- assets/images/
|
|
||||||
- assets/images/dashboard/
|
|
||||||
- assets/images/wo/
|
|
||||||
- assets/lottie/
|
|
||||||
- assets/subtitles/
|
|
||||||
- assets/rives/
|
|
||||||
fonts:
|
|
||||||
- family: Swiss
|
|
||||||
fonts:
|
|
||||||
- asset: assets/fonts/Gotham_Rounded_Light.otf
|
|
||||||
weight: 300
|
|
||||||
- asset: assets/fonts/Gotham_Rounded_Book.otf
|
|
||||||
weight: 400
|
|
||||||
- asset: assets/fonts/Gotham_Rounded_Bold.otf
|
|
||||||
weight: 700
|
|
||||||
- family: Poppins
|
|
||||||
fonts:
|
|
||||||
- asset: assets/fonts/poppins/Poppins-Black.ttf
|
|
||||||
weight: 900
|
|
||||||
- asset: assets/fonts/poppins/Poppins-ExtraBold.ttf
|
|
||||||
weight: 800
|
|
||||||
- asset: assets/fonts/poppins/Poppins-Bold.ttf
|
|
||||||
weight: 700
|
|
||||||
- asset: assets/fonts/poppins/Poppins-SemiBold.ttf
|
|
||||||
weight: 600
|
|
||||||
- asset: assets/fonts/poppins/Poppins-Medium.ttf
|
|
||||||
weight: 500
|
|
||||||
- asset: assets/fonts/poppins/Poppins-Regular.ttf
|
|
||||||
weight: 400
|
|
||||||
- asset: assets/fonts/poppins/Poppins-Light.ttf
|
|
||||||
weight: 300
|
|
||||||
- asset: assets/fonts/poppins/Poppins-ExtraLight.ttf
|
|
||||||
weight: 200
|
|
||||||
- asset: assets/fonts/poppins/Poppins-Thin.ttf
|
|
||||||
weight: 100
|
|
||||||
Loading…
Reference in New Issue