Hi guys I tried several times passing the bool value of my toogleswitch to the enum where all my cases are but its not working at all , I have tried to debug it for several hours but still its not working out
This is my ToggleView
import SwiftUI
struct ToggleView: View {
@State private var isOn: Bool = false
var body: some View {
Toggle(isOn: $isOn) {
Text("Toggle")
}
}
}
I want to pass isOn varaible to my BrailleLetters enum inside the enum there is var brailleLettersView where i want to access the boolean so I can use a ternary operator operator and change the ahapname: according to the boolean. Please if someone can help.
This is My Braille Letters Enum
import SwiftUI
enum BrailleLetters:CaseIterable {
case A,B
var brailleLettersView: some View {
HStack{
switch self {
case .A :
HStack {
VStack {
BrailleCircle(color: .red, hapticFeedback: .heavy,isFilled: true,ahapname:"Circle1")
BrailleCircle(color: .orange, hapticFeedback: .rigid,isFilled: false,ahapname: "_empty_")
BrailleCircle(color: .yellow, hapticFeedback: .medium,isFilled: false,ahapname: "_empty_")
}
VStack {
BrailleCircle(color: .green, hapticFeedback: .soft,isFilled: false,ahapname: "_empty_")
BrailleCircle(color: .blue, hapticFeedback: .light,isFilled: false,ahapname: "_empty_")
BrailleCircle(color: .purple, hapticFeedback: .medium,isFilled: false,ahapname: "_empty_")
}
}
case .B :
HStack {
VStack {
BrailleCircle(color: .red, hapticFeedback: .heavy,isFilled: true,ahapname: "Circle1")
BrailleCircle(color: .orange, hapticFeedback: .rigid,isFilled: true,ahapname: "Circle2")
BrailleCircle(color: .yellow, hapticFeedback: .medium,isFilled: false,ahapname: "_empty_")
}
VStack {
BrailleCircle(color: .green, hapticFeedback: .soft,isFilled: false,ahapname: "_empty_")
BrailleCircle(color: .blue, hapticFeedback: .light,isFilled: false,ahapname: "_empty_")
BrailleCircle(color: .purple, hapticFeedback: .medium,isFilled: false,ahapname: "_empty_")
}
}
}
}
}
}