@momo-kits/native-kits 0.169.5 → 0.169.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,13 +18,22 @@ public struct InputPhoneNumber: View {
18
18
  public var errorSpacing: Bool
19
19
  public var loading: Bool
20
20
  public var required: Bool
21
+ /// Deprecated: use `trailing`.
21
22
  public var rightIcon: String
23
+ /// Deprecated: use `trailingColor`.
22
24
  public var rightIconColor: Color?
25
+ /// Icon key or URL; wins over `rightIcon` when not empty.
26
+ public var trailing: String
27
+ /// Wins over `rightIconColor` when set.
28
+ public var trailingColor: Color?
23
29
  public var autofocus: Bool
24
30
  public var onChangeText: ((String) -> Void)?
25
31
  public var onFocus: (() -> Void)?
26
32
  public var onBlur: (() -> Void)?
33
+ /// Deprecated: use `onPressTrailing`.
27
34
  public var onRightIconPressed: (() -> Void)?
35
+ /// Wins over `onRightIconPressed` when set.
36
+ public var onPressTrailing: (() -> Void)?
28
37
  public var accessibilityLabel: String?
29
38
 
30
39
  @State private var isFocused: Bool = false
@@ -41,11 +50,14 @@ public struct InputPhoneNumber: View {
41
50
  required: Bool = false,
42
51
  rightIcon: String = "",
43
52
  rightIconColor: Color? = nil,
53
+ trailing: String = "",
54
+ trailingColor: Color? = nil,
44
55
  autofocus: Bool = false,
45
56
  onChangeText: ((String) -> Void)? = nil,
46
57
  onFocus: (() -> Void)? = nil,
47
58
  onBlur: (() -> Void)? = nil,
48
59
  onRightIconPressed: (() -> Void)? = nil,
60
+ onPressTrailing: (() -> Void)? = nil,
49
61
  accessibilityLabel: String? = nil
50
62
  ) {
51
63
  self._text = text
@@ -58,11 +70,14 @@ public struct InputPhoneNumber: View {
58
70
  self.required = required
59
71
  self.rightIcon = rightIcon
60
72
  self.rightIconColor = rightIconColor
73
+ self.trailing = trailing
74
+ self.trailingColor = trailingColor
61
75
  self.autofocus = autofocus
62
76
  self.onChangeText = onChangeText
63
77
  self.onFocus = onFocus
64
78
  self.onBlur = onBlur
65
79
  self.onRightIconPressed = onRightIconPressed
80
+ self.onPressTrailing = onPressTrailing
66
81
  self.accessibilityLabel = accessibilityLabel
67
82
  }
68
83
 
@@ -129,16 +144,13 @@ public struct InputPhoneNumber: View {
129
144
  .accessibilityIdentifier("ic_clear")
130
145
  }
131
146
 
132
- // Loading indicator
147
+ // Spinner replaces the trailing icon while loading (RN RenderTrailing)
133
148
  if loading {
134
- ActivityIndicator(isAnimating: .constant(true), style: .medium, color: rightIconColor ?? theme.colors.text.default)
149
+ ActivityIndicator(isAnimating: .constant(true), style: .medium, color: trailingTint)
135
150
  .frame(width: 16, height: 16)
136
- }
137
-
138
- // ✅ Right icon
139
- if !rightIcon.isEmpty {
140
- SwiftUI.Button(action: { onRightIconPressed?() }) {
141
- Icon(source: rightIcon, size: 24, color: rightIconColor ?? theme.colors.text.default)
151
+ } else if !trailingIcon.isEmpty {
152
+ SwiftUI.Button(action: pressTrailing) {
153
+ Icon(source: trailingIcon, size: 24, color: trailingTint)
142
154
  .padding(.leading, Spacing.S)
143
155
  }
144
156
  }
@@ -164,7 +176,23 @@ public struct InputPhoneNumber: View {
164
176
  }
165
177
 
166
178
  // MARK: - Helpers
167
-
179
+
180
+ private var trailingIcon: String {
181
+ return trailing.isEmpty ? rightIcon : trailing
182
+ }
183
+
184
+ private var trailingTint: Color {
185
+ return trailingColor ?? rightIconColor ?? theme.colors.text.default
186
+ }
187
+
188
+ private func pressTrailing() {
189
+ if let onPressTrailing {
190
+ onPressTrailing()
191
+ return
192
+ }
193
+ onRightIconPressed?()
194
+ }
195
+
168
196
  private func handleFocusChange(_ focused: Bool) {
169
197
  guard focused != isFocused else { return }
170
198
  isFocused = focused
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKits'
3
- s.version = '0.169.5'
3
+ s.version = '0.169.6'
4
4
  s.summary = 'MoMoUIKits for iOS'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'MoMoUIKitsDemo'
3
- s.version = '0.169.5'
3
+ s.version = '0.169.6'
4
4
  s.summary = 'Demo browser for MoMoUIKits SwiftUI components'
5
5
  s.homepage = 'https://momo.vn'
6
6
  s.license = { :type => 'MIT' }
@@ -28,6 +28,8 @@ private struct InputPhoneNumberPreview: View {
28
28
  @State private var t3 = ""
29
29
  @State private var t4 = ""
30
30
  @State private var t5 = ""
31
+ @State private var t6 = ""
32
+ @State private var trailingPressCount = 0
31
33
 
32
34
  var body: some View {
33
35
  BasicColumnBox("Size", alignment: .leading) {
@@ -41,7 +43,16 @@ private struct InputPhoneNumberPreview: View {
41
43
  InputPhoneNumber(text: $t4, placeholder: "Enter here", error: "error message")
42
44
  }
43
45
  BasicColumnBox("Trailing Icon", alignment: .leading) {
44
- InputPhoneNumber(text: $t5, placeholder: "Phone", rightIcon: "24_ic_public", rightIconColor: Colors.pink03)
46
+ InputPhoneNumber(text: $t5, placeholder: "Phone", trailing: "24_ic_public", trailingColor: Colors.pink03)
47
+ }
48
+ BasicColumnBox("Trailing bấm được", alignment: .leading) {
49
+ InputPhoneNumber(
50
+ text: $t6,
51
+ placeholder: "Phone",
52
+ trailing: "Phonebook",
53
+ onPressTrailing: { trailingPressCount += 1 }
54
+ )
55
+ MomoText("Đã bấm icon: \(trailingPressCount)")
45
56
  }
46
57
  }
47
58
  }
@@ -55,7 +66,7 @@ private struct InputPhoneNumberPlayground: View {
55
66
  @State private var hintText = ""
56
67
  @State private var error = ""
57
68
  @State private var size: PlaygroundOption? = inputSizeList.first { $0.key == "small" }
58
- @State private var rightIcon: PlaygroundOption?
69
+ @State private var trailing: PlaygroundOption?
59
70
  @State private var loading = false
60
71
  @State private var required = false
61
72
 
@@ -70,7 +81,7 @@ private struct InputPhoneNumberPlayground: View {
70
81
  error: error,
71
82
  loading: loading,
72
83
  required: required,
73
- rightIcon: (rightIcon?.value as? String) ?? ""
84
+ trailing: (trailing?.value as? String) ?? ""
74
85
  )
75
86
  },
76
87
  params: [
@@ -78,7 +89,7 @@ private struct InputPhoneNumberPlayground: View {
78
89
  .string("HintText", $hintText),
79
90
  .string("Error", $error),
80
91
  .radio("Size", inputSizeList, $size),
81
- .option("RightIcon", playgroundIcons, $rightIcon),
92
+ .option("Trailing", playgroundIcons, $trailing),
82
93
  .checkbox("Loading", $loading),
83
94
  .checkbox("Required", $required),
84
95
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.169.5",
3
+ "version": "0.169.6",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "publish:local": "bash publish.sh local"