@@ -18,16 +18,6 @@ import SwiftUI
1818
1919public struct DiffableTextField < Style: DiffableTextStyleXiOS > : UIViewRepresentable {
2020 public typealias Value = Style . Value
21- public typealias Proxy = ProxyTextField
22-
23- //=------------------------------------------------------------------------=
24- // MARK: Environment
25- //=------------------------------------------------------------------------=
26-
27- @usableFromInline @Environment ( \. locale) var locale : Locale
28- @usableFromInline @Environment ( \. diffableTextField_onSetup ) var onSetup : ( Proxy ) -> Void
29- @usableFromInline @Environment ( \. diffableTextField_onUpdate) var onUpdate : ( Proxy ) -> Void
30- @usableFromInline @Environment ( \. diffableTextField_onSubmit) var onSubmit : ( Proxy ) -> Void
3121
3222 //=------------------------------------------------------------------------=
3323 // MARK: State
@@ -72,11 +62,12 @@ public struct DiffableTextField<Style: DiffableTextStyleXiOS>: UIViewRepresentab
7262 uiView. setContentHuggingPriority ( . defaultHigh, for: . vertical)
7363 uiView. setContentCompressionResistancePriority ( . defaultLow, for: . horizontal)
7464 //=--------------------------------------=
75- // MARK: ProxyTextField
65+ // MARK: ActorTextField
7666 //=--------------------------------------=
7767 context. coordinator. downstream = ActorTextField ( uiView)
7868 context. coordinator. downstream. transform ( Style . onSetup)
79- context. coordinator. downstream. transform ( self . onSetup)
69+ context. coordinator. downstream. transform (
70+ context. environment. diffableTextField_onSetup)
8071 //=--------------------------------------=
8172 // MARK: Done
8273 //=--------------------------------------=
@@ -88,9 +79,7 @@ public struct DiffableTextField<Style: DiffableTextStyleXiOS>: UIViewRepresentab
8879 //=------------------------------------------------------------------------=
8980
9081 @inlinable public func updateUIView( _ uiView: UIViewType , context: Self . Context ) {
91- context. coordinator. upstream = self
92- context. coordinator. synchronize ( )
93- context. coordinator. downstream. transform ( self . onUpdate)
82+ context. coordinator. update ( self , context. environment)
9483 }
9584
9685 //*========================================================================*
@@ -107,23 +96,37 @@ public struct DiffableTextField<Style: DiffableTextStyleXiOS>: UIViewRepresentab
10796
10897 @usableFromInline let lock = Lock ( )
10998 @usableFromInline let context = Context ( )
99+
110100 @usableFromInline var upstream : DiffableTextField !
111101 @usableFromInline var downstream : ActorTextField !
102+ @usableFromInline var environment : EnvironmentValues !
112103
113104 //=--------------------------------------------------------------------=
114105 // MARK: Accessors
115106 //=--------------------------------------------------------------------=
116107
117108 @inlinable func style( ) -> Style {
118- upstream. style. locale ( upstream . locale)
109+ upstream. style. locale ( environment . locale)
119110 }
120111
112+ //=--------------------------------------------------------------------=
113+ // MARK: Update
114+ //=--------------------------------------------------------------------=
115+
116+ @inlinable func update( _ upstream: DiffableTextField , _ environment: EnvironmentValues ) {
117+ self . upstream = upstream
118+ self . environment = environment
119+ self . synchronize ( )
120+ self . downstream. transform (
121+ environment. diffableTextField_onUpdate)
122+ }
123+
121124 //=--------------------------------------------------------------------=
122125 // MARK: Respond To Submit Events
123126 //=--------------------------------------------------------------------=
124127
125128 @inlinable public func textFieldShouldReturn( _ textField: UITextField ) -> Bool {
126- downstream. transform ( upstream . onSubmit ) ; return true
129+ downstream. transform ( environment . diffableTextField_onSubmit ) ; return true
127130 }
128131
129132 //=--------------------------------------------------------------------=
0 commit comments