File tree Expand file tree Collapse file tree 5 files changed +10
-10
lines changed
Sources/SwiftUINavigation
Documentation.docc/Articles Expand file tree Collapse file tree 5 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ object and synchronizing it to view state with the `bind` view modifier that shi
14
14
library.
15
15
16
16
For example, suppose you have a sign in flow where if the API request to sign in fails, you want
17
- to refocus the email field. The model can be implement like so:
17
+ to refocus the email field. The model can be implemented like so:
18
18
19
19
``` swift
20
20
class SignInModel : ObservableObject {
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ struct EditView: View {
36
36
}
37
37
}
38
38
} else : {
39
- Text (" \( self .string ) " )
39
+ Text (self .string )
40
40
Button (" Edit" ) {
41
41
self .editableString = self .string
42
42
}
@@ -47,7 +47,7 @@ struct EditView: View {
47
47
}
48
48
```
49
49
50
- This is the most optimal way to model this domain. Without the ability to deriving a
50
+ This is the most optimal way to model this domain. Without the ability to derive a
51
51
` Binding<String> ` from a ` Binding<String?> ` we would have had to hold onto extra state to represent
52
52
whether or not we are in editing mode:
53
53
@@ -94,15 +94,15 @@ struct EditView: View {
94
94
TextField (" Edit string" , text : $string)
95
95
HStack {
96
96
Button (" Cancel" ) {
97
- self .editableString = nil
97
+ self .editableString = . inactive
98
98
}
99
99
Button (" Save" ) {
100
100
self .string = string
101
- self .editableString = nil
101
+ self .editableString = . inactive
102
102
}
103
103
}
104
104
} else : {
105
- Text (" \( self .string ) " )
105
+ Text (self .string )
106
106
Button (" Edit" ) {
107
107
self .editableString = .active (self .string )
108
108
}
@@ -136,7 +136,7 @@ enum ItemStatus {
136
136
case outOfStock (isOnBackOrder : Bool )
137
137
}
138
138
139
- struct InventoryItemView {
139
+ struct InventoryItemView : View {
140
140
@State var status: ItemStatus
141
141
142
142
var body: some View {
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import SwiftUI
15
15
/// case outOfStock(isOnBackOrder: Bool)
16
16
/// }
17
17
///
18
- /// struct InventoryItemView {
18
+ /// struct InventoryItemView: View {
19
19
/// @State var status: ItemStatus
20
20
///
21
21
/// var body: some View {
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import SwiftUI
11
11
/// optional binding.
12
12
///
13
13
/// ```swift
14
- /// struct InventoryItemView {
14
+ /// struct InventoryItemView: View {
15
15
/// @State var quantity: Int?
16
16
///
17
17
/// var body: some View {
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import SwiftUI
15
15
/// case outOfStock(isOnBackOrder: Bool)
16
16
/// }
17
17
///
18
- /// struct InventoryItemView {
18
+ /// struct InventoryItemView: View {
19
19
/// @State var status: ItemStatus
20
20
///
21
21
/// var body: some View {
You can’t perform that action at this time.
0 commit comments