Skip to content

Use scoped appearance values in PaymentSheet - #13769

Open
toluo-stripe wants to merge 1 commit into
masterfrom
tolu/appearance/scoped_payment_element_theme
Open

Use scoped appearance values in PaymentSheet#13769
toluo-stripe wants to merge 1 commit into
masterfrom
tolu/appearance/scoped_payment_element_theme

Conversation

@toluo-stripe

@toluo-stripe toluo-stripe commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Stacked on parent PR #13481.

  • Adds PaymentElementTheme, which derives immutable theme values from PaymentSheet.Appearance and resolves its configured ThemeMode.
  • Provides PaymentSheet appearance values through scoped Compose theme locals instead of reading from the mutable global StripeTheme singleton in PaymentSheet-owned views.
  • Preserves parseAppearance() and the legacy StripeTheme overload for callers that have not migrated yet.
  • Aligns the Android context UI mode with the selected PaymentSheet mode so Android Views and resource lookups use the same light or dark appearance.
  • Leaves Link, Financial Connections, Connect, crypto, Identity, CustomerSheet, and the embedded Payment Element unchanged.

Motivation

PaymentSheet appearance was parsed into process-wide mutable theme values. A composable could therefore read values written by a different PaymentSheet instance, and forced light or dark mode was not consistently available to every descendant. Scoping the converted appearance to the PaymentSheet composition makes the configured appearance the source of truth while retaining compatibility for unmigrated surfaces.

Testing

  • Added tests
  • Modified tests
  • Manually verified

Screenshots

Not included. Forced light/dark palette selection and Android context UI mode are covered by Robolectric Compose tests.

Changelog

Not included in this internal implementation PR; the user-facing changelog will be handled with the completed stack.

@toluo-stripe
toluo-stripe requested review from a team as code owners August 5, 2026 19:25
@toluo-stripe
toluo-stripe requested review from samer-stripe and removed request for a team August 5, 2026 19:25
@toluo-stripe
toluo-stripe force-pushed the tolu/appearance/scoped_payment_element_theme branch from 52e27eb to 4d2bd99 Compare August 5, 2026 19:26
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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 │   4.6 MiB │   4.6 MiB │ +1.1 KiB │   9.8 MiB │   9.8 MiB │   +1 KiB 
     arsc │   3.8 MiB │   3.8 MiB │ -1.4 KiB │   3.8 MiB │   3.8 MiB │ -1.4 KiB 
 manifest │   5.8 KiB │   5.8 KiB │     -2 B │  30.9 KiB │  30.9 KiB │      0 B 
      res │     1 MiB │     1 MiB │     -1 B │   1.7 MiB │   1.7 MiB │      0 B 
   native │   2.7 MiB │   2.7 MiB │      0 B │   2.7 MiB │   2.7 MiB │      0 B 
    asset │    21 KiB │  21.1 KiB │    +66 B │    31 KiB │  31.1 KiB │    +66 B 
    other │ 245.5 KiB │ 245.5 KiB │     -9 B │ 505.4 KiB │ 505.4 KiB │      0 B 
──────────┼───────────┼───────────┼──────────┼───────────┼───────────┼──────────
    total │  12.4 MiB │  12.4 MiB │   -292 B │  18.5 MiB │  18.5 MiB │   -354 B 

 DEX     │ old   │ new   │ diff              
─────────┼───────┼───────┼───────────────────
   files │     1 │     1 │   0               
 strings │ 45659 │ 45655 │  -4 (+102 -106)   
   types │ 14412 │ 14405 │  -7 (+88 -95)     
 classes │ 11726 │ 11720 │  -6 (+13 -19)     
 methods │ 63847 │ 63835 │ -12 (+4583 -4595) 
  fields │ 41725 │ 41740 │ +15 (+3585 -3570) 

 ARSC    │ old  │ new  │ diff       
─────────┼──────┼──────┼────────────
 configs │  320 │  320 │  0         
 entries │ 7502 │ 7500 │ -2 (+0 -2)
APK
     compressed      │     uncompressed     │                                           
