This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
/// A customized text field that allows numbers only and validates the user input | |
struct MeasurementField: NSViewRepresentable { | |
typealias NSViewType = NSTextField | |
@Binding var measurement: Measurement<Unit> | |
let range: ClosedRange<Double> | |
let measurementFormatter: MeasurementFormatter | |
let numberFormatter: NumberFormatter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Get the build date and time | |
var compileTime: Date { | |
let bundleName = Bundle.main.infoDictionary!["CFBundleName"] as? String ?? "Info.plist" | |
if let infoPath = Bundle.main.path(forResource: bundleName, ofType: nil), | |
let infoAttr = try? FileManager.default.attributesOfItem(atPath: infoPath), | |
let infoDate = infoAttr[FileAttributeKey.creationDate] as? Date | |
{ return infoDate } | |
return Date() | |
} |