Skip to content

Improved JSON format for ButtonComponent codables#4408

Merged
joshdholtz merged 3 commits into
mainfrom
paywalls-components/improve-button-component-json
Oct 25, 2024
Merged

Improved JSON format for ButtonComponent codables#4408
joshdholtz merged 3 commits into
mainfrom
paywalls-components/improve-button-component-json

Conversation

@joshdholtz

@joshdholtz joshdholtz commented Oct 25, 2024

Copy link
Copy Markdown
Member

Motivation

The ButtonComponent had great looking enums but I just realized that they wouldn't codable the JSON structure that we want them too.

Description

Previously...

{
  "type": "button",
  "action": {
    "navigateTo": {
      "destination": {
        "privacyPolicy": {
          "urlLid": "https://example.com/privacy-policy",
          "method": "externalBrowser"
        }
      }
    }
  },
  "stack": {
    "type": "stack",
    "components": []
  }
}

Now...

{
  "type": "button",
  "action": {
    "type": "navigate_to",
    "destination": "privacy_policy",
    "url": {
      "urlLid": "https://example.com/terms-of-service",
      "method": "deepLink"
    }
  },
  "stack": {
    "type": "stack",
    "components": []
  }
}

@JayShortway JayShortway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Much better, thanks for fixing! Just 1 comment/question on type vs action.

Comment thread RevenueCatUI/Templates/Components/Button/ButtonComponentView.swift
Comment thread Sources/Paywalls/Components/PaywallButtonComponent.swift
Comment thread Sources/Paywalls/Components/PaywallButtonComponent.swift

@JayShortway JayShortway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very nice!

Comment on lines +76 to +83
{
"type": "button",
"action": {
"type": "navigate_to",
"destination": "customer_center"
},
"stack": \(jsonStringDefaultStack)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Beautiful!

@joshdholtz joshdholtz merged commit 5f9bd6c into main Oct 25, 2024
@joshdholtz joshdholtz deleted the paywalls-components/improve-button-component-json branch October 25, 2024 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants