@momo-kits/native-kits 0.168.1-beta.31-debug → 0.168.1-beta.32
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/ios/Input/Input.swift +1 -3
- package/ios/Input/InputTextArea.swift +1 -3
- package/ios/Navigation/BottomTab/BottomTab.swift +48 -67
- package/ios/Navigation/BottomTab/BottomTabBar.swift +281 -131
- package/ios/Navigation/BottomTab/CurvedContainer.swift +51 -47
- package/ios/Navigation/BottomTab/DuoTabBar.swift +72 -292
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +88 -0
- package/ios/Navigation/StackScreen.swift +3 -1
- package/ios-demo/Resources/tabbar_scan_qr_button.json +1 -0
- package/ios-demo/Resources/tabbar_scan_qr_label.json +1 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +272 -59
- package/package.json +1 -1
- package/build.gradle.kts +0 -11
- package/compose/build.gradle.kts +0 -198
- package/compose/build.gradle.kts.backup +0 -198
- package/compose/compose.podspec +0 -47
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +0 -20
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +0 -6
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +0 -12
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +0 -7
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +0 -153
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +0 -17
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +0 -18
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +0 -110
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +0 -62
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +0 -1071
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +0 -269
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +0 -56
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +0 -157
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +0 -81
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +0 -32
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +0 -338
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +0 -175
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +0 -357
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +0 -115
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +0 -89
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +0 -128
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +0 -209
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +0 -542
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +0 -49
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +0 -125
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +0 -231
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +0 -189
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +0 -478
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +0 -114
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +0 -265
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +0 -235
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +0 -223
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +0 -265
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +0 -185
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +0 -343
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +0 -108
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +0 -56
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +0 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +0 -84
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +0 -40
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +0 -370
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +0 -108
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +0 -308
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +0 -59
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +0 -87
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +0 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +0 -90
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +0 -330
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +0 -220
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +0 -473
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +0 -122
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +0 -207
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +0 -92
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +0 -560
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +0 -125
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +0 -207
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +0 -501
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +0 -176
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +0 -182
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +0 -193
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +0 -29
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +0 -236
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +0 -180
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +0 -325
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +0 -17
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +0 -16
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +0 -194
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +0 -287
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +0 -54
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +0 -50
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +0 -321
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +0 -41
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +0 -52
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +0 -66
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +0 -11
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +0 -104
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +0 -48
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +0 -51
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +0 -502
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +0 -58
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +0 -148
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +0 -116
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +0 -205
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +0 -422
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +0 -8
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +0 -732
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +0 -148
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +0 -35
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +0 -232
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +0 -237
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +0 -86
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +0 -97
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoLiquidSelection.kt +0 -380
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +0 -436
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +0 -169
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +0 -455
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +0 -105
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +0 -106
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +0 -74
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +0 -399
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +0 -39
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +0 -363
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +0 -192
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +0 -133
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +0 -127
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +0 -12
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +0 -91
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +0 -9
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +0 -74
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +0 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +0 -21
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +0 -1329
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +0 -55
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +0 -15
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +0 -118
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +0 -42
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +0 -45
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +0 -32
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +0 -38
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +0 -66
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +0 -218
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +0 -48
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +0 -138
- package/gradle/libs.versions.toml +0 -69
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +0 -8
- package/gradle.properties +0 -26
- package/gradlew +0 -252
- package/gradlew.bat +0 -94
- package/ios/Navigation/BottomTab/DuoLiquidSelection.swift +0 -364
- package/ios-demo/README.md +0 -120
- package/settings.gradle.kts +0 -64
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// DuoLiquidSelection.swift
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// iOS 26 tab bar selection motion without the glass material, port of RN
|
|
6
|
-
// `BottomTab/useLiquidSelection.ts` (Compose `DuoLiquidSelection.kt`).
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
import SwiftUI
|
|
10
|
-
import UIKit
|
|
11
|
-
|
|
12
|
-
enum LiquidAxis {
|
|
13
|
-
case x, y
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// RN reanimated { damping: 18, stiffness: 220, mass: 0.8 }
|
|
17
|
-
let liquidSpring = Animation.interpolatingSpring(mass: 0.8, stiffness: 220, damping: 18)
|
|
18
|
-
|
|
19
|
-
private struct SpringParams {
|
|
20
|
-
let mass: CGFloat
|
|
21
|
-
let stiffness: CGFloat
|
|
22
|
-
let damping: CGFloat
|
|
23
|
-
|
|
24
|
-
static let standard = SpringParams(mass: 0.8, stiffness: 220, damping: 18)
|
|
25
|
-
// the lens trails the finger a little while dragged
|
|
26
|
-
static let drag = SpringParams(mass: 0.6, stiffness: 600, damping: 24)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private let reducedDuration: CFTimeInterval = 0.2
|
|
30
|
-
// while pressed the selection bubble grows into a lens past the bar's edges (80x54 to about 96x70)
|
|
31
|
-
let liquidLensScaleX: CGFloat = 1.2
|
|
32
|
-
let liquidLensScaleY: CGFloat = 1.3
|
|
33
|
-
// a moving lens stretches along its path and thins across it, eased per frame
|
|
34
|
-
private let stretchPerPoint: CGFloat = 0.012
|
|
35
|
-
private let maxStretch: CGFloat = 0.25
|
|
36
|
-
private let stretchEasing: CGFloat = 0.25
|
|
37
|
-
private let restStretch: CGFloat = 0.002
|
|
38
|
-
// a tap is shorter than the lift: the lens finishes rising, then settles, one smooth pulse
|
|
39
|
-
private let tapLiftDuration: Double = 0.12
|
|
40
|
-
private let barSwell: CGFloat = 0.04
|
|
41
|
-
private let iconPop: CGFloat = 1.15
|
|
42
|
-
private let iconPopDuration: Double = 0.12
|
|
43
|
-
// below it a press is a tap
|
|
44
|
-
private let dragSlop: CGFloat = 10
|
|
45
|
-
// UIScrollView rubber band constant
|
|
46
|
-
private let rubberBandConstant: CGFloat = 0.55
|
|
47
|
-
// a vetoed switch: the lens returns to the selected tab after this
|
|
48
|
-
private let resyncDelay: Double = 0.1
|
|
49
|
-
// RN TouchableOpacity delayLongPress
|
|
50
|
-
private let longPressDelay: Double = 0.5
|
|
51
|
-
|
|
52
|
-
/// Resistance past the first and last tab, the further the finger goes the less the lens follows.
|
|
53
|
-
private func rubberBand(_ value: CGFloat, max: CGFloat, dimension: CGFloat) -> CGFloat {
|
|
54
|
-
func band(_ overshoot: CGFloat) -> CGFloat {
|
|
55
|
-
(1 - 1 / (overshoot * rubberBandConstant / dimension + 1)) * dimension
|
|
56
|
-
}
|
|
57
|
-
if value < 0 { return -band(-value) }
|
|
58
|
-
if value > max { return max + band(value - max) }
|
|
59
|
-
return value
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/// Owns the lens: its offset is integrated on a display link (SwiftUI can't expose an animation's
|
|
63
|
-
/// in-flight value, and the stretch and the tabs' active tint follow it every frame); lift and pop
|
|
64
|
-
/// are plain SwiftUI springs. Input is one gesture over the whole bar, so a press is either a tap,
|
|
65
|
-
/// a long press or a drag.
|
|
66
|
-
final class DuoLiquidSelection: ObservableObject {
|
|
67
|
-
@Published private(set) var offset: CGFloat = 0
|
|
68
|
-
@Published private(set) var stretch: CGFloat = 0
|
|
69
|
-
@Published private(set) var lift: CGFloat = 0
|
|
70
|
-
@Published private(set) var selectedIndex = 0
|
|
71
|
-
@Published private(set) var popIndex: Int?
|
|
72
|
-
@Published private(set) var pop: CGFloat = 1
|
|
73
|
-
|
|
74
|
-
var axis: LiquidAxis = .x
|
|
75
|
-
var count = 0
|
|
76
|
-
/// Distance between two neighbouring tab centers.
|
|
77
|
-
var pitch: CGFloat = 0
|
|
78
|
-
/// The first tab's center in the gesture's coordinate space.
|
|
79
|
-
var firstCenter: CGFloat = 0
|
|
80
|
-
var reduceMotion = false
|
|
81
|
-
var onSelect: (Int) -> Void = { _ in }
|
|
82
|
-
var onLongPress: ((Int) -> Void)?
|
|
83
|
-
var onTick: () -> Void = {}
|
|
84
|
-
|
|
85
|
-
private var velocity: CGFloat = 0
|
|
86
|
-
// where the lens is heading, so a re-render doesn't restart a spring already going there
|
|
87
|
-
private var destination: CGFloat = 0
|
|
88
|
-
private var spring = SpringParams.standard
|
|
89
|
-
private var timed: (from: CGFloat, start: CFTimeInterval?)?
|
|
90
|
-
private var displayLink: CADisplayLink?
|
|
91
|
-
private var lastTimestamp: CFTimeInterval?
|
|
92
|
-
private var measured = false
|
|
93
|
-
|
|
94
|
-
private var touchIndex: Int?
|
|
95
|
-
private var dragging = false
|
|
96
|
-
private var hovered = 0
|
|
97
|
-
private var longPressWork: DispatchWorkItem?
|
|
98
|
-
private var resyncWork: DispatchWorkItem?
|
|
99
|
-
private var lastSample: (position: CGFloat, time: Date)?
|
|
100
|
-
private var dragVelocity: CGFloat = 0
|
|
101
|
-
private var liftGeneration = 0
|
|
102
|
-
private var popGeneration = 0
|
|
103
|
-
|
|
104
|
-
deinit {
|
|
105
|
-
displayLink?.invalidate()
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
func sync(index: Int) {
|
|
109
|
-
let changed = index != selectedIndex
|
|
110
|
-
selectedIndex = index
|
|
111
|
-
let target = CGFloat(index) * pitch
|
|
112
|
-
// snap on first layout so the lens doesn't slide in from the leading edge
|
|
113
|
-
if measured {
|
|
114
|
-
move(to: target)
|
|
115
|
-
if changed { popIcon(index) }
|
|
116
|
-
} else {
|
|
117
|
-
stop()
|
|
118
|
-
destination = target
|
|
119
|
-
offset = target
|
|
120
|
-
}
|
|
121
|
-
measured = pitch > 0
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
func activeOpacity(_ index: Int) -> Double {
|
|
125
|
-
guard pitch > 0 else { return selectedIndex == index ? 1 : 0 }
|
|
126
|
-
return Double(min(max(1 - abs(offset - CGFloat(index) * pitch) / pitch, 0), 1))
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
var barScale: CGFloat { 1 + lift * barSwell }
|
|
130
|
-
|
|
131
|
-
var lensScale: (along: CGFloat, across: CGFloat, x: CGFloat, y: CGFloat) {
|
|
132
|
-
(1 + stretch, 1 - stretch * 0.5, 1 + lift * (liquidLensScaleX - 1), 1 + lift * (liquidLensScaleY - 1))
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// MARK: Input
|
|
136
|
-
|
|
137
|
-
func touchChanged(location: CGPoint, translation: CGSize, time: Date) {
|
|
138
|
-
let value = position(location)
|
|
139
|
-
defer { lastSample = (value, time) }
|
|
140
|
-
guard let touchIndex else {
|
|
141
|
-
let index = nearest(value)
|
|
142
|
-
touchIndex = index
|
|
143
|
-
dragging = false
|
|
144
|
-
dragVelocity = 0
|
|
145
|
-
pressIn(index)
|
|
146
|
-
let work = DispatchWorkItem { [weak self] in self?.onLongPress?(index) }
|
|
147
|
-
longPressWork = work
|
|
148
|
-
DispatchQueue.main.asyncAfter(deadline: .now() + longPressDelay, execute: work)
|
|
149
|
-
return
|
|
150
|
-
}
|
|
151
|
-
if !dragging, hypot(translation.width, translation.height) > dragSlop {
|
|
152
|
-
dragging = true
|
|
153
|
-
longPressWork?.cancel()
|
|
154
|
-
hovered = touchIndex
|
|
155
|
-
animateLift(1)
|
|
156
|
-
}
|
|
157
|
-
guard dragging else { return }
|
|
158
|
-
if let lastSample {
|
|
159
|
-
let dt = time.timeIntervalSince(lastSample.time)
|
|
160
|
-
if dt > 0 { dragVelocity = (value - lastSample.position) / CGFloat(dt) }
|
|
161
|
-
}
|
|
162
|
-
let target = nearest(value)
|
|
163
|
-
if target != hovered {
|
|
164
|
-
hovered = target
|
|
165
|
-
onTick()
|
|
166
|
-
}
|
|
167
|
-
let follow = rubberBand(value, max: CGFloat(count - 1) * pitch, dimension: pitch)
|
|
168
|
-
if reduceMotion {
|
|
169
|
-
stop()
|
|
170
|
-
destination = follow
|
|
171
|
-
offset = follow
|
|
172
|
-
} else {
|
|
173
|
-
move(to: follow, spring: .drag)
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
func touchEnded(location: CGPoint) {
|
|
178
|
-
longPressWork?.cancel()
|
|
179
|
-
longPressWork = nil
|
|
180
|
-
defer {
|
|
181
|
-
touchIndex = nil
|
|
182
|
-
lastSample = nil
|
|
183
|
-
}
|
|
184
|
-
guard let touchIndex else { return }
|
|
185
|
-
if dragging {
|
|
186
|
-
dragging = false
|
|
187
|
-
animateLift(0)
|
|
188
|
-
let target = nearest(position(location))
|
|
189
|
-
move(to: CGFloat(target) * pitch, velocity: dragVelocity)
|
|
190
|
-
select(target)
|
|
191
|
-
} else {
|
|
192
|
-
pulseLift()
|
|
193
|
-
// a tap or a held tab, both pick the pressed tab like the system tab bar
|
|
194
|
-
select(touchIndex)
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/// The system took the touch: nothing is selected, the lens returns to the selected tab.
|
|
199
|
-
func touchCancelled() {
|
|
200
|
-
guard touchIndex != nil else { return }
|
|
201
|
-
longPressWork?.cancel()
|
|
202
|
-
longPressWork = nil
|
|
203
|
-
touchIndex = nil
|
|
204
|
-
lastSample = nil
|
|
205
|
-
dragging = false
|
|
206
|
-
animateLift(0)
|
|
207
|
-
move(to: CGFloat(selectedIndex) * pitch, velocity: 0)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// MARK: Motion
|
|
211
|
-
|
|
212
|
-
private func position(_ point: CGPoint) -> CGFloat {
|
|
213
|
-
(axis == .x ? point.x : point.y) - firstCenter
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
private func nearest(_ value: CGFloat) -> Int {
|
|
217
|
-
guard pitch > 0 else { return 0 }
|
|
218
|
-
return min(max(Int((value / pitch).rounded()), 0), max(count - 1, 0))
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
private func pressIn(_ index: Int) {
|
|
222
|
-
resyncWork?.cancel()
|
|
223
|
-
// the lens heads to the pressed tab, not only the selected one
|
|
224
|
-
move(to: CGFloat(index) * pitch)
|
|
225
|
-
animateLift(1)
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
private func select(_ index: Int) {
|
|
229
|
-
onSelect(index)
|
|
230
|
-
resync()
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/// Returns the lens to the selected tab unless a switch to where it is heading happened.
|
|
234
|
-
private func resync() {
|
|
235
|
-
resyncWork?.cancel()
|
|
236
|
-
let work = DispatchWorkItem { [weak self] in
|
|
237
|
-
guard let self, !self.dragging else { return }
|
|
238
|
-
let target = CGFloat(self.selectedIndex) * self.pitch
|
|
239
|
-
if self.destination != target { self.move(to: target) }
|
|
240
|
-
}
|
|
241
|
-
resyncWork = work
|
|
242
|
-
DispatchQueue.main.asyncAfter(deadline: .now() + resyncDelay, execute: work)
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
private func animateLift(_ target: CGFloat) {
|
|
246
|
-
liftGeneration += 1
|
|
247
|
-
if reduceMotion {
|
|
248
|
-
lift = 0
|
|
249
|
-
return
|
|
250
|
-
}
|
|
251
|
-
withAnimation(liquidSpring) { lift = target }
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
private func pulseLift() {
|
|
255
|
-
guard !reduceMotion else { return animateLift(0) }
|
|
256
|
-
liftGeneration += 1
|
|
257
|
-
let generation = liftGeneration
|
|
258
|
-
withAnimation(.linear(duration: tapLiftDuration)) { lift = 1 }
|
|
259
|
-
DispatchQueue.main.asyncAfter(deadline: .now() + tapLiftDuration) { [weak self] in
|
|
260
|
-
guard let self, self.liftGeneration == generation else { return }
|
|
261
|
-
withAnimation(liquidSpring) { self.lift = 0 }
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
private func popIcon(_ index: Int) {
|
|
266
|
-
guard !reduceMotion else { return }
|
|
267
|
-
popGeneration += 1
|
|
268
|
-
let generation = popGeneration
|
|
269
|
-
popIndex = index
|
|
270
|
-
pop = 1
|
|
271
|
-
withAnimation(.linear(duration: iconPopDuration)) { pop = iconPop }
|
|
272
|
-
DispatchQueue.main.asyncAfter(deadline: .now() + iconPopDuration) { [weak self] in
|
|
273
|
-
guard let self, self.popGeneration == generation else { return }
|
|
274
|
-
withAnimation(liquidSpring) { self.pop = 1 }
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
private func move(to target: CGFloat, velocity: CGFloat? = nil, spring: SpringParams = .standard) {
|
|
279
|
-
if destination == target, velocity == nil { return }
|
|
280
|
-
destination = target
|
|
281
|
-
self.spring = spring
|
|
282
|
-
if let velocity { self.velocity = velocity }
|
|
283
|
-
timed = reduceMotion ? (from: offset, start: nil) : nil
|
|
284
|
-
startDisplayLink()
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
private func stop() {
|
|
288
|
-
velocity = 0
|
|
289
|
-
timed = nil
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
fileprivate func tick(_ link: CADisplayLink) {
|
|
293
|
-
let now = link.targetTimestamp
|
|
294
|
-
let dt = min(now - (lastTimestamp ?? link.timestamp), 1.0 / 30)
|
|
295
|
-
lastTimestamp = now
|
|
296
|
-
let previous = offset
|
|
297
|
-
var next = offset
|
|
298
|
-
var settled = false
|
|
299
|
-
|
|
300
|
-
if var timed {
|
|
301
|
-
let start = timed.start ?? link.timestamp
|
|
302
|
-
timed.start = start
|
|
303
|
-
self.timed = timed
|
|
304
|
-
let fraction = min(max((now - start) / reducedDuration, 0), 1)
|
|
305
|
-
// reanimated withTiming default: ease in-out quad
|
|
306
|
-
let eased = fraction < 0.5 ? 2 * fraction * fraction : 1 - 2 * (1 - fraction) * (1 - fraction)
|
|
307
|
-
next = timed.from + (destination - timed.from) * CGFloat(eased)
|
|
308
|
-
settled = fraction >= 1
|
|
309
|
-
} else {
|
|
310
|
-
// a few sub steps keep the stiff drag spring stable
|
|
311
|
-
let steps = 4
|
|
312
|
-
let h = CGFloat(dt) / CGFloat(steps)
|
|
313
|
-
for _ in 0..<steps {
|
|
314
|
-
let force = -spring.stiffness * (next - destination) - spring.damping * velocity
|
|
315
|
-
velocity += force / spring.mass * h
|
|
316
|
-
next += velocity * h
|
|
317
|
-
}
|
|
318
|
-
settled = abs(next - destination) < 0.1 && abs(velocity) < 1
|
|
319
|
-
}
|
|
320
|
-
if settled {
|
|
321
|
-
next = destination
|
|
322
|
-
stop()
|
|
323
|
-
}
|
|
324
|
-
offset = next
|
|
325
|
-
|
|
326
|
-
if reduceMotion {
|
|
327
|
-
stretch = 0
|
|
328
|
-
} else {
|
|
329
|
-
let target = min(abs(next - previous) * stretchPerPoint, maxStretch)
|
|
330
|
-
// eased both ways: a slow frame (the spring turning at its overshoot) must not snap the shape
|
|
331
|
-
let eased = stretch + (target - stretch) * stretchEasing
|
|
332
|
-
stretch = eased < restStretch ? 0 : eased
|
|
333
|
-
}
|
|
334
|
-
if settled, stretch == 0 { stopDisplayLink() }
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
private func startDisplayLink() {
|
|
338
|
-
guard displayLink == nil else { return }
|
|
339
|
-
let link = CADisplayLink(target: DisplayLinkProxy(owner: self), selector: #selector(DisplayLinkProxy.tick))
|
|
340
|
-
link.preferredFrameRateRange = CAFrameRateRange(minimum: 60, maximum: 120, preferred: 120)
|
|
341
|
-
link.add(to: .main, forMode: .common)
|
|
342
|
-
displayLink = link
|
|
343
|
-
lastTimestamp = nil
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
private func stopDisplayLink() {
|
|
347
|
-
displayLink?.invalidate()
|
|
348
|
-
displayLink = nil
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
/// CADisplayLink retains its target; the proxy keeps the selection free to deinit mid motion.
|
|
353
|
-
private final class DisplayLinkProxy: NSObject {
|
|
354
|
-
weak var owner: DuoLiquidSelection?
|
|
355
|
-
|
|
356
|
-
init(owner: DuoLiquidSelection) {
|
|
357
|
-
self.owner = owner
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
@objc func tick(_ link: CADisplayLink) {
|
|
361
|
-
guard let owner else { return link.invalidate() }
|
|
362
|
-
owner.tick(link)
|
|
363
|
-
}
|
|
364
|
-
}
|
package/ios-demo/README.md
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
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/settings.gradle.kts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
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")
|