Skip to content

fix: fix paymentButtons color preservation in Demo - #1716

Merged
noguier merged 1 commit into
mainfrom
paymentbuttons-color-fix-demo
Sep 29, 2026
Merged

noguier merged 1 commit into
mainfrom
paymentbuttons-color-fix-demo

Conversation

@noguier

@noguier noguier commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Summary of changes

We noticed that the color of the payment button is defaulting to blue ("default color") after orientation change, this PR fixes that in the Demo app

  • use rememberSaveable instead of simple remember to save the int as a style selection index.
  • add a parameter to SingleChoiceSegmentedButton that will pass the index of the button style to the function
  • moved index to color mapping logic outside of onClick to map Int to the color value on every recomposition
Screen.Recording.2026-09-28.at.4.33.13.PM.mov

AI Usage

Which AI Agent Was Used?

  • Copilot
  • Claude
  • Other (Type Name Here)

How was AI used?
Solution brainstorming

Estimated AI Code Contribution

  • less than 30%
  • 30 - 60%
  • 60 - 100%

Checklist

  • Added a changelog entry
  • Tested and confirmed payment flows affected by this change are functioning as expected

Authors

List GitHub usernames for everyone who contributed to this pull request.
@noguier

@noguier
noguier requested review from a team and a balanced review from Copilot September 28, 2026 22:00
@noguier
noguier requested a review from a team as a code owner September 28, 2026 22:00
@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The behavior fix needs an entry under the changelog’s unreleased section.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Preserves selected PayPal and Venmo button colors across Demo configuration changes.

Changes:

  • Saves selected color indices with rememberSaveable.
  • Hoists segmented-button selection state.
  • Recomputes button colors from saved indices.
File Description
Demo/​src/​main/​java/​com/​braintreepayments/​demo/​ComposeUIComponentsFragment.kt Persists and restores payment-button color selection.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

setContent {
var venmoStyle: VenmoButtonColor by remember { mutableStateOf(VenmoButtonColor.Blue) }
var paypalStyle: PayPalButtonColor by remember { mutableStateOf(PayPalButtonColor.Blue) }
var venmoStyleId by rememberSaveable { mutableIntStateOf(VenmoButtonColor.Blue.key) }

@saralvasquez saralvasquez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Works great! Thanks for doing this is being open to a simpler execution!

@buzzamus buzzamus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This approach is nice and simple! I like it

@noguier
noguier merged commit c395037 into main Sep 29, 2026
14 checks passed
@noguier
noguier deleted the paymentbuttons-color-fix-demo branch September 29, 2026 14:07
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