fermoya / SwiftUIPager

Native Pager in SwiftUI
MIT License
1.3k stars 172 forks source link

[BUG] - RTL Support #293

Open metin-atalay opened 2 years ago

metin-atalay commented 2 years ago

Hello Dear, The language of the phone and the language of my application can be different in our logic.

My application language is Arabic and my phone language is English (Locale.current).

In this case, the swipe behaves according to English, not Arabic. I'm having trouble swiping.

mouness2020 commented 1 year ago

I hope can apply this fix, instead of using Local.current to Local.preferredLanguages.first in SwipeDirection.swift file

extension Locale {
    var isRightToLeft: Bool {
        guard let language = Locale.preferredLanguages.first else { return false }
        let direction = Locale.characterDirection(forLanguage: language)
        return direction == .rightToLeft
    }
}
nichita-stefanita commented 1 year ago

@metin-atalay I've handled that by disabling RTL for the pager view and setting SwipeDirection to .endToStart in modifier.

Pager(...)
.horizontal(.endToStart)
.environment(\.layoutDirection, .leftToRight)
metin-atalay commented 1 year ago

@nichita-stefanita thanks for the replay I need both directions so we decide to not use this library. I choose the native tabview. And also tabView have different behavior in ios 15 and ios 16. I fix by manually updating the index.