I'm developing a camera application with SwiftUI and I need to create a component similar to this one
I have the next code
ScrollViewReader { proxy in
ScrollView(.horizontal) {
HStack(alignment: .center, spacing: 10) {
Button {
if model.mediaType == .photo {
model.mediaType = .video
proxy.scrollTo(0)
}
} label: {
Text("Video")
.foregroundColor(model.mediaType == .video ? .yellow : .white)
}
Button {
if model.mediaType == .video {
model.mediaType = .photo
proxy.scrollTo(1)
}
} label: {
Text("Photo")
.foregroundColor(model.mediaType == .photo ? .yellow : .white)
}
}
.frame(alignment: .center)
}
}
How can I center the content of the ScrollView and reach the mentioned target?