File tree Expand file tree Collapse file tree
AndroidSwiftUICore/Sources/AndroidSwiftUICore/Primitives Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -162,6 +162,38 @@ extension TextField: PrimitiveView {
162162 }
163163}
164164
165+ /// A text field that obscures its contents. Shares the TextField node with a
166+ /// `secure` flag; the interpreter applies a password transformation.
167+ public struct SecureField : View {
168+
169+ internal let placeholder : String
170+ internal let text : Binding < String >
171+
172+ public init < S: StringProtocol > ( _ placeholder: S , text: Binding < String > ) {
173+ self . placeholder = String ( placeholder)
174+ self . text = text
175+ }
176+
177+ public typealias Body = Never
178+ }
179+
180+ extension SecureField : PrimitiveView {
181+ public func _render( in context: ResolveContext ) -> RenderNode {
182+ let binding = text
183+ let callbackID = context. callbacks. register ( . string { binding. wrappedValue = $0 } )
184+ return RenderNode (
185+ type: " TextField " ,
186+ id: context. path,
187+ props: [
188+ " text " : . string( text. wrappedValue) ,
189+ " placeholder " : . string( placeholder) ,
190+ " onChange " : . int( Int ( callbackID) ) ,
191+ " secure " : . bool( true ) ,
192+ ]
193+ )
194+ }
195+ }
196+
165197/// Eager stand-ins: laziness is an optimization the lazy container path (R7)
166198/// provides; semantics match the eager stacks.
167199public typealias LazyVStack = VStack
You can’t perform that action at this time.
0 commit comments