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/checkout/checkout_screen.dart b/Sample/lib/feature/checkout/checkout_screen.dart index 67f6b3d..88016f9 100644 --- a/Sample/lib/feature/checkout/checkout_screen.dart +++ b/Sample/lib/feature/checkout/checkout_screen.dart @@ -58,11 +58,9 @@ class _CheckoutScreenState extends State { style: ts.TextStyle(fontSize: 24), ), //Start of Merchant content - const Padding( + Padding( padding: EdgeInsets.all(12.0), - child: Text( - "Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements", - ), + child: Text(AppLocalizations.of(context)!.hostAppContent), ), //End of Merchant content Padding( @@ -77,13 +75,9 @@ class _CheckoutScreenState extends State { ), const SizedBox(height: 20), //Start of Merchant content - const Padding( + Padding( padding: EdgeInsets.all(12.0), - child: Text( - "Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements," - " Some users UI elements, Some users UI elements, Some users UI elements," - " Some users UI elements, Some users UI elements, Some users UI elements", - ), + child: Text(AppLocalizations.of(context)!.hostAppContent), ), //End of Merchant content ], diff --git a/Sample/lib/feature/home/home_screen.dart b/Sample/lib/feature/home/home_screen.dart index ef60b5a..4ca87f8 100644 --- a/Sample/lib/feature/home/home_screen.dart +++ b/Sample/lib/feature/home/home_screen.dart @@ -30,6 +30,7 @@ class _HomeScreenState extends State { late TextEditingController cardExpiryTimeController; late TextEditingController paymentsListItemCountController; late TextEditingController defaultSelectedPaymentController; + late TextEditingController languageController; @override void initState() { @@ -44,6 +45,7 @@ class _HomeScreenState extends State { cardExpiryTimeController = TextEditingController(text: state.cardExpiryTime); paymentsListItemCountController = TextEditingController(text: state.paymentsListItemCount); defaultSelectedPaymentController = TextEditingController(text: state.defaultSelectedPayment); + languageController = TextEditingController(text: state.language); } @override @@ -73,6 +75,22 @@ class _HomeScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ + DropdownMenu( + initialSelection: Platform.localeName.split("_")[0], + controller: languageController, + requestFocusOnTap: true, + label: const Text('Language'), + expandedInsets: EdgeInsets.zero, + onSelected: (String? lang) { + context.read().onLanguageChanged(lang); + }, + dropdownMenuEntries: ["en", "ar"].map>(( + String lang, + ) { + return DropdownMenuEntry(value: lang, label: lang); + }).toList(), + ), + const SizedBox(height: 8), TextFormField( controller: amountEditingController, onChanged: (text) { @@ -263,7 +281,8 @@ class _HomeScreenState extends State { ), const Text('Auto debit'), ], - ),Row( + ), + Row( children: [ Checkbox( checkColor: Colors.white, diff --git a/Sample/lib/feature/home/home_screen_cubit.dart b/Sample/lib/feature/home/home_screen_cubit.dart index 4b2ce08..17b1bc1 100644 --- a/Sample/lib/feature/home/home_screen_cubit.dart +++ b/Sample/lib/feature/home/home_screen_cubit.dart @@ -59,6 +59,7 @@ class HomeScreenCubit extends Cubit { currencyCode: currencyCode, phoneNumber: _customerPhone, customerId: customerId, + language: Platform.localeName.split("_")[0], formsOfPaymentChecked: Map.from({ FormsOfPayment.redirect: true, FormsOfPayment.flex: true, @@ -100,7 +101,9 @@ class HomeScreenCubit extends Cubit { void getSessionId({required String merchantId, required String apiKey}) async { _logger.d("getSessionId, merchantId: $merchantId, apiKey: $apiKey"); emit(state.copyWith(sessionId: null, hasSessionLoaded: false)); - final language = Platform.localeName.split("_")[0]; + + final language = state.language ?? Platform.localeName.split("_")[0]; + final cardExpiryTime = state.cardExpiryTime?.isNotEmpty == true ? int.tryParse(state.cardExpiryTime!) : null; @@ -319,7 +322,7 @@ class HomeScreenCubit extends Cubit { final brandingOptionsRequest = BrandingOptionsRequest(paymentMethods: BrandingPaymentMethods()); state.pgCodesChecked?.forEach((code, isSelected) { - if(isSelected) { + if (isSelected) { switch (code) { case PGCode.knet: brandingOptionsRequest.paymentMethods.knetStaging = BrandingOption( @@ -334,13 +337,13 @@ class HomeScreenCubit extends Cubit { fontWeight: 400, ); case PGCode.benefit: - /* brandingOptionsRequest.paymentMethods.benefit = BrandingOption( + /* brandingOptionsRequest.paymentMethods.benefit = BrandingOption( text: "Branding text for Benefit", color: "#006400", fontWeight: 900, );*/ case PGCode.benefitpay: - /* brandingOptionsRequest.paymentMethods.benefitpay = BrandingOption( + /* brandingOptionsRequest.paymentMethods.benefitpay = BrandingOption( text: "Branding text for BenefitPay", color: "#48D1CC", fontWeight: 900, @@ -381,8 +384,8 @@ class HomeScreenCubit extends Cubit { color: "#708090", fontWeight: 700, ); - case PGCode.cs: - brandingOptionsRequest.paymentMethods.cs = BrandingOption( + case PGCode.cs: + brandingOptionsRequest.paymentMethods.cs = BrandingOption( text: "Branding text for cs", color: "#D2691E", fontWeight: 300, @@ -399,11 +402,15 @@ class HomeScreenCubit extends Cubit { color: "#2F4F4F", fontWeight: 300, ); - default: + default: } } }); return brandingOptionsRequest; } + + void onLanguageChanged(String? lang) { + emit(state.copyWith(language: lang)); + } } diff --git a/Sample/lib/feature/home/home_screen_state.dart b/Sample/lib/feature/home/home_screen_state.dart index 0d42789..1ee2da0 100644 --- a/Sample/lib/feature/home/home_screen_state.dart +++ b/Sample/lib/feature/home/home_screen_state.dart @@ -15,6 +15,7 @@ final class HomeScreenState extends Equatable { final String? cardExpiryTime; final String paymentsListItemCount; final String? defaultSelectedPayment; + final String? language; final bool showPaymentDetails; final bool? noForms; final bool? preloadPayload; @@ -37,6 +38,7 @@ final class HomeScreenState extends Equatable { this.cardExpiryTime, this.paymentsListItemCount = "$_default_payments_list__item_count", this.defaultSelectedPayment, + this.language, this.showPaymentDetails = true, this.preloadPayload = true, this.isAutoDebit = false, @@ -60,6 +62,7 @@ final class HomeScreenState extends Equatable { String? cardExpiryTime, String? paymentsListItemCount, String? defaultSelectedPayment, + String? language, bool? showPaymentDetails, bool? noForms, bool? preloadPayload, @@ -82,6 +85,7 @@ final class HomeScreenState extends Equatable { cardExpiryTime: cardExpiryTime ?? this.cardExpiryTime, paymentsListItemCount: paymentsListItemCount ?? this.paymentsListItemCount, defaultSelectedPayment: defaultSelectedPayment ?? this.defaultSelectedPayment, + language: language ?? this.language, showPaymentDetails: showPaymentDetails ?? this.showPaymentDetails, noForms: noForms ?? this.noForms, preloadPayload: preloadPayload ?? this.preloadPayload, @@ -107,6 +111,7 @@ final class HomeScreenState extends Equatable { cardExpiryTime, paymentsListItemCount, defaultSelectedPayment, + language, sessionId, preloadPayload, isAutoDebit, diff --git a/Sample/lib/feature/theme/theme_customization_screen.dart b/Sample/lib/feature/theme/theme_customization_screen.dart index 7ecedd1..b964d0d 100644 --- a/Sample/lib/feature/theme/theme_customization_screen.dart +++ b/Sample/lib/feature/theme/theme_customization_screen.dart @@ -72,7 +72,7 @@ class _ThemeCustomizationScreenState extends State ), const SizedBox(height: dividerPadding), divider(), - _colorOptionItem(state.theme?.sdkBackgroundColor?.color, "SDK background", ( + _colorOptionItem(state.theme?.backgroundColor?.color, "SDK background", ( color, ) { final newTheme = (state.theme ?? ch.CheckoutTheme()).copyWith( @@ -97,7 +97,7 @@ class _ThemeCustomizationScreenState extends State divider(), const SizedBox(height: dividerPadding), _colorOptionItem( - state.theme?.selectPaymentMethodHeaderBackgroundColor?.color, + state.theme?.selectPaymentItemTitleBackgroundColor?.color, "Select payment method header background", (color) { final newTheme = (state.theme ?? ch.CheckoutTheme()).copyWith( @@ -109,7 +109,7 @@ class _ThemeCustomizationScreenState extends State const SizedBox(height: dividerPadding), divider(), const SizedBox(height: 8), - _textOptionItem("Main title", state.theme?.mainTitleText, (style) { + _textOptionItem("Main title", state.theme?.mainTitle, (style) { final newTheme = (state.theme ?? ch.CheckoutTheme()).copyWith( mainTitleText: style, ); @@ -118,7 +118,7 @@ class _ThemeCustomizationScreenState extends State const SizedBox(height: dividerPadding), divider(), const SizedBox(height: dividerPadding), - _textOptionItem("Title", state.theme?.titleText, (style) { + _textOptionItem("Title", state.theme?.title, (style) { final newTheme = (state.theme ?? ch.CheckoutTheme()).copyWith( titleText: style, ); @@ -129,7 +129,7 @@ class _ThemeCustomizationScreenState extends State const SizedBox(height: dividerPadding), _textOptionItem( "Select payment method header text", - state.theme?.selectPaymentMethodHeaderText, + state.theme?.selectPaymentMethodHeader, (style) { final newTheme = (state.theme ?? ch.CheckoutTheme()).copyWith( selectPaymentMethodHeaderText: style, @@ -140,7 +140,7 @@ class _ThemeCustomizationScreenState extends State const SizedBox(height: dividerPadding), divider(), const SizedBox(height: dividerPadding), - _textOptionItem("Subtitle", state.theme?.subtitleText, (style) { + _textOptionItem("Subtitle", state.theme?.subtitle, (style) { final newTheme = (state.theme ?? ch.CheckoutTheme()).copyWith( subtitleText: style, ); @@ -149,7 +149,7 @@ class _ThemeCustomizationScreenState extends State const SizedBox(height: dividerPadding), divider(), const SizedBox(height: dividerPadding), - _textOptionItem("Fees Title", state.theme?.feesTitleText, (style) { + _textOptionItem("Fees Title", state.theme?.feesTitle, (style) { final newTheme = (state.theme ?? ch.CheckoutTheme()).copyWith( feesTitleText: style, ); @@ -158,7 +158,7 @@ class _ThemeCustomizationScreenState extends State const SizedBox(height: dividerPadding), divider(), const SizedBox(height: dividerPadding), - _textOptionItem("Fees Subtitle", state.theme?.feesSubtitleText, (style) { + _textOptionItem("Fees Subtitle", state.theme?.feesSubtitle, (style) { final newTheme = (state.theme ?? ch.CheckoutTheme()).copyWith( feesSubtitleText: style, ); @@ -167,7 +167,7 @@ class _ThemeCustomizationScreenState extends State const SizedBox(height: dividerPadding), divider(), const SizedBox(height: dividerPadding), - _textOptionItem("Data label", state.theme?.dataLabelText, (style) { + _textOptionItem("Data label", state.theme?.dataLabel, (style) { final newTheme = (state.theme ?? ch.CheckoutTheme()).copyWith( dataLabelText: style, ); @@ -176,7 +176,7 @@ class _ThemeCustomizationScreenState extends State const SizedBox(height: dividerPadding), divider(), const SizedBox(height: dividerPadding), - _textOptionItem("Data value", state.theme?.dataValueText, (style) { + _textOptionItem("Data value", state.theme?.dataValue, (style) { final newTheme = (state.theme ?? ch.CheckoutTheme()).copyWith( dataValueText: style, ); @@ -185,7 +185,7 @@ class _ThemeCustomizationScreenState extends State const SizedBox(height: dividerPadding), divider(), const SizedBox(height: dividerPadding), - _textOptionItem("Error message", state.theme?.errorMessageText, (style) { + _textOptionItem("Error message", state.theme?.errorMessage, (style) { final newTheme = (state.theme ?? ch.CheckoutTheme()).copyWith( errorMessageText: style, ); diff --git a/Sample/lib/l10n/app_ar.arb b/Sample/lib/l10n/app_ar.arb index 73d6fdc..9351f87 100644 --- a/Sample/lib/l10n/app_ar.arb +++ b/Sample/lib/l10n/app_ar.arb @@ -1,3 +1,4 @@ { - "prepaymentFailureMessage": "لا يمكن دفع طلبك.\\nيرجى التحقق من معلومات الشراء." + "prepaymentFailureMessage": "لا يمكن دفع طلبك.\\nيرجى التحقق من معلومات الشراء.", + "hostAppContent": "بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم" } \ No newline at end of file diff --git a/Sample/lib/l10n/app_en.arb b/Sample/lib/l10n/app_en.arb index d8a70a9..d329073 100644 --- a/Sample/lib/l10n/app_en.arb +++ b/Sample/lib/l10n/app_en.arb @@ -2,5 +2,9 @@ "prepaymentFailureMessage": "Cannot pay your order.\nPlease, check purchase information", "@prepaymentFailureMessage": { "description": "This message will be showed when payment validation had been failed" + }, + "hostAppContent": "Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements", + "@hostAppContent": { + "description": "This message will be showed above and below checkout widget" } } \ No newline at end of file diff --git a/Sample/lib/l10n/app_localizations.dart b/Sample/lib/l10n/app_localizations.dart index 05055ab..95055f5 100644 --- a/Sample/lib/l10n/app_localizations.dart +++ b/Sample/lib/l10n/app_localizations.dart @@ -103,6 +103,12 @@ abstract class AppLocalizations { /// In en, this message translates to: /// **'Cannot pay your order.\nPlease, check purchase information'** String get prepaymentFailureMessage; + + /// This message will be showed above and below checkout widget + /// + /// In en, this message translates to: + /// **'Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements'** + String get hostAppContent; } class _AppLocalizationsDelegate diff --git a/Sample/lib/l10n/app_localizations_ar.dart b/Sample/lib/l10n/app_localizations_ar.dart index eba5e91..befe06d 100644 --- a/Sample/lib/l10n/app_localizations_ar.dart +++ b/Sample/lib/l10n/app_localizations_ar.dart @@ -11,4 +11,8 @@ class AppLocalizationsAr extends AppLocalizations { @override String get prepaymentFailureMessage => 'لا يمكن دفع طلبك.\\nيرجى التحقق من معلومات الشراء.'; + + @override + String get hostAppContent => + 'بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم، بعض عناصر واجهة المستخدم'; } diff --git a/Sample/lib/l10n/app_localizations_en.dart b/Sample/lib/l10n/app_localizations_en.dart index 0056dc6..8cdcf93 100644 --- a/Sample/lib/l10n/app_localizations_en.dart +++ b/Sample/lib/l10n/app_localizations_en.dart @@ -11,4 +11,8 @@ class AppLocalizationsEn extends AppLocalizations { @override String get prepaymentFailureMessage => 'Cannot pay your order.\nPlease, check purchase information'; + + @override + String get hostAppContent => + 'Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements, Some users UI elements'; } diff --git a/android/src/main/kotlin/com/ottu/flutter/checkout/CheckoutView.kt b/android/src/main/kotlin/com/ottu/flutter/checkout/CheckoutView.kt index 12efb4f..9e6ace4 100644 --- a/android/src/main/kotlin/com/ottu/flutter/checkout/CheckoutView.kt +++ b/android/src/main/kotlin/com/ottu/flutter/checkout/CheckoutView.kt @@ -299,24 +299,24 @@ internal class CheckoutView( showPaymentDetails = checkoutArguments.showPaymentDetails, appearanceLight = checkoutArguments.theme?.run { CheckoutTheme.Appearance( - mainTitleText = mainTitleText?.toCheckoutText(resources, packageName), - titleText = titleText?.toCheckoutText(resources, packageName), - selectPaymentMethodHeaderText = selectPaymentMethodHeaderText?.toCheckoutText( + mainTitleText = mainTitle?.toCheckoutText(resources, packageName), + titleText = title?.toCheckoutText(resources, packageName), + selectPaymentMethodHeaderText = selectPaymentMethodHeader?.toCheckoutText( resources, packageName ), - subtitleText = subtitleText?.toCheckoutText(resources, packageName), - feesTitleText = feesTitleText?.toCheckoutText(resources, packageName), - feesSubtitleText = feesSubtitleText?.toCheckoutText(resources, packageName), - dataLabelText = dataLabelText?.toCheckoutText(resources, packageName), - dataValueText = dataValueText?.toCheckoutText(resources, packageName), - errorMessageText = errorMessageText?.toCheckoutText(resources, packageName), + subtitleText = subtitle?.toCheckoutText(resources, packageName), + feesTitleText = feesTitle?.toCheckoutText(resources, packageName), + feesSubtitleText = feesSubtitle?.toCheckoutText(resources, packageName), + dataLabelText = dataLabel?.toCheckoutText(resources, packageName), + dataValueText = dataValue?.toCheckoutText(resources, packageName), + errorMessageText = errorMessage?.toCheckoutText(resources, packageName), inputTextField = inputTextField?.toCheckoutTextField( resources, packageName ), - sdkBackgroundColor = sdkBackgroundColor?.toCheckoutColor(), - selectPaymentMethodHeaderBackgroundColor = selectPaymentMethodHeaderBackgroundColor?.toCheckoutColor(), + sdkBackgroundColor = backgroundColor?.toCheckoutColor(), + selectPaymentMethodHeaderBackgroundColor = selectPaymentItemTitleBackgroundColor?.toCheckoutColor(), modalBackgroundColor = modalBackgroundColor?.toCheckoutColor(), paymentItemBackgroundColor = paymentItemBackgroundColor?.toCheckoutColor(), paymentItemBorderColor = paymentItemBorderColor?.toCheckoutColor(), @@ -333,24 +333,24 @@ internal class CheckoutView( }, appearanceDark = checkoutArguments.theme?.run { CheckoutTheme.Appearance( - mainTitleText = mainTitleText?.toCheckoutText(resources, packageName), - titleText = titleText?.toCheckoutText(resources, packageName), - selectPaymentMethodHeaderText = selectPaymentMethodHeaderText?.toCheckoutText( + mainTitleText = mainTitle?.toCheckoutText(resources, packageName), + titleText = title?.toCheckoutText(resources, packageName), + selectPaymentMethodHeaderText = selectPaymentMethodHeader?.toCheckoutText( resources, packageName ), - subtitleText = subtitleText?.toCheckoutText(resources, packageName), - feesTitleText = feesTitleText?.toCheckoutText(resources, packageName), - feesSubtitleText = feesSubtitleText?.toCheckoutText(resources, packageName), - dataLabelText = dataLabelText?.toCheckoutText(resources, packageName), - dataValueText = dataValueText?.toCheckoutText(resources, packageName), - errorMessageText = errorMessageText?.toCheckoutText(resources, packageName), + subtitleText = subtitle?.toCheckoutText(resources, packageName), + feesTitleText = feesTitle?.toCheckoutText(resources, packageName), + feesSubtitleText = feesSubtitle?.toCheckoutText(resources, packageName), + dataLabelText = dataLabel?.toCheckoutText(resources, packageName), + dataValueText = dataValue?.toCheckoutText(resources, packageName), + errorMessageText = errorMessage?.toCheckoutText(resources, packageName), inputTextField = inputTextField?.toCheckoutTextField( resources, packageName ), - sdkBackgroundColor = sdkBackgroundColor?.toCheckoutColor(), - selectPaymentMethodHeaderBackgroundColor = selectPaymentMethodHeaderBackgroundColor?.toCheckoutColor(), + sdkBackgroundColor = backgroundColor?.toCheckoutColor(), + selectPaymentMethodHeaderBackgroundColor = selectPaymentItemTitleBackgroundColor?.toCheckoutColor(), modalBackgroundColor = modalBackgroundColor?.toCheckoutColor(), paymentItemBackgroundColor = paymentItemBackgroundColor?.toCheckoutColor(), paymentItemBorderColor = paymentItemBorderColor?.toCheckoutColor(), diff --git a/android/src/main/kotlin/com/ottu/flutter/checkout/CustomerTheme.kt b/android/src/main/kotlin/com/ottu/flutter/checkout/CustomerTheme.kt index 8e8b0da..f8df1f0 100644 --- a/android/src/main/kotlin/com/ottu/flutter/checkout/CustomerTheme.kt +++ b/android/src/main/kotlin/com/ottu/flutter/checkout/CustomerTheme.kt @@ -5,19 +5,19 @@ import kotlinx.serialization.Serializable @Serializable data class CustomerTheme( val uiMode: String?, - val mainTitleText: TextStyle?, - val selectPaymentMethodHeaderText: TextStyle?, - val titleText: TextStyle?, - val subtitleText: TextStyle?, - val feesTitleText: TextStyle?, - val feesSubtitleText: TextStyle?, - val dataLabelText: TextStyle?, - val dataValueText: TextStyle?, - val errorMessageText: TextStyle?, + val mainTitle: TextStyle?, + val selectPaymentMethodHeader: TextStyle?, + val title: TextStyle?, + val subtitle: TextStyle?, + val feesTitle: TextStyle?, + val feesSubtitle: TextStyle?, + val dataLabel: TextStyle?, + val dataValue: TextStyle?, + val errorMessage: TextStyle?, val inputTextField: TextFieldStyle?, - val sdkBackgroundColor: ColorState?, + val backgroundColor: ColorState?, val modalBackgroundColor: ColorState?, - val selectPaymentMethodHeaderBackgroundColor: ColorState?, + val selectPaymentItemTitleBackgroundColor: ColorState?, val paymentItemBackgroundColor: ColorState?, val paymentItemDescriptionTextColor: ColorState?, val paymentItemBorderColor: ColorState?, diff --git a/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CheckoutPlatformView.swift b/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CheckoutPlatformView.swift index b85fc1c..117a5ae 100644 --- a/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CheckoutPlatformView.swift +++ b/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CheckoutPlatformView.swift @@ -319,7 +319,7 @@ public class CheckoutPlatformView: NSObject, FlutterPlatformView { return cht } - if let color = theme?.sdkBackgroundColor?.toUIColors() { + if let color = theme?.backgroundColor?.toUIColors() { if let cc = color.color { cht.backgroundColor = cc } @@ -331,7 +331,7 @@ public class CheckoutPlatformView: NSObject, FlutterPlatformView { } } - if let color = theme?.selectPaymentMethodHeaderBackgroundColor? + if let color = theme?.selectPaymentItemTitleBackgroundColor? .toUIColors() { if let cc = color.color { @@ -339,54 +339,54 @@ public class CheckoutPlatformView: NSObject, FlutterPlatformView { } } - if let comp = theme?.mainTitleText?.toLabelComponent( + if let comp = theme?.mainTitle?.toLabelComponent( ofSize: 20, weight: .semibold ) { cht.mainTitle = comp } - if let comp = theme?.selectPaymentMethodHeaderText?.toLabelComponent( + if let comp = theme?.selectPaymentMethodHeader?.toLabelComponent( ofSize: 20, weight: .semibold ) { cht.selectPaymentMethodTitleLabel = comp } - if let comp = theme?.titleText?.toLabelComponent( + if let comp = theme?.title?.toLabelComponent( ofSize: 17, weight: .semibold ) { cht.title = comp } - if let comp = theme?.subtitleText?.toLabelComponent(ofSize: 15) { + if let comp = theme?.subtitle?.toLabelComponent(ofSize: 15) { cht.subtitle = comp } - if let comp = theme?.feesTitleText?.toLabelComponent(ofSize: 17) { + if let comp = theme?.feesTitle?.toLabelComponent(ofSize: 17) { cht.feesTitle = comp } - if let comp = theme?.feesSubtitleText?.toLabelComponent(ofSize: 15) { + if let comp = theme?.feesSubtitle?.toLabelComponent(ofSize: 15) { cht.feesSubtitle = comp } - if let comp = theme?.dataLabelText?.toLabelComponent( + if let comp = theme?.dataLabel?.toLabelComponent( ofSize: 14, weight: .semibold ) { cht.dataLabel = comp } - if let comp = theme?.dataValueText?.toLabelComponent( + if let comp = theme?.dataValue?.toLabelComponent( ofSize: 16, weight: .semibold ) { cht.dataValue = comp } - if let comp = theme?.errorMessageText?.toLabelComponent( + if let comp = theme?.errorMessage?.toLabelComponent( ofSize: 13, weight: .semibold ) { diff --git a/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CustomerTheme.swift b/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CustomerTheme.swift index 81bc18c..85cb48d 100644 --- a/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CustomerTheme.swift +++ b/ios/ottu_flutter_checkout/Sources/ottu_flutter_checkout/CustomerTheme.swift @@ -7,19 +7,19 @@ struct CustomerTheme: Decodable { let uiMode: String? - let mainTitleText: TextStyle? - let selectPaymentMethodHeaderText: TextStyle? - let titleText: TextStyle? - let subtitleText: TextStyle? - let feesTitleText: TextStyle? - let feesSubtitleText: TextStyle? - let dataLabelText: TextStyle? - let dataValueText: TextStyle? - let errorMessageText: TextStyle? + let mainTitle: TextStyle? + let selectPaymentMethodHeader: TextStyle? + let title: TextStyle? + let subtitle: TextStyle? + let feesTitle: TextStyle? + let feesSubtitle: TextStyle? + let dataLabel: TextStyle? + let dataValue: TextStyle? + let errorMessage: TextStyle? let inputTextField: TextFieldStyle? - let sdkBackgroundColor: ColorState? + let backgroundColor: ColorState? let modalBackgroundColor: ColorState? - let selectPaymentMethodHeaderBackgroundColor: ColorState? + let selectPaymentItemTitleBackgroundColor: ColorState? let paymentItemBackgroundColor: ColorState? let paymentItemDescriptionTextColor: ColorState? let paymentItemBorderColor: ColorState? diff --git a/lib/src/checkout_theme.dart b/lib/src/checkout_theme.dart index 165068c..1bb5a7c 100644 --- a/lib/src/checkout_theme.dart +++ b/lib/src/checkout_theme.dart @@ -10,15 +10,15 @@ part 'checkout_theme.g.dart'; class CheckoutTheme extends Equatable { @_UiModeJsonConverter() final CustomerUiMode uiMode; - final TextStyle? mainTitleText; - final TextStyle? selectPaymentMethodHeaderText; - final TextStyle? titleText; - final TextStyle? subtitleText; - final TextStyle? feesTitleText; - final TextStyle? feesSubtitleText; - final TextStyle? dataLabelText; - final TextStyle? dataValueText; - final TextStyle? errorMessageText; + final TextStyle? mainTitle; + final TextStyle? selectPaymentMethodHeader; + final TextStyle? title; + final TextStyle? subtitle; + final TextStyle? feesTitle; + final TextStyle? feesSubtitle; + final TextStyle? dataLabel; + final TextStyle? dataValue; + final TextStyle? errorMessage; final TextFieldStyle? inputTextField; @@ -28,9 +28,9 @@ class CheckoutTheme extends Equatable { final SwitchComponent? switchControl; final Margins? margins; - final ColorState? sdkBackgroundColor; + final ColorState? backgroundColor; final ColorState? modalBackgroundColor; - final ColorState? selectPaymentMethodHeaderBackgroundColor; + final ColorState? selectPaymentItemTitleBackgroundColor; final ColorState? paymentItemBackgroundColor; final ColorState? paymentItemDescriptionTextColor; final ColorState? paymentItemBorderColor; @@ -41,24 +41,24 @@ class CheckoutTheme extends Equatable { CheckoutTheme({ this.uiMode = CustomerUiMode.auto, - this.titleText, - this.mainTitleText, - this.selectPaymentMethodHeaderText, - this.subtitleText, - this.feesTitleText, - this.feesSubtitleText, - this.dataLabelText, - this.dataValueText, - this.errorMessageText, + this.title, + this.mainTitle, + this.selectPaymentMethodHeader, + this.subtitle, + this.feesTitle, + this.feesSubtitle, + this.dataLabel, + this.dataValue, + this.errorMessage, this.inputTextField, this.button, this.backButton, this.selectorButton, this.switchControl, this.margins, - this.sdkBackgroundColor, + this.backgroundColor, this.modalBackgroundColor, - this.selectPaymentMethodHeaderBackgroundColor, + this.selectPaymentItemTitleBackgroundColor, this.paymentItemBackgroundColor, this.paymentItemDescriptionTextColor, this.paymentItemBorderColor, @@ -98,26 +98,26 @@ class CheckoutTheme extends Equatable { }) { return CheckoutTheme( uiMode: uiMode ?? this.uiMode, - titleText: titleText ?? this.titleText, - mainTitleText: mainTitleText ?? this.mainTitleText, - selectPaymentMethodHeaderText: - selectPaymentMethodHeaderText ?? this.selectPaymentMethodHeaderText, - subtitleText: subtitleText ?? this.subtitleText, - feesTitleText: feesTitleText ?? this.feesTitleText, - feesSubtitleText: feesSubtitleText ?? this.feesSubtitleText, - dataLabelText: dataLabelText ?? this.dataLabelText, - dataValueText: dataValueText ?? this.dataValueText, - errorMessageText: errorMessageText ?? this.errorMessageText, + title: titleText ?? this.title, + mainTitle: mainTitleText ?? this.mainTitle, + selectPaymentMethodHeader: + selectPaymentMethodHeaderText ?? this.selectPaymentMethodHeader, + subtitle: subtitleText ?? this.subtitle, + feesTitle: feesTitleText ?? this.feesTitle, + feesSubtitle: feesSubtitleText ?? this.feesSubtitle, + dataLabel: dataLabelText ?? this.dataLabel, + dataValue: dataValueText ?? this.dataValue, + errorMessage: errorMessageText ?? this.errorMessage, inputTextField: inputTextField ?? this.inputTextField, button: button ?? this.button, backButton: backButton ?? this.backButton, selectorButton: selectorButton ?? this.selectorButton, switchControl: switchControl ?? this.switchControl, margins: margins ?? this.margins, - sdkBackgroundColor: sdkBackgroundColor ?? this.sdkBackgroundColor, + backgroundColor: sdkBackgroundColor ?? this.backgroundColor, modalBackgroundColor: modalBackgroundColor ?? this.modalBackgroundColor, - selectPaymentMethodHeaderBackgroundColor: - selectPaymentMethodHeaderBackgroundColor ?? this.selectPaymentMethodHeaderBackgroundColor, + selectPaymentItemTitleBackgroundColor: + selectPaymentMethodHeaderBackgroundColor ?? this.selectPaymentItemTitleBackgroundColor, paymentItemBackgroundColor: paymentItemBackgroundColor ?? this.paymentItemBackgroundColor, paymentItemDescriptionTextColor: paymentItemDescriptionTextColor ?? this.paymentItemDescriptionTextColor, @@ -133,24 +133,24 @@ class CheckoutTheme extends Equatable { List get props => [ uiMode, - titleText, - mainTitleText, - selectPaymentMethodHeaderText, - subtitleText, - feesTitleText, - feesSubtitleText, - dataLabelText, - dataValueText, - errorMessageText, + title, + mainTitle, + selectPaymentMethodHeader, + subtitle, + feesTitle, + feesSubtitle, + dataLabel, + dataValue, + errorMessage, inputTextField, button, backButton, selectorButton, switchControl, margins, - sdkBackgroundColor, + backgroundColor, modalBackgroundColor, - selectPaymentMethodHeaderBackgroundColor, + selectPaymentItemTitleBackgroundColor, paymentItemBackgroundColor, paymentItemDescriptionTextColor, paymentItemBorderColor, diff --git a/lib/src/checkout_theme.g.dart b/lib/src/checkout_theme.g.dart index 987d22f..6a3d43a 100644 --- a/lib/src/checkout_theme.g.dart +++ b/lib/src/checkout_theme.g.dart @@ -12,35 +12,35 @@ CheckoutTheme _$CheckoutThemeFromJson( uiMode: json['uiMode'] == null ? CustomerUiMode.auto : const _UiModeJsonConverter().fromJson(json['uiMode'] as String), - titleText: json['titleText'] == null + title: json['title'] == null ? null - : TextStyle.fromJson(json['titleText'] as Map), - mainTitleText: json['mainTitleText'] == null + : TextStyle.fromJson(json['title'] as Map), + mainTitle: json['mainTitle'] == null ? null - : TextStyle.fromJson(json['mainTitleText'] as Map), - selectPaymentMethodHeaderText: json['selectPaymentMethodHeaderText'] == null + : TextStyle.fromJson(json['mainTitle'] as Map), + selectPaymentMethodHeader: json['selectPaymentMethodHeader'] == null ? null : TextStyle.fromJson( - json['selectPaymentMethodHeaderText'] as Map, + json['selectPaymentMethodHeader'] as Map, ), - subtitleText: json['subtitleText'] == null + subtitle: json['subtitle'] == null ? null - : TextStyle.fromJson(json['subtitleText'] as Map), - feesTitleText: json['feesTitleText'] == null + : TextStyle.fromJson(json['subtitle'] as Map), + feesTitle: json['feesTitle'] == null ? null - : TextStyle.fromJson(json['feesTitleText'] as Map), - feesSubtitleText: json['feesSubtitleText'] == null + : TextStyle.fromJson(json['feesTitle'] as Map), + feesSubtitle: json['feesSubtitle'] == null ? null - : TextStyle.fromJson(json['feesSubtitleText'] as Map), - dataLabelText: json['dataLabelText'] == null + : TextStyle.fromJson(json['feesSubtitle'] as Map), + dataLabel: json['dataLabel'] == null ? null - : TextStyle.fromJson(json['dataLabelText'] as Map), - dataValueText: json['dataValueText'] == null + : TextStyle.fromJson(json['dataLabel'] as Map), + dataValue: json['dataValue'] == null ? null - : TextStyle.fromJson(json['dataValueText'] as Map), - errorMessageText: json['errorMessageText'] == null + : TextStyle.fromJson(json['dataValue'] as Map), + errorMessage: json['errorMessage'] == null ? null - : TextStyle.fromJson(json['errorMessageText'] as Map), + : TextStyle.fromJson(json['errorMessage'] as Map), inputTextField: json['inputTextField'] == null ? null : TextFieldStyle.fromJson(json['inputTextField'] as Map), @@ -61,20 +61,19 @@ CheckoutTheme _$CheckoutThemeFromJson( margins: json['margins'] == null ? null : Margins.fromJson(json['margins'] as Map), - sdkBackgroundColor: json['sdkBackgroundColor'] == null + backgroundColor: json['backgroundColor'] == null ? null - : ColorState.fromJson(json['sdkBackgroundColor'] as Map), + : ColorState.fromJson(json['backgroundColor'] as Map), modalBackgroundColor: json['modalBackgroundColor'] == null ? null : ColorState.fromJson( json['modalBackgroundColor'] as Map, ), - selectPaymentMethodHeaderBackgroundColor: - json['selectPaymentMethodHeaderBackgroundColor'] == null + selectPaymentItemTitleBackgroundColor: + json['selectPaymentItemTitleBackgroundColor'] == null ? null : ColorState.fromJson( - json['selectPaymentMethodHeaderBackgroundColor'] - as Map, + json['selectPaymentItemTitleBackgroundColor'] as Map, ), paymentItemBackgroundColor: json['paymentItemBackgroundColor'] == null ? null @@ -109,25 +108,25 @@ Map _$CheckoutThemeToJson( CheckoutTheme instance, ) => { 'uiMode': const _UiModeJsonConverter().toJson(instance.uiMode), - 'mainTitleText': instance.mainTitleText, - 'selectPaymentMethodHeaderText': instance.selectPaymentMethodHeaderText, - 'titleText': instance.titleText, - 'subtitleText': instance.subtitleText, - 'feesTitleText': instance.feesTitleText, - 'feesSubtitleText': instance.feesSubtitleText, - 'dataLabelText': instance.dataLabelText, - 'dataValueText': instance.dataValueText, - 'errorMessageText': instance.errorMessageText, + 'mainTitle': instance.mainTitle, + 'selectPaymentMethodHeader': instance.selectPaymentMethodHeader, + 'title': instance.title, + 'subtitle': instance.subtitle, + 'feesTitle': instance.feesTitle, + 'feesSubtitle': instance.feesSubtitle, + 'dataLabel': instance.dataLabel, + 'dataValue': instance.dataValue, + 'errorMessage': instance.errorMessage, 'inputTextField': instance.inputTextField, 'button': instance.button, 'backButton': instance.backButton, 'selectorButton': instance.selectorButton, 'switchControl': instance.switchControl, 'margins': instance.margins, - 'sdkBackgroundColor': instance.sdkBackgroundColor, + 'backgroundColor': instance.backgroundColor, 'modalBackgroundColor': instance.modalBackgroundColor, - 'selectPaymentMethodHeaderBackgroundColor': - instance.selectPaymentMethodHeaderBackgroundColor, + 'selectPaymentItemTitleBackgroundColor': + instance.selectPaymentItemTitleBackgroundColor, 'paymentItemBackgroundColor': instance.paymentItemBackgroundColor, 'paymentItemDescriptionTextColor': instance.paymentItemDescriptionTextColor, 'paymentItemBorderColor': instance.paymentItemBorderColor,