From 223f0bbabffa4bd65c2e2f2406f77f57d3521e31 Mon Sep 17 00:00:00 2001 From: viktor Date: Wed, 10 Jun 2026 17:50:16 +0300 Subject: [PATCH] bump new Android to 2.2.5 and fix Sample App state management --- .../api/model/branding_options_request.g.dart | 73 +++++++++++-------- .../lib/feature/home/home_screen_cubit.dart | 19 +++-- .../lib/feature/home/home_screen_state.dart | 5 ++ Sample/lib/main.dart | 8 +- android/build.gradle.kts | 2 +- 5 files changed, 69 insertions(+), 38 deletions(-) diff --git a/Sample/lib/api/model/branding_options_request.g.dart b/Sample/lib/api/model/branding_options_request.g.dart index 1779350..2c1ff5f 100644 --- a/Sample/lib/api/model/branding_options_request.g.dart +++ b/Sample/lib/api/model/branding_options_request.g.dart @@ -20,45 +20,60 @@ Map _$BrandingOptionsRequestToJson( BrandingPaymentMethods _$BrandingPaymentMethodsFromJson( Map json, -) => BrandingPaymentMethods( - knetStaging: json['knet-staging'] == null - ? null - : BrandingOption.fromJson(json['knet-staging'] as Map), - tabby: json['tabby'] == null - ? null - : BrandingOption.fromJson(json['tabby'] as Map), - cod: json['cod'] == null - ? null - : BrandingOption.fromJson(json['cod'] as Map), - mpgs: json['mpgs-testing'] == null - ? null - : BrandingOption.fromJson(json['mpgs-testing'] as Map), - stcPay: json['stc_pay'] == null - ? null - : BrandingOption.fromJson(json['stc_pay'] as Map), - cs: json['cs'] == null - ? null - : BrandingOption.fromJson(json['cs'] as Map), - nbkMpgs: json['nbk-mpgs'] == null - ? null - : BrandingOption.fromJson(json['nbk-mpgs'] as Map), - tapPg: json['tap_pg'] == null - ? null - : BrandingOption.fromJson(json['tap_pg'] as Map), - ottuSdk: json['ottu_sdk'] == null - ? null - : BrandingOption.fromJson(json['ottu_sdk'] as Map), -); +) => + BrandingPaymentMethods( + knetStaging: json['knet-staging'] == null + ? null + : BrandingOption.fromJson( + json['knet-staging'] as Map, + ), + tabby: json['tabby'] == null + ? null + : BrandingOption.fromJson(json['tabby'] as Map), + cod: json['cod'] == null + ? null + : BrandingOption.fromJson(json['cod'] as Map), + mpgs: json['mpgs-testing'] == null + ? null + : BrandingOption.fromJson( + json['mpgs-testing'] as Map, + ), + stcPay: json['stc_pay'] == null + ? null + : BrandingOption.fromJson(json['stc_pay'] as Map), + cs: json['cs'] == null + ? null + : BrandingOption.fromJson(json['cs'] as Map), + nbkMpgs: json['nbk-mpgs'] == null + ? null + : BrandingOption.fromJson(json['nbk-mpgs'] as Map), + tapPg: json['tap_pg'] == null + ? null + : BrandingOption.fromJson(json['tap_pg'] as Map), + ottuSdk: json['ottu_sdk'] == null + ? null + : BrandingOption.fromJson(json['ottu_sdk'] as Map), + ) + ..tamara = json['tamara'] == null + ? null + : BrandingOption.fromJson(json['tamara'] as Map) + ..jamiawallet = json['jamiawallet'] == null + ? null + : BrandingOption.fromJson( + json['jamiawallet'] as Map, + ); Map _$BrandingPaymentMethodsToJson( BrandingPaymentMethods instance, ) => { 'knet-staging': ?instance.knetStaging, 'tabby': ?instance.tabby, + 'tamara': ?instance.tamara, 'cod': ?instance.cod, 'mpgs-testing': ?instance.mpgs, 'stc_pay': ?instance.stcPay, 'cs': ?instance.cs, + 'jamiawallet': ?instance.jamiawallet, 'nbk-mpgs': ?instance.nbkMpgs, 'tap_pg': ?instance.tapPg, 'ottu_sdk': ?instance.ottuSdk, diff --git a/Sample/lib/feature/home/home_screen_cubit.dart b/Sample/lib/feature/home/home_screen_cubit.dart index 17b1bc1..6dca697 100644 --- a/Sample/lib/feature/home/home_screen_cubit.dart +++ b/Sample/lib/feature/home/home_screen_cubit.dart @@ -40,7 +40,6 @@ class HomeScreenCubit extends Cubit { final _logger = Logger(); final OttuApi _api; - String? _apiTransactionDetails; ThemeModeNotifierHolder _themeModeNotifier; HomeScreenCubit({ @@ -92,9 +91,14 @@ class HomeScreenCubit extends Cubit { } } + @override + void onChange(Change change) { + super.onChange(change); + _state = change.nextState; + } + @override Future close() { - _state = state; return super.close(); } @@ -140,8 +144,13 @@ class HomeScreenCubit extends Cubit { ); result.onResult( success: (sessionResponse) { - _apiTransactionDetails = sessionResponse.transactionDetails; - emit(state.copyWith(sessionId: sessionResponse.sessionId, hasSessionLoaded: true)); + emit( + state.copyWith( + sessionId: sessionResponse.sessionId, + hasSessionLoaded: true, + apiTransactionDetails: sessionResponse.transactionDetails, + ), + ); }, error: (_) {}, ); @@ -262,7 +271,7 @@ class HomeScreenCubit extends Cubit { amount: amount, showPaymentDetails: state.showPaymentDetails, paymentOptionsDisplaySettings: displaySettings, - setupPreload: state.preloadPayload == true ? _apiTransactionDetails : null, + setupPreload: state.preloadPayload == true ? state.apiTransactionDetails : null, formsOfPayment: formOfPayments?.isNotEmpty == true ? formOfPayments : null, theme: _theme, payButtonText: state.useCustomText == true diff --git a/Sample/lib/feature/home/home_screen_state.dart b/Sample/lib/feature/home/home_screen_state.dart index 1ee2da0..d373eb6 100644 --- a/Sample/lib/feature/home/home_screen_state.dart +++ b/Sample/lib/feature/home/home_screen_state.dart @@ -26,6 +26,7 @@ final class HomeScreenState extends Equatable { final PaymentOptionsDisplayMode? paymentOptionsDisplayMode; final Map? formsOfPaymentChecked; final Map? pgCodesChecked; + final String? apiTransactionDetails; const HomeScreenState({ required this.merchantId, @@ -49,6 +50,7 @@ final class HomeScreenState extends Equatable { this.formsOfPaymentChecked, this.pgCodesChecked, this.useCustomText = false, + this.apiTransactionDetails, }); HomeScreenState copyWith({ @@ -73,6 +75,7 @@ final class HomeScreenState extends Equatable { PaymentOptionsDisplayMode? paymentOptionsDisplayMode, Map? formsOfPaymentChecked, Map? pgCodesChecked, + String? apiTransactionDetails, }) { return HomeScreenState( merchantId: merchantId ?? this.merchantId, @@ -96,6 +99,7 @@ final class HomeScreenState extends Equatable { paymentOptionsDisplayMode: paymentOptionsDisplayMode ?? this.paymentOptionsDisplayMode, formsOfPaymentChecked: formsOfPaymentChecked ?? this.formsOfPaymentChecked, pgCodesChecked: pgCodesChecked ?? this.pgCodesChecked, + apiTransactionDetails: apiTransactionDetails ?? this.apiTransactionDetails, ); } @@ -122,5 +126,6 @@ final class HomeScreenState extends Equatable { paymentOptionsDisplayMode?.name, formsOfPaymentChecked.hashCode, pgCodesChecked.hashCode, + apiTransactionDetails, ]; } diff --git a/Sample/lib/main.dart b/Sample/lib/main.dart index 92f1b61..176fd44 100644 --- a/Sample/lib/main.dart +++ b/Sample/lib/main.dart @@ -36,12 +36,14 @@ void main() { } class OttuApp extends StatelessWidget { - final modules = []; + final List modules; final routes = []; + late final GoRouter _router; - OttuApp({required final List modules, super.key}) { + OttuApp({required this.modules, super.key}) { modules.forEach((final module) => module.init(_service)); modules.forEach((final module) => routes.addAll(module.router())); + _router = GoRouter(routes: routes); } @override @@ -53,7 +55,7 @@ class OttuApp extends StatelessWidget { builder: (context, themeMode, _) { final mode = themeMode?.toThemeMode(); return MaterialApp.router( - routerConfig: GoRouter(routes: routes), + routerConfig: _router, themeMode: mode, supportedLocales: [Locale('ar'), Locale('en')], localizationsDelegates: const [ diff --git a/android/build.gradle.kts b/android/build.gradle.kts index 76a91a5..cd5b63c 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -70,7 +70,7 @@ allprojects { } dependencies { - implementation("com.github.ottuco:ottu-android-checkout:2.2.4") + implementation("com.github.ottuco:ottu-android-checkout:2.2.5") implementation("com.squareup.moshi:moshi-kotlin:1.15.2") implementation("com.squareup.moshi:moshi-adapters:1.15.2") implementation("com.squareup.moshi:moshi-kotlin-codegen:1.15.2")