──────────┬──────────┼───────────┬──────────┤                                           
 size     │ diff     │ size      │ diff     │ path                                      
──────────┼──────────┼───────────┼──────────┼───────────────────────────────────────────
  3.8 MiB │ -1.4 KiB │   3.8 MiB │ -1.4 KiB │ ∆ resources.arsc                          
  4.6 MiB │ +1.1 KiB │   9.8 MiB │   +1 KiB │ ∆ classes.dex                             
    9 KiB │    +54 B │   8.9 KiB │    +54 B │ ∆ assets/dexopt/baseline.prof             
  1.2 KiB │    +12 B │   1.1 KiB │    +12 B │ ∆ assets/dexopt/baseline.profm            
 58.9 KiB │    -11 B │ 130.8 KiB │      0 B │ ∆ META-INF/CERT.SF                        
  5.8 KiB │     -2 B │  30.9 KiB │      0 B │ ∆ AndroidManifest.xml                     
 55.6 KiB │     +2 B │ 130.7 KiB │      0 B │ ∆ META-INF/MANIFEST.MF                    
    270 B │     -1 B │     120 B │      0 B │ ∆ META-INF/version-control-info.textproto 
    785 B │     -1 B │   1.6 KiB │      0 B │ ∆ res/Bh.xml                              
  1.2 KiB │     +1 B │   1.2 KiB │      0 B │ ∆ META-INF/CERT.RSA                       
──────────┼──────────┼───────────┼──────────┼───────────────────────────────────────────
  8.6 MiB │   -292 B │  13.9 MiB │   -354 B │ (total)
