@momo-kits/native-kits 0.154.2-test.4 → 0.154.2-testbaseline.1

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.
@@ -0,0 +1,55 @@
1
+ //
2
+ // ErrorView.swift
3
+ // Pods
4
+ //
5
+ // Created by sophia on 13/1/26.
6
+ //
7
+
8
+ import SwiftUI
9
+
10
+ public struct ErrorView: View {
11
+ public var errorMessage: String
12
+ public var errorSpacing: Bool
13
+ public var hintText: String
14
+
15
+ public init(
16
+ errorMessage: String = "",
17
+ errorSpacing: Bool = false,
18
+ hintText: String = ""
19
+ ) {
20
+ self.errorMessage = errorMessage
21
+ self.errorSpacing = errorSpacing
22
+ self.hintText = hintText
23
+ }
24
+
25
+ public var body: some View {
26
+ if !errorMessage.isEmpty || !hintText.isEmpty {
27
+ HStack(alignment: .top, spacing: 4) {
28
+ Icon(source: "ic_error", size: scaleSize(16), color: displayColor())
29
+ MomoText(
30
+ displayText(),
31
+ typography: .descriptionDefaultRegular,
32
+ color: displayColor()
33
+ )
34
+ }
35
+ .padding(.top, Spacing.XS)
36
+ } else if errorSpacing {
37
+ Spacer()
38
+ .padding(.top, Spacing.XS)
39
+ .frame(height: 18)
40
+ }
41
+ }
42
+
43
+ // MARK: - Helpers
44
+
45
+ private func displayColor() -> Color {
46
+ !errorMessage.isEmpty ? Colors.red03 : Colors.black12
47
+ }
48
+
49
+ private func displayText() -> String {
50
+ if !errorMessage.isEmpty {
51
+ return errorMessage
52
+ }
53
+ return hintText.isEmpty ? "Không thể chỉnh sửa" : hintText
54
+ }
55
+ }
@@ -65,6 +65,7 @@ public struct Input: View {
65
65
  var placeholder: String
66
66
  var floatingValue: String
67
67
  var errorMessage: String
68
+ var errorSpacing: Bool
68
69
  var isSecure: Bool
69
70
  var keyboardType: UIKeyboardType
70
71
  var floatingIcon: AnyView?
@@ -86,7 +87,7 @@ public struct Input: View {
86
87
  self.value.removeAll()
87
88
  }
88
89
 
89
- public init(_ value: Binding<String>, placeholder: String = "", floatingValue: String = "", multilines: Bool = false, errorMessage: String = "", isSecure: Bool = false, keyboardType: UIKeyboardType = .default, floatingIcon: AnyView? = nil, rightIcon: AnyView? = nil, onChange: ((String)->Void)? = nil, onBlur: (()->Void)? = nil, floatingIconURL: String? = nil, floatingIconColor: Color? = Colors.pink03, size: InputSize = .small, fontWeight: InputFontWeight = .regular, disabled: Bool = false, leadingIcon: String? = nil, leadingIconColor: Color? = Colors.pink03, loading: Bool = false, required: Bool = false, hintText: String? = nil){
90
+ public init(_ value: Binding<String>, placeholder: String = "", floatingValue: String = "", multilines: Bool = false, errorMessage: String = "", isSecure: Bool = false, keyboardType: UIKeyboardType = .default, floatingIcon: AnyView? = nil, rightIcon: AnyView? = nil, onChange: ((String)->Void)? = nil, onBlur: (()->Void)? = nil, floatingIconURL: String? = nil, floatingIconColor: Color? = Colors.pink03, size: InputSize = .small, fontWeight: InputFontWeight = .regular, disabled: Bool = false, leadingIcon: String? = nil, leadingIconColor: Color? = Colors.pink03, loading: Bool = false, required: Bool = false, hintText: String? = nil, errorSpacing: Bool = false){
90
91
  self.placeholder = placeholder
91
92
  self.floatingValue = floatingValue
92
93
  self.errorMessage = errorMessage
@@ -106,6 +107,7 @@ public struct Input: View {
106
107
  self.loading = loading
107
108
  self.required = required
108
109
  self.hintText = hintText
110
+ self.errorSpacing = errorSpacing
109
111
  }
110
112
 
111
113
  func onChangeText(value: String){
@@ -147,13 +149,15 @@ public struct Input: View {
147
149
  rightIcon
148
150
  }
149
151
  .padding(.horizontal, 12)
150
- .frame(height: size == .small ? 40 : 48)
151
- .background(disabled ? Colors.black01 : Color.white)
152
+ .frame(height: scaleSize(size == .small ? 48 : 56, 1.1))
153
+ .background(
154
+ RoundedRectangle(cornerRadius: Radius.S)
155
+ .fill(Colors.black01)
156
+ )
152
157
  .overlay(RoundedRectangle(cornerRadius: 8).stroke(focused ? Colors.pink03 : Colors.border, lineWidth: 1))
153
158
 
154
159
  if value.isEmpty {
155
- Text(placeholder + (required ? " *" : ""))
156
- .foregroundColor(Colors.black09)
160
+ MomoText(placeholder + (required ? " *" : ""), typography: size == .small ? .headerSSemibold : .headerMBold, color: Colors.black09)
157
161
  .padding(.horizontal, leadingIcon == nil ? 12 : 32)
158
162
  .padding(.top, 12)
159
163
  .allowsHitTesting(false)
@@ -169,15 +173,11 @@ public struct Input: View {
169
173
  }
170
174
  }
171
175
 
172
- if !errorMessage.isEmpty {
173
- Text(errorMessage)
174
- .foregroundColor(.red)
175
- .font(.caption)
176
- } else if let hint = hintText {
177
- Text(hint)
178
- .foregroundColor(Colors.black09)
179
- .font(.caption)
180
- }
176
+ ErrorView(
177
+ errorMessage: errorMessage,
178
+ errorSpacing: errorSpacing,
179
+ hintText: hintText ?? ""
180
+ )
181
181
  }
182
182
  }
183
183
  }
@@ -70,9 +70,7 @@ public struct InputPhoneNumber: View {
70
70
  // Text input
71
71
  ZStack(alignment: .leading) {
72
72
  if text.isEmpty {
73
- Text(placeholder)
74
- .foregroundColor(Colors.black12)
75
- .font(size == .small ? .header_s_semibold : .header_m_bold)
73
+ MomoText(placeholder, typography: size == .small ? .headerSSemibold : .headerMBold, color: Colors.black12)
76
74
  }
77
75
 
78
76
  TextField("", text: $text, onEditingChanged: { focused in
@@ -96,18 +94,8 @@ public struct InputPhoneNumber: View {
96
94
 
97
95
  // Loading indicator
98
96
  if loading {
99
- if #available(iOS 14.0, *) {
100
- ProgressView()
101
- .progressViewStyle(CircularProgressViewStyle(tint: Colors.black17))
102
- .frame(width: 16, height: 16)
103
- .padding(.leading, Spacing.S)
104
- } else {
105
- Image(systemName: "clock")
106
- .rotationEffect(.degrees(isFocused ? 360 : 0))
107
- .animation(Animation.linear(duration: 1).repeatForever(autoreverses: false))
108
- .frame(width: 16, height: 16)
109
- .padding(.leading, Spacing.S)
110
- }
97
+ ActivityIndicator(isAnimating: .constant(true), style: .medium)
98
+ .frame(width: 16, height: 16)
111
99
  }
112
100
 
113
101
  // ✅ Right icon
@@ -119,24 +107,22 @@ public struct InputPhoneNumber: View {
119
107
  }
120
108
  }
121
109
  .padding(.horizontal, Spacing.M)
122
- .frame(height: size == .small ? 48 : 56)
110
+ .frame(height: scaleSize(size == .small ? 48 : 56, 1.1))
111
+ .background(
112
+ RoundedRectangle(cornerRadius: Radius.S)
113
+ .fill(Colors.black01)
114
+ )
123
115
  .overlay(
124
116
  RoundedRectangle(cornerRadius: Radius.S)
125
- .stroke(borderColor(), lineWidth: isFocused ? 1.5 : 1)
117
+ .stroke(borderColor(), lineWidth: isFocused ? 1.5 : 1)
126
118
  )
127
119
 
128
120
  // Error or hint
129
- if (!error.isEmpty || !hintText.isEmpty) {
130
- HStack(spacing: 4) {
131
- Icon(source: "ic_error", size: 16, color: errorColor())
132
- MomoText(
133
- error.isEmpty ? (hintText.isEmpty ? "Không thể chỉnh sửa" : hintText) : error,
134
- typography: .descriptionDefaultRegular,
135
- color: errorColor()
136
- )
137
- }
138
- .padding(.top, Spacing.XS)
139
- }
121
+ ErrorView(
122
+ errorMessage: error,
123
+ errorSpacing: false,
124
+ hintText: hintText
125
+ )
140
126
  }
141
127
  }
142
128
 
@@ -156,10 +142,6 @@ public struct InputPhoneNumber: View {
156
142
  if isFocused { return Colors.primary }
157
143
  return Colors.black04
158
144
  }
159
-
160
- private func errorColor() -> Color {
161
- !error.isEmpty ? Colors.red03 : Colors.black12
162
- }
163
145
  }
164
146
 
165
147
  private extension View {
@@ -1,8 +1,8 @@
1
1
  import SwiftUI
2
2
 
3
- public func scaleSize(_ size: CGFloat) -> CGFloat {
3
+ public func scaleSize(_ size: CGFloat, _ scaleRate: CGFloat? = nil) -> CGFloat {
4
4
  let defaultScreenSize: CGFloat = 375
5
- let maxFontScale: CGFloat = 1.5
5
+ let maxFontScale: CGFloat = scaleRate ?? 1.5
6
6
  let maxDeviceScale: CGFloat = 5
7
7
 
8
8
  let deviceWidth = UIScreen.main.bounds.width
@@ -3,7 +3,7 @@ import SwiftUI
3
3
  public extension Font {
4
4
  static func appFont(size: CGFloat) -> Font {
5
5
  let defaultScreenSize: CGFloat = 375
6
- let maxFontScale: CGFloat = 1.2
6
+ let maxFontScale: CGFloat = 1.5
7
7
  let maxDeviceScale: CGFloat = 5
8
8
 
9
9
  let deviceWidth = UIScreen.main.bounds.width
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/native-kits",
3
- "version": "0.154.2-test.4",
3
+ "version": "0.154.2-testbaseline.1",
4
4
  "private": false,
5
5
  "dependencies": {},
6
6
  "devDependencies": {},