File tree Expand file tree Collapse file tree 5 files changed +185
-31
lines changed
SUITextFieldExample/SUITextFieldExample Expand file tree Collapse file tree 5 files changed +185
-31
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ struct ContentView: View {
8787 SUITextField (
8888 value: $myDouble,
8989 format: . number,
90+ formatPolicy: . onChange,
9091 placeholder: AttributedString ( " Hey there " )
9192 . mergingAttributes ( AttributeContainer ( placeholderAttributes) )
9293 )
Original file line number Diff line number Diff line change 22
33## Topics
44
5+ ### Creating a text field with a string
6+
7+ - `` SUITextField/init(text:placeholder:)-5btu0 ``
8+ - `` SUITextField/init(text:placeholder:)-7334w ``
9+ - `` SUITextField/init(text:placeholder:)-9p6by ``
10+
11+ ### Creating a text field with a value (iOS 15)
12+
13+ - `` SUITextField/init(value:format:formatPolicy:placeholder:defaultValue:)-3i36v ``
14+ - `` SUITextField/init(value:format:formatPolicy:placeholder:defaultValue:)-5fdb3 ``
15+ - `` SUITextField/init(value:format:formatPolicy:placeholder:)-9l23l ``
16+ - `` SUITextField/init(value:format:formatPolicy:placeholder:)-2bhgs ``
17+ - `` FormatPolicy ``
18+
19+ ### Creating a text field with a value (pre-iOS 15)
20+
21+ - `` SUITextField/init(value:formatter:formatPolicy:placeholder:defaultValue:)-3wopi ``
22+ - `` SUITextField/init(value:formatter:formatPolicy:placeholder:defaultValue:)-1cub1 ``
23+
524### Modify style and behaviors
625
726- < doc:EnvironmentModifiers >
Original file line number Diff line number Diff line change @@ -84,7 +84,6 @@ formatters. Check all the provided initializers in ``SUITextField``!
8484- ``ResponderState``
8585- ``ResponderChainCoordinator``
8686
87-
8887### Miscellaneous
8988
9089- ``CharacterReplacement``
Original file line number Diff line number Diff line change 1+ //
2+ // FormatPolicy.swift
3+ //
4+ //
5+ // Created by Rico Crescenzio on 15/04/22.
6+ //
7+
8+ import Foundation
9+
10+ /// Indicates when the bound value is updated on a ``SUITextField`` with format/formatter.
11+ ///
12+ /// Policy can specify when the conversion is made, either during typing or when text field did end editing.
13+ public enum FormatPolicy {
14+
15+ /// Parses the text to bound value on every text insertion.
16+ case onChange
17+
18+ /// Parses the text to bound value when text field end editing.
19+ case onCommit
20+ }
You can’t perform that action at this time.
0 commit comments