stripe / stripe-android

Stripe Android SDK
https://stripe.com/docs/mobile/android
MIT License
1.29k stars 648 forks source link

Remove individually applied padding from form elements #9531

Closed samer-stripe closed 2 weeks ago

samer-stripe commented 2 weeks ago

Summary

This is a prototype of a first step to a solution for fixing form element padding within the form displayed in PaymentSheet. Rather than have the individual components define their own padding, the consumers of the elements must define how an element is spaced.

Motivation

We make a lot of padding assumptions when rendering elements, especially in regards to whether elements are above and/or below a rendered element. This has created problems in trying to properly space other UI elements outside the form because the bottom and top form padding are unknown to the consumer.

With better control over the padding in FormUI we can render the exact amount of padding we need within the form while removing any top padding from the first element and bottom padding from the last element, allowing the consumer better control over how to define the spacing outside the form which help immensely with fixing mandate and error spacing.

samer-stripe commented 2 weeks ago

With the individual padding removed, the components contain only their renderable element. The downside to this is that every screen must replicate this behavior. This is not necessarily a bad thing. It gives more control to developers using these elements manually (Identity, US Bank Account Form) to define the padding between elements as they expect based on design changes.

github-actions[bot] commented 2 weeks ago

Diffuse output:

OLD: paymentsheet-example-release-master.apk (signature: V1, V2)
NEW: paymentsheet-example-release-pr.apk (signature: V1, V2)

          │          compressed           │          uncompressed          
          ├───────────┬───────────┬───────┼───────────┬───────────┬────────
 APK      │ old       │ new       │ diff  │ old       │ new       │ diff   
──────────┼───────────┼───────────┼───────┼───────────┼───────────┼────────
      dex │   3.8 MiB │   3.8 MiB │ +32 B │   8.4 MiB │   8.4 MiB │ -132 B 
     arsc │   2.3 MiB │   2.3 MiB │   0 B │   2.3 MiB │   2.3 MiB │    0 B 
 manifest │     5 KiB │     5 KiB │   0 B │  24.7 KiB │  24.7 KiB │    0 B 
      res │ 931.2 KiB │ 931.2 KiB │   0 B │   1.5 MiB │   1.5 MiB │    0 B 
   native │   2.6 MiB │   2.6 MiB │   0 B │     6 MiB │     6 MiB │    0 B 
    asset │   1.6 MiB │   1.6 MiB │  -3 B │   1.6 MiB │   1.6 MiB │   -3 B 
    other │ 200.9 KiB │ 200.9 KiB │  -1 B │ 442.4 KiB │ 442.4 KiB │    0 B 
──────────┼───────────┼───────────┼───────┼───────────┼───────────┼────────
    total │  11.5 MiB │  11.5 MiB │ +28 B │  20.3 MiB │  20.3 MiB │ -135 B 

 DEX     │ old   │ new   │ diff           
─────────┼───────┼───────┼────────────────
   files │     1 │     1 │  0             
 strings │ 39655 │ 39653 │ -2 (+11 -13)   
   types │ 13666 │ 13665 │ -1 (+7 -8)     
 classes │ 11364 │ 11363 │ -1 (+2 -3)     
 methods │ 58386 │ 58381 │ -5 (+336 -341) 
  fields │ 38724 │ 38722 │ -2 (+512 -514) 

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  242 │  242 │  0   
 entries │ 6247 │ 6247 │  0
