@momo-kits/native-kits 0.169.6 → 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/build.gradle.kts +11 -0
- package/compose/build.gradle.kts +198 -0
- package/compose/compose.podspec +47 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +154 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +62 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1067 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +267 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +82 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +356 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +128 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +482 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +224 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +195 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +473 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +113 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +263 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +235 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +228 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +265 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +183 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +343 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +40 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +82 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +363 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +307 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +88 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +220 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +457 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +205 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +542 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +120 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +201 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +498 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +210 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +292 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +316 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +397 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +153 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +113 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +205 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +422 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +727 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +239 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +430 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +100 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +97 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +208 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +129 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +167 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +456 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +399 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +204 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +127 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +114 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +22 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +118 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +218 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +144 -0
- package/gradle/libs.versions.toml +67 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/gradle.properties +24 -0
- package/gradlew +252 -0
- package/gradlew.bat +94 -0
- 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/README.md +120 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
- package/package.json +1 -1
- package/settings.gradle.kts +64 -0
|
@@ -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()
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/bottomtab/BottomTab.kt`: tabbed screens, each in
|
|
6
|
-
// `StackScreen` chrome built from its own `Navigation`, over a `BottomTabBar` (or the iPhone Duo
|
|
7
|
-
// rail / floating bar). Switching tabs cross-fades + scales the content.
|
|
8
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/bottomtab/BottomTab.kt`: tabbed screens, each in
|
|
2
|
+
// `StackScreen` chrome built from its own `Navigation`, over a `BottomTabBar` (or the iPhone Duo
|
|
3
|
+
// rail / floating bar). Switching tabs cross-fades + scales the content.
|
|
9
4
|
|
|
10
5
|
import SwiftUI
|
|
11
6
|
import UIKit
|
|
@@ -30,10 +25,9 @@ public struct BottomTab: View {
|
|
|
30
25
|
@State private var expandedBar: DuoBar?
|
|
31
26
|
@State private var openedBar: DuoBar?
|
|
32
27
|
|
|
33
|
-
/// `compressionBehavior`: on iPhone Duo, when the side bar can't hold
|
|
34
|
-
///
|
|
35
|
-
///
|
|
36
|
-
/// `backToInitialTab`: back off another tab returns to the initial one before leaving the screen.
|
|
28
|
+
/// `compressionBehavior`: on iPhone Duo, the bar that starts compressed when the side bar can't hold
|
|
29
|
+
/// both (tapping it swaps them). `onTabPress` gets every press with the switch to run, e.g. after a
|
|
30
|
+
/// login gate. `backToInitialTab`: back off another tab returns to the initial one first.
|
|
37
31
|
public init(
|
|
38
32
|
items: [BottomTabItem],
|
|
39
33
|
floatingButton: BottomTabFloatingButton? = nil,
|
|
@@ -86,7 +80,6 @@ public struct BottomTab: View {
|
|
|
86
80
|
public var body: some View {
|
|
87
81
|
let compression = compression
|
|
88
82
|
ZStack(alignment: .bottom) {
|
|
89
|
-
// Tab content area, inset above the bar.
|
|
90
83
|
TabHost(selectedIndex: selectedIndex, count: items.count) { index in AnyView(tabScreen(for: index)) }
|
|
91
84
|
// each tab hosts itself, so it needs the window's safe area to draw its header under the status bar
|
|
92
85
|
.ignoresSafeArea(.container, edges: [.top, .horizontal])
|
|
@@ -183,10 +176,9 @@ private struct TabScreenHost: View {
|
|
|
183
176
|
|
|
184
177
|
// MARK: - Tab host
|
|
185
178
|
|
|
186
|
-
/// Compose's tab NavHost with `saveState` / `restoreState
|
|
187
|
-
///
|
|
188
|
-
///
|
|
189
|
-
/// destination or a UITabBarController tab. Same scheme as `StackController`.
|
|
179
|
+
/// Compose's tab NavHost with `saveState` / `restoreState`: a tab keeps its UIHostingController from
|
|
180
|
+
/// first selection, so state and scroll survive a switch; while hidden it is out of the window and
|
|
181
|
+
/// gets onDisappear / onAppear (re-running screen tracking). Same scheme as `StackController`.
|
|
190
182
|
private struct TabHost: UIViewControllerRepresentable {
|
|
191
183
|
let selectedIndex: Int
|
|
192
184
|
let count: Int
|
|
@@ -287,7 +279,7 @@ private final class TabController: UIViewController {
|
|
|
287
279
|
AnyView(content(index).environment(\.self, environment))
|
|
288
280
|
}
|
|
289
281
|
|
|
290
|
-
/// Bounds and center, a sliding tab carries a transform
|
|
282
|
+
/// Bounds and center, not frame: a sliding tab carries a transform.
|
|
291
283
|
private func place(_ subview: UIView) {
|
|
292
284
|
subview.bounds = view.bounds
|
|
293
285
|
subview.center = CGPoint(x: view.bounds.midX, y: view.bounds.midY)
|
|
@@ -318,7 +310,6 @@ private final class TabController: UIViewController {
|
|
|
318
310
|
}
|
|
319
311
|
}
|
|
320
312
|
|
|
321
|
-
/// Bottom safe-area inset (home indicator).
|
|
322
313
|
private func safeAreaBottomInset() -> CGFloat {
|
|
323
314
|
UIApplication.shared.connectedScenes
|
|
324
315
|
.compactMap { ($0 as? UIWindowScene)?.keyWindow?.safeAreaInsets.bottom }
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `navigation/bottomtab/BottomTabBar.kt`.
|
|
6
|
-
// Horizontal navigation bar (Figma "Specs Navigation", DS-984): floating container, items split
|
|
7
|
-
// evenly with a tonal active indicator, badges/dots, and the Special type's center action in a notch.
|
|
8
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `navigation/bottomtab/BottomTabBar.kt`.
|
|
2
|
+
// Horizontal navigation bar (Figma "Specs Navigation", DS-984): floating container, items split
|
|
3
|
+
// evenly with a tonal active indicator, badges/dots, and the Special type's center action in a notch.
|
|
9
4
|
|
|
10
5
|
import SwiftUI
|
|
11
6
|
|
|
@@ -212,8 +207,7 @@ struct ActiveIndicator: View {
|
|
|
212
207
|
/// and the notch stay aligned.
|
|
213
208
|
private let tabLabelMaxScale: CGFloat = 1.2
|
|
214
209
|
|
|
215
|
-
///
|
|
216
|
-
/// host/OS font scale but stops growing past 1.2× so it fits the fixed bar geometry.
|
|
210
|
+
/// Compose's `CappedFontScale`: caps the label scale at `tabLabelMaxScale` when enabled.
|
|
217
211
|
struct CappedFontScale: ViewModifier {
|
|
218
212
|
let enabled: Bool
|
|
219
213
|
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// SwiftUI mirror of Compose's `CurvedContainer.kt`: the navigation bar container shape, a rounded
|
|
6
|
-
// rectangle with a notch cut into the top edge around the center action, and its floating shadow.
|
|
7
|
-
//
|
|
1
|
+
// SwiftUI mirror of Compose's `CurvedContainer.kt`: the navigation bar container shape, a rounded
|
|
2
|
+
// rectangle with a notch cut into the top edge around the center action, and its floating shadow.
|
|
8
3
|
|
|
9
4
|
import SwiftUI
|
|
10
5
|
|
|
@@ -45,10 +40,9 @@ struct NotchedBarShape: Shape {
|
|
|
45
40
|
}
|
|
46
41
|
}
|
|
47
42
|
|
|
48
|
-
/// Navigation bar container: translucent
|
|
49
|
-
///
|
|
50
|
-
///
|
|
51
|
-
/// keeps the first from being re-cast). iOS could back this with a real material later; see Compose note.
|
|
43
|
+
/// Navigation bar container: one translucent surface fill (Figma .Nav/Background) with the floating
|
|
44
|
+
/// shadow following the shape. Opaque shadow layers under it would make the glass solid, so both
|
|
45
|
+
/// shadows go over the fill (compositingGroup keeps the first from being re-cast).
|
|
52
46
|
struct TabBarContainer<S: Shape>: ViewModifier {
|
|
53
47
|
let shape: S
|
|
54
48
|
|