Post

Replies

Boosts

Views

Activity

Reply to How to solve these TextField and Label problem?
Sorry I changed to HStack textField statement     HStack {Text("Calculated number"); TextField("", value: $calculated, format: .number) }     HStack {Text("Calculate number"); TextField("", value: $calculator, format: .number) }     HStack {Text("Calculate way"); TextField("", value: $calculateway, format: .number)}
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’22
Reply to How to fix the TextField?
Here is the whole code @Claude31 import SwiftUI public var calculated = 0.0 public var calculator = 0.0 public var calculateway = "" struct Panel: View {     var body: some View {         VStack {             Image(systemName: "person")                 .imageScale(.large)                 .foregroundColor(.red)             HStack {Text("Calculated number"); TextField("", value: $calculated, format: .number) }             HStack {Text("Calculate numebr"); TextField("", value: $calculator, format: .number) }             HStack {Text("Calculate way"); TextField("", value: $calculateway, format: .number)}         }     } } public var calresult = 0.0 public func calculate() {     if calculateway == "+" {         calresult = Double(Float(calculated + calculator))     }     else if calculateway == "-" {         calresult = Double(Float(calculated - calculator))     }     else if calculateway == "*" {         calresult = Double(Float(calculated * calculator))     }     else if calculateway == "x" {         calresult = Double(Float(calculated * calculator))     }     else if calculateway == "X" {         calresult = Double(Float(calculated * calculator))     }     else if calculateway == "divided by" {         calresult = Double(Float(calculated / calculator))     } } struct Result: View {     var body: some View {         VStack {             Label("Result:", systemImage: /*@START_MENU_TOKEN@*/"42.circle"/*@END_MENU_TOKEN@*/)                 .labelStyle(.titleOnly)         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’22