Created
August 10, 2022 14:14
-
-
Save metin-atalay/bdf28a604fe9678403730d14f02946ca to your computer and use it in GitHub Desktop.
SwiftUI RTL ScrollView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ScrollViewRTL<Content: View>: View { | |
@ViewBuilder var content: Content | |
@Environment(\.layoutDirection) private var layoutDirection | |
var type: RowType | |
init(type: RowType, @ViewBuilder content: () -> Content) { | |
self.type = type | |
self.content = content() | |
} | |
@ViewBuilder var body: some View { | |
ScrollView(type.scrollAxis, showsIndicators: false) { | |
content | |
.rotation3DEffect(Angle(degrees: layoutDirection == .rightToLeft ? -180 : 0), axis: ( | |
x: CGFloat(0), | |
y: CGFloat(layoutDirection == .rightToLeft ? -10 : 0), | |
z: CGFloat(0))) | |
} | |
.rotation3DEffect(Angle(degrees: layoutDirection == .rightToLeft ? 180 : 0), axis: ( | |
x: CGFloat(0), | |
y: CGFloat(layoutDirection == .rightToLeft ? 10 : 0), | |
z: CGFloat(0))) | |
} | |
} | |
public enum RowType { | |
case hList | |
case vList | |
var scrollAxis: Axis.Set { | |
switch self { | |
case .hList: | |
return .horizontal | |
case .vList: | |
return .vertical | |
} | |
} | |
} |
hi @mouness2020, what is your RTL problem? We use it and working well. Can you give me more detail please let's fix the issue.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not working now
https://developer.apple.com/forums/thread/728394?login=true&page=1#752722022