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

Add Support for Right-to-Left (RTL) Languages #26

Closed
ReenadGh opened this issue Aug 6, 2024 · 3 comments
Closed

Add Support for Right-to-Left (RTL) Languages #26

ReenadGh opened this issue Aug 6, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@ReenadGh
Copy link

ReenadGh commented Aug 6, 2024

The SwipeActions library currently does not support right-to-left (RTL) languages such as Arabic, Hebrew, or Persian. This limits the usability of the library in applications that require RTL support, particularly in regions where these languages are predominant.

Current Behavior:
Swipe actions only support left-to-right (LTR) configurations.
RTL languages display swipe actions in the same direction as LTR, which can be confusing for users expecting standard RTL behavior.

Expected Behavior:
The library should automatically adjust swipe directions based on the device's locale settings.
For RTL languages, the swipe actions should be mirrored to match the expected interaction patterns, with primary actions swiping from the right and secondary actions from the left.
Steps to Reproduce:

Set your iOS device language to Arabic (or another RTL language).
Implement SwipeActions in a SwiftUI view.
Observe the swipe direction and layout.
Example Code:

struct ContentView: View {
    var body: some View {
        List {
            ForEach(0..<5) { index in
                Text("Item \(index)")
                    .swipeActions {
                        Button("Delete") {
                            print("Item deleted")
                        }
                        .tint(.red)
                    }
            }
        }
        .environment(\.layoutDirection, .rightToLeft) // Force RTL for testing
    }
}

Proposed Solution:

Add support for detecting and adapting to the device's layout direction using SwiftUI's .environment(.layoutDirection, .rightToLeft) modifier.

Implement conditional logic in the swipe action handling to adjust swipe directions for RTL languages.

Providing RTL support will enhance the library's accessibility and user experience for a broader audience, aligning with iOS's built-in RTL support capabilities.

@c-villain
Copy link
Owner

@ReenadGh Thx for ur feedback! =) That's nice suggestion for a improvement!

@tunds
Copy link

tunds commented Aug 29, 2024

It would be great to see this support added!

@c-villain
Copy link
Owner

c-villain commented Aug 29, 2024

@ReenadGh @tunds FYI

Supporting in 0.3.6

@c-villain c-villain self-assigned this Sep 7, 2024
@c-villain c-villain added the enhancement New feature or request label Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants