@momo-kits/native-kits 0.158.1-beta.1 → 0.158.1-beta.2-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 +180 -0
- package/compose/build.gradle.kts.backup +180 -0
- package/compose/compose.podspec +54 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +117 -0
- package/compose/src/commonMain/composeResources/font/momosignature.otf +0 -0
- package/compose/src/commonMain/composeResources/font/momotrustdisplay.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_black.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_black.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_bold.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_heavy.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_light.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_medium.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_regular.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_semibold.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_thin.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_thin.ttf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.otf +0 -0
- package/compose/src/commonMain/composeResources/font/sfprotext_ultralight.ttf +0 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/AnimationSearchInput.kt +57 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +107 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +201 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +222 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +48 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderBackground.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderDefault.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderExtended.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderRight.kt +305 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderTitle.kt +33 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +720 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +121 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +405 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/useHeaderSearchAnimation.kt +69 -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 +85 -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 +340 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +198 -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 +123 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +94 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +136 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +224 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +543 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +23 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +148 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +188 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +116 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +448 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +172 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +255 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +231 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +233 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +254 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +241 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +364 -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 +92 -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 +352 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +103 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +338 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +70 -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 +17 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +96 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +348 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +256 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +494 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +131 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +215 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +96 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +531 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +92 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +130 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +214 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +590 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +177 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +192 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +205 -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 +239 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +191 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +306 -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 +188 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +285 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +2 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +50 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +68 -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 +14 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +50 -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 +253 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +99 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +164 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +333 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +552 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +162 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +243 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +187 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +279 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +80 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +306 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +370 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +132 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +167 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +46 -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 +62 -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 +88 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +161 -0
- package/example/ios/Example.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/Example.xcscheme +32 -0
- package/example/ios/Example.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/WorkspaceSettings.xcsettings +16 -0
- package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +6 -0
- package/example/ios/Example.xcworkspace/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +5 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/Pods-Example.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SDWebImage.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/SkeletonUI.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/lottie-ios-LottiePrivacyInfo.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/lottie-ios.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sonnguyen.xcuserdatad/xcschemes/xcschememanagement.plist +60 -0
- package/gradle/libs.versions.toml +57 -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/local.properties +8 -0
- package/package.json +1 -1
- package/settings.gradle.kts +52 -0
- package/.claude/settings.local.json +0 -11
- package/.claude/skills/design-system/SKILL.md +0 -88
- package/.claude/skills/design-system/references/components/avatar.md +0 -134
- package/.claude/skills/design-system/references/components/badge.md +0 -127
- package/.claude/skills/design-system/references/components/bottom-tab.md +0 -177
- package/.claude/skills/design-system/references/components/bottomsheet.md +0 -170
- package/.claude/skills/design-system/references/components/button.md +0 -206
- package/.claude/skills/design-system/references/components/carousel.md +0 -117
- package/.claude/skills/design-system/references/components/checkbox.md +0 -98
- package/.claude/skills/design-system/references/components/chip.md +0 -146
- package/.claude/skills/design-system/references/components/collapse.md +0 -120
- package/.claude/skills/design-system/references/components/date-picker.md +0 -119
- package/.claude/skills/design-system/references/components/divider.md +0 -84
- package/.claude/skills/design-system/references/components/icon.md +0 -130
- package/.claude/skills/design-system/references/components/image.md +0 -81
- package/.claude/skills/design-system/references/components/information.md +0 -107
- package/.claude/skills/design-system/references/components/input-dropdown.md +0 -138
- package/.claude/skills/design-system/references/components/input-money.md +0 -157
- package/.claude/skills/design-system/references/components/input-otp.md +0 -132
- package/.claude/skills/design-system/references/components/input-phone-number.md +0 -140
- package/.claude/skills/design-system/references/components/input-search.md +0 -124
- package/.claude/skills/design-system/references/components/input-text-area.md +0 -133
- package/.claude/skills/design-system/references/components/input.md +0 -152
- package/.claude/skills/design-system/references/components/loader.md +0 -87
- package/.claude/skills/design-system/references/components/pagination.md +0 -105
- package/.claude/skills/design-system/references/components/popup-notify.md +0 -128
- package/.claude/skills/design-system/references/components/progress-info.md +0 -114
- package/.claude/skills/design-system/references/components/radio.md +0 -86
- package/.claude/skills/design-system/references/components/rating.md +0 -126
- package/.claude/skills/design-system/references/components/skeleton.md +0 -120
- package/.claude/skills/design-system/references/components/slider.md +0 -141
- package/.claude/skills/design-system/references/components/snackbar.md +0 -97
- package/.claude/skills/design-system/references/components/stepper.md +0 -100
- package/.claude/skills/design-system/references/components/steps.md +0 -91
- package/.claude/skills/design-system/references/components/suggest-action.md +0 -95
- package/.claude/skills/design-system/references/components/swipe.md +0 -121
- package/.claude/skills/design-system/references/components/switch.md +0 -98
- package/.claude/skills/design-system/references/components/tab-view.md +0 -120
- package/.claude/skills/design-system/references/components/tag.md +0 -118
- package/.claude/skills/design-system/references/components/text.md +0 -151
- package/.claude/skills/design-system/references/components/toast.md +0 -99
- package/.claude/skills/design-system/references/components/tooltip.md +0 -138
- package/.claude/skills/design-system/references/components/top-nav-miniapp.md +0 -94
- package/.claude/skills/design-system/references/components/top-nav.md +0 -226
- package/.claude/skills/design-system/references/components/uploader.md +0 -115
- package/.claude/skills/design-system/references/navigation/bottom-tab.md +0 -131
- package/.claude/skills/design-system/references/navigation/bottomsheet.md +0 -161
- package/.claude/skills/design-system/references/navigation/modal.md +0 -133
- package/.claude/skills/design-system/references/navigation/navigation-options.md +0 -225
- package/.claude/skills/design-system/references/navigation/navigator.md +0 -111
- package/.claude/skills/design-system/references/navigation/setup.md +0 -134
- package/.claude/skills/design-system/references/navigation/stack.md +0 -128
- package/.claude/skills/design-system/references/spec-convention.md +0 -80
- package/.claude/skills/design-system/references/tokens/colors.md +0 -131
- package/.claude/skills/design-system/references/tokens/spacing-radius.md +0 -144
- package/.claude/skills/design-system/references/tokens/theme.md +0 -125
- package/.claude/skills/design-system/references/tokens/typography.md +0 -135
- package/.claude/skills/design-system-kits/SKILL.md +0 -102
- package/.claude/skills/design-system-kits/references/code-convention.md +0 -118
- package/.claude/skills/design-system-kits/references/components/avatar.md +0 -45
- package/.claude/skills/design-system-kits/references/components/badge.md +0 -27
- package/.claude/skills/design-system-kits/references/components/button.md +0 -65
- package/.claude/skills/design-system-kits/references/components/carousel.md +0 -51
- package/.claude/skills/design-system-kits/references/components/checkbox.md +0 -39
- package/.claude/skills/design-system-kits/references/components/chip.md +0 -54
- package/.claude/skills/design-system-kits/references/components/collapse.md +0 -63
- package/.claude/skills/design-system-kits/references/components/date-picker.md +0 -36
- package/.claude/skills/design-system-kits/references/components/divider.md +0 -21
- package/.claude/skills/design-system-kits/references/components/icon.md +0 -382
- package/.claude/skills/design-system-kits/references/components/image.md +0 -62
- package/.claude/skills/design-system-kits/references/components/information.md +0 -61
- package/.claude/skills/design-system-kits/references/components/input-dropdown.md +0 -92
- package/.claude/skills/design-system-kits/references/components/input-money.md +0 -128
- package/.claude/skills/design-system-kits/references/components/input-otp.md +0 -85
- package/.claude/skills/design-system-kits/references/components/input-phone-number.md +0 -96
- package/.claude/skills/design-system-kits/references/components/input-search.md +0 -127
- package/.claude/skills/design-system-kits/references/components/input-text-area.md +0 -100
- package/.claude/skills/design-system-kits/references/components/input.md +0 -126
- package/.claude/skills/design-system-kits/references/components/loader.md +0 -41
- package/.claude/skills/design-system-kits/references/components/pagination.md +0 -47
- package/.claude/skills/design-system-kits/references/components/popup-notify.md +0 -69
- package/.claude/skills/design-system-kits/references/components/popup-promotion.md +0 -35
- package/.claude/skills/design-system-kits/references/components/progress-info.md +0 -55
- package/.claude/skills/design-system-kits/references/components/radio.md +0 -42
- package/.claude/skills/design-system-kits/references/components/rating.md +0 -36
- package/.claude/skills/design-system-kits/references/components/skeleton.md +0 -25
- package/.claude/skills/design-system-kits/references/components/slider.md +0 -53
- package/.claude/skills/design-system-kits/references/components/snackbar.md +0 -52
- package/.claude/skills/design-system-kits/references/components/stepper.md +0 -46
- package/.claude/skills/design-system-kits/references/components/steps.md +0 -57
- package/.claude/skills/design-system-kits/references/components/suggest-action.md +0 -44
- package/.claude/skills/design-system-kits/references/components/swipe.md +0 -44
- package/.claude/skills/design-system-kits/references/components/switch.md +0 -43
- package/.claude/skills/design-system-kits/references/components/tab-view.md +0 -56
- package/.claude/skills/design-system-kits/references/components/tag.md +0 -50
- package/.claude/skills/design-system-kits/references/components/text.md +0 -56
- package/.claude/skills/design-system-kits/references/components/toast.md +0 -51
- package/.claude/skills/design-system-kits/references/components/tooltip.md +0 -95
- package/.claude/skills/design-system-kits/references/components/uploader.md +0 -48
- package/.claude/skills/design-system-kits/references/design-spec-structure.md +0 -356
- package/.claude/skills/design-system-kits/references/design-spec-to-code.md +0 -596
- package/.claude/skills/design-system-kits/references/navigation/bottom-tab.md +0 -155
- package/.claude/skills/design-system-kits/references/navigation/bottomsheet.md +0 -94
- package/.claude/skills/design-system-kits/references/navigation/modal.md +0 -125
- package/.claude/skills/design-system-kits/references/navigation/navigation-options.md +0 -430
- package/.claude/skills/design-system-kits/references/navigation/navigator.md +0 -177
- package/.claude/skills/design-system-kits/references/navigation/setup.md +0 -94
- package/.claude/skills/design-system-kits/references/navigation/stack.md +0 -152
- package/.claude/skills/design-system-kits/references/screen-layout-rule.md +0 -125
- package/.claude/skills/design-system-kits/references/tokens/colors.md +0 -183
- package/.claude/skills/design-system-kits/references/tokens/spacing-radius.md +0 -45
- package/.claude/skills/design-system-kits/references/tokens/theme.md +0 -97
- package/.claude/skills/design-system-kits/references/tokens/typography.md +0 -105
- package/.claude/skills/vibe-design/SKILL.md +0 -306
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
package vn.momo.kits.navigation
|
|
2
|
+
|
|
3
|
+
import androidx.compose.animation.animateColorAsState
|
|
4
|
+
import androidx.compose.animation.core.animateDpAsState
|
|
5
|
+
import androidx.compose.foundation.ScrollState
|
|
6
|
+
import androidx.compose.foundation.background
|
|
7
|
+
import androidx.compose.foundation.border
|
|
8
|
+
import androidx.compose.foundation.gestures.ScrollableState
|
|
9
|
+
import androidx.compose.foundation.layout.Box
|
|
10
|
+
import androidx.compose.foundation.layout.Column
|
|
11
|
+
import androidx.compose.foundation.layout.ColumnScope
|
|
12
|
+
import androidx.compose.foundation.layout.Spacer
|
|
13
|
+
import androidx.compose.foundation.layout.WindowInsets
|
|
14
|
+
import androidx.compose.foundation.layout.aspectRatio
|
|
15
|
+
import androidx.compose.foundation.layout.fillMaxSize
|
|
16
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
17
|
+
import androidx.compose.foundation.layout.height
|
|
18
|
+
import androidx.compose.foundation.layout.ime
|
|
19
|
+
import androidx.compose.foundation.layout.imePadding
|
|
20
|
+
import androidx.compose.foundation.layout.offset
|
|
21
|
+
import androidx.compose.foundation.layout.padding
|
|
22
|
+
import androidx.compose.foundation.lazy.LazyListState
|
|
23
|
+
import androidx.compose.foundation.lazy.rememberLazyListState
|
|
24
|
+
import androidx.compose.foundation.rememberScrollState
|
|
25
|
+
import androidx.compose.foundation.verticalScroll
|
|
26
|
+
import androidx.compose.material.ExperimentalMaterialApi
|
|
27
|
+
import androidx.compose.runtime.Composable
|
|
28
|
+
import androidx.compose.runtime.CompositionLocalProvider
|
|
29
|
+
import androidx.compose.runtime.LaunchedEffect
|
|
30
|
+
import androidx.compose.runtime.getValue
|
|
31
|
+
import androidx.compose.runtime.mutableIntStateOf
|
|
32
|
+
import androidx.compose.runtime.mutableStateOf
|
|
33
|
+
import androidx.compose.runtime.remember
|
|
34
|
+
import androidx.compose.runtime.snapshotFlow
|
|
35
|
+
import androidx.compose.runtime.staticCompositionLocalOf
|
|
36
|
+
import androidx.compose.ui.Alignment
|
|
37
|
+
import androidx.compose.ui.Modifier
|
|
38
|
+
import androidx.compose.ui.graphics.Brush
|
|
39
|
+
import androidx.compose.ui.graphics.Color
|
|
40
|
+
import androidx.compose.ui.graphics.lerp
|
|
41
|
+
import androidx.compose.ui.layout.onGloballyPositioned
|
|
42
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
43
|
+
import androidx.compose.ui.unit.Dp
|
|
44
|
+
import androidx.compose.ui.unit.dp
|
|
45
|
+
import androidx.compose.ui.unit.min
|
|
46
|
+
import androidx.compose.ui.zIndex
|
|
47
|
+
import vn.momo.kits.components.InputSearch
|
|
48
|
+
import vn.momo.kits.const.AppNavigationBar
|
|
49
|
+
import vn.momo.kits.const.AppStatusBar
|
|
50
|
+
import vn.momo.kits.const.AppTheme
|
|
51
|
+
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
52
|
+
import vn.momo.kits.const.Colors
|
|
53
|
+
import vn.momo.kits.const.Spacing
|
|
54
|
+
import vn.momo.kits.modifier.conditional
|
|
55
|
+
import vn.momo.kits.modifier.hideKeyboardOnTap
|
|
56
|
+
import vn.momo.kits.navigation.component.FABPosition
|
|
57
|
+
import vn.momo.kits.navigation.component.FloatingButton
|
|
58
|
+
import vn.momo.kits.navigation.component.HEADER_HEIGHT
|
|
59
|
+
import vn.momo.kits.navigation.component.Header
|
|
60
|
+
import vn.momo.kits.navigation.component.HeaderBackground
|
|
61
|
+
import vn.momo.kits.navigation.component.HeaderRight
|
|
62
|
+
import vn.momo.kits.navigation.component.HeaderType
|
|
63
|
+
import vn.momo.kits.navigation.component.InputSearchType
|
|
64
|
+
import vn.momo.kits.platform.BackHandler
|
|
65
|
+
import vn.momo.kits.platform.getAndroidBuildVersion
|
|
66
|
+
import vn.momo.kits.navigation.tracking.ScreenTracker
|
|
67
|
+
import vn.momo.kits.navigation.tracking.ScreenTrackingState
|
|
68
|
+
import kotlinx.coroutines.delay
|
|
69
|
+
import vn.momo.kits.application.ApplicationContext
|
|
70
|
+
import kotlin.time.Clock
|
|
71
|
+
import kotlin.time.ExperimentalTime
|
|
72
|
+
|
|
73
|
+
internal val LocalFooterHeightPx = staticCompositionLocalOf { mutableIntStateOf(0) }
|
|
74
|
+
internal val LocalHeaderRightWidthPx = staticCompositionLocalOf { mutableIntStateOf(0) }
|
|
75
|
+
|
|
76
|
+
@OptIn(ExperimentalMaterialApi::class, ExperimentalTime::class)
|
|
77
|
+
@Composable
|
|
78
|
+
internal fun StackScreen(
|
|
79
|
+
content: @Composable () -> Unit,
|
|
80
|
+
navigationOptions: NavigationOptions? = null,
|
|
81
|
+
id: Int = -1,
|
|
82
|
+
name: String = "",
|
|
83
|
+
bottomTabIndex: Int = -1,
|
|
84
|
+
onBackHandler: (() -> Unit)? = null,
|
|
85
|
+
) {
|
|
86
|
+
val navigator = LocalNavigator.current
|
|
87
|
+
val maxApi = LocalMaxApi.current
|
|
88
|
+
val context = ApplicationContext.current
|
|
89
|
+
val statusBar = AppStatusBar.current
|
|
90
|
+
val density = LocalDensity.current
|
|
91
|
+
val navigation = remember { Navigation(id = id, bottomTabIndex = bottomTabIndex, initOptions = navigationOptions) }
|
|
92
|
+
|
|
93
|
+
val options by navigation.currentOptions
|
|
94
|
+
|
|
95
|
+
// Auto tracking state
|
|
96
|
+
val trackingState = remember {
|
|
97
|
+
ScreenTrackingState().apply {
|
|
98
|
+
startTime = Clock.System.now().toEpochMilliseconds()
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Determine action: push or back
|
|
103
|
+
val action = remember {
|
|
104
|
+
if (ScreenTracker.getLastScreenName() != null) "push" else "back"
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Auto tracking effects
|
|
108
|
+
LaunchedEffect(name) {
|
|
109
|
+
// Track screen navigated immediately
|
|
110
|
+
ScreenTracker.trackScreenNavigated(
|
|
111
|
+
maxApi = maxApi,
|
|
112
|
+
context = context,
|
|
113
|
+
screenName = name,
|
|
114
|
+
action = action,
|
|
115
|
+
state = trackingState
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
// Track screen displayed after 2 seconds (debounce)
|
|
119
|
+
delay(2000)
|
|
120
|
+
val loadTime = Clock.System.now().toEpochMilliseconds() - trackingState.startTime
|
|
121
|
+
ScreenTracker.trackScreenDisplayed(
|
|
122
|
+
maxApi = maxApi,
|
|
123
|
+
context = context,
|
|
124
|
+
screenName = name,
|
|
125
|
+
duration = loadTime,
|
|
126
|
+
state = trackingState
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
// Track screen interacted after displayed
|
|
130
|
+
val interactionTime = Clock.System.now().toEpochMilliseconds() - trackingState.startTime
|
|
131
|
+
ScreenTracker.trackScreenInteracted(
|
|
132
|
+
maxApi = maxApi,
|
|
133
|
+
context = context,
|
|
134
|
+
screenName = name,
|
|
135
|
+
duration = interactionTime - loadTime,
|
|
136
|
+
totalDuration = interactionTime,
|
|
137
|
+
state = trackingState
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
val limit = with(density) {
|
|
142
|
+
(statusBar).toPx() + HEADER_HEIGHT
|
|
143
|
+
}.toInt()
|
|
144
|
+
|
|
145
|
+
val (scrollState, scrollInProcess) = if (options.scrollData.scrollState is LazyListState)
|
|
146
|
+
(options.scrollData.scrollState as? LazyListState ?: rememberLazyListState()).proxyScrollState(limit, 15)
|
|
147
|
+
else
|
|
148
|
+
(options.scrollData.scrollState as? ScrollState ?: rememberScrollState()).proxyLimitedScrollState(limit, 15)
|
|
149
|
+
|
|
150
|
+
val footerHeightPx = remember { mutableIntStateOf(0) }
|
|
151
|
+
val headerRightWidthPx = remember { mutableIntStateOf(0) }
|
|
152
|
+
|
|
153
|
+
BackHandler(true) { navigator.onBackSafe() }
|
|
154
|
+
|
|
155
|
+
CompositionLocalProvider(
|
|
156
|
+
StackScreenScrollableState provides options.scrollData.scrollState,
|
|
157
|
+
LocalNavigation provides navigation,
|
|
158
|
+
LocalScrollState provides scrollState,
|
|
159
|
+
LocalOptions provides options,
|
|
160
|
+
LocalFooterHeightPx provides footerHeightPx,
|
|
161
|
+
LocalHeaderRightWidthPx provides headerRightWidthPx
|
|
162
|
+
) {
|
|
163
|
+
Box(Modifier
|
|
164
|
+
.fillMaxSize()
|
|
165
|
+
.background(options.backgroundColor ?: AppTheme.current.colors.background.default)
|
|
166
|
+
.conditional(options.keyboardOptions.keyboardShouldPersistTaps) {
|
|
167
|
+
hideKeyboardOnTap()
|
|
168
|
+
}
|
|
169
|
+
.conditional(options.keyboardOptions.useAvoidKeyboard && getAndroidBuildVersion() > 29) {
|
|
170
|
+
imePadding()
|
|
171
|
+
}
|
|
172
|
+
) {
|
|
173
|
+
Box(Modifier.zIndex(1f)) {
|
|
174
|
+
HeaderBackground()
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
Box(Modifier.zIndex(5f)) {
|
|
178
|
+
Header(onBackHandler)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
Column (Modifier.zIndex(6f)) {
|
|
182
|
+
SearchAnimated(isScrollInProgress = scrollInProcess)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
Column(Modifier.zIndex(2f).fillMaxSize()) {
|
|
186
|
+
MainContent(content = content)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
Box(Modifier.zIndex(4f).align(Alignment.BottomCenter)) {
|
|
190
|
+
FooterContent()
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
Box(Modifier.zIndex(7f)){
|
|
194
|
+
FloatingContent()
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
OverplayView(bottomTabIndex = bottomTabIndex, id = id)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@Composable
|
|
203
|
+
fun FloatingContent(){
|
|
204
|
+
val options = LocalOptions.current
|
|
205
|
+
val density = LocalDensity.current
|
|
206
|
+
val footerHeightPx = LocalFooterHeightPx.current
|
|
207
|
+
val scrollState = LocalScrollState.current
|
|
208
|
+
|
|
209
|
+
val fabProps = options.floatingButtonProps ?: return
|
|
210
|
+
val bottomPadding = fabProps.bottom ?:
|
|
211
|
+
(Spacing.M + if (options.footerComponent != null) with(density){ footerHeightPx.intValue.toDp() } else 0.dp)
|
|
212
|
+
|
|
213
|
+
FloatingButton(
|
|
214
|
+
scrollPosition = fabProps.scrollState?.value ?: scrollState.value,
|
|
215
|
+
onClick = fabProps.onClick,
|
|
216
|
+
containerColor = AppTheme.current.colors.primary,
|
|
217
|
+
bottom = bottomPadding,
|
|
218
|
+
icon = fabProps.icon,
|
|
219
|
+
iconColor = fabProps.iconColor,
|
|
220
|
+
text = fabProps.label,
|
|
221
|
+
size = fabProps.size,
|
|
222
|
+
position = fabProps.position ?: FABPosition.END,
|
|
223
|
+
)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
@Composable
|
|
227
|
+
fun ColumnScope.MainContent(content: @Composable ()-> Unit){
|
|
228
|
+
val options = LocalOptions.current
|
|
229
|
+
val inputSearchType = getInputSearchType(options)
|
|
230
|
+
val density = LocalDensity.current
|
|
231
|
+
val scrollState = LocalScrollState.current
|
|
232
|
+
|
|
233
|
+
Spacer(Modifier.height(
|
|
234
|
+
if (options.headerType is HeaderType.DefaultOrExtended || (options.headerType is HeaderType.Transparent && !options.headerType.isFullScreenContent))
|
|
235
|
+
AppStatusBar.current + HEADER_HEIGHT.dp else 0.dp)
|
|
236
|
+
)
|
|
237
|
+
if (inputSearchType == InputSearchType.Animated){
|
|
238
|
+
val scrollDp = with(density) { scrollState.value.toDp() }
|
|
239
|
+
|
|
240
|
+
val animatedTopPadding by animateDpAsState(
|
|
241
|
+
targetValue = (HEADER_HEIGHT.dp - scrollDp).coerceIn(0.dp, HEADER_HEIGHT.dp),
|
|
242
|
+
label = "AnimatedTopPadding"
|
|
243
|
+
)
|
|
244
|
+
Spacer(Modifier.height(animatedTopPadding))
|
|
245
|
+
}
|
|
246
|
+
Column (Modifier
|
|
247
|
+
.fillMaxWidth()
|
|
248
|
+
.weight(1f)
|
|
249
|
+
.conditional(options.scrollData.scrollable && options.scrollData.scrollState is ScrollState) {
|
|
250
|
+
verticalScroll(scrollState)
|
|
251
|
+
}
|
|
252
|
+
) {
|
|
253
|
+
ScreenContent(content = content)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (options.footerComponent != null){
|
|
257
|
+
val footerHeight = LocalFooterHeightPx.current
|
|
258
|
+
val footerHeightDp = with(density) { footerHeight.value.toDp() }
|
|
259
|
+
Spacer(Modifier.height(footerHeightDp))
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
@Composable
|
|
264
|
+
fun ScreenContent(content: @Composable () -> Unit){
|
|
265
|
+
val scrollState = LocalScrollState.current
|
|
266
|
+
val options = LocalOptions.current
|
|
267
|
+
|
|
268
|
+
if (options.headerType is HeaderType.Animated){
|
|
269
|
+
val animatedHeader = options.headerType
|
|
270
|
+
Box {
|
|
271
|
+
Box(Modifier.fillMaxWidth().aspectRatio(animatedHeader.aspectRatio.value)){
|
|
272
|
+
animatedHeader.composable.invoke(scrollState.value)
|
|
273
|
+
}
|
|
274
|
+
Box(Modifier.offset(x = 0.dp, y = AppStatusBar.current + HEADER_HEIGHT.dp + animatedHeader.layoutOffSet)){
|
|
275
|
+
content()
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
} else {
|
|
279
|
+
content()
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
@Composable
|
|
284
|
+
fun FooterContent(){
|
|
285
|
+
val options = LocalOptions.current
|
|
286
|
+
if (options.footerComponent != null){
|
|
287
|
+
val ime = WindowInsets.ime
|
|
288
|
+
val density = LocalDensity.current
|
|
289
|
+
val imeBottom = ime.getBottom(density)
|
|
290
|
+
val thresholdPx = with(density) { 50.dp.toPx() }
|
|
291
|
+
val isKeyboardVisible = imeBottom > thresholdPx
|
|
292
|
+
val bottomPadding = min(AppNavigationBar.current, if (isKeyboardVisible) 0.dp else 21.dp)
|
|
293
|
+
Footer(footerComponent = options.footerComponent, bottomPadding = bottomPadding)
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
@Composable
|
|
298
|
+
fun OverplayView(bottomTabIndex: Int, id: Int){
|
|
299
|
+
val overplayType = OverplayComponentRegistry.getOverplayType()
|
|
300
|
+
|
|
301
|
+
if (overplayType != null) {
|
|
302
|
+
Box(Modifier.zIndex(if (overplayType == OverplayComponentType.SNACK_BAR) 3f else 8f).fillMaxSize()){
|
|
303
|
+
if (bottomTabIndex != -1) return@Box
|
|
304
|
+
if (OverplayComponentRegistry.currentRootId() != id) return@Box
|
|
305
|
+
OverplayComponentRegistry.OverlayComponent()
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
@Composable
|
|
311
|
+
fun Footer(footerComponent: @Composable (() -> Unit)?, bottomPadding: Dp) {
|
|
312
|
+
if (footerComponent == null) return
|
|
313
|
+
|
|
314
|
+
val footerHeightPx = LocalFooterHeightPx.current
|
|
315
|
+
|
|
316
|
+
val shadowBrush = remember {
|
|
317
|
+
Brush.verticalGradient(
|
|
318
|
+
colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.05f))
|
|
319
|
+
)
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
Box(Modifier.onGloballyPositioned {
|
|
323
|
+
if (footerHeightPx.intValue != it.size.height) footerHeightPx.intValue = it.size.height
|
|
324
|
+
}) {
|
|
325
|
+
Box(Modifier
|
|
326
|
+
.fillMaxWidth()
|
|
327
|
+
.background(AppTheme.current.colors.background.surface)
|
|
328
|
+
.conditional(IsShowBaseLineDebug) {
|
|
329
|
+
border(1.dp, Colors.blue_03)
|
|
330
|
+
}
|
|
331
|
+
.padding(top = Spacing.S, start = Spacing.M, end = Spacing.M, bottom = bottomPadding + Spacing.S)
|
|
332
|
+
){
|
|
333
|
+
footerComponent.invoke()
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
Box(modifier = Modifier
|
|
337
|
+
.fillMaxWidth()
|
|
338
|
+
.height(6.dp)
|
|
339
|
+
.offset(x = 0.dp, y = (-6).dp)
|
|
340
|
+
.background(shadowBrush)
|
|
341
|
+
)
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
data class InputSearchLayoutParams(
|
|
346
|
+
val topPadding: Dp,
|
|
347
|
+
val startPadding: Dp,
|
|
348
|
+
val endPadding: Dp
|
|
349
|
+
)
|
|
350
|
+
@Composable
|
|
351
|
+
fun SearchAnimated(
|
|
352
|
+
isScrollInProgress: Boolean
|
|
353
|
+
) {
|
|
354
|
+
val scrollState = LocalScrollState.current
|
|
355
|
+
val options = LocalOptions.current
|
|
356
|
+
val navigator = LocalNavigator.current
|
|
357
|
+
val density = LocalDensity.current
|
|
358
|
+
|
|
359
|
+
val scrollDp = with(density) { scrollState.value.toDp() }
|
|
360
|
+
|
|
361
|
+
val inputSearchType = getInputSearchType(options)
|
|
362
|
+
val headerRightWidthPx = LocalHeaderRightWidthPx.current
|
|
363
|
+
val headerRightWidthDp = with(density) { headerRightWidthPx.intValue.toDp() }
|
|
364
|
+
|
|
365
|
+
if (inputSearchType == InputSearchType.None) return
|
|
366
|
+
val inputSearchProps = (options.headerType as? HeaderType.DefaultOrExtended)?.inputSearchProps ?: return
|
|
367
|
+
|
|
368
|
+
val minTopPadding = AppStatusBar.current
|
|
369
|
+
val maxTopPadding = AppStatusBar.current + HEADER_HEIGHT.dp
|
|
370
|
+
val minStartPadding = Spacing.M
|
|
371
|
+
val maxStartPadding = if (options.hiddenBack) Spacing.M else 52.dp
|
|
372
|
+
val minEndPadding = Spacing.M
|
|
373
|
+
val maxEndPadding = headerRightWidthDp + if (options.headerRight is HeaderRight.None) Spacing.M else Spacing.M * 2
|
|
374
|
+
|
|
375
|
+
val targetColor = lerp(
|
|
376
|
+
AppTheme.current.colors.background.surface,
|
|
377
|
+
AppTheme.current.colors.background.default,
|
|
378
|
+
(scrollDp / minTopPadding).coerceIn(0f, 1f)
|
|
379
|
+
)
|
|
380
|
+
val animatedColor by animateColorAsState(targetValue = targetColor, label = "BackgroundColor")
|
|
381
|
+
|
|
382
|
+
val layoutParams = when (inputSearchType) {
|
|
383
|
+
InputSearchType.Header -> {
|
|
384
|
+
InputSearchLayoutParams(
|
|
385
|
+
topPadding = minTopPadding,
|
|
386
|
+
startPadding = maxStartPadding,
|
|
387
|
+
endPadding = maxEndPadding
|
|
388
|
+
)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
InputSearchType.Animated -> {
|
|
392
|
+
val animatedTopPadding by animateDpAsState(
|
|
393
|
+
targetValue = (maxTopPadding - scrollDp).coerceIn(minTopPadding, maxTopPadding),
|
|
394
|
+
label = "AnimatedTopPadding"
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
val animatedStartPadding by animateDpAsState(
|
|
398
|
+
targetValue = (minStartPadding + scrollDp).coerceIn(minStartPadding, maxStartPadding),
|
|
399
|
+
label = "AnimatedStartPadding"
|
|
400
|
+
)
|
|
401
|
+
|
|
402
|
+
val animatedEndPadding by animateDpAsState(
|
|
403
|
+
targetValue = (minEndPadding + scrollDp).coerceIn(minEndPadding, maxEndPadding),
|
|
404
|
+
label = "AnimatedEndPadding"
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
val maxPadding = remember(maxTopPadding, maxStartPadding, maxEndPadding) {
|
|
408
|
+
maxOf(maxEndPadding, maxStartPadding, maxTopPadding)
|
|
409
|
+
}
|
|
410
|
+
val snapScrollValue = with(density) { maxPadding.toPx().toInt() }
|
|
411
|
+
|
|
412
|
+
LaunchedEffect(isScrollInProgress && scrollState.value != 0 && scrollState.value != snapScrollValue) {
|
|
413
|
+
if (scrollDp < maxPadding) {
|
|
414
|
+
if (!isScrollInProgress) {
|
|
415
|
+
val midpoint = (maxTopPadding - minTopPadding) / 2
|
|
416
|
+
|
|
417
|
+
if (scrollDp < midpoint) {
|
|
418
|
+
scrollState.animateScrollTo(0)
|
|
419
|
+
} else {
|
|
420
|
+
scrollState.animateScrollTo(snapScrollValue)
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
InputSearchLayoutParams(
|
|
427
|
+
topPadding = animatedTopPadding,
|
|
428
|
+
startPadding = animatedStartPadding,
|
|
429
|
+
endPadding = animatedEndPadding
|
|
430
|
+
)
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
InputSearchType.None -> return
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
Spacer(Modifier.height(layoutParams.topPadding))
|
|
437
|
+
Box(
|
|
438
|
+
modifier = Modifier
|
|
439
|
+
.height(HEADER_HEIGHT.dp)
|
|
440
|
+
.fillMaxWidth()
|
|
441
|
+
.padding(
|
|
442
|
+
start = layoutParams.startPadding,
|
|
443
|
+
end = layoutParams.endPadding
|
|
444
|
+
),
|
|
445
|
+
contentAlignment = Alignment.Center
|
|
446
|
+
) {
|
|
447
|
+
InputSearch(
|
|
448
|
+
inputSearchProps = inputSearchProps.copy(
|
|
449
|
+
backgroundColor = animatedColor,
|
|
450
|
+
onPressButtonText = {
|
|
451
|
+
navigator.pop()
|
|
452
|
+
}
|
|
453
|
+
)
|
|
454
|
+
)
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
@Composable
|
|
459
|
+
internal fun isKeyboardVisible(): Boolean {
|
|
460
|
+
val ime = WindowInsets.ime
|
|
461
|
+
val density = LocalDensity.current
|
|
462
|
+
return ime.getBottom(density) > 0
|
|
463
|
+
}
|
|
464
|
+
private fun quantize(value: Int, stepPx: Int): Int {
|
|
465
|
+
if (stepPx <= 1) return value
|
|
466
|
+
return (value / stepPx) * stepPx
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
@Composable
|
|
470
|
+
fun LazyListState.proxyScrollState(
|
|
471
|
+
thresholdPx: Int = 200,
|
|
472
|
+
stepPx: Int = 4
|
|
473
|
+
): Pair<ScrollState, Boolean> {
|
|
474
|
+
val scrollState = rememberScrollState()
|
|
475
|
+
val locked = remember { mutableStateOf(false) }
|
|
476
|
+
|
|
477
|
+
LaunchedEffect(this, scrollState, thresholdPx, stepPx) {
|
|
478
|
+
snapshotFlow { firstVisibleItemIndex to firstVisibleItemScrollOffset }
|
|
479
|
+
.collect { (index, offset) ->
|
|
480
|
+
val rawTarget = if (index == 0) offset else SCROLLED_PAST_FIRST_ITEM_THRESHOLD
|
|
481
|
+
val shouldLock = rawTarget > thresholdPx
|
|
482
|
+
if (locked.value != shouldLock) locked.value = shouldLock
|
|
483
|
+
|
|
484
|
+
val desired = if (shouldLock) thresholdPx else quantize(rawTarget, stepPx)
|
|
485
|
+
|
|
486
|
+
if (scrollState.value != desired) {
|
|
487
|
+
scrollState.scrollTo(desired.coerceAtLeast(0))
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
val inProgress = remember { mutableStateOf(false) }
|
|
493
|
+
LaunchedEffect(this, thresholdPx) {
|
|
494
|
+
snapshotFlow { isScrollInProgress }
|
|
495
|
+
.collect { progressing ->
|
|
496
|
+
inProgress.value = if (locked.value) false else progressing
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
return scrollState to inProgress.value
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
@Composable
|
|
504
|
+
fun ScrollState.proxyLimitedScrollState(
|
|
505
|
+
thresholdPx: Int = 200,
|
|
506
|
+
stepPx: Int = 4
|
|
507
|
+
): Pair<ScrollState, Boolean> {
|
|
508
|
+
val proxy = rememberScrollState()
|
|
509
|
+
val locked = remember { mutableStateOf(false) }
|
|
510
|
+
|
|
511
|
+
LaunchedEffect(this, proxy, thresholdPx, stepPx) {
|
|
512
|
+
snapshotFlow { value }
|
|
513
|
+
.collect { rawTarget ->
|
|
514
|
+
val shouldLock = rawTarget > thresholdPx
|
|
515
|
+
if (locked.value != shouldLock) locked.value = shouldLock
|
|
516
|
+
|
|
517
|
+
val desired = if (shouldLock) thresholdPx else quantize(rawTarget, stepPx)
|
|
518
|
+
|
|
519
|
+
if (proxy.value != desired) {
|
|
520
|
+
proxy.scrollTo(desired.coerceAtLeast(0))
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
val inProgress = remember { mutableStateOf(false) }
|
|
526
|
+
LaunchedEffect(this, thresholdPx) {
|
|
527
|
+
snapshotFlow { isScrollInProgress }
|
|
528
|
+
.collect { progressing ->
|
|
529
|
+
inProgress.value = if (locked.value) false else progressing
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
return proxy to inProgress.value
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
private const val SCROLLED_PAST_FIRST_ITEM_THRESHOLD = 10_000
|
|
537
|
+
|
|
538
|
+
internal val LocalScrollState = staticCompositionLocalOf<ScrollState> { error("No Scroll State provided") }
|
|
539
|
+
internal val LocalOptions = staticCompositionLocalOf<NavigationOptions> { error("No NavigationOptions provided") }
|
|
540
|
+
|
|
541
|
+
val StackScreenScrollableState = staticCompositionLocalOf<ScrollableState?> { null }
|
|
542
|
+
|
|
543
|
+
internal fun getInputSearchType(options: NavigationOptions): InputSearchType{
|
|
544
|
+
return when (val headerType = options.headerType) {
|
|
545
|
+
is HeaderType.DefaultOrExtended -> when {
|
|
546
|
+
headerType.inputSearchProps == null -> InputSearchType.None
|
|
547
|
+
headerType.useAnimated -> InputSearchType.Animated
|
|
548
|
+
else -> InputSearchType.Header
|
|
549
|
+
}
|
|
550
|
+
else -> InputSearchType.None
|
|
551
|
+
}
|
|
552
|
+
}
|