c-villain / SwipeActions

Swipe actions for any view, swipe menu based on SwiftUI, full swiping and RTL languages supporting, iOS 13+, add your own views to swipes
https://t.me/swiftui_dev
MIT License
212 stars 24 forks source link

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

Closed ReenadGh closed 2 weeks ago

ReenadGh commented 1 month ago

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 commented 1 month ago

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

tunds commented 2 weeks ago

It would be great to see this support added!

c-villain commented 2 weeks ago

@ReenadGh @tunds FYI

Supporting in 0.3.6