APK ``` compressed │ uncompressed │ ──────────┬───────┼───────────┬────────┤ size │ diff │ size │ diff │ path ──────────┼───────┼───────────┼────────┼──────────────────────────────── 3.8 MiB │ +32 B │ 8.4 MiB │ -132 B │ ∆ classes.dex 7.8 KiB │ -2 B │ 7.7 KiB │ -2 B │ ∆ assets/dexopt/baseline.prof 1,004 B │ -1 B │ 872 B │ -1 B │ ∆ assets/dexopt/baseline.profm 53.5 KiB │ +1 B │ 118.7 KiB │ 0 B │ ∆ META-INF/CERT.SF 1.2 KiB │ -1 B │ 1.2 KiB │ 0 B │ ∆ META-INF/CERT.RSA 50.3 KiB │ -1 B │ 118.6 KiB │ 0 B │ ∆ META-INF/MANIFEST.MF ──────────┼───────┼───────────┼────────┼──────────────────────────────── 3.9 MiB │ +28 B │ 8.6 MiB │ -135 B │ (total) ```
DEX ``` STRINGS: old │ new │ diff ───────┼───────┼────────────── 39655 │ 39653 │ -2 (+11 -13) + Le6/x; + Ly6/a; + VLLLZLLII + VLLLZLLLII + VZLLLLIII + [LH7/Y1; + [LH7/v0; + [Le6/n; + [Ls8/L1; + [Ls8/N1; + ~~R8{"backend":"dex","compilation-mode":"release","has-checksums":false,"min-api":21,"pg-map-id":"949af08","r8-mode":"full","version":"8.7.14"} - LH7/c2; - Ls8/O1; - Ly5/f; - VLLLZZLLII - VLLLZZLLLII - VZLLLIII - VZLLLIILI - [LH7/b2; - [LH7/x0; - [Le6/m; - [Ls8/M1; - [Ls8/O1; - ~~R8{"backend":"dex","compilation-mode":"release","has-checksums":false,"min-api":21,"pg-map-id":"6250490","r8-mode":"full","version":"8.7.14"} TYPES: old │ new │ diff ───────┼───────┼──────────── 13666 │ 13665 │ -1 (+7 -8) + Le6/x; + Ly6/a; + [LH7/Y1; + [LH7/v0; + [Le6/n; + [Ls8/L1; + [Ls8/N1; - LH7/c2; - Ls8/O1; - Ly5/f; - [LH7/b2; - [LH7/x0; - [Le6/m; - [Ls8/M1; - [Ls8/O1; METHODS: old │ new │ diff ───────┼───────┼──────────────── 58386 │ 58381 │ -5 (+336 -341) + A5.m0 G(boolean, f1, Set, f0, p, int, int, p, int) + B8.C (F1, boolean, c, int) + B8.C (Object, Object, boolean, int, int) + B8.C (boolean, Object, p, int, int) + B8.Y1 (H1, boolean, p, int, int) + B8.Y1 (boolean, int, a, a, int) + B8.g1 (boolean, f1, Set, f0, p, int, int, int) + B8.k (boolean, Object, f0, Object, int, int) + B8.p1 (Integer, String, p, boolean, e, a, int, int) + B8.p1 (List, int, boolean, c, z, p, z, int) + B8.y (String, boolean, boolean, m1, a, a, int, int) + D5.b (l, boolean, View, a) + D8.f (S0, long) + E5.e (m1, a, String, boolean) + H7.A0 (b, W, int) + H7.A0 f(Object) → Object + H7.A1 (List, v1, boolean, boolean, a, c, c, c, p, z, int) + H7.A1 e(Object, Object) → Object + H7.B0 (d, c, P, M, c, t, f, int) + H7.B0 e(Object, Object) → Object + H7.B1 (d0, boolean, int, int, int) + H7.C0 (B, d) + H7.C0 k(d, Object) → d + H7.C0 n(Object) → Object + H7.C1 (t1, float, boolean, boolean, boolean, boolean, c, c, c, p, int, int) + H7.D0 (W, int) + H7.D0 h(Object, d) → Object + H7.D1 (boolean, String, boolean) + H7.D1 f(Object) → Object + H7.E0 (d, W, d) + H7.E0 e(Object, Object) → Object + H7.E0 k(d, Object) → d + H7.E0 n(Object) → Object + H7.E1 (c, t1, int) + H7.E1 a() → Object + H7.F0 (E, W, d) + H7.F1 (float, boolean, boolean, c, p, int, int) + H7.F1 (String, boolean, boolean, float, a, int) + H7.F1 e(Object, Object) → Object + H7.G0 (d, W, d) + H7.G1 (v1, float, boolean, boolean, boolean, a, c, c, c, p, int) + H7.H0 (E0, d) + H7.H1 (J, int) + H7.H1 f(Object) → Object + H7.I0 (c) + H7.I0 a(i) + H7.I0 b() → e + H7.I0 equals(Object) → boolean + H7.I0 hashCode() → int + H7.I1 (boolean, h, d) + H7.I1 e(Object, Object) → Object + H7.I1 k(d, Object) → d + H7.I1 n(Object) → Object + H7.J0 (a) + H7.J0 a() + H7.J1 (int, W, d) + H7.K0 (float, boolean, a, p, int) + H7.K0 (S0, boolean, float, a, int) + H7.K0 (S0, boolean, a, float, int) + H7.K0 e(Object, Object) → Object + H7.K1 (List, boolean, boolean, v1, float, a, c, c, c) + H7.K1 f(Object) → Object + H7.L0 (int, boolean, long, a, int) + H7.L1 () + H7.M0 (int, long, long, Typeface) + H7.M1 (List, boolean, boolean, v1, float, a, c, c, c) + H7.M1 j(Object, Object, Object, Object) → Object + H7.N0 (B, a, boolean, S0, long) + H7.N1 (boolean, z, List, boolean, v1, a, c, c, c) + H7.N1 d(Object, Object, Object) → Object + H7.O0 (S0, boolean, long) + H7.O0 d(Object, Object, Object) → Object + H7.O1 (List, v1, boolean, boolean, boolean, boolean) + H7.O1 a(O1, List, v1, boolean, boolean, boolean, boolean, int) → O1 + H7.O1 equals(Object) → boolean + H7.O1 hashCode() → int + H7.O1 toString() → String + H7.P0 (boolean, boolean, a) + H7.P0 equals(Object) → boolean + H7.P0 hashCode() → int + H7.P0 toString() → String + H7.P1 () + H7.Q0 () + H7.Q1 (s1) + H7.S0 (int, int, boolean, boolean, boolean, a) + H7.S0 equals(Object) → boolean + H7.S0 hashCode() → int + H7.S0 toString() → String + H7.S1 (z ...✂ ```
emerge-tools[bot] commented 2 weeks ago

