Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate remote config for updates #224

Merged
merged 13 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 67 additions & 45 deletions app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,71 +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.28.0)
- Firebase/Core (10.28.0):
- Firebase/CoreOnly
- FirebaseAuth (~> 10.27.0)
- Firebase/Core (10.27.0):
- FirebaseAnalytics (~> 10.28.0)
- Firebase/CoreOnly (10.28.0):
- FirebaseCore (= 10.28.0)
- Firebase/Crashlytics (10.28.0):
- Firebase/CoreOnly
- FirebaseAnalytics (~> 10.27.0)
- Firebase/CoreOnly (10.27.0):
- FirebaseCore (= 10.27.0)
- Firebase/Crashlytics (10.27.0):
- FirebaseCrashlytics (~> 10.28.0)
- Firebase/RemoteConfig (10.28.0):
- Firebase/CoreOnly
- FirebaseCrashlytics (~> 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
- FirebaseAnalytics (10.27.0):
- FirebaseAnalytics/AdIdSupport (= 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.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 @@ -90,6 +97,14 @@ PODS:
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
- PromisesObjC (~> 2.1)
- FirebaseRemoteConfig (10.28.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.28.0)
- FirebaseSessions (10.28.0):
- FirebaseCore (~> 10.5)
Expand All @@ -100,28 +115,29 @@ PODS:
- GoogleUtilities/UserDefaults (~> 7.13)
- nanopb (< 2.30911.0, >= 2.30908.0)
- PromisesSwift (~> 2.1)
- FirebaseSharedSwift (10.28.0)
- Flutter (1.0.0)
- google_sign_in_ios (0.0.1):
- AppAuth (>= 1.7.4)
- Flutter
- 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 @@ -202,11 +218,11 @@ 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`)
- firebase_crashlytics (from `.symlinks/plugins/firebase_crashlytics/ios`)
- firebase_remote_config (from `.symlinks/plugins/firebase_remote_config/ios`)
- Flutter (from `Flutter`)
- google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`)
- just_audio (from `.symlinks/plugins/just_audio/ios`)
Expand All @@ -221,6 +237,7 @@ SPEC REPOS:
trunk:
- AppAuth
- Firebase
- FirebaseABTesting
- FirebaseAnalytics
- FirebaseAppCheckInterop
- FirebaseAuth
Expand All @@ -229,8 +246,10 @@ SPEC REPOS:
- FirebaseCoreInternal
- FirebaseCrashlytics
- FirebaseInstallations
- FirebaseRemoteConfig
- FirebaseRemoteConfigInterop
- FirebaseSessions
- FirebaseSharedSwift
- GoogleAppMeasurement
- GoogleDataTransport
- GoogleSignIn
Expand All @@ -249,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 All @@ -259,6 +276,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
google_sign_in_ios:
Expand All @@ -283,25 +302,28 @@ 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
FirebaseAnalytics: f9211b719db260cc91aebee8bb539cb367d0dfd1
Firebase: 5121c624121af81cbc81df3bda414b3c28c4f3c3
firebase_analytics: e51d02e2da883fd058f2a4f151f6a80acdfe67aa
firebase_auth: e778ee89483b86fe4200d1f8e9a1c52aa5fb64a8
firebase_core: a9d0180d5285527884d07a41eb4a9ec9ed12cdb6
firebase_crashlytics: 12b2b1ecfc50f6c551c68e491ae156b2b7d41273
firebase_remote_config: 5f92bfc62c3ef2c657bf3d703ffa4be29082280f
FirebaseABTesting: 589bc28c0ab3e5554336895a34aa262e24276665
FirebaseAnalytics: 1e06fe7d246af7230b08d1d9cdca54a4624dd461
FirebaseAppCheckInterop: 5315f40293191bfec04b2cfab0215760e441540a
FirebaseAuth: 77a012b7e08042bf44d0db835ca2e86e6ca7bbd3
FirebaseCore: a2b95ae4ce7c83ceecfbbbe3b6f1cddc7415a808
FirebaseAuth: 3d872fbbfc4223edeb72769e488f325fa8b0a4a9
FirebaseCore: 857dc1c6dd1255675047404d8466f7dfaac5d779
FirebaseCoreExtension: f63147b723e2a700fe0f34ec6fb7f358d6fe83e0
FirebaseCoreInternal: 58d07f1362fddeb0feb6a857d1d1d1c5e558e698
FirebaseCrashlytics: 81ea6ec96519388687f6061beb838a8eec482293
FirebaseCrashlytics: f51e12b93f8e1134bbed602ed22df33804d55ccf
FirebaseInstallations: 60c1d3bc1beef809fd1ad1189a8057a040c59f2e
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
Expand Down
5 changes: 1 addition & 4 deletions app/lib/app/presentation/cubit/app_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ class AppCubit extends Cubit<AppState> {
required this.setColorUseCase,
required this.getAppVersionUseCase,
}) : super(
AppState(
getInitialThemeUseCase.call,
getAppVersionUseCase.call,
),
AppState(getInitialThemeUseCase.call, getAppVersionUseCase.call),
);

final GetAppInitialThemeUseCase getInitialThemeUseCase;
Expand Down
49 changes: 49 additions & 0 deletions app/lib/app/presentation/cubit/remote_config_cubit.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:meta/meta.dart';
import 'package:my_quran/core/core.dart';
import 'package:package_info_plus/package_info_plus.dart';

part 'remote_config_state.dart';

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

final PackageInfo packageInfo;
final MqRemoteConfig remoteConfig;

Future<void> init() async {
_emitNewState();
remoteConfig.remoteConfig.onConfigUpdated.listen((event) async {
await remoteConfig.remoteConfig.activate();
_emitNewState();
});
}

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) {
return YesRequiredVersion(requiredBuildNumber);
} else if (currentBuildNumber < recommendedBuildNumber) {
return YesRecommendedVersion(recommendedBuildNumber);
} else {
return const NoNewVersion();
}
}
}
56 changes: 56 additions & 0 deletions app/lib/app/presentation/cubit/remote_config_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
part of 'remote_config_cubit.dart';

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

final AppVersionStatus appVersionStatus;
final String? deviceId;
final bool isHatimEnable;

@override
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,
deviceId: deviceId ?? this.deviceId,
);
}
}

@immutable
abstract class AppVersionStatus {
const AppVersionStatus();
}

@immutable
final class NoNewVersion extends AppVersionStatus {
const NoNewVersion();
}

@immutable
final class YesRecommendedVersion extends AppVersionStatus {
const YesRecommendedVersion(this.buildNumber);

final int buildNumber;
}

@immutable
final class YesRequiredVersion extends AppVersionStatus {
const YesRequiredVersion(this.buildNumber);

final int buildNumber;
}
2 changes: 2 additions & 0 deletions app/lib/app/presentation/presenation.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export 'cubit/app_cubit.dart';
export 'cubit/auth_cubit.dart';
export 'cubit/remote_config_cubit.dart';
export 'view/app_view.dart';
export 'view/app_listener.dart';
Loading
Loading