Updated RecipeView

This commit is contained in:
VincentMeilinger
2024-03-01 14:17:24 +01:00
parent d3e0366ce6
commit 744ea76a34
41 changed files with 588 additions and 383 deletions

View File

@@ -58,6 +58,21 @@ class DurationComponents: ObservableObject {
}
}
var displayString: String {
let intHour = Int(hourComponent) ?? 0
let intMinute = Int(minuteComponent) ?? 0
if intHour != 0 && intMinute != 0 {
return "\(intHour) h \(intMinute) min"
} else if intHour == 0 && intMinute != 0 {
return "\(intMinute) min"
} else if intHour != 0 && intMinute == 0 {
return "\(intHour) h"
} else {
return "-"
}
}
static func fromPTString(_ PTRepresentation: String) -> DurationComponents {
let duration = DurationComponents()
let hourRegex = /([0-9]{1,2})H/
@@ -86,21 +101,6 @@ class DurationComponents: ObservableObject {
return "PT\(hourComponent)H\(minuteComponent)M00S"
}
func toText() -> LocalizedStringKey {
let intHour = Int(hourComponent) ?? 0
let intMinute = Int(minuteComponent) ?? 0
if intHour != 0 && intMinute != 0 {
return "\(intHour) h, \(intMinute) min"
} else if intHour == 0 && intMinute != 0 {
return "\(intMinute) min"
} else if intHour != 0 && intMinute == 0 {
return "\(intHour) h"
} else {
return "-"
}
}
func toTimerText() -> String {
var timeString = ""
if hourComponent != "00" {
@@ -152,4 +152,5 @@ class DurationComponents: ObservableObject {
return nil
}
}
}