@momo-kits/native-kits 0.168.1-beta.25 → 0.168.1-beta.26-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/CLAUDE.md +1 -2
- package/build.gradle.kts +11 -0
- package/compose/build.gradle.kts +198 -0
- package/compose/build.gradle.kts.backup +198 -0
- package/compose/compose.podspec +47 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +20 -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 +153 -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 +1071 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -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 +81 -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 +357 -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 +542 -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 +231 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +189 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +478 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +114 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +265 -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 +223 -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 +185 -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 +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +84 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +370 -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 +308 -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 +90 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +330 -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 +473 -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 +207 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +92 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +560 -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 +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +207 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +501 -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 +236 -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 +17 -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 +287 -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/ScreenLayout.kt +321 -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 +502 -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 +148 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +116 -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 +732 -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 +228 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +217 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -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 +377 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +169 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +455 -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 +192 -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 +91 -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 +74 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +20 -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/ReservedRegions.ios.kt +138 -0
- package/gradle/libs.versions.toml +69 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/gradle.properties +26 -0
- package/gradlew +252 -0
- package/gradlew.bat +94 -0
- package/ios/Navigation/BottomSheet.swift +3 -2
- package/ios/Navigation/BottomTab/BottomTab.swift +3 -16
- package/ios/Navigation/BottomTab/BottomTabBar.swift +29 -47
- package/ios/Navigation/BottomTab/DuoTabBar.swift +69 -156
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/README.md +120 -0
- package/package.json +1 -1
- package/settings.gradle.kts +64 -0
- package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +0 -364
|
@@ -67,7 +67,6 @@ struct BottomTabBar: View {
|
|
|
67
67
|
let floatingButton: BottomTabFloatingButton?
|
|
68
68
|
let selectedIndex: Int
|
|
69
69
|
let onTabSelected: (Int) -> Void
|
|
70
|
-
var onTabLongPress: ((Int) -> Void)?
|
|
71
70
|
|
|
72
71
|
@Environment(\.screenLayout) private var layout
|
|
73
72
|
@Environment(\.appTheme) private var theme
|
|
@@ -134,10 +133,7 @@ struct BottomTabBar: View {
|
|
|
134
133
|
TabBarItem(
|
|
135
134
|
item: items[index],
|
|
136
135
|
selected: index == selectedIndex,
|
|
137
|
-
|
|
138
|
-
badgeMaxWidth: tabWidth / 2 - Spacing.XXS * 2,
|
|
139
|
-
onClick: { onTabSelected(index) },
|
|
140
|
-
onLongClick: onTabLongPress.map { callback in { callback(index) } }
|
|
136
|
+
onClick: { onTabSelected(index) }
|
|
141
137
|
)
|
|
142
138
|
.frame(maxWidth: .infinity)
|
|
143
139
|
}
|
|
@@ -149,9 +145,7 @@ struct BottomTabBar: View {
|
|
|
149
145
|
private struct TabBarItem: View {
|
|
150
146
|
let item: BottomTabItem
|
|
151
147
|
let selected: Bool
|
|
152
|
-
let badgeMaxWidth: CGFloat
|
|
153
148
|
let onClick: () -> Void
|
|
154
|
-
let onLongClick: (() -> Void)?
|
|
155
149
|
|
|
156
150
|
@Environment(\.appTheme) private var theme
|
|
157
151
|
|
|
@@ -165,52 +159,40 @@ private struct TabBarItem: View {
|
|
|
165
159
|
}
|
|
166
160
|
|
|
167
161
|
var body: some View {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
162
|
+
ZStack(alignment: .topTrailing) {
|
|
163
|
+
VStack(spacing: 0) {
|
|
164
|
+
Icon(source: item.icon, size: 28, color: tintColor)
|
|
165
|
+
.padding(Spacing.XS)
|
|
166
|
+
MomoText(
|
|
167
|
+
item.label,
|
|
168
|
+
typography: selected ? .labelXsMedium : .descriptionXsRegular,
|
|
169
|
+
color: tintColor,
|
|
170
|
+
textAlign: .center,
|
|
171
|
+
maxLines: 1
|
|
172
|
+
)
|
|
173
|
+
.truncationMode(.tail)
|
|
174
|
+
}
|
|
175
|
+
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
176
|
+
.padding(.horizontal, Spacing.S)
|
|
177
|
+
.padding(.vertical, Spacing.S)
|
|
178
|
+
|
|
179
|
+
if let badgeLabel {
|
|
180
|
+
if badgeLabel.isEmpty {
|
|
181
|
+
BadgeDot(size: .small)
|
|
182
|
+
.offset(x: -Spacing.S, y: Spacing.XS)
|
|
183
|
+
} else {
|
|
184
|
+
Badge(label: badgeLabel)
|
|
185
|
+
.offset(x: -Spacing.XS, y: 0)
|
|
182
186
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
color: tintColor,
|
|
188
|
-
textAlign: .center,
|
|
189
|
-
maxLines: 1
|
|
190
|
-
)
|
|
191
|
-
.truncationMode(.tail)
|
|
187
|
+
} else if item.showDot {
|
|
188
|
+
BadgeDot(size: .small)
|
|
189
|
+
.offset(x: -Spacing.S, y: Spacing.XS)
|
|
190
|
+
}
|
|
192
191
|
}
|
|
193
192
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
194
|
-
.padding(.horizontal, Spacing.S)
|
|
195
|
-
.padding(.vertical, Spacing.S)
|
|
196
|
-
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
197
193
|
.padding(.horizontal, Spacing.XXS)
|
|
198
194
|
.contentShape(Rectangle())
|
|
199
195
|
.onTapGesture { onClick() }
|
|
200
|
-
.modifier(TabLongPress(action: onLongClick))
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/// Only attached with a callback, so a held tab without one still selects on release.
|
|
205
|
-
private struct TabLongPress: ViewModifier {
|
|
206
|
-
let action: (() -> Void)?
|
|
207
|
-
|
|
208
|
-
func body(content: Content) -> some View {
|
|
209
|
-
if let action {
|
|
210
|
-
content.onLongPressGesture(minimumDuration: 0.5, perform: action)
|
|
211
|
-
} else {
|
|
212
|
-
content
|
|
213
|
-
}
|
|
214
196
|
}
|
|
215
197
|
}
|
|
216
198
|
|
|
@@ -20,11 +20,12 @@ private let floatingHeight = DuoMetrics.floatingTabBarHeight
|
|
|
20
20
|
private let floatingPadding = Spacing.XS
|
|
21
21
|
// the system bar sizes its pill to the tabs instead of stretching it across the display
|
|
22
22
|
private let floatingItemWidth: CGFloat = 80
|
|
23
|
-
//
|
|
24
|
-
private let
|
|
25
|
-
private let
|
|
23
|
+
// while pressed the selection bubble grows into a lens past the pill's edges
|
|
24
|
+
private let lensScaleX: CGFloat = 1.2
|
|
25
|
+
private let lensScaleY: CGFloat = 1.3
|
|
26
26
|
// Figma Home-2026 tab bar "Selection": brand pink at 8%
|
|
27
27
|
private let selectionTintOpacity: Double = 0x14 / 255
|
|
28
|
+
private let tabSpring = Animation.interpolatingSpring(mass: 0.8, stiffness: 220, damping: 18)
|
|
28
29
|
|
|
29
30
|
/// Room tab screens leave for the Duo tab bar, provided by BottomTab to its tab StackScreens.
|
|
30
31
|
struct DuoTabBarInsets: Equatable {
|
|
@@ -90,20 +91,16 @@ struct DuoTabBar: View {
|
|
|
90
91
|
let selectedIndex: Int
|
|
91
92
|
let onTabSelected: (Int) -> Void
|
|
92
93
|
var compression = DuoBarCompression()
|
|
93
|
-
var onTabLongPress: ((Int) -> Void)?
|
|
94
|
-
/// A tick per tab the lens enters while dragged.
|
|
95
|
-
var onTick: () -> Void = {}
|
|
96
94
|
|
|
97
95
|
@Environment(\.screenLayout) private var layout
|
|
98
96
|
|
|
99
97
|
var body: some View {
|
|
100
98
|
if let sideBar = layout.sideBar {
|
|
101
99
|
DuoRailTabBar(sideBar: sideBar, items: items, floatingButton: floatingButton,
|
|
102
|
-
selectedIndex: selectedIndex, onTabSelected: onTabSelected, compression: compression
|
|
103
|
-
onTabLongPress: onTabLongPress, onTick: onTick)
|
|
100
|
+
selectedIndex: selectedIndex, onTabSelected: onTabSelected, compression: compression)
|
|
104
101
|
} else {
|
|
105
|
-
DuoFloatingTabBar(items: items, floatingButton: floatingButton,
|
|
106
|
-
|
|
102
|
+
DuoFloatingTabBar(items: items, floatingButton: floatingButton,
|
|
103
|
+
selectedIndex: selectedIndex, onTabSelected: onTabSelected)
|
|
107
104
|
}
|
|
108
105
|
}
|
|
109
106
|
}
|
|
@@ -118,11 +115,8 @@ private struct DuoRailTabBar: View {
|
|
|
118
115
|
let selectedIndex: Int
|
|
119
116
|
let onTabSelected: (Int) -> Void
|
|
120
117
|
let compression: DuoBarCompression
|
|
121
|
-
let onTabLongPress: ((Int) -> Void)?
|
|
122
|
-
let onTick: () -> Void
|
|
123
118
|
|
|
124
|
-
@
|
|
125
|
-
@StateObject private var selection = DuoLiquidSelection()
|
|
119
|
+
@State private var pressedIndex: Int?
|
|
126
120
|
|
|
127
121
|
private var isRight: Bool { sideBar.edge == .right }
|
|
128
122
|
|
|
@@ -130,11 +124,11 @@ private struct DuoRailTabBar: View {
|
|
|
130
124
|
VStack(spacing: Spacing.M) {
|
|
131
125
|
if compression.tabBarCompressed, items.indices.contains(selectedIndex) {
|
|
132
126
|
SwiftUI.Button(action: compression.expandTabBar) {
|
|
133
|
-
DuoTabIcon(item: items[selectedIndex], selected: true
|
|
127
|
+
DuoTabIcon(item: items[selectedIndex], selected: true)
|
|
134
128
|
.frame(width: itemSize, height: itemSize)
|
|
135
129
|
.contentShape(Circle())
|
|
136
130
|
}
|
|
137
|
-
.buttonStyle(
|
|
131
|
+
.buttonStyle(.plain)
|
|
138
132
|
.modifier(DuoBarMaterial(shape: Circle()))
|
|
139
133
|
.accessibilityLabel(items[selectedIndex].label)
|
|
140
134
|
.accessibilityIdentifier("bottom_tab_bar")
|
|
@@ -153,51 +147,35 @@ private struct DuoRailTabBar: View {
|
|
|
153
147
|
.ignoresSafeArea()
|
|
154
148
|
}
|
|
155
149
|
|
|
156
|
-
|
|
157
|
-
onTabSelected(index)
|
|
158
|
-
compression.onTabSelected()
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/// Column of icon-only tab items with the sliding selection lens.
|
|
150
|
+
/// Column of icon-only tab items with the sliding selection bubble.
|
|
162
151
|
private var rail: some View {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return ZStack(alignment: .top) {
|
|
166
|
-
DuoSelectionMaterial()
|
|
152
|
+
ZStack(alignment: .top) {
|
|
153
|
+
DuoSelectionMaterial(lens: pressedIndex != nil)
|
|
167
154
|
.frame(width: railBubbleWidth, height: railBubbleHeight)
|
|
168
|
-
.
|
|
169
|
-
|
|
155
|
+
.offset(y: railPadding - (railBubbleHeight - itemSize) / 2
|
|
156
|
+
+ CGFloat(pressedIndex ?? selectedIndex) * (itemSize + railGap))
|
|
157
|
+
.animation(tabSpring, value: selectedIndex)
|
|
158
|
+
.animation(tabSpring, value: pressedIndex)
|
|
170
159
|
|
|
171
160
|
VStack(spacing: railGap) {
|
|
172
161
|
ForEach(items.indices, id: \.self) { index in
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
162
|
+
SwiftUI.Button {
|
|
163
|
+
onTabSelected(index)
|
|
164
|
+
compression.onTabSelected()
|
|
165
|
+
} label: {
|
|
166
|
+
DuoTabIcon(item: items[index], selected: index == selectedIndex)
|
|
176
167
|
.frame(width: itemSize, height: itemSize)
|
|
168
|
+
.contentShape(Rectangle())
|
|
177
169
|
}
|
|
170
|
+
.buttonStyle(DuoLensPressStyle(index: index, pressedIndex: $pressedIndex))
|
|
171
|
+
.accessibilityLabel(items[index].label)
|
|
178
172
|
}
|
|
179
173
|
}
|
|
180
174
|
.padding(.vertical, railPadding)
|
|
181
175
|
}
|
|
182
176
|
.frame(width: itemSize)
|
|
183
|
-
.modifier(DuoLiquidInput(selection: selection, space: "DuoRail"))
|
|
184
177
|
.modifier(DuoBarMaterial(shape: Capsule()))
|
|
185
|
-
.scaleEffect(selection.barScale)
|
|
186
178
|
.accessibilityIdentifier("bottom_tab_bar")
|
|
187
|
-
.onAppear { selection.sync(index: selectedIndex) }
|
|
188
|
-
.onChange(of: selectedIndex) { selection.sync(index: $0) }
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
private func configured() -> DuoLiquidSelection {
|
|
192
|
-
selection.axis = .y
|
|
193
|
-
selection.count = items.count
|
|
194
|
-
selection.pitch = itemSize + railGap
|
|
195
|
-
selection.firstCenter = railPadding + itemSize / 2
|
|
196
|
-
selection.reduceMotion = reduceMotion
|
|
197
|
-
selection.onSelect = select
|
|
198
|
-
selection.onLongPress = onTabLongPress
|
|
199
|
-
selection.onTick = onTick
|
|
200
|
-
return selection
|
|
201
179
|
}
|
|
202
180
|
}
|
|
203
181
|
|
|
@@ -207,13 +185,10 @@ private struct DuoFloatingTabBar: View {
|
|
|
207
185
|
let floatingButton: BottomTabFloatingButton?
|
|
208
186
|
let selectedIndex: Int
|
|
209
187
|
let onTabSelected: (Int) -> Void
|
|
210
|
-
let onTabLongPress: ((Int) -> Void)?
|
|
211
|
-
let onTick: () -> Void
|
|
212
188
|
|
|
213
189
|
@Environment(\.screenLayout) private var layout
|
|
214
190
|
@Environment(\.appTheme) private var theme
|
|
215
|
-
@
|
|
216
|
-
@StateObject private var selection = DuoLiquidSelection()
|
|
191
|
+
@State private var pressedIndex: Int?
|
|
217
192
|
|
|
218
193
|
private var barWidth: CGFloat {
|
|
219
194
|
let margins = layout.insets.leading + layout.insets.trailing + 2 * DuoMetrics.floatingTabBarMargin
|
|
@@ -238,139 +213,82 @@ private struct DuoFloatingTabBar: View {
|
|
|
238
213
|
}
|
|
239
214
|
|
|
240
215
|
private var bar: some View {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return ZStack(alignment: .leading) {
|
|
244
|
-
DuoSelectionMaterial()
|
|
216
|
+
ZStack(alignment: .leading) {
|
|
217
|
+
DuoSelectionMaterial(lens: pressedIndex != nil)
|
|
245
218
|
.frame(width: cellWidth)
|
|
246
|
-
.
|
|
247
|
-
.
|
|
219
|
+
.offset(x: CGFloat(pressedIndex ?? selectedIndex) * cellWidth)
|
|
220
|
+
.animation(tabSpring, value: selectedIndex)
|
|
221
|
+
.animation(tabSpring, value: pressedIndex)
|
|
248
222
|
|
|
249
223
|
HStack(spacing: 0) {
|
|
250
224
|
ForEach(items.indices, id: \.self) { index in
|
|
251
|
-
|
|
252
|
-
selected: index == selectedIndex, onSelect: { onTabSelected(index) }) { active in
|
|
253
|
-
tabCell(index, active: active)
|
|
254
|
-
}
|
|
225
|
+
tabCell(index)
|
|
255
226
|
}
|
|
256
227
|
}
|
|
257
228
|
}
|
|
258
|
-
.modifier(DuoLiquidInput(selection: selection, space: "DuoFloatingBar"))
|
|
259
229
|
.padding(floatingPadding)
|
|
260
230
|
.frame(width: barWidth, height: floatingHeight)
|
|
261
231
|
.modifier(DuoBarMaterial(shape: Capsule()))
|
|
262
|
-
.scaleEffect(selection.barScale)
|
|
263
232
|
.accessibilityIdentifier("bottom_tab_bar")
|
|
264
|
-
.onAppear { selection.sync(index: selectedIndex) }
|
|
265
|
-
.onChange(of: selectedIndex) { selection.sync(index: $0) }
|
|
266
|
-
.onChange(of: cellWidth) { _ in selection.sync(index: selectedIndex) }
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
private func configured() -> DuoLiquidSelection {
|
|
270
|
-
selection.axis = .x
|
|
271
|
-
selection.count = items.count
|
|
272
|
-
selection.pitch = cellWidth
|
|
273
|
-
selection.firstCenter = cellWidth / 2
|
|
274
|
-
selection.reduceMotion = reduceMotion
|
|
275
|
-
selection.onSelect = onTabSelected
|
|
276
|
-
selection.onLongPress = onTabLongPress
|
|
277
|
-
selection.onTick = onTick
|
|
278
|
-
return selection
|
|
279
233
|
}
|
|
280
234
|
|
|
281
|
-
private func tabCell(_ index: Int
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
items[index]
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
/// One gesture over the whole bar drives the selection; SwiftUI drops `onEnded` when the system
|
|
300
|
-
/// cancels a touch, so the reset of the gesture state ends it instead.
|
|
301
|
-
private struct DuoLiquidInput: ViewModifier {
|
|
302
|
-
let selection: DuoLiquidSelection
|
|
303
|
-
let space: String
|
|
304
|
-
|
|
305
|
-
@GestureState private var touching = false
|
|
306
|
-
|
|
307
|
-
func body(content: Content) -> some View {
|
|
308
|
-
content
|
|
309
|
-
.coordinateSpace(name: space)
|
|
235
|
+
private func tabCell(_ index: Int) -> some View {
|
|
236
|
+
let selected = index == selectedIndex
|
|
237
|
+
return SwiftUI.Button { onTabSelected(index) } label: {
|
|
238
|
+
VStack(spacing: Spacing.XXS) {
|
|
239
|
+
DuoTabIcon(item: items[index], selected: selected)
|
|
240
|
+
MomoText(
|
|
241
|
+
items[index].label,
|
|
242
|
+
typography: .labelXsMedium,
|
|
243
|
+
color: selected ? theme.colors.primary : theme.colors.text.hint,
|
|
244
|
+
textAlign: .center,
|
|
245
|
+
maxLines: 1
|
|
246
|
+
)
|
|
247
|
+
// like the system tab bar the label keeps its design size; a constant snapshot, nothing to observe
|
|
248
|
+
.environment(\.momoFontScale, FontScale(userScaleRate: 1, useOSScaleRate: false))
|
|
249
|
+
}
|
|
250
|
+
.frame(width: cellWidth)
|
|
251
|
+
.frame(maxHeight: .infinity)
|
|
310
252
|
.contentShape(Rectangle())
|
|
311
|
-
.gesture(
|
|
312
|
-
DragGesture(minimumDistance: 0, coordinateSpace: .named(space))
|
|
313
|
-
.updating($touching) { _, state, _ in state = true }
|
|
314
|
-
.onChanged { selection.touchChanged(location: $0.location, translation: $0.translation, time: $0.time) }
|
|
315
|
-
.onEnded { selection.touchEnded(location: $0.location) }
|
|
316
|
-
)
|
|
317
|
-
.onChange(of: touching) { if !$0 { selection.touchCancelled() } }
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/// A tab drawn twice, inactive with the active layer over it fading in as the lens passes;
|
|
322
|
-
/// the tab the lens lands on pops.
|
|
323
|
-
private struct DuoLiquidTab<Content: View>: View {
|
|
324
|
-
@ObservedObject var selection: DuoLiquidSelection
|
|
325
|
-
let index: Int
|
|
326
|
-
let label: String
|
|
327
|
-
let selected: Bool
|
|
328
|
-
let onSelect: () -> Void
|
|
329
|
-
@ViewBuilder let content: (_ active: Bool) -> Content
|
|
330
|
-
|
|
331
|
-
var body: some View {
|
|
332
|
-
ZStack {
|
|
333
|
-
content(false)
|
|
334
|
-
content(true).opacity(selection.activeOpacity(index))
|
|
335
253
|
}
|
|
336
|
-
.
|
|
337
|
-
.
|
|
338
|
-
.accessibilityLabel(label)
|
|
339
|
-
.accessibilityAddTraits(selected ? [.isButton, .isSelected] : .isButton)
|
|
340
|
-
.accessibilityAction { onSelect() }
|
|
254
|
+
.buttonStyle(DuoLensPressStyle(index: index, pressedIndex: $pressedIndex))
|
|
255
|
+
.accessibilityLabel(items[index].label)
|
|
341
256
|
}
|
|
342
257
|
}
|
|
343
258
|
|
|
344
|
-
/// Pink tinted capsule under the selected tab.
|
|
259
|
+
/// Pink tinted capsule under the selected tab; while pressed it grows into a lens (80x54 to about 96x70).
|
|
345
260
|
private struct DuoSelectionMaterial: View {
|
|
261
|
+
let lens: Bool
|
|
262
|
+
|
|
346
263
|
@Environment(\.appTheme) private var theme
|
|
347
264
|
|
|
348
265
|
var body: some View {
|
|
349
266
|
Capsule()
|
|
350
267
|
.fill(theme.colors.primary.opacity(selectionTintOpacity))
|
|
268
|
+
.scaleEffect(x: lens ? lensScaleX : 1, y: lens ? lensScaleY : 1)
|
|
351
269
|
.allowsHitTesting(false)
|
|
352
270
|
}
|
|
353
271
|
}
|
|
354
272
|
|
|
355
|
-
///
|
|
356
|
-
private struct
|
|
357
|
-
|
|
273
|
+
/// Tracks the finger so the selection lens jumps to the pressed tab before it is selected.
|
|
274
|
+
private struct DuoLensPressStyle: ButtonStyle {
|
|
275
|
+
let index: Int
|
|
276
|
+
@Binding var pressedIndex: Int?
|
|
358
277
|
|
|
359
278
|
func makeBody(configuration: Configuration) -> some View {
|
|
360
|
-
configuration.label
|
|
361
|
-
|
|
362
|
-
|
|
279
|
+
configuration.label.onChange(of: configuration.isPressed) { pressed in
|
|
280
|
+
if pressed {
|
|
281
|
+
pressedIndex = index
|
|
282
|
+
} else if pressedIndex == index {
|
|
283
|
+
pressedIndex = nil
|
|
284
|
+
}
|
|
285
|
+
}
|
|
363
286
|
}
|
|
364
287
|
}
|
|
365
288
|
|
|
366
|
-
/// Floating bar: the badge starts at the icon's center and grows toward the cell's end edge.
|
|
367
|
-
/// Rail: it ends just inside the capsule and grows back over the icon (RN TabBarIcon `end: -3`).
|
|
368
|
-
/// Capped at `badgeMaxWidth` (an overlay alone would only offer it the icon's 28pt).
|
|
369
289
|
private struct DuoTabIcon: View {
|
|
370
290
|
let item: BottomTabItem
|
|
371
291
|
let selected: Bool
|
|
372
|
-
let badgeMaxWidth: CGFloat
|
|
373
|
-
var inRail = false
|
|
374
292
|
|
|
375
293
|
@Environment(\.appTheme) private var theme
|
|
376
294
|
|
|
@@ -382,15 +300,10 @@ private struct DuoTabIcon: View {
|
|
|
382
300
|
|
|
383
301
|
var body: some View {
|
|
384
302
|
Icon(source: item.icon, size: iconSize, color: selected ? theme.colors.primary : theme.colors.text.hint)
|
|
385
|
-
.overlay(alignment: inRail ? .topTrailing : .topLeading) {
|
|
386
|
-
if let badgeLabel, !badgeLabel.isEmpty {
|
|
387
|
-
Badge(label: badgeLabel)
|
|
388
|
-
.frame(width: max(badgeMaxWidth, 0), alignment: inRail ? .trailing : .leading)
|
|
389
|
-
.offset(x: inRail ? railBadgeEndOffset : iconSize / 2, y: -Spacing.XS)
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
303
|
.overlay(alignment: .topTrailing) {
|
|
393
|
-
if badgeLabel
|
|
304
|
+
if let badgeLabel, !badgeLabel.isEmpty {
|
|
305
|
+
Badge(label: badgeLabel).offset(x: Spacing.S, y: -Spacing.XS)
|
|
306
|
+
} else if badgeLabel != nil || item.showDot {
|
|
394
307
|
BadgeDot(size: .small)
|
|
395
308
|
}
|
|
396
309
|
}
|
package/ios/native-kits.podspec
CHANGED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# MoMoUIKitsDemo
|
|
2
|
+
|
|
3
|
+
SwiftUI demo browser for `MoMoUIKits`.
|
|
4
|
+
|
|
5
|
+
The package can optionally host a Compose UIKits screen by receiving a
|
|
6
|
+
`UIViewController` factory from the host app. It does not import the KMP
|
|
7
|
+
`shared` module directly.
|
|
8
|
+
|
|
9
|
+
SwiftUI mode reuses the full demo screen set from
|
|
10
|
+
`sample/iosApp/iosApp/Demo`, including the sample `HomeView` registry and demo
|
|
11
|
+
screens for all currently available components.
|
|
12
|
+
|
|
13
|
+
## CocoaPods
|
|
14
|
+
|
|
15
|
+
In the host app `Podfile`, include both local pods:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
pod 'MoMoUIKits', :path => '../momo-native-kits/ios/native-kits.podspec'
|
|
19
|
+
pod 'MoMoUIKitsDemo', :path => '../momo-native-kits/ios-demo'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Adjust the relative paths to match the host app checkout.
|
|
23
|
+
|
|
24
|
+
## Host App Usage
|
|
25
|
+
|
|
26
|
+
```swift
|
|
27
|
+
import MoMoUIKitsDemo
|
|
28
|
+
import shared
|
|
29
|
+
|
|
30
|
+
class UIKitsViewController: BaseComposeAppViewController {
|
|
31
|
+
override func getViewController() -> UIViewController? {
|
|
32
|
+
let params = self.application.data as? [String: Any]
|
|
33
|
+
|
|
34
|
+
return MoMoUIKitsDemoViewControllerFactory.make(
|
|
35
|
+
context: MoMoUIKitsDemoContext(
|
|
36
|
+
appId: params?["appId"] as? String ?? "",
|
|
37
|
+
appCode: params?["code"] as? String ?? "",
|
|
38
|
+
appName: params?["name"] as? String,
|
|
39
|
+
appIcon: params?["icon"] as? String ?? ""
|
|
40
|
+
),
|
|
41
|
+
composeViewController: {
|
|
42
|
+
UIKitsScreenComposeViewControllerKt.UIKitsScreenComposeViewController(
|
|
43
|
+
params: params
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
override func viewDidDisappear(_ animated: Bool) {
|
|
50
|
+
super.viewDidDisappear(animated)
|
|
51
|
+
composeViewController = nil
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
If the host does not pass `composeViewController`, the demo opens directly in
|
|
57
|
+
SwiftUI mode.
|
|
58
|
+
|
|
59
|
+
## Included SwiftUI Demos
|
|
60
|
+
|
|
61
|
+
The pod includes the sample demo screens for:
|
|
62
|
+
|
|
63
|
+
- Animated Header
|
|
64
|
+
- Avatar
|
|
65
|
+
- Badge
|
|
66
|
+
- Baseline View
|
|
67
|
+
- Bottom Tab
|
|
68
|
+
- Button
|
|
69
|
+
- Carousel
|
|
70
|
+
- Checkbox
|
|
71
|
+
- Chip
|
|
72
|
+
- Collapse
|
|
73
|
+
- DateTimePicker
|
|
74
|
+
- Divider
|
|
75
|
+
- Header User
|
|
76
|
+
- Icon Button
|
|
77
|
+
- Image
|
|
78
|
+
- Information
|
|
79
|
+
- Input
|
|
80
|
+
- Input DropDown
|
|
81
|
+
- Input Money
|
|
82
|
+
- Input OTP
|
|
83
|
+
- Input Phone Number
|
|
84
|
+
- Input Search
|
|
85
|
+
- Input TextArea
|
|
86
|
+
- Loader
|
|
87
|
+
- Navigation
|
|
88
|
+
- Pagination
|
|
89
|
+
- Popup Display
|
|
90
|
+
- Popup Notify
|
|
91
|
+
- Popup Promotion
|
|
92
|
+
- Progress Info
|
|
93
|
+
- Radio
|
|
94
|
+
- Rating
|
|
95
|
+
- Skeleton
|
|
96
|
+
- Slider
|
|
97
|
+
- SnackBar
|
|
98
|
+
- Stepper
|
|
99
|
+
- Steps
|
|
100
|
+
- Suggest Action
|
|
101
|
+
- Swipe
|
|
102
|
+
- Switch
|
|
103
|
+
- TabView
|
|
104
|
+
- Tag
|
|
105
|
+
- Theme
|
|
106
|
+
- Title
|
|
107
|
+
- Tooltip
|
|
108
|
+
- Typography
|
|
109
|
+
- Uploader
|
|
110
|
+
|
|
111
|
+
## Validation Notes
|
|
112
|
+
|
|
113
|
+
Validated locally with:
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
pod ipc spec ios/MoMoUIKits.podspec
|
|
117
|
+
pod ipc spec ios-demo/MoMoUIKitsDemo.podspec
|
|
118
|
+
pod lib lint ios/MoMoUIKits.podspec --allow-warnings --skip-import-validation
|
|
119
|
+
pod lib lint ios-demo/MoMoUIKitsDemo.podspec --allow-warnings --skip-import-validation --include-podspecs=ios/MoMoUIKits.podspec
|
|
120
|
+
```
|
package/package.json
CHANGED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import org.gradle.kotlin.dsl.maven
|
|
2
|
+
|
|
3
|
+
rootProject.name = "momo-native-kits"
|
|
4
|
+
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
|
5
|
+
|
|
6
|
+
pluginManagement {
|
|
7
|
+
repositories {
|
|
8
|
+
google {
|
|
9
|
+
mavenContent {
|
|
10
|
+
includeGroupAndSubgroups("androidx")
|
|
11
|
+
includeGroupAndSubgroups("com.android")
|
|
12
|
+
includeGroupAndSubgroups("com.google")
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
mavenCentral()
|
|
16
|
+
gradlePluginPortal()
|
|
17
|
+
maven {
|
|
18
|
+
url = uri("https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven")
|
|
19
|
+
credentials {username = "download_packages"; password = "gldt-bjDqLpU_sPcHDuXau2ws" }
|
|
20
|
+
}
|
|
21
|
+
maven {
|
|
22
|
+
url = uri("https://artifacts.mservice.com.vn/repository/maven-momo-app/")
|
|
23
|
+
credentials {
|
|
24
|
+
username = "viewer"
|
|
25
|
+
password = "viewer"
|
|
26
|
+
}
|
|
27
|
+
isAllowInsecureProtocol = true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
dependencyResolutionManagement {
|
|
33
|
+
repositories {
|
|
34
|
+
google {
|
|
35
|
+
mavenContent {
|
|
36
|
+
includeGroupAndSubgroups("androidx")
|
|
37
|
+
includeGroupAndSubgroups("com.android")
|
|
38
|
+
includeGroupAndSubgroups("com.google")
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
mavenCentral()
|
|
42
|
+
maven { url = uri("https://maven.pkg.jetbrains.space/public/p/compose/dev") }
|
|
43
|
+
maven {
|
|
44
|
+
url = uri("https://gitlab.mservice.com.vn/api/v4/projects/5400/packages/maven")
|
|
45
|
+
credentials {
|
|
46
|
+
username = "download_packages";
|
|
47
|
+
password = "gldt-bjDqLpU_sPcHDuXau2ws"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
maven {
|
|
51
|
+
url = uri("https://artifacts.mservice.com.vn/repository/maven-momo-app/")
|
|
52
|
+
credentials {
|
|
53
|
+
username = "viewer"
|
|
54
|
+
password = "viewer"
|
|
55
|
+
}
|
|
56
|
+
isAllowInsecureProtocol = true
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
include(":compose")
|
|
62
|
+
|
|
63
|
+
include(":sample:androidApp")
|
|
64
|
+
include(":sample:shared")
|