I'm getting the following compiler error.
error: function declares an opaque return type, but the return statements in its body do not have matching underlying types
var body: some View {
^
I'm trying to switch on some state to determine what the rest of the view hierachy looks like. How do I do this in SwiftUI? Thanks!
enum Choices: Equatable, Hashable {
case one
case two
}
struct HeaderView: View {
@State var choices = Choices.one
var body: some View {
switch choices {
case .two:
return ChoiceTwoView(choices: $choices)
default:
return ChoiceOneView(choices: $choices)
}
}
}
struct ChoiceOneView: View {
@Binding var choices: Choices
init(choices: Binding) {
$choices = choices
}
var body: some View {
VStack {
HStack {
Image(systemName: "person.icloud")
VStack(alignment: .leading) {
Text("Person Name")
.font(.headline)
Text("Some long long long long long long long long text")
.lineLimit(nil)
.multilineTextAlignment(.leading)
}
}
}
}
}
struct ChoiceTwoView: View {
@Binding var choices: Choices
init(choices: Binding) {
$choices = choices
}
var body: some View {
VStack {
HStack {
Image(systemName: "person.icloud")
VStack(alignment: .leading) {
Text("Person Name")
.font(.headline)
}
}
}
}
}