Post

Replies

Boosts

Views

Activity

Reply to im using stepper to add the number of items for a check out Im creating, but I can't seem to link the total amount with the items.
@State private var pentitle = "total pens" @State private var penText = "Choose up to 250 pens" @State private var penvalue = 0  var totalAmount = 0 let penStep = 1 let penrange = 0...250  Section{                     Text("\(totalAmount)").font(.largeTitle)                 }  Section{                             VStack(spacing: 20) {                                 VStack{                                     Text(pentitle).font(.largeTitle).foregroundColor(.darkStart).shadow(color: Color.black.opacity(0.2), radius:10 , x:10 , y:10).shadow(color: Color.white.opacity(0.7), radius: 10, x: -5, y: -5)                                         .padding(.bottom,10)                                     Text("\(penvalue) Pens").font(.title2).foregroundColor(.darkStart).shadow(color: Color.black.opacity(0.2), radius:10 , x:10 , y:10).shadow(color: Color.white.opacity(0.7), radius: 10, x: -5, y: -5)                                 }.padding(.bottom,5)                                 Stepper(penText, value:$penvalue, in: penrange, step: penStep).foregroundColor(.darkStart).padding(.horizontal,150)                             }                         }.padding(.top,20).padding(.bottom,20)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21
Reply to im using stepper to add the number of items for a check out Im creating, but I can't seem to link the total amount with the items.
struct utiView: View {     @State private var markTitle = "marker"     @State private var papertitle = "paper"     @State private var paperText = "Choose up to 250 papers"     @State private var papervalue = 0     @State private var penvalue = 0     @State private var markvalue = 0     @State private var pentitle = "Pens"     @State private var penText = "Choose up to 60 pens"     @State private var marktittle = "Choose up to 10 markers"     var customtotalAmount = 0     let markStep = 1     let paperStep = 1     let penStep = 1     let markrange = 0...10     let penRange = 0...60     let paperrange = 0...250     var body: some View {         VStack{             Text("Total $\(customtotalAmount)")             Section{                 VStack{                     Section{                         VStack(spacing: 20) {                             VStack{                                 Text(papertitle).font(.largeTitle).foregroundColor(.darkStart).shadow(color: Color.black.opacity(0.2), radius:10 , x:10 , y:10).shadow(color: Color.white.opacity(0.7), radius: 10, x: -5, y: -5)                                     .padding(.bottom,10)                                 Text("\(papervalue) Miles").font(.title2).foregroundColor(.darkStart).shadow(color: Color.black.opacity(0.2), radius:10 , x:10 , y:10).shadow(color: Color.white.opacity(0.7), radius: 10, x: -5, y: -5)                             }.padding(.bottom,5)                             Stepper(paperText, value:$papervalue, in: paperrange, step: paperStep).foregroundColor(.darkStart).padding(.horizontal,150)                                                      }                     }.padding(.top,20).padding(.bottom,20)                     Divider()                     Section{                         VStack(spacing: 20) {                             VStack{                                 Text(pentitle).font(.largeTitle).foregroundColor(.darkStart).shadow(color: Color.black.opacity(0.2), radius:10 , x:10 , y:10).shadow(color: Color.white.opacity(0.7), radius: 10, x: -5, y: -5)                                     .padding(.bottom,10)                                 Text("\(penvalue) pens").font(.title2).foregroundColor(.darkStart).shadow(color: Color.black.opacity(0.2), radius:10 , x:10 , y:10).shadow(color: Color.white.opacity(0.7), radius: 10, x: -5, y: -5)                             }.padding(.bottom,5)                             Stepper(penText, value: $penvalue, in: penRange, step: penStep).foregroundColor(.darkStart).padding(.horizontal,150)                         }                     }                     Divider()                     Section{                         VStack(spacing: 20) {                             VStack{                                 Text(markTitle).font(.largeTitle).foregroundColor(.darkStart).shadow(color: Color.black.opacity(0.2), radius:10 , x:10 , y:10).shadow(color: Color.white.opacity(0.7), radius: 10, x: -5, y: -5)                                     .padding(.bottom,10)                                 Text("\(markvalue) markers").font(.title2).foregroundColor(.darkStart).shadow(color: Color.black.opacity(0.2), radius:10 , x:10 , y:10).shadow(color: Color.white.opacity(0.7), radius: 10, x: -5, y: -5)                             }.padding(.bottom,5)                             Stepper(marktittle, value: $markvalue, in: markrange, step: markStep).foregroundColor(.darkStart).padding(.horizontal,150)                         }                     }                 }             }         }     } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21
Reply to im using stepper to add the number of items for a check out Im creating, but I can't seem to link the total amount with the items.
@EDbarnes . IT works!!!! The only thing is that the numbers come out in 7 digits 0.000000 like this. Is there a way this can be solved into 3 digits 0.00 like this? How can I add a observableObject to the checkout view so the total number can appear on the checkout view? every time when I go to Checkout it goes back to 0.000000. and I get a error saying it needs a observableObject
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’21