-
Notifications
You must be signed in to change notification settings - Fork 115
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
[Woo POS][Design System] Reimplement 0.5 width for 4 payment error views #15249
Open
jaclync
wants to merge
12
commits into
trunk
Choose a base branch
from
feat/15235-error-view-design
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+80
−32
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f3b8968
PointOfSaleCardPresentPaymentErrorMessageView: update layout so that …
jaclync 6745fc3
PointOfSaleCardPresentPaymentCaptureErrorMessageView: update layout a…
jaclync 6f0f744
PointOfSaleCardPresentPaymentIntentCreationErrorMessageView: remove h…
jaclync 4ea1fbf
PointOfSaleCardPresentPaymentNonRetryableErrorMessageView: update lay…
jaclync 5207425
Remove unused `PointOfSaleCardPresentPaymentLayout` constant.
jaclync d72fd94
Merge branch 'trunk' into feat/15235-error-view-design
jaclync d5355e1
Fix test case now that `PointOfSaleCardPresentPaymentCaptureErrorMess…
jaclync 2bf7c2a
Also set text container to 0.5 width to be consistent with CTA.
jaclync e54b35e
Merge branch 'trunk' into feat/15235-error-view-design
jaclync 5ef6ccf
Remove unused topAligned constant.
jaclync a74e66a
Create `DynamicWidthScaler` to dynamically scale width based on dynam…
jaclync 0343e5d
Update 4 error message views to use `dynamicWidthScaling` instead of …
jaclync File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
WooCommerce/Classes/POS/Presentation/Reusable Views/DynamicFrameScaler.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import SwiftUI | ||
|
||
/// A view modifier that adjusts the width multiplier based on dynamic type size. | ||
struct DynamicWidthScaler: ViewModifier { | ||
@Environment(\.dynamicTypeSize) private var dynamicTypeSize | ||
let containerWidth: CGFloat | ||
let threshold: DynamicTypeSize | ||
let smallSizeScale: CGFloat | ||
let largeSizeScale: CGFloat | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.frame(width: containerWidth * widthMultiplier) | ||
} | ||
|
||
/// Returns a width multiplier based on the current dynamic type size | ||
private var widthMultiplier: CGFloat { | ||
dynamicTypeSize >= threshold ? largeSizeScale : smallSizeScale | ||
} | ||
} | ||
|
||
extension View { | ||
/// Applies a dynamic width scaling based on the current dynamic type size. | ||
/// - Parameters: | ||
/// - containerWidth: The container width to scale. | ||
/// - threshold: The dynamic type size threshold at which to switch from small to large scale (default: .accessibility2). | ||
/// - smallSizeScale: The scale factor to apply for sizes smaller than the threshold (default: 0.5). | ||
/// - largeSizeScale: The scale factor to apply for sizes larger than or equal to the threshold (default: 1.0). | ||
/// - Returns: A view with dynamically scaled width | ||
func dynamicWidthScaling( | ||
containerWidth: CGFloat, | ||
threshold: DynamicTypeSize = .accessibility2, | ||
smallSizeScale: CGFloat = 0.5, | ||
largeSizeScale: CGFloat = 1.0 | ||
) -> some View { | ||
modifier(DynamicWidthScaler( | ||
containerWidth: containerWidth, | ||
threshold: threshold, | ||
smallSizeScale: smallSizeScale, | ||
largeSizeScale: largeSizeScale | ||
)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove the
topAligned
definition if we're not using it here. Or update it to match this new one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, removed in 5ef6ccf.