@@ -49,46 +49,53 @@ public struct SUInputField<FocusValue: Hashable>: View {
4949 // MARK: Body
5050
5151 public var body : some View {
52- HStack ( spacing: self . model. spacing) {
53- if let title = self . model. attributedTitle {
52+ VStack ( alignment: . leading, spacing: self . model. spacing) {
53+ if let title = self . model. attributedTitle,
54+ self . model. titlePosition == . outside {
5455 Text ( title)
55- . font ( self . model. preferredFont. font)
5656 }
5757
58- Group {
59- if self . model. isSecureInput {
60- SecureField ( text: self . $text, label: {
61- Text ( self . model. placeholder ?? " " )
62- . foregroundStyle ( self . model. placeholderColor. color)
63- } )
64- } else {
65- TextField ( text: self . $text, label: {
66- Text ( self . model. placeholder ?? " " )
67- . foregroundStyle ( self . model. placeholderColor. color)
68- } )
58+ HStack ( spacing: self . model. spacing) {
59+ if let title = self . model. attributedTitle,
60+ self . model. titlePosition == . inside {
61+ Text ( title)
6962 }
63+
64+ Group {
65+ if self . model. isSecureInput {
66+ SecureField ( text: self . $text, label: {
67+ Text ( self . model. placeholder ?? " " )
68+ . foregroundStyle ( self . model. placeholderColor. color)
69+ } )
70+ } else {
71+ TextField ( text: self . $text, label: {
72+ Text ( self . model. placeholder ?? " " )
73+ . foregroundStyle ( self . model. placeholderColor. color)
74+ } )
75+ }
76+ }
77+ . tint ( self . model. tintColor. color)
78+ . font ( self . model. preferredFont. font)
79+ . foregroundStyle ( self . model. foregroundColor. color)
80+ . applyFocus ( globalFocus: self . globalFocus, localFocus: self . localFocus)
81+ . disabled ( !self . model. isEnabled)
82+ . keyboardType ( self . model. keyboardType)
83+ . submitLabel ( self . model. submitType. submitLabel)
84+ . autocorrectionDisabled ( !self . model. isAutocorrectionEnabled)
85+ . textInputAutocapitalization ( self . model. autocapitalization. textInputAutocapitalization)
7086 }
71- . tint ( self . model. tintColor. color)
72- . font ( self . model. preferredFont. font)
73- . foregroundStyle ( self . model. foregroundColor. color)
74- . applyFocus ( globalFocus: self . globalFocus, localFocus: self . localFocus)
75- . disabled ( !self . model. isEnabled)
76- . keyboardType ( self . model. keyboardType)
77- . submitLabel ( self . model. submitType. submitLabel)
78- . autocorrectionDisabled ( !self . model. isAutocorrectionEnabled)
79- . textInputAutocapitalization ( self . model. autocapitalization. textInputAutocapitalization)
80- }
81- . padding ( . horizontal, self . model. horizontalPadding)
82- . frame ( height: self . model. height)
83- . background ( self . model. backgroundColor. color)
84- . onTapGesture {
85- self . globalFocus? . wrappedValue = self . localFocus
86- }
87- . clipShape (
88- RoundedRectangle (
89- cornerRadius: self . model. cornerRadius. value ( )
87+ . padding ( . horizontal, self . model. horizontalPadding)
88+ . frame ( height: self . model. height)
89+ . background ( self . model. backgroundColor. color)
90+ . onTapGesture {
91+ self . globalFocus? . wrappedValue = self . localFocus
92+ }
93+ . clipShape (
94+ RoundedRectangle (
95+ cornerRadius: self . model. cornerRadius. value ( )
96+ )
9097 )
91- )
98+ }
9299 }
93100}
94101
0 commit comments