Hello, I used GeometryReader to proportion the size of my Frames vertically regardless of the device. Yet the List on the Ipad contains 3 lines and only 1 on the Iphone. Where is my error in the code for this layout? Thanks in advance
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)
.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)
.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)
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)
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))
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
}
}
}
}
}