1

I have issue in SwiftUI with Right to Left Languages (Arabic)

The navigation bar is correct, but check the list row and text editor, its flipped to the left edge, which it must be in the right edge in Arabic, the default language in project file, is Arabic, also the built in options menu for the search bar is flipped

struct ContentView: View {
    
    @State private var searchText: String = ""
    @State private var text: String = "تجريبي"
    
    var body: some View {
        
        NavigationStack {
                
            
            List {
                Section {
                    Text("مرحبا")
                    
                    TextEditor(text: self.$text)
                }
            }
            .navigationTitle("جديد")
        }
        .searchable(text: self.$searchText, placement: .navigationBarDrawer(displayMode: .always))
    }
}

Screen1 Screen2

sample project

The list content should start appearing from right edge, also the search bar options menu should be flipped

1 Answer 1

0

I solved the problem in List by adding this code:

@Environment(\.layoutDirection) private var layoutDirection

List {
    // text views …  
}
.scaleEffect(x: self.layoutDirection == .rightToLeft ? -1 : 1)

But the issue on the search bar menu options remains unsolved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.