mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Fix interval drop down formatter
This commit is contained in:
parent
2ee6cdfcba
commit
0fcf4fdbcb
2 changed files with 18 additions and 15 deletions
|
|
@ -1486,8 +1486,8 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"⚠️ The configured value: (%@ seconds) is not one of the optimized options." : {
|
||||
"comment" : "A text warning that the configured update interval is not one of the optimized options.",
|
||||
"⚠️ The configured value: (%@) is not one of the optimized options." : {
|
||||
"comment" : "A warning label below the picker, indicating that the selected update interval is not one of the optimized options.",
|
||||
"isCommentAutoGenerated" : true
|
||||
},
|
||||
"🦕 End of life Version 🦖 ☄️" : {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
//
|
||||
// UpdateIntervalPicker.swift
|
||||
// Meshtastic
|
||||
// UpdateIntervalPicker.swift
|
||||
// Meshtastic
|
||||
//
|
||||
// Copyright(c) Garth Vander Houwen 10/4/25.
|
||||
// Copyright(c) Garth Vander Houwen 10/4/25.
|
||||
//
|
||||
import SwiftUI
|
||||
|
||||
struct UpdateIntervalPicker: View {
|
||||
let config: IntervalConfiguration
|
||||
let pickerLabel: String
|
||||
let formatter = DateComponentsFormatter()
|
||||
let formatter: DateComponentsFormatter // Make it a stored property
|
||||
|
||||
@Binding var selectedInterval: UpdateInterval
|
||||
|
||||
|
|
@ -17,11 +17,14 @@ struct UpdateIntervalPicker: View {
|
|||
config.allowedCases
|
||||
.map { UpdateInterval(from: $0.rawValue) }
|
||||
}
|
||||
|
||||
|
||||
init(config: IntervalConfiguration, pickerLabel: String, selectedInterval: Binding<UpdateInterval>) {
|
||||
self.config = config
|
||||
self.pickerLabel = pickerLabel
|
||||
self._selectedInterval = selectedInterval
|
||||
let f = DateComponentsFormatter()
|
||||
f.unitsStyle = .full
|
||||
self.formatter = f
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
|
|
@ -36,7 +39,7 @@ struct UpdateIntervalPicker: View {
|
|||
if isOutOfRange {
|
||||
let interval: TimeInterval = Double(selectedInterval.intValue)
|
||||
if let formattedString = formatter.string(from: interval) {
|
||||
Text("⚠️ The configured value: (\(formattedString) seconds) is not one of the optimized options.")
|
||||
Text("⚠️ The configured value: (\(formattedString)) is not one of the optimized options.")
|
||||
.font(.caption)
|
||||
.foregroundColor(.orange)
|
||||
}
|
||||
|
|
@ -44,11 +47,11 @@ struct UpdateIntervalPicker: View {
|
|||
}
|
||||
}
|
||||
private var isOutOfRange: Bool {
|
||||
switch selectedInterval.type {
|
||||
case .manual:
|
||||
return true
|
||||
case .fixed(let fixedCase):
|
||||
return !config.allowedCases.contains(fixedCase)
|
||||
}
|
||||
}
|
||||
switch selectedInterval.type {
|
||||
case .manual:
|
||||
return true
|
||||
case .fixed(let fixedCase):
|
||||
return !config.allowedCases.contains(fixedCase)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue