I'm building a settings page and simply want an active preview display embedded into a larger Font Settings View that has:
- editable text (so
TextField
) - rendering of corresponding Apple provided
TextStyle
(so ask to keep with DynamicType guidelines)
struct PairingDisplayView: View {
@Binding var displayStyle: Font.TextStyle
@State var displaySample = "This is a title"
@State var bodySample = "Here's some body text to elaborate the font paring preview"
var body: some View {
VStack(alignment: .leading) {
Group {
TextField(
"display",
text: $displaySample
)
.font(displayStyle)
TextField(
"body",
text: $bodySample
)
.font(.body)
}
.padding()
}
.overlay(
RoundedRectangle(cornerSize: CGSize(width: 20, height: 20))
.strokeBorder()
.foregroundColor(.cyan)
)
.padding()
}
}
I have a @State var selectedSystemStyle: Font.TextStyle = .caption2
that later feeds the said Binding... but I can't get over how confusing it is to me that a Font.TextStyle
is not acceptable for the .font()
modifier considering it's a Font and I appropriately call .font(displayStyle)
Am I missing something fundamental here?