2 builds increased size, 1 build decreased size

Name Version Download Change Install Change Approval
Stripe Identity Example
com.stripe.android.identity.example.theme1
20.53.0-theme1 (20) 3.8 MB ⬆️ 758 B (0.02%) 8.9 MB ⬆️ 293 B N/A
Financial Connections Example
com.stripe.android.financialconnections.example
20.53.0 (205300) 4.2 MB ⬇️ 560 B (-0.01%) 9.4 MB ⬆️ 35 B N/A
PaymentSheet Example
com.stripe.android.paymentsheet.example
20.53.0 (11) 7.1 MB ⬆️ 360 B 14.4 MB ⬇️ 135 B N/A

Stripe Identity Example 20.53.0-theme1 (20)
com.stripe.android.identity.example.theme1

⚖️ Compare build ⏱️ Analyze build performance

Total install size change: ⬆️ 293 B Total download size change: ⬆️ 758 B (0.02%)

Largest size changes

Item Install Size Change Download Size Change
kotlin.math.MathKt ⬆️ 3.5 kB ⬆️ 1.7 kB
Other ⬇️ -3.2 kB ⬇️ -936 B
View Treemap [![Image of diff](https://diff-treemap-images.s3.us-west-1.amazonaws.com/6272f78c33c477006f824149/7ced7818-b945-489c-8f11-fbf0b12765de.a224021e-645f-4904-924d-c9cf0115a26d.png)](https://www.emergetools.com/compare?head=a224021e-645f-4904-924d-c9cf0115a26d&base=7ced7818-b945-489c-8f11-fbf0b12765de&sizeOpen=true&utm_source=github&utm_medium=vcs)

Financial Connections Example 20.53.0 (205300)
com.stripe.android.financialconnections.example

⚖️ Compare build ⏱️ Analyze build performance

Total install size change: ⬆️ 35 B Total download size change: ⬇️ 560 B (-0.01%)

Largest size changes

Item Install Size Change Download Size Change
📝 com.stripe.android.financialconnections.navigation.Destination$$E... ⬆️ 1.5 kB ⬆️ 702 B
com.stripe.android.financialconnections.features.common.Verificat... ⬇️ -1.4 kB ⬇️ -641 B
Other ⬇️ -97 B ⬇️ -621 B
View Treemap [![Image of diff](https://diff-treemap-images.s3.us-west-1.amazonaws.com/6272f78c33c477006f824149/90f22f91-2aae-461b-b24f-414c64cf726a.094d755e-227d-4204-b8f9-770398be5cbc.png)](https://www.emergetools.com/compare?head=094d755e-227d-4204-b8f9-770398be5cbc&base=90f22f91-2aae-461b-b24f-414c64cf726a&sizeOpen=true&utm_source=github&utm_medium=vcs)

PaymentSheet Example 20.53.0 (11)
com.stripe.android.paymentsheet.example

⚖️ Compare build ⏱️ Analyze build performance

Total install size change: ⬇️ 135 B Total download size change: ⬆️ 360 B

Largest size changes

Item Install Size Change Download Size Change
androidx.compose.material.TextFieldMeasurePolicy ⬇️ -3.0 kB ⬇️ -1.3 kB
com.google.android.libraries.places.internal.zzazh ⬆️ 2.4 kB ⬆️ 1.1 kB
Other ⬆️ 456 B ⬆️ 630 B
View Treemap [![Image of diff](https://diff-treemap-images.s3.us-west-1.amazonaws.com/6272f78c33c477006f824149/23a8e6ee-bf8f-4064-952e-7029c5a260cf.3be724f6-118e-4f5f-a046-fb9a5dbf6f18.png)](https://www.emergetools.com/compare?head=3be724f6-118e-4f5f-a046-fb9a5dbf6f18&base=23a8e6ee-bf8f-4064-952e-7029c5a260cf&sizeOpen=true&utm_source=github&utm_medium=vcs)

:flying_saucer: Powered by Emerge Tools