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

[Woo POS] Accessibility improvements iOS17+ #14970

Open
iamgabrielma opened this issue Jan 24, 2025 · 1 comment
Open

[Woo POS] Accessibility improvements iOS17+ #14970

iamgabrielma opened this issue Jan 24, 2025 · 1 comment
Labels
category: accessibility Related to accessibility. feature: POS type: enhancement A request for an enhancement.

Comments

@iamgabrielma
Copy link
Contributor

iamgabrielma commented Jan 24, 2025

Ref: #14919 (review)

In some views we need to set upper bounds to accessibility sizes so we can still fit all the elements. For example in the case of Cash Collection when the keyboard is open it will take half of the screen, risking buttons being hidden. This can be improved with the usage of .safeAreaPadding

Since we still need a fallback while we support iOS16, we need to create several extensions that would apply the view modifiers conditionally based on iOS versions. For the case above:

extension View {
    @ViewBuilder
    func safeAreaPaddingIfAvailable(_ edges: Edge.Set, _ length: CGFloat) -> some View {
        if #available(iOS 17.0, *) {
            self.safeAreaPadding(edges, length)
        } else {
            self.padding(edges, length)
        }
    }
}

struct ConditionalDynamicTypeSizeModifier: ViewModifier {
    func body(content: Content) -> some View {
        if #available(iOS 17, *) {
            // On iOS 17 and above, do not limit the dynamic type size
            content
        } else {
            // On iOS 16 or lower, apply the .dynamicTypeSize(...Accessibility1) (or other) limit
            content.dynamicTypeSize(...DynamicTypeSize.accessibility1)
        }
    }
}

extension View {
    /// Applies `.dynamicTypeSize(...DynamicTypeSize.accessibility1)` only on iOS < 17.
    func conditionalDynamicTypeSizeLimit() -> some View {
        modifier(ConditionalDynamicTypeSizeModifier())
    }
}

In the case above for cash collection, combining these a keyboard height observer and applying the modifiers to the ScrollView would make this scrollable despite the keyboard.

                .safeAreaPaddingIfAvailable(.bottom, keyboardObserver.keyboardHeight)
                .scrollDismissesKeyboard(.interactively)
@iamgabrielma iamgabrielma added category: accessibility Related to accessibility. feature: POS type: enhancement A request for an enhancement. labels Jan 24, 2025
@dangermattic
Copy link
Collaborator

Thanks for reporting! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: accessibility Related to accessibility. feature: POS type: enhancement A request for an enhancement.
Projects
None yet
Development

No branches or pull requests

2 participants