DEX
STRINGS:

   old   │ new   │ diff           
  ───────┼───────┼────────────────
   45659 │ 45655 │ -4 (+102 -106) 
  
  + , formInsets=
  + , primaryButtonStyle=
  + Ldl/q6;
  + Ldm/u;
  + Ldm/v;
  + Lgm/l5;
  + Lmh/k;
  + Loj/j5;
  + Loj/k5;
  + Lqf/o;
  + Lsf/p;
  + Lum/i;
  + Lvh/s0;
  + Lwj/q1;
  + Ly0/u0;
  + PaymentElementThemeValues(colorsLight=
  + VLLLLLLLLLF
  + VLLLLLLLZI
  + VLLLZLLJZLLJLZZ
  + VZLLLLLLLLLFLII
  + VZLLLLLLLLLFLLII
  + [Lbl/i;
  + [Ldl/n2;
  + [Ldl/q5;
  + [Ldl/u5;
  + [Lgm/c4;
  + [Lgm/h4;
  + [Lhd/f0;
  + [Lhd/l0;
  + [Lhd/w0;
  + [Lhd/y;
  + [Ljg/a1;
  + [Ljg/d1;
  + [Ljg/h1;
  + [Ljg/k1;
  + [Ljg/q0;
  + [Ljg/t0;
  + [Ljg/x0;
  + [Ljg/y1;
  + [Lmm/p;
  + [Loj/b1;
  + [Loj/b2;
  + [Loj/b3;
  + [Loj/e2;
  + [Loj/j2;
  + [Loj/j4;
  + [Loj/k4;
  + [Loj/l2;
  + [Loj/n0;
  + [Loj/n1;
  + [Loj/p2;
  + [Loj/q4;
  + [Loj/u0;
  + [Loj/u1;
  + [Loj/x2;
  + [Loj/y3;
  + [Lpj/p0;
  + [Lpj/s1;
  + [Lpj/w1;
  + [Lqe/c;
  + [Lqe/j;
  + [Lum/g;
  + [Lvc/h0;
  + [Lvc/j0;
  + [Lvh/k;
  + [Lvh/n;
  + [Lwj/n1;
  + [Lxi/l;
  + [Lxj/c0;
  + [Lxj/g0;
  + [Lxl/a0;
  + [Lxl/b2;
  + [Lxl/c3;
  + [Lxl/e2;
  + [Lxl/e3;
  + [Lxl/e4;
  + [Lxl/g5;
  + [Lxl/h2;
  + [Lxl/h3;
  + [Lxl/i0;
  + [Lxl/j1;
  + [Lxl/k2;
  + [Lxl/k3;
  + [Lxl/l0;
  + [Lxl/m1;
  + [Lxl/m2;
  + [Lxl/n4;
  + [Lxl/q3;
  + [Lxl/q4;
  + [Lxl/v3;
  + [Lxl/w4;
  + [Lxl/x;
  + [Lz0/l1;
  + [Lz0/y1;
  + [Lzk/e;
  + [Lzk/g;
  + formInsets
  + getLabelTextStyle
  + r8-map-id-86550e1c3fef5ba2886e31c54c566110f9100e67ccc5e07b792d7fd0a456b88b
  + sectionStyle
  + setLabelTextStyle
  + ~~R8{"backend":"dex","compilation-mode":"release","has-checksums":false,"min-api":23,"pg-map-id":"86550e1c3fef5ba2886e31c54c566110f9100e67ccc5e07b792d7fd0a456b88b","r8-mode":"full","version":"8.13.19"}
  
  - Country(additionalFieldsByCountry=
  - GooglePayDisplayItem(label=
  - Lbl/a1;
  - Lei/h;
  - Lhd/f1;
  - Lik/o;
  - Ljj/m;
  - Lmm/f0;
  - Lpj/x1;
  - Lqe/o;
  - Lr3/w;
  - Lri/d;
  - Lvc/s0;
  - Lvl/q;
  - Lxj/d1;
  - Lxl/h5;
  - Lxl/i5;
  - Lxl/j5;
  - Lxl/k5;
  - Lz/b2;
  - Lzk/p;
  - VLLZLLJZLLJLZZ
  - [Lbl/x;
  - [Ldl/l2;
  - [Ldl/n5;
  - [Ldl/t5;
  - [Lgm/b4;
  - [Lgm/g4;
  - [Lhd/f1;
  - [Lhd/i0;
  - [Lhd/o0;
  - [Lhd/z;
  - [Ljg/c1;
  - [Ljg/g1;
  - [Ljg/j1;
  - [Ljg/p0;
  - [Ljg/s0;
  - [Ljg/w0;
  - [Ljg/x1;
  - [Ljg/z0;
  - [Lmm/r;
  - [Loj/c2;
  - [Loj/c3;
  - [Loj/e4;
  - [Loj/f1;
  - [Loj/f2;
  - [Loj/f4;
  - [Loj/k2;
  - [Loj/m0;
  - [Loj/o1;
  - [Loj/o2;
  - [Loj/o4;
  - [Loj/q2;
  - [Loj/s0;
  - [Loj/v1;
  - [Loj/y0;
  - [Loj/y2;
  - [Lpj/q0;
  - [Lpj/t1;
  - [Lpj/x1;
  - [Lqe/d;
  - [Lqe/k;
  - [Lri/d;
  - [Lum/f;
  - [Lvc/i0;
  - [Lvc/k0;
  - [Lvh/i;
  - [Lvh/l;
  - [Lwj/k1;
  - [Lxi/m;
  - [Lxj/f0;
  - [Lxj/z;
  - [Lxl/b0;
  - [Lxl/f2;
  - [Lxl/g3;
  - [Lxl/h4;
  - [Lxl/i2;
  - [Lxl/i3;
  - [Lxl/i4;
  - [Lxl/i5;
  - [Lxl/k5;
  - [Lxl/l2;
  - [Lxl/l3;
  - [Lxl/n1;
  - [Lxl/o2;
  - [Lxl/o3;
  - [Lxl/p0;
  - [Lxl/q1;
  - [Lxl/r4;
  - [Lxl/s0;
  - [Lxl/u4;
  - [Lxl/y2;
  - [Lxl/y3;
  - [Lxl/y;
  - [Lz0/k1;
  - [Lz0/x1;
  - [Lzk/f;
  - [Lzk/h;
  - r8-map-id-e8488517386e2fe3bd7e1e7b227f592e9109af435155a112806423f030d3c79e
  - tax_region[city]
  - tax_region[country]
  - tax_region[line1]
  - tax_region[line2]
  - tax_region[postal_code]
  - tax_region[state]
  - ~~R8{"backend":"dex","compilation-mode":"release","has-checksums":false,"min-api":23,"pg-map-id":"e8488517386e2fe3bd7e1e7b227f592e9109af435155a112806423f030d3c79e","r8-mode":"full","version":"8.13.19"}
  

TYPES:

   old   │ new   │ diff         
  ───────┼───────┼──────────────
   14412 │ 14405 │ -7 (+88 -95) 
  
  + Ldl/q6;
  + Ldm/u;
  + Ldm/v;
  + Lgm/l5;
  + Lmh/k;
  + Loj/j5;
  + Loj/k5;
  + Lqf/o;
  + Lsf/p;
  + Lum/i;
  + Lvh/s0;
  + Lwj/q1;
  + Ly0/u0;
  + [Lbl/i;
  + [Ldl/n2;
  + [Ldl/q5;
  + [Ldl/u5;
  + [Lgm/c4;
  + [Lgm/h4;
  + [Lhd/f0;
  + [Lhd/l0;
  + [Lhd/w0;
  + [Lhd/y;
  + [Ljg/a1;
  + [Ljg/d1;
  + [Ljg/h1;
  + [Ljg/k1;
  + [Ljg/q0;
  + [Ljg/t0;
  + [Ljg/x0;
  + [Ljg/y1;
  + [Lmm/p;
  + [Loj/b1;
  + [Loj/b2;
  + [Loj/b3;
  + [Loj/e2;
  + [Loj/j2;
  + [Loj/j4;
  + [Loj/k4;
  + [Loj/l2;
  + [Loj/n0;
  + [Loj/n1;
  + [Loj/p2;
  + [Loj/q4;
  + [Loj/u0;
  + [Loj/u1;
  + [Loj/x2;
  + [Loj/y3;
  + [Lpj/p0;
  + [Lpj/s1;
  + [Lpj/w1;
  + [Lqe/c;
  + [Lqe/j;
  + [Lum/g;
  + [Lvc/h0;
  + [Lvc/j0;
  + [Lvh/k;
  + [Lvh/n;
  + [Lwj/n1;
  + [Lxi/l;
  + [Lxj/c0;
  + [Lxj/g0;
  + [Lxl/a0;
  + [Lxl/b2;
  + [Lxl/c3;
  + [Lxl/e2;
  + [Lxl/e3;
  + [Lxl/e4;
  + [Lxl/g5;
  + [Lxl/h2;
  + [Lxl/h3;
  + [Lxl/i
...✂
ARSC
ENTRIES:

   old  │ new  │ diff       
  ──────┼──────┼────────────
   7502 │ 7500 │ -2 (+0 -2) 
  - string/stripe_google_pay_cost_excluding_tax
  - string/stripe_google_pay_estimated_total

@toluo-stripe
toluo-stripe marked this pull request as draft August 6, 2026 14:42
@toluo-stripe
toluo-stripe force-pushed the tolu/appearance/scoped_payment_element_theme branch from 4d2bd99 to 7240060 Compare August 6, 2026 14:56
@toluo-stripe
toluo-stripe force-pushed the tolu/appearance/scoped_payment_element_theme branch from 7240060 to 2e379f5 Compare August 6, 2026 15:01
Base automatically changed from tolu/appearance/theme_mode_implementation to master August 6, 2026 15:18
@toluo-stripe
toluo-stripe force-pushed the tolu/appearance/scoped_payment_element_theme branch 3 times, most recently from 3240b5f to 046c25e Compare August 7, 2026 18:48
Committed-By-Agent: codex
Co-authored-by: codex <noreply@openai.com>
Committed-By-Agent: codex
Co-authored-by: codex <noreply@openai.com>
Committed-By-Agent: codex
Co-authored-by: codex <noreply@openai.com>
@toluo-stripe
toluo-stripe force-pushed the tolu/appearance/scoped_payment_element_theme branch from 046c25e to 2ba9632 Compare August 7, 2026 18:51
@toluo-stripe
toluo-stripe marked this pull request as ready for review August 7, 2026 19:11
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.

1 participant