-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFontDesignerView.swift
52 lines (41 loc) · 1.56 KB
/
FontDesignerView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// FontDesignerView.swift
//
//
// Created by Andre Albach on 14.02.22.
//
import SwiftUI
/// A small view to pick a UIFont, set a font color and a font size.
/// There is also a preview included
struct FontDesignerView: View {
/// The view model
@ObservedObject var fontDesigner: FontDesigner
/// The minimum font size the stepper allows
let minimumFontSize: CGFloat = 8
/// The maximum font size the stepper allows
let maximumFontSize: CGFloat = 100
/// The body of the view
var body: some View {
NavigationView {
Form {
Section("Preview") {
Text(fontDesigner.previewText)
.foregroundColor(Color(fontDesigner.fontColor))
}
Section("Configuration") {
NavigationLink(fontDesigner.displayedFontName, isActive: $fontDesigner.isFontPickerActive) {
UIFontPickerRepresentable(fontDesigner: fontDesigner)
}
ColorPicker("Font color", selection: $fontDesigner.fontColor)
Stepper("Font size (\(Float(fontDesigner.fontSize).formatted(.number.precision(.fractionLength(0)))))", value: $fontDesigner.fontSize, in: minimumFontSize ... maximumFontSize)
}
}
}
}
}
// MARK: - Previews
struct FontDesignerView_Previews: PreviewProvider {
static var previews: some View {
FontDesignerView(fontDesigner: FontDesigner.preview)
}
}