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

Span PMs across the PaymentSheet when there are only two of them. #4432

Merged
merged 2 commits into from
Dec 6, 2021

Conversation

skyler-stripe
Copy link
Contributor

@skyler-stripe skyler-stripe commented Dec 2, 2021

Summary

This makes it so when there are only two payment methods we span them across the sheet each taking 50% of the width. This matches iOS behavior: https://github.com/stripe-ios/stripe-ios/pull/538

Edit: We now span the payment methods evenly across the sheet if they all fit. See wide device screenshots for example.

Motivation

https://paper.dropbox.com/doc/Klarna-UI-polish-items--BWwhjD7FRVxPRMr5_HnXwep0AQ-Ox7FXrEh90mKen5IeploR

Testing

  • Added tests
  • Modified tests
  • Manually verified

Screenshots

Before 2 methods After 2 methods
twobefore twoafter
Before 2+ methods After 2+ methods
severalbefore severalafter
before extra wide 2+ methods after extra wide 2+ methods
widebefore wideafter

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2021

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 │  11.8 MiB │  11.8 MiB │ +57 B │  39.9 MiB │  39.9 MiB │ +68 B 
     arsc │   1.4 MiB │   1.4 MiB │   0 B │   1.4 MiB │   1.4 MiB │   0 B 
 manifest │   2.6 KiB │   2.6 KiB │   0 B │  10.6 KiB │  10.6 KiB │   0 B 
      res │ 653.3 KiB │ 653.3 KiB │   0 B │     1 MiB │     1 MiB │   0 B 
    asset │  77.8 KiB │  77.8 KiB │  +2 B │ 109.3 KiB │ 109.3 KiB │  +2 B 
    other │    78 KiB │    78 KiB │  +2 B │   154 KiB │   154 KiB │   0 B 
──────────┼───────────┼───────────┼───────┼───────────┼───────────┼───────
    total │    14 MiB │    14 MiB │ +61 B │  42.6 MiB │  42.6 MiB │ +70 B 


         │          raw           │           unique            
         ├────────┬────────┬──────┼────────┬────────┬───────────
 DEX     │ old    │ new    │ diff │ old    │ new    │ diff      
─────────┼────────┼────────┼──────┼────────┼────────┼───────────
   files │      3 │      3 │    0 │        │        │           
 strings │ 182390 │ 182390 │    0 │ 168530 │ 168530 │ 0 (+1 -1) 
   types │  32308 │  32308 │    0 │  30586 │  30586 │ 0 (+0 -0) 
 classes │  28260 │  28260 │    0 │  28260 │  28260 │ 0 (+0 -0) 
 methods │ 163762 │ 163762 │    0 │ 159239 │ 159239 │ 0 (+0 -0) 
  fields │ 110278 │ 110278 │    0 │ 109936 │ 109936 │ 0 (+0 -0) 


 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  288 │  288 │  0   
 entries │ 4368 │ 4368 │  0
APK
   compressed    │  uncompressed   │                                                       
─────────┬───────┼─────────┬───────┤                                                       
 size    │ diff  │ size    │ diff  │ path                                                  
─────────┼───────┼─────────┼───────┼───────────────────────────────────────────────────────
 3.4 MiB │ +57 B │ 9.9 MiB │ +68 B │ ∆ classes2.dex                                        
 5.6 KiB │  +2 B │ 5.4 KiB │  +2 B │ ∆ assets/dexopt/baseline.prof                         
   188 B │  +2 B │     6 B │   0 B │ ∆ META-INF/androidx.activity_activity-compose.version 
─────────┼───────┼─────────┼───────┼───────────────────────────────────────────────────────
 3.4 MiB │ +61 B │ 9.9 MiB │ +70 B │ (total)
DEX
STRINGS:

   old    │ new    │ diff      
  ────────┼────────┼───────────
   168530 │ 168530 │ 0 (+1 -1) 
  
  + SMAP
  AddPaymentMethodsAdapter.kt
  Kotlin
  *S Kotlin
  *F
  + 1 AddPaymentMethodsAdapter.kt
  com/stripe/android/paymentsheet/AddPaymentMethodsAdapter
  + 2 Delegates.kt
  kotlin/properties/Delegates
  + 3 View.kt
  androidx/core/view/ViewKt
  *L
  1#1,116:1
  33#2,3:117
  384#3,2:120
  371#3,2:122
  384#3,2:124
  371#3,2:126
  *S KotlinDebug
  *F
  + 1 AddPaymentMethodsAdapter.kt
  com/stripe/android/paymentsheet/AddPaymentMethodsAdapter
  *L
  21#1:117,3
  34#1:120,2
  34#1:122,2
  49#1:124,2
  49#1:126,2
  *E
  
  
  - SMAP
  AddPaymentMethodsAdapter.kt
  Kotlin
  *S Kotlin
  *F
  + 1 AddPaymentMethodsAdapter.kt
  com/stripe/android/paymentsheet/AddPaymentMethodsAdapter
  + 2 Delegates.kt
  kotlin/properties/Delegates
  + 3 View.kt
  androidx/core/view/ViewKt
  *L
  1#1,106:1
  33#2,3:107
  384#3,2:110
  371#3,2:112
  384#3,2:114
  371#3,2:116
  *S KotlinDebug
  *F
  + 1 AddPaymentMethodsAdapter.kt
  com/stripe/android/paymentsheet/AddPaymentMethodsAdapter
  *L
  21#1:107,3
  34#1:110,2
  34#1:112,2
  38#1:114,2
  38#1:116,2
  *E

@brnunes-stripe
Copy link
Contributor

brnunes-stripe commented Dec 3, 2021

Say you have an ultra wide screen like w540dp in #4321. For 2 PMs they'll be very wide and take the full width. For 3 they'll not, and will end in the middle of the screen. Is that what we want?
I'm guessing instead of hardcoding the number 2 you want to always let them take at least the full width.

@skyler-stripe
Copy link
Contributor Author

Say you have an ultra wide screen like w540dp in #4321. For 2 PMs they'll be very wide and take the full width. For 3 they'll not, and will end in the middle of the screen. Is that what we want? I'm guessing instead of hardcoding the number 2 you want to always let them take at least the full width.

That makes sense and gets rid of the magic numbers. I added screenshots of a wide device showing the PMs being spread across evenly.

@skyler-stripe skyler-stripe merged commit 6e2d53f into master Dec 6, 2021
@skyler-stripe skyler-stripe deleted the widths branch December 6, 2021 19:23
brnunes-stripe added a commit that referenced this pull request Dec 6, 2021
brnunes-stripe added a commit that referenced this pull request Dec 6, 2021
@skyler-stripe skyler-stripe restored the widths branch December 6, 2021 19:41
skyler-stripe added a commit that referenced this pull request Dec 6, 2021
)

* fix width of PMs when only two methods

* spread across for all number of PMs rather than just 2
skyler-stripe added a commit that referenced this pull request Dec 6, 2021
* Span PMs across the PaymentSheet when there are only two of them.  (#4432)

* fix width of PMs when only two methods

* spread across for all number of PMs rather than just 2

* fix unit test
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.

None yet

3 participants