@momo-kits/native-kits 0.169.6-debug → 0.169.7-debug
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.
- package/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +2 -4
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +13 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +2 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +13 -73
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +1 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +3 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +7 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +1 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +6 -30
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +2 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +6 -24
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -5
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +1 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -3
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +4 -30
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +2 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +1 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +4 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +5 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -2
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +1 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +1 -1
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +1 -2
- package/gradle/libs.versions.toml +0 -2
- package/gradle.properties +1 -1
- package/ios/Application/ApplicationEnvironment.swift +2 -3
- package/ios/Application/DesignSystemKits.swift +4 -20
- package/ios/Application/DesignSystemKitsPayload.swift +0 -8
- package/ios/Application/LanguageSource.swift +0 -8
- package/ios/Application/Localize.swift +7 -31
- package/ios/Application/LocalizeModifier.swift +0 -8
- package/ios/Application/MaxApi.swift +3 -11
- package/ios/Avatar/Avatar.swift +0 -1
- package/ios/Badge/Badge.swift +0 -1
- package/ios/Badge/BadgeRibbon.swift +2 -5
- package/ios/Button/Button.swift +2 -5
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +2 -2
- package/ios/Carousel/Carousel.swift +5 -17
- package/ios/Checkbox/Checkbox.swift +0 -2
- package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
- package/ios/DateTimePicker/DateTimePicker.swift +4 -10
- package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
- package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
- package/ios/DateTimePicker/WheelPicker.swift +2 -4
- package/ios/Extensions/SkeletonUICompat.swift +0 -8
- package/ios/Icon/Icon.swift +1 -3
- package/ios/IconButton/IconButton.swift +0 -2
- package/ios/Input/ErrorView.swift +0 -7
- package/ios/Input/Input.swift +6 -19
- package/ios/Input/InputPhoneNumber.swift +0 -11
- package/ios/Input/InputSearch.swift +0 -6
- package/ios/Input/InputTextArea.swift +1 -12
- package/ios/InputDropDown/InputDropDown.swift +1 -11
- package/ios/InputMoney/InputMoney.swift +9 -28
- package/ios/InputOTP/InputOTP.swift +2 -9
- package/ios/Layout/Item.swift +1 -2
- package/ios/Layout/ModalLayout.swift +7 -14
- package/ios/Layout/ScreenLayout.swift +2 -7
- package/ios/Loader/Loader.swift +3 -12
- package/ios/Lottie/LottieView.swift +0 -11
- package/ios/Navigation/BottomSheet.swift +14 -35
- package/ios/Navigation/BottomTab/BottomTab.swift +10 -19
- package/ios/Navigation/BottomTab/BottomTabBar.swift +4 -10
- package/ios/Navigation/BottomTab/CurvedContainer.swift +5 -11
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +6 -12
- package/ios/Navigation/BottomTab/DuoTabBar.swift +2 -7
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +3 -9
- package/ios/Navigation/Component/FloatingButton.swift +4 -11
- package/ios/Navigation/Component/Header.swift +4 -8
- package/ios/Navigation/Component/HeaderBackground.swift +2 -8
- package/ios/Navigation/Component/HeaderJourney.swift +2 -7
- package/ios/Navigation/Component/HeaderLocation.swift +2 -7
- package/ios/Navigation/Component/HeaderRight.swift +2 -7
- package/ios/Navigation/Component/HeaderTitle.swift +1 -6
- package/ios/Navigation/Component/HeaderUser.swift +2 -9
- package/ios/Navigation/Component/SideBar.swift +3 -8
- package/ios/Navigation/Component/SnackBar.swift +5 -13
- package/ios/Navigation/HostBackGestureBridge.swift +3 -9
- package/ios/Navigation/ModalScreen.swift +2 -8
- package/ios/Navigation/Navigation.swift +2 -15
- package/ios/Navigation/NavigationContainer.swift +3 -12
- package/ios/Navigation/Navigator.swift +15 -27
- package/ios/Navigation/StackScreen.swift +8 -28
- package/ios/Navigation/StackTransition.swift +3 -11
- package/ios/Navigation/SwipeBackHaptic.swift +2 -7
- package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
- package/ios/Pagination/PaginationDot.swift +0 -9
- package/ios/Pagination/PaginationNumber.swift +1 -9
- package/ios/Pagination/PaginationScroll.swift +2 -14
- package/ios/Pagination/PaginationWhiteDot.swift +1 -10
- package/ios/Popup/PopupDisplay.swift +3 -3
- package/ios/Popup/PopupInput.swift +1 -1
- package/ios/Popup/PopupLayout.swift +3 -3
- package/ios/PopupView/FullscreenPopup.swift +3 -4
- package/ios/PopupView/PopupView.swift +2 -2
- package/ios/PopupView/Utils++.swift +1 -2
- package/ios/ProgressInfo/ProgressInfo.swift +2 -13
- package/ios/Skeleton/Skeleton.swift +2 -10
- package/ios/Slider/Slider.swift +5 -12
- package/ios/StatusBarTap/StatusBarTap.h +2 -3
- package/ios/StatusBarTap/StatusBarTap.m +3 -16
- package/ios/Stepper/Stepper.swift +8 -27
- package/ios/Steps/Steps.swift +9 -11
- package/ios/Swipeable/SwipeCell.swift +2 -2
- package/ios/Swipeable/SwipeCellModel.swift +3 -6
- package/ios/TabView/TabView.swift +12 -25
- package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
- package/ios/Tooltip/Tooltip.swift +2 -7
- package/ios/Typography/FontScale.swift +3 -15
- package/ios/Typography/Text.swift +2 -7
- package/ios/Typography/Typography.swift +8 -10
- package/ios/Uploader/Uploader.swift +2 -17
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
- package/package.json +1 -1
package/ios/Input/Input.swift
CHANGED
|
@@ -101,10 +101,8 @@ public struct Input: View {
|
|
|
101
101
|
let textBinding = Binding<String>(
|
|
102
102
|
get: { self.text },
|
|
103
103
|
set: { newValue in
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
// render with the untrimmed value that a separate `.onChange` correction
|
|
107
|
-
// would otherwise briefly show.
|
|
104
|
+
// Trimmed before publishing, like Compose's `newText.take(maxLength)`: an `.onChange`
|
|
105
|
+
// correction would briefly render the untrimmed value.
|
|
108
106
|
let limited = limitText(newValue)
|
|
109
107
|
self.text = limited
|
|
110
108
|
self.onChangeText?(limited)
|
|
@@ -112,15 +110,12 @@ public struct Input: View {
|
|
|
112
110
|
)
|
|
113
111
|
|
|
114
112
|
VStack(alignment: .leading, spacing: 0) {
|
|
115
|
-
// Input container
|
|
116
113
|
HStack(alignment: .center, spacing: 0) {
|
|
117
|
-
// Leading icon
|
|
118
114
|
if !leadingIcon.isEmpty {
|
|
119
115
|
Icon(source: leadingIcon, size: size == .small ? 24 : 32, color: leadingIconColor ?? theme.colors.text.hint)
|
|
120
116
|
.padding(.trailing, Spacing.M)
|
|
121
117
|
}
|
|
122
118
|
|
|
123
|
-
// Text input field
|
|
124
119
|
ZStack(alignment: .leading) {
|
|
125
120
|
if text.isEmpty {
|
|
126
121
|
MomoText(
|
|
@@ -162,16 +157,12 @@ public struct Input: View {
|
|
|
162
157
|
.onAppear {
|
|
163
158
|
if autofocus { isFieldFocused = true }
|
|
164
159
|
}
|
|
165
|
-
// SwiftUI reads
|
|
166
|
-
//
|
|
167
|
-
// change is silently dropped. The secure path can call
|
|
168
|
-
// `reloadInputViews()` in `updateUIView`; here the only lever
|
|
169
|
-
// is to force a rebuild.
|
|
160
|
+
// SwiftUI reads UIKit input traits only when it builds the UITextField, so a later
|
|
161
|
+
// `keyboardType` change is dropped; force a rebuild.
|
|
170
162
|
.id(keyboardType.rawValue)
|
|
171
163
|
}
|
|
172
164
|
}
|
|
173
165
|
|
|
174
|
-
// Clear button (only show when focused and has text)
|
|
175
166
|
if isFocused && !text.isEmpty {
|
|
176
167
|
SwiftUI.Button(action: {
|
|
177
168
|
text = ""
|
|
@@ -183,7 +174,6 @@ public struct Input: View {
|
|
|
183
174
|
.accessibilityIdentifier("ic_clear")
|
|
184
175
|
}
|
|
185
176
|
|
|
186
|
-
// Loading indicator
|
|
187
177
|
if loading {
|
|
188
178
|
ActivityIndicator(isAnimating: .constant(true), style: .medium, color: getRightIconColor())
|
|
189
179
|
.frame(width: 16, height: 16)
|
|
@@ -220,7 +210,6 @@ public struct Input: View {
|
|
|
220
210
|
)
|
|
221
211
|
.overlay(alignment: .topLeading) { floatingLabel }
|
|
222
212
|
|
|
223
|
-
// Error or hint
|
|
224
213
|
ErrorView(
|
|
225
214
|
errorMessage: error,
|
|
226
215
|
errorSpacing: errorSpacing,
|
|
@@ -409,10 +398,8 @@ private struct SecureInputField: UIViewRepresentable {
|
|
|
409
398
|
self.parent = parent
|
|
410
399
|
}
|
|
411
400
|
|
|
412
|
-
//
|
|
413
|
-
//
|
|
414
|
-
// replace ALL of it. Re-inserting via insertText() puts it back into an
|
|
415
|
-
// "active editing" state (and moves the caret to the end).
|
|
401
|
+
// A secure field regaining focus (or turning secure mid-edit) marks its text committed, so
|
|
402
|
+
// the next keystroke would replace all of it; re-inserting resumes editing, caret at the end.
|
|
416
403
|
func reinsertText(in textField: UITextField) {
|
|
417
404
|
let existingText = textField.text ?? ""
|
|
418
405
|
guard !existingText.isEmpty else { return }
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// InputPhoneNumber.swift
|
|
3
|
-
// Pods
|
|
4
|
-
//
|
|
5
|
-
// Created by sophia on 20/10/25.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
1
|
import SwiftUI
|
|
9
2
|
public struct InputPhoneNumber: View {
|
|
10
3
|
@Environment(\.appTheme) private var theme
|
|
@@ -93,7 +86,6 @@ public struct InputPhoneNumber: View {
|
|
|
93
86
|
|
|
94
87
|
VStack(alignment: .leading, spacing: 0) {
|
|
95
88
|
HStack(spacing: 0) {
|
|
96
|
-
// 🇻🇳 Flag
|
|
97
89
|
ImageView("https://static.momocdn.net/app/img/icon/ic-qrcode-package/ic_vn_flag.png")
|
|
98
90
|
.frame(width: 24, height: 24)
|
|
99
91
|
.padding(.trailing, Spacing.XS)
|
|
@@ -105,7 +97,6 @@ public struct InputPhoneNumber: View {
|
|
|
105
97
|
.frame(width: 1, height: size == .small ? 24 : 32)
|
|
106
98
|
.padding(.horizontal, Spacing.M)
|
|
107
99
|
|
|
108
|
-
// Text input
|
|
109
100
|
ZStack(alignment: .leading) {
|
|
110
101
|
if text.isEmpty {
|
|
111
102
|
MomoText(
|
|
@@ -132,7 +123,6 @@ public struct InputPhoneNumber: View {
|
|
|
132
123
|
.accessibilityValue(textBinding.wrappedValue.isEmpty ? placeholder : textBinding.wrappedValue)
|
|
133
124
|
}
|
|
134
125
|
|
|
135
|
-
// Clear button
|
|
136
126
|
if isFocused && !text.isEmpty {
|
|
137
127
|
SwiftUI.Button(action: {
|
|
138
128
|
text = ""
|
|
@@ -166,7 +156,6 @@ public struct InputPhoneNumber: View {
|
|
|
166
156
|
.stroke(borderColor(), lineWidth: isFocused ? 1.5 : 1)
|
|
167
157
|
)
|
|
168
158
|
|
|
169
|
-
// Error or hint
|
|
170
159
|
ErrorView(
|
|
171
160
|
errorMessage: error,
|
|
172
161
|
errorSpacing: errorSpacing,
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
// InputTextArea.swift
|
|
3
|
-
// Pods
|
|
4
|
-
//
|
|
5
|
-
// Created by dung.pham2 on 2/12/24.
|
|
6
|
-
//
|
|
7
1
|
import SwiftUI
|
|
8
2
|
|
|
9
|
-
// Make these constants public
|
|
10
3
|
public let MAX_LENGTH = 300
|
|
11
4
|
public let DEFAULT_HEIGHT: CGFloat = 104
|
|
12
5
|
|
|
@@ -92,7 +85,6 @@ struct UITextViewWrapper: UIViewRepresentable {
|
|
|
92
85
|
}
|
|
93
86
|
}
|
|
94
87
|
|
|
95
|
-
// Make the struct public
|
|
96
88
|
public struct InputTextArea: View {
|
|
97
89
|
@Environment(\.appTheme) private var theme
|
|
98
90
|
@Environment(\.momoFontScale) private var fontScale
|
|
@@ -120,7 +112,6 @@ public struct InputTextArea: View {
|
|
|
120
112
|
|
|
121
113
|
@State private var isFocused = false
|
|
122
114
|
|
|
123
|
-
// Make the initializer public
|
|
124
115
|
public init(
|
|
125
116
|
text: Binding<String>,
|
|
126
117
|
maxLength: Int = MAX_LENGTH,
|
|
@@ -204,7 +195,6 @@ public struct InputTextArea: View {
|
|
|
204
195
|
}
|
|
205
196
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
|
206
197
|
|
|
207
|
-
// Clear button (mirrors Compose: focused + non-empty).
|
|
208
198
|
if isFocused && !text.isEmpty {
|
|
209
199
|
SwiftUI.Button(action: {
|
|
210
200
|
text = ""
|
|
@@ -215,8 +205,7 @@ public struct InputTextArea: View {
|
|
|
215
205
|
.padding(.leading, Spacing.XS)
|
|
216
206
|
}
|
|
217
207
|
|
|
218
|
-
//
|
|
219
|
-
// Compose's RenderRightIcon: both can render at once).
|
|
208
|
+
// Not if/else: Compose's RenderRightIcon can show the spinner and the icon together.
|
|
220
209
|
if loading {
|
|
221
210
|
ActivityIndicator(isAnimating: .constant(true), style: .medium, color: iconTintColor)
|
|
222
211
|
.frame(width: 16, height: 16)
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// InputDropDown.swift
|
|
3
|
-
// Pods
|
|
4
|
-
//
|
|
5
|
-
// Hand-written SwiftUI reimplementation of Compose `InputDropDown`.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
1
|
import SwiftUI
|
|
9
2
|
|
|
10
3
|
// MARK: - RenderRightIcon (mirrors Compose RenderRightIcon for InputDropDown)
|
|
@@ -16,8 +9,7 @@ private struct RenderRightIcon: View {
|
|
|
16
9
|
let onPressed: () -> Void
|
|
17
10
|
|
|
18
11
|
var body: some View {
|
|
19
|
-
//
|
|
20
|
-
// can both render at once, not exclusively (not an if/else).
|
|
12
|
+
// Not if/else, as in Compose: the spinner and the icon can show together.
|
|
21
13
|
if loading {
|
|
22
14
|
ActivityIndicator(isAnimating: .constant(true), style: .medium, color: color)
|
|
23
15
|
.frame(width: 16, height: 16)
|
|
@@ -100,7 +92,6 @@ public struct InputDropDown: View {
|
|
|
100
92
|
public var body: some View {
|
|
101
93
|
VStack(alignment: .leading, spacing: 0) {
|
|
102
94
|
ZStack(alignment: .topLeading) {
|
|
103
|
-
// Floating label
|
|
104
95
|
if !floatingValue.isEmpty || !floatingIcon.isEmpty {
|
|
105
96
|
HStack(spacing: 0) {
|
|
106
97
|
MomoText(floatingValue, typography: .labelSMedium, color: floatingTitleColor)
|
|
@@ -118,7 +109,6 @@ public struct InputDropDown: View {
|
|
|
118
109
|
.zIndex(10)
|
|
119
110
|
}
|
|
120
111
|
|
|
121
|
-
// Input container
|
|
122
112
|
HStack(alignment: .center, spacing: 0) {
|
|
123
113
|
if !leadingIcon.isEmpty {
|
|
124
114
|
Icon(source: leadingIcon, size: size == .small ? 24 : 32, color: leadingIconTintColor)
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
// InputMoney.swift
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// Native SwiftUI reimplementation of Compose `InputMoney`.
|
|
6
|
-
// The bound `text` holds RAW DIGITS only, as in Compose; the field shows
|
|
7
|
-
// the thousands-separated currency and edits apply at the caret.
|
|
8
|
-
//
|
|
9
|
-
|
|
10
1
|
import Foundation
|
|
11
2
|
import SwiftUI
|
|
12
3
|
import UIKit
|
|
@@ -35,7 +26,6 @@ public func formatNumberToMoney(_ digits: String, currency: String = "đ") -> St
|
|
|
35
26
|
for i in 0..<reversed.count {
|
|
36
27
|
count += 1
|
|
37
28
|
chars.append(reversed[i])
|
|
38
|
-
// i counts from the least significant digit; original index = len-1-i.
|
|
39
29
|
let originalIndex = reversed.count - 1 - i
|
|
40
30
|
if count == 3 && originalIndex >= 1 {
|
|
41
31
|
chars.append(".")
|
|
@@ -47,9 +37,8 @@ public func formatNumberToMoney(_ digits: String, currency: String = "đ") -> St
|
|
|
47
37
|
|
|
48
38
|
private func isMoneyDigit(_ char: Character) -> Bool { char.isASCII && char.isNumber }
|
|
49
39
|
|
|
50
|
-
/// Applies
|
|
51
|
-
///
|
|
52
|
-
/// digit before it instead, removing only the currency leaves the digits untouched. Returns the new digits and the caret as a digit index.
|
|
40
|
+
/// Applies the edit `display[start..<end]` → `inserted` to the digits of `display`. Separators and
|
|
41
|
+
/// currency are never deleted: removing a separator deletes the digit before it instead.
|
|
53
42
|
private func applyMoneyEdit(_ display: String, start: Int, end: Int, inserted: String) -> (digits: String, caretDigit: Int) {
|
|
54
43
|
let chars = Array(display)
|
|
55
44
|
let start = min(start, chars.count)
|
|
@@ -83,6 +72,8 @@ private func moneyCaret(_ display: String, digitIndex: Int) -> Int {
|
|
|
83
72
|
|
|
84
73
|
// MARK: - InputMoney
|
|
85
74
|
|
|
75
|
+
/// Compose `InputMoney`: the bound `text` holds raw digits only; the field shows the
|
|
76
|
+
/// thousands-separated currency and edits apply at the caret.
|
|
86
77
|
public struct InputMoney: View {
|
|
87
78
|
@Environment(\.appTheme) private var theme
|
|
88
79
|
@Environment(\.momoFontScale) private var fontScale
|
|
@@ -166,7 +157,6 @@ public struct InputMoney: View {
|
|
|
166
157
|
public var body: some View {
|
|
167
158
|
VStack(alignment: .leading, spacing: 0) {
|
|
168
159
|
ZStack(alignment: .topLeading) {
|
|
169
|
-
// Floating label
|
|
170
160
|
if !floatingValue.isEmpty || !floatingIcon.isEmpty {
|
|
171
161
|
HStack(spacing: 0) {
|
|
172
162
|
MomoText(floatingValue, typography: .labelSMedium, color: floatingTitleColor)
|
|
@@ -185,24 +175,18 @@ public struct InputMoney: View {
|
|
|
185
175
|
}
|
|
186
176
|
)
|
|
187
177
|
.background(theme.colors.background.surface)
|
|
188
|
-
//
|
|
189
|
-
//
|
|
190
|
-
// the label ends up centered exactly on the box's top border. Our ZStack
|
|
191
|
-
// anchors top-leading instead, so matching that requires offsetting by
|
|
192
|
-
// half the label's OWN measured height, not half the box height.
|
|
178
|
+
// Compose centers the label in the box and offsets it by -box height / 2, onto the
|
|
179
|
+
// top border; this ZStack anchors top-leading, so it offsets by half the label height.
|
|
193
180
|
.offset(x: Spacing.S, y: -floatingLabelHeight / 2)
|
|
194
181
|
.zIndex(10)
|
|
195
182
|
}
|
|
196
183
|
|
|
197
|
-
// Input container
|
|
198
184
|
HStack(alignment: .center, spacing: 0) {
|
|
199
|
-
// Leading icon
|
|
200
185
|
if !leadingIcon.isEmpty {
|
|
201
186
|
Icon(source: leadingIcon, size: size == .small ? 24 : 32, color: leadingIconTintColor)
|
|
202
187
|
.padding(.trailing, Spacing.XS)
|
|
203
188
|
}
|
|
204
189
|
|
|
205
|
-
// Money field
|
|
206
190
|
ZStack(alignment: .leading) {
|
|
207
191
|
if !hasDigits {
|
|
208
192
|
MomoText(
|
|
@@ -226,7 +210,6 @@ public struct InputMoney: View {
|
|
|
226
210
|
}
|
|
227
211
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
228
212
|
|
|
229
|
-
// Clear button (focused + has value)
|
|
230
213
|
if isFocused && hasDigits {
|
|
231
214
|
SwiftUI.Button(action: {
|
|
232
215
|
text = ""
|
|
@@ -238,8 +221,7 @@ public struct InputMoney: View {
|
|
|
238
221
|
}
|
|
239
222
|
}
|
|
240
223
|
|
|
241
|
-
//
|
|
242
|
-
// Compose's two independent `if` blocks, not if/else).
|
|
224
|
+
// Not if/else, as in Compose: the spinner and the icon can show together.
|
|
243
225
|
if loading {
|
|
244
226
|
ActivityIndicator(isAnimating: .constant(true), style: .medium, color: iconTintColor)
|
|
245
227
|
.frame(width: 16, height: 16)
|
|
@@ -303,9 +285,8 @@ public struct InputMoney: View {
|
|
|
303
285
|
|
|
304
286
|
// MARK: - MoneyTextField (UIViewRepresentable)
|
|
305
287
|
|
|
306
|
-
///
|
|
307
|
-
///
|
|
308
|
-
/// but never past the trailing currency symbol; edits apply at the caret.
|
|
288
|
+
/// Shows the formatted currency while `digits` holds the raw value; the caret never passes the
|
|
289
|
+
/// currency suffix.
|
|
309
290
|
private struct MoneyTextField: UIViewRepresentable {
|
|
310
291
|
@Binding var digits: String
|
|
311
292
|
var keyboardType: UIKeyboardType
|
|
@@ -27,11 +27,8 @@ private struct OTPCaret: View {
|
|
|
27
27
|
|
|
28
28
|
// MARK: - InputOTP
|
|
29
29
|
|
|
30
|
-
///
|
|
31
|
-
///
|
|
32
|
-
/// A row of OTP cells driven by a hidden `TextField`. When `length` is provided
|
|
33
|
-
/// it renders fixed-count slots (`-` placeholders + blinking caret); otherwise it
|
|
34
|
-
/// renders the typed characters followed by a trailing caret while focused.
|
|
30
|
+
/// Compose `InputOTP`: cells driven by a hidden `TextField`. With `length`, fixed slots (`-`
|
|
31
|
+
/// placeholders + blinking caret); without, the typed characters and a trailing caret while focused.
|
|
35
32
|
public struct InputOTP: View {
|
|
36
33
|
@Environment(\.appTheme) private var theme
|
|
37
34
|
@Binding public var value: String
|
|
@@ -80,10 +77,8 @@ public struct InputOTP: View {
|
|
|
80
77
|
public var body: some View {
|
|
81
78
|
VStack(alignment: .leading, spacing: 0) {
|
|
82
79
|
ZStack {
|
|
83
|
-
// Hidden text field that owns the keyboard / cursor.
|
|
84
80
|
hiddenField
|
|
85
81
|
|
|
86
|
-
// Floating label over the border.
|
|
87
82
|
if !floatingValue.isEmpty {
|
|
88
83
|
HStack {
|
|
89
84
|
MomoText(floatingValue, typography: .labelSMedium, color: theme.colors.text.hint)
|
|
@@ -94,7 +89,6 @@ public struct InputOTP: View {
|
|
|
94
89
|
.zIndex(10)
|
|
95
90
|
}
|
|
96
91
|
|
|
97
|
-
// Bordered container with cells.
|
|
98
92
|
cells
|
|
99
93
|
.frame(maxWidth: .infinity)
|
|
100
94
|
.frame(height: 56)
|
|
@@ -103,7 +97,6 @@ public struct InputOTP: View {
|
|
|
103
97
|
.stroke(borderColor, lineWidth: 1)
|
|
104
98
|
)
|
|
105
99
|
|
|
106
|
-
// Trailing clear button.
|
|
107
100
|
HStack {
|
|
108
101
|
Spacer()
|
|
109
102
|
SwiftUI.Button(action: clearText) {
|
package/ios/Layout/Item.swift
CHANGED
|
@@ -19,8 +19,7 @@ public struct ItemView<Content: View>: View {
|
|
|
19
19
|
// MARK: Public
|
|
20
20
|
|
|
21
21
|
public var body: some View {
|
|
22
|
-
//
|
|
23
|
-
// on top of each other — matches the React Item's flex-column content.
|
|
22
|
+
// VStack, not ZStack: children flow vertically like RN Item's flex-column content.
|
|
24
23
|
VStack(alignment: .leading, spacing: 0) { content() }
|
|
25
24
|
.frame(width: width, height: height, alignment: .topLeading)
|
|
26
25
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// Foldable spec for Popup and BottomSheet (Figma "Modal - Foldable Guideline"). Mirrors Compose
|
|
6
|
-
// `layout/ModalLayout.kt` and RN; keep the three in sync.
|
|
7
|
-
//
|
|
1
|
+
// Foldable spec for Popup and BottomSheet (Figma "Modal - Foldable Guideline"). Mirrors Compose
|
|
2
|
+
// `layout/ModalLayout.kt` and RN; keep the three in sync.
|
|
8
3
|
|
|
9
4
|
import SwiftUI
|
|
10
5
|
|
|
@@ -61,11 +56,9 @@ public extension ScreenLayout {
|
|
|
61
56
|
}
|
|
62
57
|
|
|
63
58
|
public extension ModalLayout {
|
|
64
|
-
///
|
|
65
|
-
/// (`ScreenLayout.current.modalLayout` covers the key window).
|
|
66
|
-
///
|
|
67
|
-
/// Points, window coordinates. `safeInsets` is the window safe area; on iPhone Duo it also carries the
|
|
68
|
-
/// control column. `hinge` is the vertical hinge of a half-folded iPhone Duo, nil while flat.
|
|
59
|
+
/// Popup / bottom sheet geometry from plain window metrics, for hosts without a kits screen
|
|
60
|
+
/// (`ScreenLayout.current.modalLayout` covers the key window). Points, window coordinates; on iPhone
|
|
61
|
+
/// Duo `safeInsets` also carries the control column and `hinge` is the half-fold hinge (nil while flat).
|
|
69
62
|
static func resolve(
|
|
70
63
|
width: CGFloat,
|
|
71
64
|
height: CGFloat,
|
|
@@ -79,8 +72,8 @@ public extension ModalLayout {
|
|
|
79
72
|
return ModalLayout(
|
|
80
73
|
isFoldable: false,
|
|
81
74
|
placement: placement,
|
|
82
|
-
popup: popupGeometry(placementWidth: width, maxHeight: nil, margin: Spacing.XL, radius: Radius.
|
|
83
|
-
sheet: SheetGeometry(width: nil, maxHeight: nil, minHeight: 0, margin: 0, radius: Radius.
|
|
75
|
+
popup: popupGeometry(placementWidth: width, maxHeight: nil, margin: Spacing.XL, radius: Radius.XL),
|
|
76
|
+
sheet: SheetGeometry(width: nil, maxHeight: nil, minHeight: 0, margin: 0, radius: Radius.XL),
|
|
84
77
|
scrimOpacity: ModalMetrics.phoneScrimOpacity
|
|
85
78
|
)
|
|
86
79
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// Port of momo-kits RN `useScreenLayout` (Layout/utils.ts) and `Application/device.ts`:
|
|
6
|
-
// window size, safe-area insets, content width, header geometry and the iPhone Duo side bar.
|
|
7
|
-
//
|
|
1
|
+
// Port of momo-kits RN `useScreenLayout` (Layout/utils.ts) and `Application/device.ts`:
|
|
2
|
+
// window size, safe-area insets, content width, header geometry and the iPhone Duo side bar.
|
|
8
3
|
|
|
9
4
|
import SwiftUI
|
|
10
5
|
import UIKit
|
package/ios/Loader/Loader.swift
CHANGED
|
@@ -7,12 +7,8 @@ public enum LoaderType {
|
|
|
7
7
|
case spinner
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
///
|
|
11
|
-
///
|
|
12
|
-
/// Mirrors Compose `Loader(type:, tintColor:, modifier:)` which delegates to
|
|
13
|
-
/// `DotLoader` / `SpinnerLoader`. Both variants render Lottie animations
|
|
14
|
-
/// (`files/dot_loading` and `files/lottie_circle_loader`) and optionally tint
|
|
15
|
-
/// the fill/stroke through a Lottie color value provider.
|
|
10
|
+
/// Compose `Loader`: the `dot_loading` / `lottie_circle_loader` Lottie animations, with the
|
|
11
|
+
/// fill/stroke optionally tinted through a Lottie color value provider.
|
|
16
12
|
public struct Loader: View {
|
|
17
13
|
private let type: LoaderType
|
|
18
14
|
private let tintColor: Color?
|
|
@@ -60,12 +56,7 @@ public struct SpinnerLoader: View {
|
|
|
60
56
|
}
|
|
61
57
|
}
|
|
62
58
|
|
|
63
|
-
///
|
|
64
|
-
///
|
|
65
|
-
/// Mirrors Compose `ProgressBar(percent:, color:, modifier:)`:
|
|
66
|
-
/// - `percent` clamped to 0...100, animated with a 200ms ease.
|
|
67
|
-
/// - track = theme background default (`0xFFF2F2F6`), fill = `color` or primary (pink_03).
|
|
68
|
-
/// - height 4, corner radius `Radius.XXS`, fills max width.
|
|
59
|
+
/// Compose `ProgressBar`: `percent` is clamped to 0...100 and animated with a 200ms ease.
|
|
69
60
|
public struct ProgressBar: View {
|
|
70
61
|
@Environment(\.appTheme) private var theme
|
|
71
62
|
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
// LottieView.swift
|
|
3
|
-
// MoMoPlatform
|
|
4
|
-
//
|
|
5
|
-
// Created by thanhdat on 16/01/2023.
|
|
6
1
|
// Copyright © 2023 Facebook. All rights reserved.
|
|
7
|
-
//
|
|
8
2
|
|
|
9
3
|
import SwiftUI
|
|
10
4
|
import Lottie
|
|
@@ -18,13 +12,11 @@ struct LottieView: UIViewRepresentable {
|
|
|
18
12
|
// Recolors every fill and stroke, as Compose's iOS LottieAnimation does; nil keeps the file's colors.
|
|
19
13
|
var tintColor: UIColor?
|
|
20
14
|
|
|
21
|
-
// Add static cache for animations
|
|
22
15
|
private static var animationCache = NSCache<NSString, LottieAnimation>()
|
|
23
16
|
|
|
24
17
|
func makeUIView(context: UIViewRepresentableContext<LottieView>) -> UIView {
|
|
25
18
|
let view = UIView(frame: .zero)
|
|
26
19
|
|
|
27
|
-
// Configure Lottie with optimized settings
|
|
28
20
|
let configuration = LottieConfiguration(
|
|
29
21
|
renderingEngine: .coreAnimation,
|
|
30
22
|
decodingStrategy: .dictionaryBased
|
|
@@ -33,7 +25,6 @@ struct LottieView: UIViewRepresentable {
|
|
|
33
25
|
let animationView = LottieAnimationView(configuration: configuration)
|
|
34
26
|
|
|
35
27
|
if let url = url {
|
|
36
|
-
// Use cached animation if available
|
|
37
28
|
if let cachedAnimation = Self.animationCache.object(forKey: url as NSString) {
|
|
38
29
|
animationView.animation = cachedAnimation
|
|
39
30
|
setupAnimationView(animationView, view)
|
|
@@ -48,7 +39,6 @@ struct LottieView: UIViewRepresentable {
|
|
|
48
39
|
}, animationCache: nil)
|
|
49
40
|
}
|
|
50
41
|
} else {
|
|
51
|
-
// Use cached animation if available
|
|
52
42
|
if let cachedAnimation = Self.animationCache.object(forKey: name as NSString) {
|
|
53
43
|
animationView.animation = cachedAnimation
|
|
54
44
|
setupAnimationView(animationView, view)
|
|
@@ -74,7 +64,6 @@ struct LottieView: UIViewRepresentable {
|
|
|
74
64
|
}
|
|
75
65
|
animationView.backgroundBehavior = loopMode == .loop ? .pauseAndRestore : .pause
|
|
76
66
|
|
|
77
|
-
// Optimize rendering
|
|
78
67
|
animationView.shouldRasterizeWhenIdle = true
|
|
79
68
|
|
|
80
69
|
animationView.translatesAutoresizingMaskIntoConstraints = false
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/BottomSheet.kt`.
|
|
6
|
-
// A sheet that slides up from the bottom over a dimmed scrim, with a drag
|
|
7
|
-
// handle, a header (title or custom), a divider and the content body.
|
|
8
|
-
// Dragging down past a threshold (or tapping the scrim) dismisses it.
|
|
9
|
-
// Driven by `Navigator.showBottomSheet`.
|
|
10
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/BottomSheet.kt`, driven by `Navigator.showBottomSheet`:
|
|
2
|
+
// drag handle, header and body over a dimmed scrim; a long drag down or a scrim tap dismisses it.
|
|
11
3
|
|
|
12
4
|
import SwiftUI
|
|
13
5
|
|
|
@@ -68,10 +60,8 @@ struct BottomSheetView<Content: View>: View {
|
|
|
68
60
|
@State private var didAppear = false
|
|
69
61
|
@State private var isClosing = false
|
|
70
62
|
@State private var keyboardHeight: CGFloat = 0
|
|
71
|
-
///
|
|
72
|
-
///
|
|
73
|
-
/// `content()`) to reconstruct every frame — mirrors the pattern already used in
|
|
74
|
-
/// `ios/PopupView/PopupView.swift` for smooth drag-to-dismiss.
|
|
63
|
+
/// Kept apart from `sheetOffset` so a touch-move invalidates only this value instead of
|
|
64
|
+
/// rebuilding `content()` every frame (as PopupView does for drag-to-dismiss).
|
|
75
65
|
@GestureState private var dragTranslation: CGFloat = 0
|
|
76
66
|
|
|
77
67
|
/// Mirrors Compose's `sheetCloseOffset` (100dp drag threshold to dismiss).
|
|
@@ -92,8 +82,7 @@ struct BottomSheetView<Content: View>: View {
|
|
|
92
82
|
|
|
93
83
|
private var maxHeight: CGFloat { modal.sheet.maxHeight ?? screenHeight - 90 }
|
|
94
84
|
private var bottomInset: CGFloat { useBottomInset ? safeAreaBottomInset() : 0 }
|
|
95
|
-
///
|
|
96
|
-
/// replaces (rather than adds to) the usual bottom-inset filler.
|
|
85
|
+
/// The keyboard already covers the home-indicator area, so it replaces the filler, not adds to it.
|
|
97
86
|
private var effectiveBottomInset: CGFloat { keyboardHeight > 0 ? keyboardHeight : bottomInset }
|
|
98
87
|
|
|
99
88
|
private var backgroundColor: Color {
|
|
@@ -102,9 +91,8 @@ struct BottomSheetView<Content: View>: View {
|
|
|
102
91
|
|
|
103
92
|
private var effectiveOffset: CGFloat { sheetOffset + dragTranslation }
|
|
104
93
|
|
|
105
|
-
/// Mirrors Compose's `dynamicAlpha`:
|
|
106
|
-
///
|
|
107
|
-
/// dragged down.
|
|
94
|
+
/// Mirrors Compose's `dynamicAlpha`: derived from the live offset (not animated), shrinking
|
|
95
|
+
/// toward 0 as the sheet is dragged down.
|
|
108
96
|
private var dynamicAlpha: CGFloat {
|
|
109
97
|
let denom = sheetHeight > 0 ? sheetHeight : screenHeight
|
|
110
98
|
guard denom > 0 else { return maxDynamicAlpha }
|
|
@@ -119,7 +107,7 @@ struct BottomSheetView<Content: View>: View {
|
|
|
119
107
|
|
|
120
108
|
var body: some View {
|
|
121
109
|
ZStack(alignment: .bottom) {
|
|
122
|
-
//
|
|
110
|
+
// full screen on foldables too
|
|
123
111
|
Colors.black20.opacity(totalScrimAlpha)
|
|
124
112
|
.contentShape(Rectangle())
|
|
125
113
|
.onTapGesture {
|
|
@@ -233,20 +221,12 @@ struct BottomSheetView<Content: View>: View {
|
|
|
233
221
|
// MARK: - Drag handling (mirrors Compose's detectDragGestures)
|
|
234
222
|
|
|
235
223
|
private var dragGesture: some Gesture {
|
|
236
|
-
// `.global
|
|
237
|
-
//
|
|
238
|
-
// every frame by this same gesture's output (`sheet.offset(y: effectiveOffset)`
|
|
239
|
-
// in `body`) — the local coordinate space chasing its own moving reference
|
|
240
|
-
// frame is a plausible source of a continuous drag-time jitter.
|
|
224
|
+
// `.global`: the handle moves with this gesture's own output, so the local space would
|
|
225
|
+
// chase a moving reference frame and jitter.
|
|
241
226
|
DragGesture(coordinateSpace: .global)
|
|
242
227
|
.onChanged { _ in
|
|
243
|
-
//
|
|
244
|
-
//
|
|
245
|
-
// open animation — or the keyboard-driven resize, which shifts this
|
|
246
|
-
// same bottom-anchored top edge — is still in flight doesn't fight a
|
|
247
|
-
// moving target. Without this, the live drag value chases an animated
|
|
248
|
-
// one, producing a couple of corrective jumps before it settles.
|
|
249
|
-
// A closing sheet keeps going down.
|
|
228
|
+
// Settle an in-flight open (or keyboard resize) at rest without animation, or the
|
|
229
|
+
// drag chases an animated value and jumps. A closing sheet keeps going down.
|
|
250
230
|
if sheetOffset != 0 && !isClosing {
|
|
251
231
|
sheetOffset = 0
|
|
252
232
|
}
|
|
@@ -257,9 +237,8 @@ struct BottomSheetView<Content: View>: View {
|
|
|
257
237
|
.onEnded { value in
|
|
258
238
|
guard !isClosing else { return }
|
|
259
239
|
let finalOffset = max(value.translation.height, 0)
|
|
260
|
-
//
|
|
261
|
-
//
|
|
262
|
-
// slide-out animation starts (mirrors PopupView's `lastDragPosition`).
|
|
240
|
+
// Persist before @GestureState resets to 0, or the sheet snaps back for a frame
|
|
241
|
+
// before close() slides it out (PopupView's `lastDragPosition`).
|
|
263
242
|
sheetOffset = finalOffset
|
|
264
243
|
if finalOffset > closeThreshold {
|
|
265
244
|
close()
|