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

Refactor FormUI for Link use #4942

Merged
merged 7 commits into from
May 3, 2022
Merged

Refactor FormUI for Link use #4942

merged 7 commits into from
May 3, 2022

Conversation

brnunes-stripe
Copy link
Contributor

@brnunes-stripe brnunes-stripe commented May 1, 2022

Summary

  • Move TransformToPaymentMethodCreateParams into payments-ui-core as FieldValuesToParamsMapConverter.
  • Make all methods in FieldValuesToParamsMapConverter static since the class doesn't hold any state.
  • Move the logic that creates the Form UI into payments-ui-core.
  • Create ResourceRepositoryModule in payments-ui-core which provides the ResourceRepository so that Link can also depend on it.

Motivation

Refactoring for code reuse by Link.

Testing

  • Added tests
  • Modified tests
  • Manually verified

@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2022

Diffuse output:

OLD: paymentsheet-example-release-master.apk (signature: none)
NEW: paymentsheet-example-release-pr.apk (signature: none)

          │           compressed           │          uncompressed          
          ├──────────┬──────────┬──────────┼──────────┬──────────┬──────────
 APK      │ old      │ new      │ diff     │ old      │ new      │ diff     
──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────
      dex │ 13.5 MiB │ 13.5 MiB │ +1.8 KiB │ 45.2 MiB │ 45.2 MiB │ +5.2 KiB 
     arsc │  1.7 MiB │  1.7 MiB │      0 B │  1.7 MiB │  1.7 MiB │      0 B 
 manifest │  3.1 KiB │  3.1 KiB │      0 B │ 13.7 KiB │ 13.7 KiB │      0 B 
      res │  711 KiB │  711 KiB │      0 B │  1.1 MiB │  1.1 MiB │      0 B 
   native │  5.4 MiB │  5.4 MiB │      0 B │ 13.4 MiB │ 13.4 MiB │      0 B 
    asset │    3 MiB │    3 MiB │     -8 B │    3 MiB │    3 MiB │     -8 B 
    other │   80 KiB │   80 KiB │      0 B │  155 KiB │  155 KiB │      0 B 
──────────┼──────────┼──────────┼──────────┼──────────┼──────────┼──────────
    total │ 24.3 MiB │ 24.3 MiB │ +1.8 KiB │ 64.6 MiB │ 64.6 MiB │ +5.2 KiB 

         │          raw           │             unique              
         ├────────┬────────┬──────┼────────┬────────┬───────────────
 DEX     │ old    │ new    │ diff │ old    │ new    │ diff          
─────────┼────────┼────────┼──────┼────────┼────────┼───────────────
   files │      3 │      3 │    0 │        │        │               
 strings │ 218923 │ 218949 │  +26 │ 192564 │ 192586 │ +22 (+61 -39) 
   types │  38024 │  38035 │  +11 │  35165 │  35175 │ +10 (+17 -7)  
 classes │  32534 │  32543 │   +9 │  32534 │  32543 │  +9 (+16 -7)  
 methods │ 195616 │ 195646 │  +30 │ 189107 │ 189136 │ +29 (+64 -35) 
  fields │ 139594 │ 139610 │  +16 │ 138674 │ 138690 │ +16 (+27 -11) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  292 │  292 │  0   
 entries │ 5766 │ 5766 │  0
APK
     compressed     │    uncompressed     │                               
─────────┬──────────┼──────────┬──────────┤                               
 size    │ diff     │ size     │ diff     │ path                          
─────────┼──────────┼──────────┼──────────┼───────────────────────────────
 3.9 MiB │ +1.8 KiB │ 11.2 MiB │ +5.2 KiB │ ∆ classes3.dex                
 7.6 KiB │     -8 B │  7.4 KiB │     -8 B │ ∆ assets/dexopt/baseline.prof 
─────────┼──────────┼──────────┼──────────┼───────────────────────────────
 3.9 MiB │ +1.8 KiB │ 11.2 MiB │ +5.2 KiB │ (total)
DEX
STRINGS:

   old    │ new    │ diff          
  ────────┼────────┼───────────────
   192564 │ 192586 │ +22 (+61 -39) 
  + �
  
  ���
  ���
  ���
  �������0�8�X��¢��
  �����������0�8�X��¢��
  �����������0�X��¢��
  �����	¨�
  
  + �
  ���
  ��
  ���
  ���
  
  ���
  ����'� �2�0�:��B�¢����J�����0�2�����0�H'¨��
  + ,
  
  ���
  
  ���
  ���
  ���
  �� 
  ���
  
  ���
  
  ���
  ��������0�2�����0�H�¢�����U����0�2������
  ������0	0�0�2�
  ������0�0�2������
  ����0
  ��0�0�2����
  ������0	0�H�¢�����
  ����0�H�¢����¨��
  + 6
  ���
  ��
  ���
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  ���
  
  ���
  �������2�0�B���¢����J�����0�H�J
  ������0�H�J�����0�2��	��0
  H�J���������0
  02��������0�0�H�J����
  ������0
  02��������0�0�H�¨��
  + 8
  
  ���
  
  ���
  �� 
  ���
  
  ���
  
  ���
  ���
  ���
  ���
  ���
  ���
  ����s���0�2������
  ������0�0�0�2��������0�0�2�������
  ����0	��0�0�2��
  �
  ������0�0�2���������0
  ����0�0¢����¢����H�¢����¨��
  + :
  ���
  ��
  ���
  ���
  
  ���
  
  ���
  ���
  
  ���
  
  ���
  
  ���
  ���
  ����!� �2�0�:��B�¢����J�����0�2�����0�H'J�����0�2�����0	H'J��
  ��0�2����0
  H'J�����0�2�����0�H'¨��
  + D
  ���
  ��
  ���
  ���
  
  ��%
  ���
  
  �� 
  ���
  ���
  ���
  ��_
  ���
  ���
  ���
  
  ���
  ����2�0�B���¢����J;����0�2���������0�������0�0�2��������0�0	2��
  ����0�H�¢����J<���0�2��
  ��0�2���������0�������0�0�2���������0�������0�0�H�J���������0�0	2�����0�H�¢����J2��������0�������0�0�2���������0�����0�0�2��
  ��0�H�J����0�2���������0�����0�0�2��
  ��0�¨��
  + L
  ���
  ���
  
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  �7� �2�0�:���	
�
  ��������B���������0�¢����R�����0�¢��
  ������������������� !#¨�_
  + P
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  
  ���
  
  ���
  
  ���
  
  ���
  ���
  ���
  
  ���
  
  ���
  �����  2�0�:� B�¢����J_����0�2�����0�2�������0�2�������0�H�J�����0�2�����0�2�������0�H�J!������0�2�������0�2�����0�H�¢����R�����0�8BX���¢�
  �����������R��	��0
  8FX���¢�
  ��
  �������¨�!
  + _loadingComposable
  + _this_FormUI
  + (Landroidx/compose/foundation/layout/ColumnScope;Landroidx/compose/runtime/Composer;I)V
  + (Lkotlinx/coroutines/flow/Flow;Lkotlinx/coroutines/flow/Flow;Lkotlinx/coroutines/flow/Flow;Lkotlinx/coroutines/flow/Flow;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;I)V
  + C(FormUI)P(2,1)
  + CardCvc
  + FieldValuesToParamsMapConverter.kt
  + FormUI
  + FormUI_lambda-0
  + FormUI_lambda-1
  + FormUI_lambda-2
  + FormUI_lambda-3
  + Lcom/stripe/android/paymentsheet/forms/ComposableSingletons_FormUIKt_lambda-1_1;
  + Lcom/stripe/android/paymentsheet/forms/ComposableSingletons_FormUIKt;
  + Lcom/stripe/android/paymentsheet/forms/FormUIKt_FormInternal_1;
  + Lcom/stripe/android/paymentsheet/forms/FormUIKt_Loading_2;
  + Lcom/stripe/android/ui/core/FieldValuesToParamsMapConverter_Companion_getKeys_1;
  + Lcom/stripe/android/ui/core/FieldValuesToParamsMapConverter_Companion_getKeys_2;
  + Lcom/stripe/android/ui/core/FieldValuesToParamsMapConverter_Companion;
  + Lcom/stripe/android/ui/core/FieldValuesToParamsMapConverter;
  + Lcom/stripe/android/ui/core/FieldValuesToParamsMapConverterKt;
  + Lcom/stripe/android/ui/core/FormUIKt_FormUI_2;
  + Lcom/stripe/android/ui/core/FormUIKt;
  + Lcom/stripe/android/ui/core/elements/IdentifierSpec_CardCvc_Creator;
  + Lcom/stripe/android/ui/core/elements/IdentifierSpec_CardCvc;
  + Lcom/stripe/android/ui/core/forms/resources/injection/ResourceRepositoryModule_Companion;
  + Lcom/stripe/android/ui/core/forms/resources/injection/ResourceRepositoryModule;
  + Lcom/stripe/android/ui/core/forms/resources/injection/ResourceRepositoryModule_Companion_ProvideResourcesFactory;
  + LinkCardForm
  + ResourceRepositoryModule.kt
  + ResourceRepositoryModule_Companion_ProvideResourcesFactory.java
  + SMAP
  ComposeFormDataCollectionFragment.kt
  Kotlin
  *S Kotlin
  *F
  + 1 ComposeFormDataCollectionFragment.kt
  com/stripe/android/paymentsheet/paymentdatacollection/ComposeFormDataCollectionFragment
  + 2 FragmentViewModelLazy.kt
  androidx/fragment/app/FragmentViewModelLazyKt
  + 3 Maps.kt
  kotlin/collections/MapsKt__MapsKt
  *L
  1#1,161:1
  56#2,10:162
  84#2,6:172
  84#2,6:178
  536#3:184
  521#3,6:185
  *S KotlinDebug
  *F
  + 1 ComposeFormDataCollectionFragment.kt
  com/stripe/android/paymentsheet/paymentdatacollection/ComposeFormDataCollectionFragment
  *L
  48#1:162,10
  8
...✂

Base automatically changed from brnunes/paymentoptions to master May 2, 2022 23:08
jameswoo-stripe
jameswoo-stripe previously approved these changes May 2, 2022
Copy link
Contributor

@jameswoo-stripe jameswoo-stripe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple small things

# Conflicts:
#	paymentsheet/src/main/java/com/stripe/android/paymentsheet/BaseAddPaymentMethodFragment.kt
# Conflicts:
#	payments-ui-core/src/main/java/com/stripe/android/ui/core/FieldValuesToParamsMapConverter.kt
#	paymentsheet/src/test/java/com/stripe/android/paymentsheet/paymentdatacollection/TransformToPaymentMethodCreateParamMapTest.kt
@brnunes-stripe brnunes-stripe merged commit 1d5408b into master May 3, 2022
@brnunes-stripe brnunes-stripe deleted the brnunes/newcard branch May 3, 2022 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants