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

Added new individual corner radius and border modifier #4328

Merged
merged 12 commits into from
Oct 16, 2024

Conversation

joshdholtz
Copy link
Member

@joshdholtz joshdholtz commented Sep 30, 2024

Motivation

We need borders for package selection states

Description

Replaced .roundedCorner() view modifier (which was from Paywalls V1) with new .borderCorner() view modifier

  • Allows individual clip radius for each corner
  • Allows individual border radius for each corner (border is an overlay)

Also added a bunch of SwiftUI previews (that will be used as snapshots once we enable Emerge)

SwiftUI Previews

Equal Radius - No Border No Radius - Blue Border Two Round - Blue Border Equal Radius - Blue Border Two Round - No Border
Screenshot 2024-10-02 at 3 00 34 PM Screenshot 2024-10-02 at 3 01 04 PM Screenshot 2024-10-02 at 3 01 43 PM Screenshot 2024-10-02 at 3 01 23 PM Screenshot 2024-10-02 at 3 01 11 PM

@joshdholtz joshdholtz mentioned this pull request Oct 1, 2024
4 tasks
@joshdholtz joshdholtz requested review from a team October 3, 2024 00:27
@joshdholtz joshdholtz marked this pull request as ready for review October 3, 2024 00:28
@joshdholtz joshdholtz changed the title [WIP] Added new individual corner radius and border modifier Added new individual corner radius and border modifier Oct 3, 2024
Copy link
Member

@JayShortway JayShortway left a comment

Choose a reason for hiding this comment

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

Absolutely beautiful! Had a few questions and suggestions.


}

struct RaidusInfo {
Copy link
Member

Choose a reason for hiding this comment

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

Typo 🙂

-    struct RaidusInfo {
+    struct RadiusInfo {

Copy link
Member Author

Choose a reason for hiding this comment

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

This is how I leave my mark everywhere I go but... I'll change it just for you 🫶

Copy link
Member

Choose a reason for hiding this comment

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

Haha I'm honored ❤️

Comment on lines +36 to +39
let topLeft: CGFloat?
let topRight: CGFloat?
let bottomLeft: CGFloat?
let bottomRight: CGFloat?
Copy link
Member

Choose a reason for hiding this comment

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

How does this work with RTL languages? Not sure how SwiftUI handles that in general, but should we rename them like so?

-        let topLeft: CGFloat?
-        let topRight: CGFloat?
-        let bottomLeft: CGFloat?
-        let bottomRight: CGFloat?
+        let topStart: CGFloat?
+        let topEnd: CGFloat?
+        let bottomStart: CGFloat?
+        let bottomEnd: CGFloat?

Copy link
Member Author

Choose a reason for hiding this comment

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

I should put a todo in here but we would have to manually flip it in this case for RTL languages since there isn't native support for this. Thanks for catching!

Comment on lines +164 to +185
// Start from the top-left corner
path.move(to: CGPoint(x: rect.minX + topLeft, y: rect.minY))

// Top edge and top-right corner
path.addLine(to: CGPoint(x: rect.maxX - topRight, y: rect.minY))
path.addQuadCurve(to: CGPoint(x: rect.maxX, y: rect.minY + topRight),
control: CGPoint(x: rect.maxX, y: rect.minY))

// Right edge and bottom-right corner
path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY - bottomRight))
path.addQuadCurve(to: CGPoint(x: rect.maxX - bottomRight, y: rect.maxY),
control: CGPoint(x: rect.maxX, y: rect.maxY))

// Bottom edge and bottom-left corner
path.addLine(to: CGPoint(x: rect.minX + bottomLeft, y: rect.maxY))
path.addQuadCurve(to: CGPoint(x: rect.minX, y: rect.maxY - bottomLeft),
control: CGPoint(x: rect.minX, y: rect.maxY))

// Left edge and top-left corner
path.addLine(to: CGPoint(x: rect.minX, y: rect.minY + topLeft))
path.addQuadCurve(to: CGPoint(x: rect.minX + topLeft, y: rect.minY),
control: CGPoint(x: rect.minX, y: rect.minY))
Copy link
Member

Choose a reason for hiding this comment

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

Beautiful! 😚👌

Comment on lines +108 to +111
topLeft: CGFloat?,
topRight: CGFloat?,
bottomLeft: CGFloat?,
bottomRight: CGFloat?
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if this makes sense, but we could also make these non-nil and default to 0? That way you can apply rounding to some corners, without having to specify all corners.

}

var border: BorderInfo?
var radiuses: RaidusInfo?
Copy link
Member

Choose a reason for hiding this comment

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

Is my understanding correct that we now have 2 ways to define corner radiuses, RadiusInfo and CornerRadiuses? Is that necessary, or can we consolidate the 2? I think it would be great if we could have a single concept of "corner radiuses".

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeaaaahhh, this is kind of confusing 🤔 I'll take another look to see if they can combined in a sensible way 💪

@joshdholtz joshdholtz force-pushed the paywalls-components/packages-views branch from 62fe323 to 55f6ad1 Compare October 4, 2024 02:06
@joshdholtz joshdholtz force-pushed the paywalls-components/packages-views branch from 1ba5ddf to 8fb89a4 Compare October 4, 2024 02:47
@joshdholtz joshdholtz force-pushed the paywalls-components/borders branch from 1e9ed50 to 690d572 Compare October 4, 2024 03:14
@joshdholtz joshdholtz force-pushed the paywalls-components/packages-views branch from 8fb89a4 to fc7311d Compare October 16, 2024 15:17
Base automatically changed from paywalls-components/packages-views to main October 16, 2024 15:59
@joshdholtz joshdholtz merged commit e772e93 into main Oct 16, 2024
7 checks passed
@joshdholtz joshdholtz deleted the paywalls-components/borders branch October 16, 2024 17:38
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.

3 participants