3

As you can see in the attached image, the picker options are not aligned automatically to the right-hand side for RTL languages, and also flipped.

enter image description here

The picker is nothing fancy either, the standard way.

struct ContentView: View {
    
    @State private var selectedDay: String = "יום שבת"
    private let days: [String] = ["יום שבת", "יוֹם רִאשׁוֹן", "יוֹם שֵׁנִי"]
    
    var body: some View {
        Picker(selection: $selectedDay) {
            ForEach(days, id: \.self) { day in
                Text(day).tag(day)
            }
        } label: {
            Text("")
        }
    }
}

I have changed the development localization to Hebrew so RTL alignments are automatically done.

I have tried to force the alignment with

.environment(\.layoutDirection, .rightToLeft)

but nothing has worked.

CrisAhmad
  • 29
  • 5
  • Hmm. Seems like `.flipsForRightToLeftLayoutDirection(true)` should do this, but it doesn't seem to. – Ashley Mills Feb 20 '23 at 13:16
  • Could this answer for a similar problem with menus help? https://stackoverflow.com/a/68802086/123632 – Ashley Mills Feb 20 '23 at 13:19
  • @AshleyMills I've tried that. If used on the picker itself it flips the selected string, but when used on the text within the foreach loop it doesn't do anything. – CrisAhmad Feb 20 '23 at 13:21
  • @AshleyMills I've already seen the post in the link you shared. I've copy-pasted it in my project as a new file and nothing changed - selected text has the correct alignment, picker options don't. – CrisAhmad Feb 20 '23 at 13:24

0 Answers0