Is there an elegant way to produce macOS conforming label/text field alignment with SwiftUI?
Once upon a time the Human Interface Guidelines provided diagrams illustrating how Labels should be right aligned on macOS. Big Sur's System Preferences > General still presents this best practice with the colons right aligned (the design guidelines seem to no longer mention this) and the text fields left aligned.
Whilst we will use a combination of VStacks and HStacks to layout an interface in this manner, it isn't clear how you currently specify a modifier to align the contents of multiple HStacks so that each has all the text labels right aligned, all the Text Fields left aligned (and the same width or opt in to do so) and also maintain a constant and standard distance between every Label and TextField.
To add, one might think that in SwiftUI parlance that we would drop the colon (:) from the Text definition and that SwiftUI would automagically put that in for us. Also not put it in on iOS. Dropping the colon from the Text string would help accessibility - one less character to convey.
HorizontalAlignment didn't seem to offer this.
A naive form layout for macOS doesn't produce a HIG-happy visual design.
Once upon a time the Human Interface Guidelines provided diagrams illustrating how Labels should be right aligned on macOS. Big Sur's System Preferences > General still presents this best practice with the colons right aligned (the design guidelines seem to no longer mention this) and the text fields left aligned.
Whilst we will use a combination of VStacks and HStacks to layout an interface in this manner, it isn't clear how you currently specify a modifier to align the contents of multiple HStacks so that each has all the text labels right aligned, all the Text Fields left aligned (and the same width or opt in to do so) and also maintain a constant and standard distance between every Label and TextField.
To add, one might think that in SwiftUI parlance that we would drop the colon (:) from the Text definition and that SwiftUI would automagically put that in for us. Also not put it in on iOS. Dropping the colon from the Text string would help accessibility - one less character to convey.
HorizontalAlignment didn't seem to offer this.
A naive form layout for macOS doesn't produce a HIG-happy visual design.