From 571a4ff28b66a2a4aa5a7f8b1b3637a0a436fbc2 Mon Sep 17 00:00:00 2001 From: Jordy de Jonghe Date: Thu, 10 Oct 2024 11:35:56 +0200 Subject: [PATCH] #349: fix mocks --- ios/Podfile.lock | 28 ++ ios/Runner.xcodeproj/project.pbxproj | 6 + lib/di/injectable.config.dart | 268 +++++++++--------- lib/di/injectable.dart | 4 + .../remote_config_repository.dart | 10 +- lib/viewmodel/splash/splash_viewmodel.dart | 4 + .../splash/splash_viewmodel_test.dart | 11 +- .../splash/splash_viewmodel_test.mocks.dart | 87 ++++++ 8 files changed, 283 insertions(+), 135 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 03a44346..ba42cc57 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -14,6 +14,9 @@ PODS: - Firebase/Crashlytics (10.25.0): - Firebase/CoreOnly - FirebaseCrashlytics (~> 10.25.0) + - Firebase/RemoteConfig (10.25.0): + - Firebase/CoreOnly + - FirebaseRemoteConfig (~> 10.25.0) - firebase_analytics (10.10.7): - Firebase/Analytics (= 10.25.0) - firebase_core @@ -25,6 +28,12 @@ PODS: - Firebase/Crashlytics (= 10.25.0) - firebase_core - Flutter + - firebase_remote_config (4.4.7): + - Firebase/RemoteConfig (= 10.25.0) + - firebase_core + - Flutter + - FirebaseABTesting (10.29.0): + - FirebaseCore (~> 10.0) - FirebaseAnalytics (10.25.0): - FirebaseAnalytics/AdIdSupport (= 10.25.0) - FirebaseCore (~> 10.0) @@ -65,6 +74,14 @@ PODS: - GoogleUtilities/Environment (~> 7.8) - GoogleUtilities/UserDefaults (~> 7.8) - PromisesObjC (~> 2.1) + - FirebaseRemoteConfig (10.25.0): + - FirebaseABTesting (~> 10.0) + - FirebaseCore (~> 10.0) + - FirebaseInstallations (~> 10.0) + - FirebaseRemoteConfigInterop (~> 10.23) + - FirebaseSharedSwift (~> 10.0) + - GoogleUtilities/Environment (~> 7.8) + - "GoogleUtilities/NSData+zlib (~> 7.8)" - FirebaseRemoteConfigInterop (10.29.0) - FirebaseSessions (10.29.0): - FirebaseCore (~> 10.5) @@ -75,6 +92,7 @@ PODS: - GoogleUtilities/UserDefaults (~> 7.13) - nanopb (< 2.30911.0, >= 2.30908.0) - PromisesSwift (~> 2.1) + - FirebaseSharedSwift (10.29.0) - Flutter (1.0.0) - flutter_secure_storage (6.0.0): - Flutter @@ -175,6 +193,7 @@ DEPENDENCIES: - firebase_analytics (from `.symlinks/plugins/firebase_analytics/ios`) - firebase_core (from `.symlinks/plugins/firebase_core/ios`) - firebase_crashlytics (from `.symlinks/plugins/firebase_crashlytics/ios`) + - firebase_remote_config (from `.symlinks/plugins/firebase_remote_config/ios`) - Flutter (from `Flutter`) - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) @@ -186,14 +205,17 @@ DEPENDENCIES: SPEC REPOS: trunk: - Firebase + - FirebaseABTesting - FirebaseAnalytics - FirebaseCore - FirebaseCoreExtension - FirebaseCoreInternal - FirebaseCrashlytics - FirebaseInstallations + - FirebaseRemoteConfig - FirebaseRemoteConfigInterop - FirebaseSessions + - FirebaseSharedSwift - GoogleAppMeasurement - GoogleDataTransport - GoogleUtilities @@ -214,6 +236,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/firebase_core/ios" firebase_crashlytics: :path: ".symlinks/plugins/firebase_crashlytics/ios" + firebase_remote_config: + :path: ".symlinks/plugins/firebase_remote_config/ios" Flutter: :path: Flutter flutter_secure_storage: @@ -236,14 +260,18 @@ SPEC CHECKSUMS: firebase_analytics: cc06e24d6a2343c44f845b3112143db72d10ef78 firebase_core: a626d00494efa398e7c54f25f1454a64c8abf197 firebase_crashlytics: 17e856fabec68d993662abaf2f6fe2413f0abece + firebase_remote_config: 7b05c80210ab558c80f7a756681022b4ee98eea0 + FirebaseABTesting: d87f56707159bae64e269757a6e963d490f2eebe FirebaseAnalytics: ec00fe8b93b41dc6fe4a28784b8e51da0647a248 FirebaseCore: 7ec4d0484817f12c3373955bc87762d96842d483 FirebaseCoreExtension: 705ca5b14bf71d2564a0ddc677df1fc86ffa600f FirebaseCoreInternal: df84dd300b561c27d5571684f389bf60b0a5c934 FirebaseCrashlytics: 4b96efb0ce73b38b2a85e8b8bd1bd8f63f09d015 FirebaseInstallations: 913cf60d0400ebd5d6b63a28b290372ab44590dd + FirebaseRemoteConfig: 9f3935cefecd85d5b312192117f444957de24a75 FirebaseRemoteConfigInterop: 6efda51fb5e2f15b16585197e26eaa09574e8a4d FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc + FirebaseSharedSwift: 20530f495084b8d840f78a100d8c5ee613375f6e Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 flutter_secure_storage: d33dac7ae2ea08509be337e775f6b59f1ff45f12 GoogleAppMeasurement: 9abf64b682732fed36da827aa2a68f0221fd2356 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index c57d596f..e857b1b4 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -298,13 +298,16 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/FirebaseABTesting/FirebaseABTesting.framework", "${BUILT_PRODUCTS_DIR}/FirebaseCore/FirebaseCore.framework", "${BUILT_PRODUCTS_DIR}/FirebaseCoreExtension/FirebaseCoreExtension.framework", "${BUILT_PRODUCTS_DIR}/FirebaseCoreInternal/FirebaseCoreInternal.framework", "${BUILT_PRODUCTS_DIR}/FirebaseCrashlytics/FirebaseCrashlytics.framework", "${BUILT_PRODUCTS_DIR}/FirebaseInstallations/FirebaseInstallations.framework", + "${BUILT_PRODUCTS_DIR}/FirebaseRemoteConfig/FirebaseRemoteConfig.framework", "${BUILT_PRODUCTS_DIR}/FirebaseRemoteConfigInterop/FirebaseRemoteConfigInterop.framework", "${BUILT_PRODUCTS_DIR}/FirebaseSessions/FirebaseSessions.framework", + "${BUILT_PRODUCTS_DIR}/FirebaseSharedSwift/FirebaseSharedSwift.framework", "${BUILT_PRODUCTS_DIR}/GoogleDataTransport/GoogleDataTransport.framework", "${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework", "${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework", @@ -323,13 +326,16 @@ ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseABTesting.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCore.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCoreExtension.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCoreInternal.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseCrashlytics.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseInstallations.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseRemoteConfig.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseRemoteConfigInterop.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseSessions.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseSharedSwift.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleDataTransport.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBLPromises.framework", diff --git a/lib/di/injectable.config.dart b/lib/di/injectable.config.dart index 93cc267f..35628d0e 100644 --- a/lib/di/injectable.config.dart +++ b/lib/di/injectable.config.dart @@ -8,77 +8,80 @@ // coverage:ignore-file // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:dio/dio.dart' as _i44; +import 'package:dio/dio.dart' as _i46; import 'package:drift/drift.dart' as _i6; import 'package:firebase_analytics/firebase_analytics.dart' as _i8; -import 'package:flutter_secure_storage/flutter_secure_storage.dart' as _i9; +import 'package:firebase_remote_config/firebase_remote_config.dart' as _i9; +import 'package:flutter_secure_storage/flutter_secure_storage.dart' as _i10; import 'package:flutter_template/database/flutter_template_database.dart' - as _i10; -import 'package:flutter_template/database/todo/todo_dao_storage.dart' as _i20; -import 'package:flutter_template/di/injectable.dart' as _i46; -import 'package:flutter_template/navigator/main_navigator.dart' as _i13; -import 'package:flutter_template/navigator/onboarding_navigator.dart' as _i33; + as _i11; +import 'package:flutter_template/database/todo/todo_dao_storage.dart' as _i22; +import 'package:flutter_template/di/injectable.dart' as _i48; +import 'package:flutter_template/navigator/main_navigator.dart' as _i14; +import 'package:flutter_template/navigator/onboarding_navigator.dart' as _i35; import 'package:flutter_template/repository/analytics/firebase_analytics_repository.dart' - as _i24; + as _i26; import 'package:flutter_template/repository/debug/debug_repository.dart' - as _i28; -import 'package:flutter_template/repository/locale/locale_repository.dart' as _i30; +import 'package:flutter_template/repository/locale/locale_repository.dart' + as _i32; import 'package:flutter_template/repository/login/login_repository.dart' - as _i31; + as _i33; import 'package:flutter_template/repository/refresh/refresh_repository.dart' - as _i34; + as _i36; import 'package:flutter_template/repository/remote_config/remote_config.dart' - as _i16; + as _i17; +import 'package:flutter_template/repository/remote_config/remote_config_repository.dart' + as _i18; import 'package:flutter_template/repository/secure_storage/auth/auth_storage.dart' - as _i27; + as _i29; import 'package:flutter_template/repository/secure_storage/secure_storage.dart' - as _i17; + as _i19; import 'package:flutter_template/repository/shared_prefs/local/local_storage.dart' - as _i29; -import 'package:flutter_template/repository/todo/todo_repository.dart' as _i26; + as _i31; +import 'package:flutter_template/repository/todo/todo_repository.dart' as _i28; import 'package:flutter_template/util/cache/cache_controller.dart' as _i4; import 'package:flutter_template/util/cache/cache_controlling.dart' as _i3; import 'package:flutter_template/util/interceptor/network_auth_interceptor.dart' - as _i32; + as _i34; import 'package:flutter_template/util/interceptor/network_error_interceptor.dart' - as _i14; -import 'package:flutter_template/util/interceptor/network_log_interceptor.dart' as _i15; +import 'package:flutter_template/util/interceptor/network_log_interceptor.dart' + as _i16; import 'package:flutter_template/util/interceptor/network_refresh_interceptor.dart' - as _i42; + as _i44; import 'package:flutter_template/util/locale/localization_overrides.dart' - as _i11; -import 'package:flutter_template/util/locale/localization_overrides_impl.dart' as _i12; +import 'package:flutter_template/util/locale/localization_overrides_impl.dart' + as _i13; import 'package:flutter_template/util/snackbar/error_util.dart' as _i7; -import 'package:flutter_template/util/theme/theme_config.dart' as _i19; +import 'package:flutter_template/util/theme/theme_config.dart' as _i21; import 'package:flutter_template/viewmodel/debug/debug_platform_selector_viewmodel.dart' - as _i23; + as _i25; import 'package:flutter_template/viewmodel/debug/debug_theme_selector_viewmodel.dart' - as _i43; -import 'package:flutter_template/viewmodel/debug/debug_viewmodel.dart' as _i39; + as _i45; +import 'package:flutter_template/viewmodel/debug/debug_viewmodel.dart' as _i41; import 'package:flutter_template/viewmodel/global/global_viewmodel.dart' - as _i40; + as _i42; import 'package:flutter_template/viewmodel/license/license_viewmodel.dart' - as _i25; -import 'package:flutter_template/viewmodel/login/login_viewmodel.dart' as _i41; + as _i27; +import 'package:flutter_template/viewmodel/login/login_viewmodel.dart' as _i43; import 'package:flutter_template/viewmodel/permission/analytics_permission_viewmodel.dart' - as _i38; + as _i40; import 'package:flutter_template/viewmodel/splash/splash_viewmodel.dart' - as _i35; + as _i37; import 'package:flutter_template/viewmodel/todo/todo_add/todo_add_viewmodel.dart' - as _i36; + as _i38; import 'package:flutter_template/viewmodel/todo/todo_list/todo_list_viewmodel.dart' - as _i37; + as _i39; import 'package:flutter_template/webservice/todo/todo_dummy_service.dart' - as _i22; -import 'package:flutter_template/webservice/todo/todo_service.dart' as _i21; -import 'package:flutter_template/webservice/todo/todo_webservice.dart' as _i45; + as _i24; +import 'package:flutter_template/webservice/todo/todo_service.dart' as _i23; +import 'package:flutter_template/webservice/todo/todo_webservice.dart' as _i47; import 'package:get_it/get_it.dart' as _i1; import 'package:icapps_architecture/icapps_architecture.dart' as _i5; import 'package:injectable/injectable.dart' as _i2; -import 'package:shared_preferences/shared_preferences.dart' as _i18; +import 'package:shared_preferences/shared_preferences.dart' as _i20; const String _dummy = 'dummy'; const String _dev = 'dev'; @@ -106,125 +109,130 @@ extension GetItInjectableX on _i1.GetIt { gh.lazySingleton<_i7.ErrorUtil>(() => _i7.ErrorUtil()); gh.lazySingleton<_i8.FirebaseAnalytics>( () => registerModule.provideFirebaseAnalytics()); - gh.lazySingleton<_i9.FlutterSecureStorage>(() => registerModule.storage()); - gh.lazySingleton<_i10.FlutterTemplateDatabase>(() => registerModule + gh.lazySingleton<_i9.FirebaseRemoteConfig>( + () => registerModule.provideFirebaseRemoteConfig()); + gh.lazySingleton<_i10.FlutterSecureStorage>(() => registerModule.storage()); + gh.lazySingleton<_i11.FlutterTemplateDatabase>(() => registerModule .provideFlutterTemplateDatabase(gh<_i6.DatabaseConnection>())); - gh.lazySingleton<_i11.LocalizationOverrides>( - () => _i12.LocalizationOverridesImpl()); - gh.lazySingleton<_i13.MainNavigator>( - () => _i13.MainNavigator(gh<_i7.ErrorUtil>())); - gh.singleton<_i14.NetworkErrorInterceptor>( - () => _i14.NetworkErrorInterceptor(gh<_i5.ConnectivityHelper>())); - gh.singleton<_i15.NetworkLogInterceptor>( - () => _i15.NetworkLogInterceptor()); - gh.lazySingleton<_i16.RemoteConfig>(() => _i16.RemoteConfig()); - gh.lazySingleton<_i17.SecureStorage>( - () => _i17.SecureStorage(gh<_i9.FlutterSecureStorage>())); - await gh.singletonAsync<_i18.SharedPreferences>( + gh.lazySingleton<_i12.LocalizationOverrides>( + () => _i13.LocalizationOverridesImpl()); + gh.lazySingleton<_i14.MainNavigator>( + () => _i14.MainNavigator(gh<_i7.ErrorUtil>())); + gh.singleton<_i15.NetworkErrorInterceptor>( + () => _i15.NetworkErrorInterceptor(gh<_i5.ConnectivityHelper>())); + gh.singleton<_i16.NetworkLogInterceptor>( + () => _i16.NetworkLogInterceptor()); + gh.lazySingleton<_i17.RemoteConfig>(() => _i17.RemoteConfig()); + gh.lazySingleton<_i18.RemoteConfigRepository>( + () => _i18.RemoteConfigRepository(gh<_i9.FirebaseRemoteConfig>())); + gh.lazySingleton<_i19.SecureStorage>( + () => _i19.SecureStorage(gh<_i10.FlutterSecureStorage>())); + await gh.singletonAsync<_i20.SharedPreferences>( () => registerModule.prefs(), preResolve: true, ); - gh.lazySingleton<_i19.ThemeConfigUtil>(() => _i19.ThemeConfigUtil()); - gh.lazySingleton<_i20.TodoDaoStorage>( - () => _i20.TodoDaoStorage(gh<_i10.FlutterTemplateDatabase>())); - gh.singleton<_i21.TodoService>( - () => _i22.TodoDummyService(), + gh.lazySingleton<_i21.ThemeConfigUtil>(() => _i21.ThemeConfigUtil()); + gh.lazySingleton<_i22.TodoDaoStorage>( + () => _i22.TodoDaoStorage(gh<_i11.FlutterTemplateDatabase>())); + gh.singleton<_i23.TodoService>( + () => _i24.TodoDummyService(), registerFor: {_dummy}, ); - gh.factory<_i23.DebugPlatformSelectorViewModel>( - () => _i23.DebugPlatformSelectorViewModel(gh<_i13.MainNavigator>())); - gh.lazySingleton<_i24.FireBaseAnalyticsRepository>( - () => _i24.FireBaseAnalyticsRepository(gh<_i8.FirebaseAnalytics>())); - gh.factory<_i25.LicenseViewModel>( - () => _i25.LicenseViewModel(gh<_i13.MainNavigator>())); + gh.factory<_i25.DebugPlatformSelectorViewModel>( + () => _i25.DebugPlatformSelectorViewModel(gh<_i14.MainNavigator>())); + gh.lazySingleton<_i26.FireBaseAnalyticsRepository>( + () => _i26.FireBaseAnalyticsRepository(gh<_i8.FirebaseAnalytics>())); + gh.factory<_i27.LicenseViewModel>( + () => _i27.LicenseViewModel(gh<_i14.MainNavigator>())); gh.lazySingleton<_i5.SharedPreferenceStorage>( - () => registerModule.sharedPreferences(gh<_i18.SharedPreferences>())); + () => registerModule.sharedPreferences(gh<_i20.SharedPreferences>())); gh.lazySingleton<_i5.SimpleKeyValueStorage>( () => registerModule.keyValueStorage( gh<_i5.SharedPreferenceStorage>(), - gh<_i17.SecureStorage>(), + gh<_i19.SecureStorage>(), )); - gh.lazySingleton<_i26.TodoRepository>(() => _i26.TodoRepository( - gh<_i21.TodoService>(), - gh<_i20.TodoDaoStorage>(), + gh.lazySingleton<_i28.TodoRepository>(() => _i28.TodoRepository( + gh<_i23.TodoService>(), + gh<_i22.TodoDaoStorage>(), )); - gh.lazySingleton<_i27.AuthStorage>( - () => _i27.AuthStorage(gh<_i5.SimpleKeyValueStorage>())); - gh.lazySingleton<_i28.DebugRepository>( - () => _i28.DebugRepository(gh<_i5.SharedPreferenceStorage>())); - gh.lazySingleton<_i29.LocalStorage>(() => _i29.LocalStorage( - gh<_i27.AuthStorage>(), + gh.lazySingleton<_i29.AuthStorage>( + () => _i29.AuthStorage(gh<_i5.SimpleKeyValueStorage>())); + gh.lazySingleton<_i30.DebugRepository>( + () => _i30.DebugRepository(gh<_i5.SharedPreferenceStorage>())); + gh.lazySingleton<_i31.LocalStorage>(() => _i31.LocalStorage( + gh<_i29.AuthStorage>(), gh<_i5.SharedPreferenceStorage>(), )); - gh.lazySingleton<_i30.LocaleRepository>( - () => _i30.LocaleRepository(gh<_i5.SharedPreferenceStorage>())); - gh.lazySingleton<_i31.LoginRepository>( - () => _i31.LoginRepository(gh<_i27.AuthStorage>())); - gh.singleton<_i32.NetworkAuthInterceptor>( - () => _i32.NetworkAuthInterceptor(gh<_i27.AuthStorage>())); - gh.lazySingleton<_i33.OnboardingNavigator>(() => _i33.OnboardingNavigator( - gh<_i13.MainNavigator>(), - gh<_i29.LocalStorage>(), - gh<_i31.LoginRepository>(), + gh.lazySingleton<_i32.LocaleRepository>( + () => _i32.LocaleRepository(gh<_i5.SharedPreferenceStorage>())); + gh.lazySingleton<_i33.LoginRepository>( + () => _i33.LoginRepository(gh<_i29.AuthStorage>())); + gh.singleton<_i34.NetworkAuthInterceptor>( + () => _i34.NetworkAuthInterceptor(gh<_i29.AuthStorage>())); + gh.lazySingleton<_i35.OnboardingNavigator>(() => _i35.OnboardingNavigator( + gh<_i14.MainNavigator>(), + gh<_i31.LocalStorage>(), + gh<_i33.LoginRepository>(), )); - gh.lazySingleton<_i34.RefreshRepository>( - () => _i34.RefreshRepository(gh<_i27.AuthStorage>())); - gh.factory<_i35.SplashViewModel>(() => _i35.SplashViewModel( - gh<_i29.LocalStorage>(), - gh<_i33.OnboardingNavigator>(), + gh.lazySingleton<_i36.RefreshRepository>( + () => _i36.RefreshRepository(gh<_i29.AuthStorage>())); + gh.factory<_i37.SplashViewModel>(() => _i37.SplashViewModel( + gh<_i31.LocalStorage>(), + gh<_i35.OnboardingNavigator>(), + gh<_i18.RemoteConfigRepository>(), )); - gh.factory<_i36.TodoAddViewModel>(() => _i36.TodoAddViewModel( - gh<_i26.TodoRepository>(), - gh<_i13.MainNavigator>(), + gh.factory<_i38.TodoAddViewModel>(() => _i38.TodoAddViewModel( + gh<_i28.TodoRepository>(), + gh<_i14.MainNavigator>(), )); - gh.factory<_i37.TodoListViewModel>(() => _i37.TodoListViewModel( - gh<_i26.TodoRepository>(), - gh<_i13.MainNavigator>(), + gh.factory<_i39.TodoListViewModel>(() => _i39.TodoListViewModel( + gh<_i28.TodoRepository>(), + gh<_i14.MainNavigator>(), )); - gh.factory<_i38.AnalyticsPermissionViewModel>( - () => _i38.AnalyticsPermissionViewModel( - gh<_i33.OnboardingNavigator>(), - gh<_i29.LocalStorage>(), + gh.factory<_i40.AnalyticsPermissionViewModel>( + () => _i40.AnalyticsPermissionViewModel( + gh<_i35.OnboardingNavigator>(), + gh<_i31.LocalStorage>(), )); - gh.factory<_i39.DebugViewModel>(() => _i39.DebugViewModel( - gh<_i28.DebugRepository>(), - gh<_i13.MainNavigator>(), - gh<_i10.FlutterTemplateDatabase>(), - gh<_i29.LocalStorage>(), + gh.factory<_i41.DebugViewModel>(() => _i41.DebugViewModel( + gh<_i30.DebugRepository>(), + gh<_i14.MainNavigator>(), + gh<_i11.FlutterTemplateDatabase>(), + gh<_i31.LocalStorage>(), )); - gh.lazySingleton<_i40.GlobalViewModel>(() => _i40.GlobalViewModel( - gh<_i30.LocaleRepository>(), - gh<_i28.DebugRepository>(), - gh<_i29.LocalStorage>(), - gh<_i19.ThemeConfigUtil>(), - gh<_i11.LocalizationOverrides>(), + gh.lazySingleton<_i42.GlobalViewModel>(() => _i42.GlobalViewModel( + gh<_i32.LocaleRepository>(), + gh<_i30.DebugRepository>(), + gh<_i31.LocalStorage>(), + gh<_i21.ThemeConfigUtil>(), + gh<_i12.LocalizationOverrides>(), )); - gh.factory<_i41.LoginViewModel>(() => _i41.LoginViewModel( - gh<_i31.LoginRepository>(), - gh<_i13.MainNavigator>(), - gh<_i33.OnboardingNavigator>(), + gh.factory<_i43.LoginViewModel>(() => _i43.LoginViewModel( + gh<_i33.LoginRepository>(), + gh<_i14.MainNavigator>(), + gh<_i35.OnboardingNavigator>(), )); - gh.singleton<_i42.NetworkRefreshInterceptor>( - () => _i42.NetworkRefreshInterceptor( - gh<_i27.AuthStorage>(), - gh<_i34.RefreshRepository>(), + gh.singleton<_i44.NetworkRefreshInterceptor>( + () => _i44.NetworkRefreshInterceptor( + gh<_i29.AuthStorage>(), + gh<_i36.RefreshRepository>(), )); gh.lazySingleton<_i5.CombiningSmartInterceptor>( () => registerModule.provideCombiningSmartInterceptor( - gh<_i15.NetworkLogInterceptor>(), - gh<_i32.NetworkAuthInterceptor>(), - gh<_i14.NetworkErrorInterceptor>(), - gh<_i42.NetworkRefreshInterceptor>(), + gh<_i16.NetworkLogInterceptor>(), + gh<_i34.NetworkAuthInterceptor>(), + gh<_i15.NetworkErrorInterceptor>(), + gh<_i44.NetworkRefreshInterceptor>(), )); - gh.factory<_i43.DebugThemeSelectorViewModel>( - () => _i43.DebugThemeSelectorViewModel( - gh<_i13.MainNavigator>(), - gh<_i40.GlobalViewModel>(), + gh.factory<_i45.DebugThemeSelectorViewModel>( + () => _i45.DebugThemeSelectorViewModel( + gh<_i14.MainNavigator>(), + gh<_i42.GlobalViewModel>(), )); - gh.lazySingleton<_i44.Dio>( + gh.lazySingleton<_i46.Dio>( () => registerModule.provideDio(gh<_i5.CombiningSmartInterceptor>())); - gh.singleton<_i21.TodoService>( - () => _i45.TodoWebService(gh<_i44.Dio>()), + gh.singleton<_i23.TodoService>( + () => _i47.TodoWebService(gh<_i46.Dio>()), registerFor: { _dev, _prod, @@ -234,4 +242,4 @@ extension GetItInjectableX on _i1.GetIt { } } -class _$RegisterModule extends _i46.RegisterModule {} +class _$RegisterModule extends _i48.RegisterModule {} diff --git a/lib/di/injectable.dart b/lib/di/injectable.dart index cc01145f..e7856551 100644 --- a/lib/di/injectable.dart +++ b/lib/di/injectable.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:dio/dio.dart'; import 'package:drift/drift.dart'; import 'package:firebase_analytics/firebase_analytics.dart'; +import 'package:firebase_remote_config/firebase_remote_config.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:flutter_template/database/flutter_template_database.dart'; @@ -70,6 +71,9 @@ abstract class RegisterModule { return secure; } + @lazySingleton + FirebaseRemoteConfig provideFirebaseRemoteConfig() => FirebaseRemoteConfig.instance; + @lazySingleton CombiningSmartInterceptor provideCombiningSmartInterceptor( NetworkLogInterceptor logInterceptor, diff --git a/lib/repository/remote_config/remote_config_repository.dart b/lib/repository/remote_config/remote_config_repository.dart index 567a932b..90152b06 100644 --- a/lib/repository/remote_config/remote_config_repository.dart +++ b/lib/repository/remote_config/remote_config_repository.dart @@ -4,22 +4,24 @@ import 'package:flutter_template/styles/theme_durations.dart'; import 'package:flutter_template/util/locale/localization_overrides.dart'; import 'package:get_it/get_it.dart'; import 'package:icapps_architecture/icapps_architecture.dart'; +import 'package:injectable/injectable.dart'; +@lazySingleton class RemoteConfigRepository extends BaseRemoteConfigRepo { + final FirebaseRemoteConfig _remoteConfig; - RemoteConfigRepository(); + RemoteConfigRepository(this._remoteConfig); @override Future refreshRemoteConfig() async { - final remoteConfig = FirebaseRemoteConfig.instance; - await remoteConfig.setConfigSettings( + await _remoteConfig.setConfigSettings( RemoteConfigSettings( fetchTimeout: ThemeDurations.remoteConfigTimeOut, minimumFetchInterval: Duration.zero, ), ); try { - await remoteConfig.fetchAndActivate(); + await _remoteConfig.fetchAndActivate(); await GetIt.I().refreshOverrideLocalizations(); } catch (error, trace) { logger.error('Unable to fetch remote config. Cached or default values will be used', error: error, stackTrace: trace); diff --git a/lib/viewmodel/splash/splash_viewmodel.dart b/lib/viewmodel/splash/splash_viewmodel.dart index de36b7d8..8223c704 100644 --- a/lib/viewmodel/splash/splash_viewmodel.dart +++ b/lib/viewmodel/splash/splash_viewmodel.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:flutter_template/navigator/onboarding_navigator.dart'; +import 'package:flutter_template/repository/remote_config/remote_config_repository.dart'; import 'package:flutter_template/repository/shared_prefs/local/local_storage.dart'; import 'package:icapps_architecture/icapps_architecture.dart'; import 'package:injectable/injectable.dart'; @@ -9,14 +10,17 @@ import 'package:injectable/injectable.dart'; class SplashViewModel with ChangeNotifierEx { final LocalStorage _localStorage; final OnboardingNavigator _onboardingNavigator; + final RemoteConfigRepository _remoteConfigRepository; SplashViewModel( this._localStorage, this._onboardingNavigator, + this._remoteConfigRepository, ); Future init() async { await _localStorage.checkForNewInstallation(); + await _remoteConfigRepository.refreshRemoteConfig(); await _onboardingNavigator.goToNextScreen(); } } diff --git a/test/viewmodel/splash/splash_viewmodel_test.dart b/test/viewmodel/splash/splash_viewmodel_test.dart index aec62398..c36e9ac3 100644 --- a/test/viewmodel/splash/splash_viewmodel_test.dart +++ b/test/viewmodel/splash/splash_viewmodel_test.dart @@ -1,4 +1,5 @@ import 'package:flutter_template/navigator/onboarding_navigator.dart'; +import 'package:flutter_template/repository/remote_config/remote_config_repository.dart'; import 'package:flutter_template/repository/shared_prefs/local/local_storage.dart'; import 'package:flutter_template/viewmodel/splash/splash_viewmodel.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -11,16 +12,24 @@ import 'splash_viewmodel_test.mocks.dart'; @GenerateMocks([ LocalStorage, OnboardingNavigator, + RemoteConfigRepository, ]) void main() { late SplashViewModel sut; late LocalStorage localStorage; late OnboardingNavigator onboardingNavigator; + late RemoteConfigRepository remoteConfigRepository; setUp(() async { onboardingNavigator = MockOnboardingNavigator(); localStorage = MockLocalStorage(); - sut = SplashViewModel(localStorage, onboardingNavigator); + remoteConfigRepository = MockRemoteConfigRepository(); + + sut = SplashViewModel( + localStorage, + onboardingNavigator, + remoteConfigRepository, + ); }); test('SplashViewModel init with loggedin user', () async { diff --git a/test/viewmodel/splash/splash_viewmodel_test.mocks.dart b/test/viewmodel/splash/splash_viewmodel_test.mocks.dart index 75d0962d..7149259d 100644 --- a/test/viewmodel/splash/splash_viewmodel_test.mocks.dart +++ b/test/viewmodel/splash/splash_viewmodel_test.mocks.dart @@ -7,6 +7,8 @@ import 'dart:async' as _i3; import 'package:flutter/material.dart' as _i4; import 'package:flutter_template/navigator/onboarding_navigator.dart' as _i5; +import 'package:flutter_template/repository/remote_config/remote_config_repository.dart' + as _i6; import 'package:flutter_template/repository/shared_prefs/local/local_storage.dart' as _i2; import 'package:mockito/mockito.dart' as _i1; @@ -84,3 +86,88 @@ class MockOnboardingNavigator extends _i1.Mock returnValueForMissingStub: _i3.Future.value(), ) as _i3.Future); } + +/// A class which mocks [RemoteConfigRepository]. +/// +/// See the documentation for Mockito's code generation for more information. +class MockRemoteConfigRepository extends _i1.Mock + implements _i6.RemoteConfigRepository { + MockRemoteConfigRepository() { + _i1.throwOnMissingStub(this); + } + + @override + _i3.Future refreshRemoteConfig() => (super.noSuchMethod( + Invocation.method( + #refreshRemoteConfig, + [], + ), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) as _i3.Future); + + @override + String? getOptionalValue(String? key) => + (super.noSuchMethod(Invocation.method( + #getOptionalValue, + [key], + )) as String?); + + @override + String? getOptionalString(String? key) => + (super.noSuchMethod(Invocation.method( + #getOptionalString, + [key], + )) as String?); + + @override + int? getOptionalInt(String? key) => (super.noSuchMethod(Invocation.method( + #getOptionalInt, + [key], + )) as int?); + + @override + bool? getOptionalBool(String? key) => (super.noSuchMethod(Invocation.method( + #getOptionalBool, + [key], + )) as bool?); + + @override + double? getOptionalDouble(String? key) => + (super.noSuchMethod(Invocation.method( + #getOptionalDouble, + [key], + )) as double?); + + @override + Map getCustomObjectMap( + String? key, + R Function(Map)? fromJson, + ) => + (super.noSuchMethod( + Invocation.method( + #getCustomObjectMap, + [ + key, + fromJson, + ], + ), + returnValue: {}, + ) as Map); + + @override + List getCustomObjectList( + String? key, + T Function(Map)? fromJson, + ) => + (super.noSuchMethod( + Invocation.method( + #getCustomObjectList, + [ + key, + fromJson, + ], + ), + returnValue: [], + ) as List); +}