Created
May 28, 2024 09:53
-
-
Save elkraneo/e1cd603b598e609614cd7f71911a32e7 to your computer and use it in GitHub Desktop.
This file contains 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
struct ContentView: View { | |
let temperature = Measurement<UnitTemperature>(value: 13, unit: .celsius) | |
var body: some View { | |
List { | |
Text("let temperature = Measurement<UnitTemperature>(value: 13, unit: .celsius)") | |
.font(.headline) | |
Section("Implicit formatting") { | |
LabeledContent("temperature.formatted()", value: temperature.formatted()) | |
LabeledContent( | |
"temperature.converted(to: .celsius).formatted()", | |
value: temperature.converted(to: .celsius).formatted()) | |
} | |
Section("Explicit formatting: .measurement()") { | |
LabeledContent("temperature", value: temperature, format: .measurement()) | |
LabeledContent( | |
"temperature.converted(to: .celsius)", value: temperature, format: .measurement()) | |
} | |
Section("Explicit formatting: .measurement(usage: .asProvided))") { | |
LabeledContent( | |
"temperature.converted(to: .celsius)", value: temperature.converted(to: .celsius), | |
format: .measurement(usage: .asProvided)) | |
LabeledContent( | |
"temperature.converted(to: .kelvin)", value: temperature.converted(to: .kelvin), | |
format: .measurement(usage: .asProvided)) | |
} | |
} | |
.monospaced() | |
.padding() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment