Post

Replies

Boosts

Views

Activity

Reply to Compare 2 values
Thanks for your help. No problem with the picker. it recovers seconds and tenths. Example 15"8 would be a lap time to aim for for the athlete and I have to compare it with his last Lap. If his Lap is higher the Rectangle() is red otherwise it is green. The declarations are already in the Zstack, how should I to do with the calcul comparisonTemps? How would I see the result returned by `let tempsTour = Double(secondesSelection) + Double(dixiemesSelection)                     let lapTourCompare = Double(seconds) + Double(centiseconds)`
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’22
Reply to Compare 2 values
ZStack { Rectangle() .foregroundColor(comparaisonTemps ? Color.red.opacity(0.5) : Color.green.opacity(0.5)) .onTapGesture { if(!self.running) { self.minutes = 0 self.seconds = 0 self.centiseconds = 0 self.lapTimes = [] self.lapMinutes = 0 self.lapSeconds = 0 self.lapCentiseconds = 0 self.lapCount = 1 } else { self.lapTimes.append(LapTime(n: self.lapCount, m: self.lapMinutes, s: self.lapSeconds, c: self.lapCentiseconds)) self.lapCount += 1 self.lapMinutes = 0 self.lapSeconds = 0 self.lapCentiseconds = 0 } } let tempsTour = Double(secondesSelection) + Double(dixiemesSelection) let lapTourCompare = Double(seconds) + Double(centiseconds) // comparaisonTemps = tempsTour <= lapTourCompare VStack { ZStack { Rectangle() .fill(Color.brown.opacity(0.0)) .frame(height: UIScreen.main.bounds.height * 0.3) Text("\(lapCount - 1)") .font(.system(size: min(geo.size.height, geo.size.width) * 0.40)) .fontWeight(.bold) .frame(height: UIScreen.main.bounds.height * 0.25) .foregroundColor(.red) } ZStack { Rectangle() .fill(Color.yellow.opacity(0.0)) .frame(height: UIScreen.main.bounds.height * 0.65) Text(self.lapTimes.last?.getLapSecondsString() ?? "") .font(.system(size: min(geo.size.height, geo.size.width) * 0.40)) .fontWeight(.bold) .frame(height: UIScreen.main.bounds.height * 0.38) } } } } } } func timerCalcs() { if(self.centiseconds < 99) { self.centiseconds += 1 } else { self.centiseconds = 0 if(self.seconds < 59) { self.seconds += 1 } else { self.seconds = 0 self.minutes += 1 } } if(self.lapCentiseconds < 99) { self.lapCentiseconds += 1 } else { self.lapCentiseconds = 0 if(self.lapSeconds < 59) { self.lapSeconds += 1 } else { self.lapSeconds = 0 self.lapMinutes += 1 } } } } func getTimeString(m: Int, s: Int, c: Int) -> String { var centiString = String(c) var secString = String(s) var minString = String(m) if(c < 10) { centiString = "0\(c)" } if(s < 10) { secString = "0\(s)" } if(m < 10) { minString = "0\(m)" } return "\(minString):\(secString).\(centiString)" } struct LapTime: View, Identifiable { let id = UUID() let num: Int let minutes: Int let seconds: Int let centiSeconds: Int let time: String var body: some View { HStack { Text("\(num)").font(.system(size: 20, design: .monospaced)) //Lap Spacer() Text(time).font(.system(size: 20, design: .monospaced)) } } init(n: Int, m: Int, s: Int, c: Int) { num = n minutes = m seconds = s centiSeconds = c time = getTimeString(m: minutes, s: seconds, c: centiSeconds) } func getLapSecondsString() -> String { var centiString = String(centiSeconds) var secString = String(seconds) if(centiSeconds < 10) { centiString = "0\(centiSeconds)" } if(seconds < 10) { secString = "0\(seconds)" } return "\(secString).\(centiString)" } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’22
Reply to Display of the last LAP
hello, how to retrieve the value of the lap Times.last to compare it with the lap time retrieved via the Picker? I think the picker format for tempsTour is let tempsTour = Double(secondesSelection) + (Double(dixiemesSelection) / 10) Thanks
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’22
Reply to Color of BackGround and Condition
Hello, I'm coming back to you because I have a problem comparing my lap time (retrieved via the Picker) and the lapTimes.last the value of the lap time is let tempsTour = Double(secondesSelection) + (Double(dixiemesSelection) / 10) but I don't see how to retrieve the LapTimes.last in the same format to perform the comparison. a idea? Thanks code snippet List { LapTime(n: self.lapCount, m: self.lapMinutes, s: self.lapSeconds, c: self.lapCentiseconds) ForEach(self.lapTimes.reversed()) { time in time } }.frame(width: UIScreen.main.bounds.width * 0.15) } ZStack { Rectangle() .fill(Color.yellow.opacity(0.0)) .frame(height: UIScreen.main.bounds.height * 0.65) Text(self.lapTimes.last?.getLapSecondsString() ?? "") .font(.system(size: min(geo.size.height, geo.size.width) * 0.40)) .fontWeight(.bold) .frame(height: UIScreen.main.bounds.height * 0.38) // <<-- HERE } } Rectangle() .fill(Color.green.opacity(0.1)) .onTapGesture { if(!self.running) { self.minutes = 0 self.seconds = 0 self.centiseconds = 0 self.lapTimes = [] self.lapMinutes = 0 self.lapSeconds = 0 self.lapCentiseconds = 0 self.lapCount = 1 } else { self.lapTimes.append(LapTime(n: self.lapCount, m: self.lapMinutes, s: self.lapSeconds, c: self.lapCentiseconds)) self.lapCount += 1 self.lapMinutes = 0 self.lapSeconds = 0 self.lapCentiseconds = 0 } } } } } } func timerCalcs() { if(self.centiseconds < 99) { self.centiseconds += 1 } else { self.centiseconds = 0 if(self.seconds < 59) { self.seconds += 1 } else { self.seconds = 0 self.minutes += 1 } } if(self.lapCentiseconds < 99) { self.lapCentiseconds += 1 } else { self.lapCentiseconds = 0 if(self.lapSeconds < 59) { self.lapSeconds += 1 } else { self.lapSeconds = 0 self.lapMinutes += 1 } } } } func getTimeString(m: Int, s: Int, c: Int) -> String { var centiString = String(c) var secString = String(s) var minString = String(m) if(c < 10) { centiString = "0\(c)" } if(s < 10) { secString = "0\(s)" } if(m < 10) { minString = "0\(m)" } return "\(minString):\(secString).\(centiString)" } struct LapTime: View, Identifiable { let id = UUID() let num: Int let minutes: Int let seconds: Int let centiSeconds: Int let time: String var body: some View { HStack { Text("\(num)").font(.system(size: 20, design: .monospaced)) //Lap Spacer() Text(time).font(.system(size: 20, design: .monospaced)) } } init(n: Int, m: Int, s: Int, c: Int) { num = n minutes = m seconds = s centiSeconds = c time = getTimeString(m: minutes, s: seconds, c: centiSeconds) } func getLapSecondsString() -> String { var centiString = String(centiSeconds) var secString = String(seconds) if(centiSeconds < 10) { centiString = "0\(centiSeconds)" } if(seconds < 10) { secString = "0\(seconds)" } return "\(secString).\(centiString)" } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’22
Reply to Problem with GeometryReader
Hi, it's the iPad Pro 12,9 pouces. After change I have that : the code if you want test Thanks let timer = Timer.publish(every: 0.01, on: .main, in: .common).autoconnect() @State var minutes = 0 @State var seconds = 0 @State var centiseconds = 0 @State var running = false @State var lapTimes: [LapTime] = [] @State var lapCount = 1 @State var lapMinutes = 0 @State var lapSeconds = 0 @State var lapCentiseconds = 0 var body: some View { GeometryReader { geo in VStack(spacing: 0){ Text(getTimeString(m: self.minutes, s: self.seconds, c: self.centiseconds)) .font(.system(size: min(geo.size.height, geo.size.width) * 0.05, design: .monospaced)) .frame(height: UIScreen.main.bounds.height * 0.05) // <<-- HERE .onReceive(timer) {_ in if(self.running) { self.timerCalcs() } } Text("\(lapCount - 1)") .font(.system(size: min(geo.size.height, geo.size.width) * 0.25)) .fontWeight(.bold) .frame(height: UIScreen.main.bounds.height * 0.25) // <<-- HERE .foregroundColor(.red) ZStack { Text(self.lapTimes.last?.getLapSecondsString() ?? "") .font(.system(size: min(geo.size.height, geo.size.width) * 0.45)) .fontWeight(.bold) .frame(height: UIScreen.main.bounds.height * 0.38) // <<-- HERE Rectangle().fill(Color.gray.opacity(0.1)) } HStack(spacing : 10) { Button(action: { if(!self.running) { self.minutes = 0 self.seconds = 0 self.centiseconds = 0 self.lapTimes = [] self.lapMinutes = 0 self.lapSeconds = 0 self.lapCentiseconds = 0 self.lapCount = 1 } else { self.lapTimes.append(LapTime(n: self.lapCount, m: self.lapMinutes, s: self.lapSeconds, c: self.lapCentiseconds)) self.lapCount += 1 self.lapMinutes = 0 self.lapSeconds = 0 self.lapCentiseconds = 0 } }) { ZStack{ Circle().fill(Color.gray).frame(height: UIScreen.main.bounds.height * 0.12) // <<-- HERE self.running ? Text("Lap").foregroundColor(Color.white).font(.system(size: min(geo.size.height, geo.size.width) * 0.04, design: .monospaced)) : Text("Reset").foregroundColor(Color.white).font(.system(size: min(geo.size.height, geo.size.width) * 0.04, design: .monospaced)) } } .padding(8) Spacer() Button(action: { self.running = !self.running }) { ZStack{ Circle().fill(self.running ? Color.red : Color.green).frame(height: UIScreen.main.bounds.height * 0.12).font(.system(size: min(geo.size.height, geo.size.width) * 0.04, design: .monospaced)) // <<-- HERE self.running ? Text("Stop").foregroundColor(Color.white).font(.system(size: min(geo.size.height, geo.size.width) * 0.04, design: .monospaced)) : Text("Start").foregroundColor(Color.white).font(.system(size: min(geo.size.height, geo.size.width) * 0.04, design: .monospaced)) } } .padding(8) } List { LapTime(n: self.lapCount, m: self.lapMinutes, s: self.lapSeconds, c: self.lapCentiseconds) ForEach(self.lapTimes.reversed()) { time in time } } } } } func timerCalcs() { if(self.centiseconds < 99) { self.centiseconds += 1 } else { self.centiseconds = 0 if(self.seconds < 59) { self.seconds += 1 } else { self.seconds = 0 self.minutes += 1 } } if(self.lapCentiseconds < 99) { self.lapCentiseconds += 1 } else { self.lapCentiseconds = 0 if(self.lapSeconds < 59) { self.lapSeconds += 1 } else { self.lapSeconds = 0 self.lapMinutes += 1 } } } } func getTimeString(m: Int, s: Int, c: Int) -> String { var centiString = String(c) var secString = String(s) var minString = String(m) if(c < 10) { centiString = "0\(c)" } if(s < 10) { secString = "0\(s)" } if(m < 10) { minString = "0\(m)" } return "\(minString):\(secString).\(centiString)" } struct LapTime: View, Identifiable { let id = UUID() let num: Int let minutes: Int let seconds: Int let centiSeconds: Int let time: String var body: some View { HStack { Text("Lap \(num)").font(.system(size: 20, design: .monospaced)) Spacer() Text(time).font(.system(size: 20, design: .monospaced)) } } init(n: Int, m: Int, s: Int, c: Int) { num = n minutes = m seconds = s centiSeconds = c time = getTimeString(m: minutes, s: seconds, c: centiSeconds) } func getLapSecondsString() -> String { var centiString = String(centiSeconds) var secString = String(seconds) if(centiSeconds < 10) { centiString = "0\(centiSeconds)" } if(seconds < 10) { secString = "0\(seconds)" } return "\(secString).\(centiString)" } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’22
Reply to Calculation for a Picker
I found the right formula for my problem ;) `var tpsauTour: Double {         let tpspoursuite = (Double(minutesSelection)*60) + Double(secondesSelection)         return ((Double(tpspoursuite)-valeurSliderTpsFirstTour) / (valeurSliderNbreTour - 1))     }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’22
Reply to Compare 2 values
Where I can depose the code, it is longer for here?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Compare 2 values
I did the test, I no longer have the message, thank you. I wanted to know the result of my 2 calculations because whatever the Lap the red color applies.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Compare 2 values
Thanks for your help. No problem with the picker. it recovers seconds and tenths. Example 15"8 would be a lap time to aim for for the athlete and I have to compare it with his last Lap. If his Lap is higher the Rectangle() is red otherwise it is green. The declarations are already in the Zstack, how should I to do with the calcul comparisonTemps? How would I see the result returned by `let tempsTour = Double(secondesSelection) + Double(dixiemesSelection)                     let lapTourCompare = Double(seconds) + Double(centiseconds)`
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Compare 2 values
Screenshot
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Compare 2 values
ZStack { Rectangle() .foregroundColor(comparaisonTemps ? Color.red.opacity(0.5) : Color.green.opacity(0.5)) .onTapGesture { if(!self.running) { self.minutes = 0 self.seconds = 0 self.centiseconds = 0 self.lapTimes = [] self.lapMinutes = 0 self.lapSeconds = 0 self.lapCentiseconds = 0 self.lapCount = 1 } else { self.lapTimes.append(LapTime(n: self.lapCount, m: self.lapMinutes, s: self.lapSeconds, c: self.lapCentiseconds)) self.lapCount += 1 self.lapMinutes = 0 self.lapSeconds = 0 self.lapCentiseconds = 0 } } let tempsTour = Double(secondesSelection) + Double(dixiemesSelection) let lapTourCompare = Double(seconds) + Double(centiseconds) // comparaisonTemps = tempsTour <= lapTourCompare VStack { ZStack { Rectangle() .fill(Color.brown.opacity(0.0)) .frame(height: UIScreen.main.bounds.height * 0.3) Text("\(lapCount - 1)") .font(.system(size: min(geo.size.height, geo.size.width) * 0.40)) .fontWeight(.bold) .frame(height: UIScreen.main.bounds.height * 0.25) .foregroundColor(.red) } ZStack { Rectangle() .fill(Color.yellow.opacity(0.0)) .frame(height: UIScreen.main.bounds.height * 0.65) Text(self.lapTimes.last?.getLapSecondsString() ?? "") .font(.system(size: min(geo.size.height, geo.size.width) * 0.40)) .fontWeight(.bold) .frame(height: UIScreen.main.bounds.height * 0.38) } } } } } } func timerCalcs() { if(self.centiseconds < 99) { self.centiseconds += 1 } else { self.centiseconds = 0 if(self.seconds < 59) { self.seconds += 1 } else { self.seconds = 0 self.minutes += 1 } } if(self.lapCentiseconds < 99) { self.lapCentiseconds += 1 } else { self.lapCentiseconds = 0 if(self.lapSeconds < 59) { self.lapSeconds += 1 } else { self.lapSeconds = 0 self.lapMinutes += 1 } } } } func getTimeString(m: Int, s: Int, c: Int) -> String { var centiString = String(c) var secString = String(s) var minString = String(m) if(c < 10) { centiString = "0\(c)" } if(s < 10) { secString = "0\(s)" } if(m < 10) { minString = "0\(m)" } return "\(minString):\(secString).\(centiString)" } struct LapTime: View, Identifiable { let id = UUID() let num: Int let minutes: Int let seconds: Int let centiSeconds: Int let time: String var body: some View { HStack { Text("\(num)").font(.system(size: 20, design: .monospaced)) //Lap Spacer() Text(time).font(.system(size: 20, design: .monospaced)) } } init(n: Int, m: Int, s: Int, c: Int) { num = n minutes = m seconds = s centiSeconds = c time = getTimeString(m: minutes, s: seconds, c: centiSeconds) } func getLapSecondsString() -> String { var centiString = String(centiSeconds) var secString = String(seconds) if(centiSeconds < 10) { centiString = "0\(centiSeconds)" } if(seconds < 10) { secString = "0\(seconds)" } return "\(secString).\(centiString)" } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Color of BackGround and Condition
Thanks, I Make that
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Display of the last LAP
hello, how to retrieve the value of the lap Times.last to compare it with the lap time retrieved via the Picker? I think the picker format for tempsTour is let tempsTour = Double(secondesSelection) + (Double(dixiemesSelection) / 10) Thanks
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Color of BackGround and Condition
Hello, I'm coming back to you because I have a problem comparing my lap time (retrieved via the Picker) and the lapTimes.last the value of the lap time is let tempsTour = Double(secondesSelection) + (Double(dixiemesSelection) / 10) but I don't see how to retrieve the LapTimes.last in the same format to perform the comparison. a idea? Thanks code snippet List { LapTime(n: self.lapCount, m: self.lapMinutes, s: self.lapSeconds, c: self.lapCentiseconds) ForEach(self.lapTimes.reversed()) { time in time } }.frame(width: UIScreen.main.bounds.width * 0.15) } ZStack { Rectangle() .fill(Color.yellow.opacity(0.0)) .frame(height: UIScreen.main.bounds.height * 0.65) Text(self.lapTimes.last?.getLapSecondsString() ?? "") .font(.system(size: min(geo.size.height, geo.size.width) * 0.40)) .fontWeight(.bold) .frame(height: UIScreen.main.bounds.height * 0.38) // <<-- HERE } } Rectangle() .fill(Color.green.opacity(0.1)) .onTapGesture { if(!self.running) { self.minutes = 0 self.seconds = 0 self.centiseconds = 0 self.lapTimes = [] self.lapMinutes = 0 self.lapSeconds = 0 self.lapCentiseconds = 0 self.lapCount = 1 } else { self.lapTimes.append(LapTime(n: self.lapCount, m: self.lapMinutes, s: self.lapSeconds, c: self.lapCentiseconds)) self.lapCount += 1 self.lapMinutes = 0 self.lapSeconds = 0 self.lapCentiseconds = 0 } } } } } } func timerCalcs() { if(self.centiseconds < 99) { self.centiseconds += 1 } else { self.centiseconds = 0 if(self.seconds < 59) { self.seconds += 1 } else { self.seconds = 0 self.minutes += 1 } } if(self.lapCentiseconds < 99) { self.lapCentiseconds += 1 } else { self.lapCentiseconds = 0 if(self.lapSeconds < 59) { self.lapSeconds += 1 } else { self.lapSeconds = 0 self.lapMinutes += 1 } } } } func getTimeString(m: Int, s: Int, c: Int) -> String { var centiString = String(c) var secString = String(s) var minString = String(m) if(c < 10) { centiString = "0\(c)" } if(s < 10) { secString = "0\(s)" } if(m < 10) { minString = "0\(m)" } return "\(minString):\(secString).\(centiString)" } struct LapTime: View, Identifiable { let id = UUID() let num: Int let minutes: Int let seconds: Int let centiSeconds: Int let time: String var body: some View { HStack { Text("\(num)").font(.system(size: 20, design: .monospaced)) //Lap Spacer() Text(time).font(.system(size: 20, design: .monospaced)) } } init(n: Int, m: Int, s: Int, c: Int) { num = n minutes = m seconds = s centiSeconds = c time = getTimeString(m: minutes, s: seconds, c: centiSeconds) } func getLapSecondsString() -> String { var centiString = String(centiSeconds) var secString = String(seconds) if(centiSeconds < 10) { centiString = "0\(centiSeconds)" } if(seconds < 10) { secString = "0\(seconds)" } return "\(secString).\(centiString)" } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Color of BackGround and Condition
Thanks Darkpaw and Claude31, The three solutions work for my example, I'll look at which one is the easiest to adapt to my project where I have to compare a target time with the lap on a stopwatch.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Problem with GeometryReader
Hi, it's the iPad Pro 12,9 pouces. After change I have that : the code if you want test Thanks let timer = Timer.publish(every: 0.01, on: .main, in: .common).autoconnect() @State var minutes = 0 @State var seconds = 0 @State var centiseconds = 0 @State var running = false @State var lapTimes: [LapTime] = [] @State var lapCount = 1 @State var lapMinutes = 0 @State var lapSeconds = 0 @State var lapCentiseconds = 0 var body: some View { GeometryReader { geo in VStack(spacing: 0){ Text(getTimeString(m: self.minutes, s: self.seconds, c: self.centiseconds)) .font(.system(size: min(geo.size.height, geo.size.width) * 0.05, design: .monospaced)) .frame(height: UIScreen.main.bounds.height * 0.05) // <<-- HERE .onReceive(timer) {_ in if(self.running) { self.timerCalcs() } } Text("\(lapCount - 1)") .font(.system(size: min(geo.size.height, geo.size.width) * 0.25)) .fontWeight(.bold) .frame(height: UIScreen.main.bounds.height * 0.25) // <<-- HERE .foregroundColor(.red) ZStack { Text(self.lapTimes.last?.getLapSecondsString() ?? "") .font(.system(size: min(geo.size.height, geo.size.width) * 0.45)) .fontWeight(.bold) .frame(height: UIScreen.main.bounds.height * 0.38) // <<-- HERE Rectangle().fill(Color.gray.opacity(0.1)) } HStack(spacing : 10) { Button(action: { if(!self.running) { self.minutes = 0 self.seconds = 0 self.centiseconds = 0 self.lapTimes = [] self.lapMinutes = 0 self.lapSeconds = 0 self.lapCentiseconds = 0 self.lapCount = 1 } else { self.lapTimes.append(LapTime(n: self.lapCount, m: self.lapMinutes, s: self.lapSeconds, c: self.lapCentiseconds)) self.lapCount += 1 self.lapMinutes = 0 self.lapSeconds = 0 self.lapCentiseconds = 0 } }) { ZStack{ Circle().fill(Color.gray).frame(height: UIScreen.main.bounds.height * 0.12) // <<-- HERE self.running ? Text("Lap").foregroundColor(Color.white).font(.system(size: min(geo.size.height, geo.size.width) * 0.04, design: .monospaced)) : Text("Reset").foregroundColor(Color.white).font(.system(size: min(geo.size.height, geo.size.width) * 0.04, design: .monospaced)) } } .padding(8) Spacer() Button(action: { self.running = !self.running }) { ZStack{ Circle().fill(self.running ? Color.red : Color.green).frame(height: UIScreen.main.bounds.height * 0.12).font(.system(size: min(geo.size.height, geo.size.width) * 0.04, design: .monospaced)) // <<-- HERE self.running ? Text("Stop").foregroundColor(Color.white).font(.system(size: min(geo.size.height, geo.size.width) * 0.04, design: .monospaced)) : Text("Start").foregroundColor(Color.white).font(.system(size: min(geo.size.height, geo.size.width) * 0.04, design: .monospaced)) } } .padding(8) } List { LapTime(n: self.lapCount, m: self.lapMinutes, s: self.lapSeconds, c: self.lapCentiseconds) ForEach(self.lapTimes.reversed()) { time in time } } } } } func timerCalcs() { if(self.centiseconds < 99) { self.centiseconds += 1 } else { self.centiseconds = 0 if(self.seconds < 59) { self.seconds += 1 } else { self.seconds = 0 self.minutes += 1 } } if(self.lapCentiseconds < 99) { self.lapCentiseconds += 1 } else { self.lapCentiseconds = 0 if(self.lapSeconds < 59) { self.lapSeconds += 1 } else { self.lapSeconds = 0 self.lapMinutes += 1 } } } } func getTimeString(m: Int, s: Int, c: Int) -> String { var centiString = String(c) var secString = String(s) var minString = String(m) if(c < 10) { centiString = "0\(c)" } if(s < 10) { secString = "0\(s)" } if(m < 10) { minString = "0\(m)" } return "\(minString):\(secString).\(centiString)" } struct LapTime: View, Identifiable { let id = UUID() let num: Int let minutes: Int let seconds: Int let centiSeconds: Int let time: String var body: some View { HStack { Text("Lap \(num)").font(.system(size: 20, design: .monospaced)) Spacer() Text(time).font(.system(size: 20, design: .monospaced)) } } init(n: Int, m: Int, s: Int, c: Int) { num = n minutes = m seconds = s centiSeconds = c time = getTimeString(m: minutes, s: seconds, c: centiSeconds) } func getLapSecondsString() -> String { var centiString = String(centiSeconds) var secString = String(seconds) if(centiSeconds < 10) { centiString = "0\(centiSeconds)" } if(seconds < 10) { secString = "0\(seconds)" } return "\(secString).\(centiString)" } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Display of the last LAP
thanks for the advice. I will look at it. Thanks again
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Display of the last LAP
You are a boss. Very big thanks. is it feasible to save the times on another View as a list? as like the screenshot?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Display of the last LAP
A other question, if I want only this format : ss.00 what is the code? Thanks
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Display of the last LAP
Very nice. A big thanks
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’22
Reply to Calculation for a Picker
I found the right formula for my problem ;) `var tpsauTour: Double {         let tpspoursuite = (Double(minutesSelection)*60) + Double(secondesSelection)         return ((Double(tpspoursuite)-valeurSliderTpsFirstTour) / (valeurSliderNbreTour - 1))     }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Nov ’22