Skip to content

Commit

Permalink
Refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
Eldar2021 committed Jul 9, 2024
1 parent 2305c44 commit 91dfb48
Show file tree
Hide file tree
Showing 10 changed files with 248 additions and 333 deletions.
108 changes: 51 additions & 57 deletions app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,80 +12,78 @@ PODS:
- connectivity_plus (0.0.1):
- Flutter
- FlutterMacOS
- device_info_plus (0.0.1):
- Flutter
- Firebase/Analytics (10.27.0):
- Firebase/Analytics (10.28.0):
- Firebase/Core
- Firebase/Auth (10.27.0):
- Firebase/Auth (10.28.0):
- Firebase/CoreOnly
- FirebaseAuth (~> 10.27.0)
- Firebase/Core (10.27.0):
- FirebaseAuth (~> 10.28.0)
- Firebase/Core (10.28.0):
- Firebase/CoreOnly
- FirebaseAnalytics (~> 10.27.0)
- Firebase/CoreOnly (10.27.0):
- FirebaseCore (= 10.27.0)
- Firebase/Crashlytics (10.27.0):
- FirebaseAnalytics (~> 10.28.0)
- Firebase/CoreOnly (10.28.0):
- FirebaseCore (= 10.28.0)
- Firebase/Crashlytics (10.28.0):
- Firebase/CoreOnly
- FirebaseCrashlytics (~> 10.27.0)
- Firebase/RemoteConfig (10.27.0):
- FirebaseCrashlytics (~> 10.28.0)
- Firebase/RemoteConfig (10.28.0):
- Firebase/CoreOnly
- FirebaseRemoteConfig (~> 10.27.0)
- firebase_analytics (11.1.0):
- Firebase/Analytics (= 10.27.0)
- FirebaseRemoteConfig (~> 10.28.0)
- firebase_analytics (11.2.0):
- Firebase/Analytics (= 10.28.0)
- firebase_core
- Flutter
- firebase_auth (5.1.1):
- Firebase/Auth (= 10.27.0)
- firebase_auth (5.1.2):
- Firebase/Auth (= 10.28.0)
- firebase_core
- Flutter
- firebase_core (3.1.1):
- Firebase/CoreOnly (= 10.27.0)
- firebase_core (3.2.0):
- Firebase/CoreOnly (= 10.28.0)
- Flutter
- firebase_crashlytics (4.0.2):
- Firebase/Crashlytics (= 10.27.0)
- firebase_crashlytics (4.0.3):
- Firebase/Crashlytics (= 10.28.0)
- firebase_core
- Flutter
- firebase_remote_config (5.0.2):
- Firebase/RemoteConfig (= 10.27.0)
- firebase_remote_config (5.0.3):
- Firebase/RemoteConfig (= 10.28.0)
- firebase_core
- Flutter
- FirebaseABTesting (10.28.0):
- FirebaseCore (~> 10.0)
- FirebaseAnalytics (10.27.0):
- FirebaseAnalytics/AdIdSupport (= 10.27.0)
- FirebaseAnalytics (10.28.0):
- FirebaseAnalytics/AdIdSupport (= 10.28.0)
- FirebaseCore (~> 10.0)
- FirebaseInstallations (~> 10.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30911.0, >= 2.30908.0)
- FirebaseAnalytics/AdIdSupport (10.27.0):
- FirebaseAnalytics/AdIdSupport (10.28.0):
- FirebaseCore (~> 10.0)
- FirebaseInstallations (~> 10.0)
- GoogleAppMeasurement (= 10.27.0)
- GoogleAppMeasurement (= 10.28.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30911.0, >= 2.30908.0)
- FirebaseAppCheckInterop (10.28.0)
- FirebaseAuth (10.27.0):
- FirebaseAuth (10.28.0):
- FirebaseAppCheckInterop (~> 10.17)
- FirebaseCore (~> 10.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.8)
- GoogleUtilities/Environment (~> 7.8)
- GTMSessionFetcher/Core (< 4.0, >= 2.1)
- RecaptchaInterop (~> 100.0)
- FirebaseCore (10.27.0):
- FirebaseCore (10.28.0):
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.12)
- GoogleUtilities/Logger (~> 7.12)
- FirebaseCoreExtension (10.28.0):
- FirebaseCore (~> 10.0)
- FirebaseCoreInternal (10.28.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseCrashlytics (10.27.0):
- FirebaseCrashlytics (10.28.1):
- FirebaseCore (~> 10.5)
- FirebaseInstallations (~> 10.0)
- FirebaseRemoteConfigInterop (~> 10.23)
Expand All @@ -99,7 +97,7 @@ PODS:
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
- PromisesObjC (~> 2.1)
- FirebaseRemoteConfig (10.27.0):
- FirebaseRemoteConfig (10.28.0):
- FirebaseABTesting (~> 10.0)
- FirebaseCore (~> 10.0)
- FirebaseInstallations (~> 10.0)
Expand All @@ -125,21 +123,21 @@ PODS:
- FlutterMacOS
- GoogleSignIn (~> 7.1)
- GTMSessionFetcher (>= 3.4.0)
- GoogleAppMeasurement (10.27.0):
- GoogleAppMeasurement/AdIdSupport (= 10.27.0)
- GoogleAppMeasurement (10.28.0):
- GoogleAppMeasurement/AdIdSupport (= 10.28.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30911.0, >= 2.30908.0)
- GoogleAppMeasurement/AdIdSupport (10.27.0):
- GoogleAppMeasurement/WithoutAdIdSupport (= 10.27.0)
- GoogleAppMeasurement/AdIdSupport (10.28.0):
- GoogleAppMeasurement/WithoutAdIdSupport (= 10.28.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30911.0, >= 2.30908.0)
- GoogleAppMeasurement/WithoutAdIdSupport (10.27.0):
- GoogleAppMeasurement/WithoutAdIdSupport (10.28.0):
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
Expand Down Expand Up @@ -184,10 +182,10 @@ PODS:
- GTMAppAuth (4.1.1):
- AppAuth/Core (~> 1.7)
- GTMSessionFetcher/Core (< 4.0, >= 3.3)
- GTMSessionFetcher (3.5.0):
- GTMSessionFetcher/Full (= 3.5.0)
- GTMSessionFetcher/Core (3.5.0)
- GTMSessionFetcher/Full (3.5.0):
- GTMSessionFetcher (3.4.1):
- GTMSessionFetcher/Full (= 3.4.1)
- GTMSessionFetcher/Core (3.4.1)
- GTMSessionFetcher/Full (3.4.1):
- GTMSessionFetcher/Core
- just_audio (0.0.1):
- Flutter
Expand Down Expand Up @@ -220,7 +218,6 @@ DEPENDENCIES:
- audio_service (from `.symlinks/plugins/audio_service/ios`)
- audio_session (from `.symlinks/plugins/audio_session/ios`)
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/darwin`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- firebase_analytics (from `.symlinks/plugins/firebase_analytics/ios`)
- firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
Expand Down Expand Up @@ -271,8 +268,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/audio_session/ios"
connectivity_plus:
:path: ".symlinks/plugins/connectivity_plus/darwin"
device_info_plus:
:path: ".symlinks/plugins/device_info_plus/ios"
firebase_analytics:
:path: ".symlinks/plugins/firebase_analytics/ios"
firebase_auth:
Expand Down Expand Up @@ -307,34 +302,33 @@ SPEC CHECKSUMS:
audio_service: f509d65da41b9521a61f1c404dd58651f265a567
audio_session: 088d2483ebd1dc43f51d253d4a1c517d9a2e7207
connectivity_plus: ddd7f30999e1faaef5967c23d5b6d503d10434db
device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d
Firebase: 26b040b20866a55f55eb3611b9fcf3ae64816b86
firebase_analytics: cc6e3ca8f159facf99fb1ceb2d81bda9cc811556
firebase_auth: cc4ea3f47dda7afc4c64f59540aa570aca60814d
firebase_core: f8d0424c45e0f1e596811085fc12c638d628457c
firebase_crashlytics: 39ca2155bac4fa2eec0aec9f0eb5e938a08bca23
firebase_remote_config: 962876d64b52d7710d756ea85e27c768002dc628
Firebase: 5121c624121af81cbc81df3bda414b3c28c4f3c3
firebase_analytics: e51d02e2da883fd058f2a4f151f6a80acdfe67aa
firebase_auth: e778ee89483b86fe4200d1f8e9a1c52aa5fb64a8
firebase_core: a9d0180d5285527884d07a41eb4a9ec9ed12cdb6
firebase_crashlytics: 12b2b1ecfc50f6c551c68e491ae156b2b7d41273
firebase_remote_config: 5f92bfc62c3ef2c657bf3d703ffa4be29082280f
FirebaseABTesting: 589bc28c0ab3e5554336895a34aa262e24276665
FirebaseAnalytics: f9211b719db260cc91aebee8bb539cb367d0dfd1
FirebaseAnalytics: 1e06fe7d246af7230b08d1d9cdca54a4624dd461
FirebaseAppCheckInterop: 5315f40293191bfec04b2cfab0215760e441540a
FirebaseAuth: 77a012b7e08042bf44d0db835ca2e86e6ca7bbd3
FirebaseCore: a2b95ae4ce7c83ceecfbbbe3b6f1cddc7415a808
FirebaseAuth: 3d872fbbfc4223edeb72769e488f325fa8b0a4a9
FirebaseCore: 857dc1c6dd1255675047404d8466f7dfaac5d779
FirebaseCoreExtension: f63147b723e2a700fe0f34ec6fb7f358d6fe83e0
FirebaseCoreInternal: 58d07f1362fddeb0feb6a857d1d1d1c5e558e698
FirebaseCrashlytics: 81ea6ec96519388687f6061beb838a8eec482293
FirebaseCrashlytics: f51e12b93f8e1134bbed602ed22df33804d55ccf
FirebaseInstallations: 60c1d3bc1beef809fd1ad1189a8057a040c59f2e
FirebaseRemoteConfig: 37a2ba3c8c454be8553a41ba1a2f4a4f0b845670
FirebaseRemoteConfig: f0879a8dccf4e8905716ed849569130efaeab3e2
FirebaseRemoteConfigInterop: 70d200c6956ef3b5c3592a95e824c1210682d785
FirebaseSessions: 20da8500ad66bb12622743e170459bf62a0768e8
FirebaseSharedSwift: 48de4aec81a6b79bb30404e5e6db43ea74848fed
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
google_sign_in_ios: 07375bfbf2620bc93a602c0e27160d6afc6ead38
GoogleAppMeasurement: f65fc137531af9ad647f1c0a42f3b6a4d3a98049
GoogleAppMeasurement: 55a4a3c8000c1280d68bf4c084adbfef20c49db1
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleSignIn: d4281ab6cf21542b1cfaff85c191f230b399d2db
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
GTMAppAuth: f69bd07d68cd3b766125f7e072c45d7340dea0de
GTMSessionFetcher: 5aea5ba6bd522a239e236100971f10cb71b96ab6
GTMSessionFetcher: 8000756fc1c19d2e5697b90311f7832d2e33f6cd
just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
nanopb: 438bc412db1928dac798aa6fd75726007be04262
package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c
Expand Down
45 changes: 22 additions & 23 deletions app/lib/app/presentation/cubit/remote_config_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,42 @@ import 'package:package_info_plus/package_info_plus.dart';
part 'remote_config_state.dart';

class RemoteConfigCubit extends Cubit<RemoteConfigState> {
RemoteConfigCubit(this.packageInfo, this.remoteConfig)
: super(const RemoteConfigState(appVersionStatus: NoNewVersion(), isHatimEnable: true));
RemoteConfigCubit({
required this.packageInfo,
required this.remoteConfig,
}) : super(const RemoteConfigState());

final PackageInfo packageInfo;
final MqRemoteConfig remoteConfig;

Future<void> init() async {
await setAppVersionStatus(
requiredBuildNumber: remoteConfig.requiredBuildNumber,
recommendedBuildNumber: remoteConfig.recommendedBuildNumber,
);
_checkHatimIsEnable();
_emitNewState();
remoteConfig.remoteConfig.onConfigUpdated.listen((event) async {
await remoteConfig.remoteConfig.activate();
_checkHatimIsEnable();
_emitNewState();
});
}

Future<void> setAppVersionStatus({
required int requiredBuildNumber,
required int recommendedBuildNumber,
}) async {
final currentBuildNumber = int.parse(packageInfo.buildNumber);
void _emitNewState() {
final newState = state.copyWith(
appVersionStatus: _getAppVersionStatus,
isHatimEnable: _hatimIsEnable,
);
emit(newState);
}

bool get _hatimIsEnable => remoteConfig.hatimIsEnable;

AppVersionStatus get _getAppVersionStatus {
final currentBuildNumber = int.parse(packageInfo.buildNumber);
final requiredBuildNumber = remoteConfig.requiredBuildNumber;
final recommendedBuildNumber = remoteConfig.recommendedBuildNumber;
if (currentBuildNumber < requiredBuildNumber) {
emit(state.copyWith(appVersionStatus: YesRequiredVersion(requiredBuildNumber)));
return YesRequiredVersion(requiredBuildNumber);
} else if (currentBuildNumber < recommendedBuildNumber) {
emit(state.copyWith(appVersionStatus: YesRecommendedVersion(recommendedBuildNumber)));
return YesRecommendedVersion(recommendedBuildNumber);
} else {
emit(state.copyWith(appVersionStatus: const NoNewVersion()));
}
}

void _checkHatimIsEnable() {
final currentHatimIsEnable = remoteConfig.hatimIsEnable;
if (state.isHatimEnable != currentHatimIsEnable) {
emit(state.copyWith(isHatimEnable: currentHatimIsEnable));
return const NoNewVersion();
}
}
}
18 changes: 13 additions & 5 deletions app/lib/app/presentation/cubit/remote_config_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ part of 'remote_config_cubit.dart';

class RemoteConfigState extends Equatable {
const RemoteConfigState({
required this.appVersionStatus,
required this.isHatimEnable,
this.appVersionStatus = const NoNewVersion(),
this.isHatimEnable = true,
this.deviceId,
});

Expand All @@ -12,9 +12,17 @@ class RemoteConfigState extends Equatable {
final bool isHatimEnable;

@override
List<Object?> get props => [appVersionStatus, deviceId, isHatimEnable];

RemoteConfigState copyWith({AppVersionStatus? appVersionStatus, String? deviceId, bool? isHatimEnable}) {
List<Object?> get props => [
appVersionStatus,
deviceId,
isHatimEnable,
];

RemoteConfigState copyWith({
AppVersionStatus? appVersionStatus,
String? deviceId,
bool? isHatimEnable,
}) {
return RemoteConfigState(
appVersionStatus: appVersionStatus ?? this.appVersionStatus,
isHatimEnable: isHatimEnable ?? this.isHatimEnable,
Expand Down
4 changes: 2 additions & 2 deletions app/lib/app/presentation/view/app_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class MyApp extends StatelessWidget {
),
BlocProvider(
create: (context) => RemoteConfigCubit(
context.read<PackageInfo>(),
context.read<MqRemoteConfig>(),
packageInfo: context.read<PackageInfo>(),
remoteConfig: context.read<MqRemoteConfig>(),
),
),
],
Expand Down
Loading

0 comments on commit 91dfb48

Please sign in to comment.