Post

Replies

Boosts

Views

Activity

Reply to cannot find in scope
Thanks for answering. I'm sorry I'm not sure how to go about it. Is AnotherView a function? How do I call AnotherView? I have no experience with binding. I can't follow what you wrote. Can you rewrite what you wrote with more detail? Please help.
Dec ’24
Reply to cannot find in scope
Let me explain. The user(driver) enters the cost of the delivery and the amount he got paid. The program(enterp) figures out the tip, tip %, average tip, total costs, total tips, total tip % and total cash and writes it out to the screen. Using detailLine I want to print all deliveries(up to 44) and tips to the second screen. I hope this helps.
Dec ’24
Reply to cannot find text1 in scope
I call enterp from a button. The button is in var some body. I'll send the code. Look at the bottom. var body: some View { NavigationStack { VStack { Text(" " + Date().formatted(date: .numeric, time: .omitted)) .foregroundColor(.black) .fontWeight(.bold) Text("Driver's Food Delivery") .font(.largeTitle) .fontWeight(.bold) Image("Screenshot 2024") HStack { Text("Cost") .font(.largeTitle) .padding(10) Spacer() Text("Paid") .font(.largeTitle) .padding(10) Spacer() Text("Tip") .font(.title) Spacer() Text("Tip %") .font(.title) } HStack { TextField("Cost", text: $cost) .frame(width: 75, height: 25) .padding(20) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) .background(Color.brown) .cornerRadius(025) TextField("Paid", text: $paid) .frame(width: 75, height: 25) .padding(20) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) .background(Color.brown) .cornerRadius(025) Text(tipp) .frame(width: 95, height: 25) .background(Color.white) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) Text(tipc) .frame(width: 75, height: 5) .padding(10) .background(Color.white) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) } VStack { Text (emsg) .foregroundColor(.red) Text (msg) .foregroundColor(.blue) HStack { Text (msg2) .foregroundColor(.blue) Spacer() } Button { enterp() } label: { Text("Enter") .font(.largeTitle) .foregroundColor(.green ) }
Dec ’24
Reply to cannot find in scope
Yes I call enterp() from a button. But it's not in viewdetail. It's in the main program(var some body). var body: some View { NavigationStack { VStack { Text(" " + Date().formatted(date: .numeric, time: .omitted)) .foregroundColor(.black) .fontWeight(.bold) Text("Driver's Food Delivery") .font(.largeTitle) .fontWeight(.bold) Image("Screenshot 2024") HStack { Text("Cost") .font(.largeTitle) .padding(10) Spacer() Text("Paid") .font(.largeTitle) .padding(10) Spacer() Text("Tip") .font(.title) Spacer() Text("Tip %") .font(.title) } HStack { TextField("Cost", text: $cost) .frame(width: 75, height: 25) .padding(20) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) .background(Color.brown) .cornerRadius(025) TextField("Paid", text: $paid) .frame(width: 75, height: 25) .padding(20) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) .background(Color.brown) .cornerRadius(025) Text(tipp) .frame(width: 95, height: 25) .background(Color.white) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) Text(tipc) .frame(width: 75, height: 5) .padding(10) .background(Color.white) .fontWeight(.bold) .font(.system(size: 22)) .foregroundColor(.blue) } VStack { Text (emsg) .foregroundColor(.red) Text (msg) .foregroundColor(.blue) HStack { Text (msg2) .foregroundColor(.blue) Spacer() } Button { enterp() } label: { Text("Enter") .font(.largeTitle) .foregroundColor(.green ) } I'm going to have text1 to text44. What else do you need to know?
Dec ’24
Reply to cannot find in scope
func enterp() { var ipc = 50.0 var ipcc = 50.0 var tippp = 0.0 var totalcsh = 0.0 var ttips = 0.0 var tcost = 0.0 var tipo = 0.00 costt = Double(cost) paidt = Double(paid) emsg = "" if (costt != nil) && (paidt != nil) { tipo = (Double(paid)! - Double(cost)!) tipa.append (tipo) costa.append (Double(cost)!) number += 1 numbc = String(number) ttips = (tipa.reduce(0, +)) tcost = (costa.reduce(0,+)) tippp = (ttips / Double(number)) tipaa = tippp.formatted(.currency(code: "USD")) totaltips = ttips.formatted(.currency(code: "USD")) totalcost = tcost.formatted(.currency(code: "USD")) tipp = tipo.formatted(.currency(code: "USD")) tipc = String(tipo / Double(cost)! * 100) ipc = Double (tipc)! tipc = String(format: "%3.0f%%", ipc) tipcc = String(ttips / tcost * 100) ipcc = Double (tipcc)! tipcc = String(format: "%3.0f%%", ipcc) totalcsh = (tcost + ttips) totalcash = totalcsh.formatted(.currency(code: "USD")) } else { emsg = "Enter numbers and 1 decimal point only." } detailLine(costa: &costa,tipa: &tipa) } }
Dec ’24