@momo-kits/native-kits 0.157.1-beta.9-debug → 0.157.1-com.1-debug
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compose/build.gradle.kts +1 -1
- package/compose/compose.podspec +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +123 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +224 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +350 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +360 -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/TabView.kt +449 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +21 -7
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +192 -0
- package/gradle.properties +1 -1
- package/ios/Input/Input.swift +4 -0
- package/local.properties +2 -2
- package/package.json +1 -1
- package/src/doctor/README.md +73 -0
- package/src/doctor/package-lock.json +885 -0
- package/src/doctor/package.json +44 -0
- package/src/doctor/publish.sh +27 -0
- package/src/doctor/src/Users.json +112 -0
- package/src/doctor/src/Whitelist.json +6 -0
- package/src/doctor/src/commands/check.ts +81 -0
- package/src/doctor/src/commands/doctor.ts +193 -0
- package/src/doctor/src/index.ts +35 -0
- package/src/doctor/src/logger.ts +84 -0
- package/src/doctor/src/task/native.ts +21 -0
- package/src/doctor/src/task/utils.ts +20 -0
- package/src/doctor/src/utils/checkCoreDependencies.ts +138 -0
- package/src/doctor/src/utils/checkDeletedPackage.ts +53 -0
- package/src/doctor/src/utils/checkDeprecatedPackages.ts +168 -0
- package/src/doctor/src/utils/checkDeprecatedVersion.ts +60 -0
- package/src/doctor/src/utils/checkShareDependencies.ts +251 -0
- package/src/doctor/src/utils/checkWrongVersionCommunityPackage.ts +64 -0
- package/src/doctor/src/utils/getErrorMessage.ts +84 -0
- package/src/doctor/src/utils/scanComponentUsage.ts +206 -0
- package/src/doctor/src/utils/scanFoundationImports.ts +169 -0
- package/src/doctor/src/utils/scanMaxApiUsage.ts +86 -0
- package/src/doctor/src/utils/scanNativeModulesUsage.ts +78 -0
- package/src/doctor/src/utils/sendMessage.ts +28 -0
- package/src/doctor/tsconfig.json +14 -0
- package/src/doctor/yarn.lock +492 -0
- package/src/foundations/Application/BottomSheet.tsx +358 -0
- package/src/foundations/Application/BottomTab/BottomTabBar.tsx +320 -0
- package/src/foundations/Application/BottomTab/CustomBottomTabItem.tsx +155 -0
- package/src/foundations/Application/BottomTab/TabBarIcon.tsx +113 -0
- package/src/foundations/Application/BottomTab/index.tsx +449 -0
- package/src/foundations/Application/Components/BackgroundImageView.tsx +126 -0
- package/src/foundations/Application/Components/HeaderAnimated.tsx +69 -0
- package/src/foundations/Application/Components/HeaderBackground.tsx +83 -0
- package/src/foundations/Application/Components/HeaderExtendHeader.tsx +225 -0
- package/src/foundations/Application/Components/HeaderLeft.tsx +93 -0
- package/src/foundations/Application/Components/HeaderRight.tsx +444 -0
- package/src/foundations/Application/Components/HeaderTitle.tsx +596 -0
- package/src/foundations/Application/Components/NavigationButton.tsx +76 -0
- package/src/foundations/Application/Components/SearchHeader.tsx +127 -0
- package/src/foundations/Application/Localize.ts +44 -0
- package/src/foundations/Application/ModalScreen.tsx +148 -0
- package/src/foundations/Application/Navigation.ts +63 -0
- package/src/foundations/Application/NavigationContainer.tsx +245 -0
- package/src/foundations/Application/Navigator.ts +171 -0
- package/src/foundations/Application/ScaleSizeProvider.tsx +16 -0
- package/src/foundations/Application/StackScreen.tsx +420 -0
- package/src/foundations/Application/TooltipPortal.tsx +127 -0
- package/src/foundations/Application/WidgetContainer.tsx +162 -0
- package/src/foundations/Application/index.ts +34 -0
- package/src/foundations/Application/types.ts +350 -0
- package/src/foundations/Application/utils.tsx +239 -0
- package/src/foundations/Assets/DotAnimation.json +256 -0
- package/src/foundations/Assets/SpinnerAnimation.json +1027 -0
- package/src/foundations/Assets/icon.json +4052 -0
- package/src/foundations/Assets/icon_bank.json +506 -0
- package/src/foundations/Assets/language.json +208 -0
- package/src/foundations/Assets/lottie_circle_loader.json +1 -0
- package/src/foundations/Assets/pinAnimation.json +1 -0
- package/src/foundations/Assets/unpinAnimation.json +1 -0
- package/src/foundations/Badge/Badge.tsx +104 -0
- package/src/foundations/Badge/BadgeDot.tsx +35 -0
- package/src/foundations/Badge/BadgeDotAnimation.tsx +95 -0
- package/src/foundations/Badge/BadgeRibbon.tsx +112 -0
- package/src/foundations/Badge/Shape.tsx +29 -0
- package/src/foundations/Badge/index.tsx +8 -0
- package/src/foundations/Badge/styles.ts +125 -0
- package/src/foundations/Badge/types.ts +68 -0
- package/src/foundations/Button/index.tsx +371 -0
- package/src/foundations/Button/styles.ts +65 -0
- package/src/foundations/CheckBox/index.tsx +104 -0
- package/src/foundations/CheckBox/styles.ts +17 -0
- package/src/foundations/CheckBox/types.ts +37 -0
- package/src/foundations/Consts/colors+spacing+radius.ts +232 -0
- package/src/foundations/Consts/index.ts +4 -0
- package/src/foundations/Consts/styles.ts +52 -0
- package/src/foundations/Consts/theme.ts +121 -0
- package/src/foundations/Context/index.ts +27 -0
- package/src/foundations/Divider/DashDivider.tsx +46 -0
- package/src/foundations/Divider/index.tsx +45 -0
- package/src/foundations/FoundationList/index.tsx +12 -0
- package/src/foundations/FoundationList/types.ts +7 -0
- package/src/foundations/Icon/index.tsx +57 -0
- package/src/foundations/Icon/types.ts +32 -0
- package/src/foundations/IconButton/index.tsx +144 -0
- package/src/foundations/IconButton/styles.ts +20 -0
- package/src/foundations/Image/index.tsx +115 -0
- package/src/foundations/Image/styles.ts +7 -0
- package/src/foundations/Image/types.ts +7 -0
- package/src/foundations/Input/Input.tsx +280 -0
- package/src/foundations/Input/InputDropDown.tsx +161 -0
- package/src/foundations/Input/InputMoney.tsx +325 -0
- package/src/foundations/Input/InputOTP.tsx +299 -0
- package/src/foundations/Input/InputPhoneNumber.tsx +287 -0
- package/src/foundations/Input/InputSearch.tsx +351 -0
- package/src/foundations/Input/InputTextArea.tsx +218 -0
- package/src/foundations/Input/SystemTextInput.tsx +44 -0
- package/src/foundations/Input/TextTyping.tsx +115 -0
- package/src/foundations/Input/common.tsx +243 -0
- package/src/foundations/Input/index.tsx +373 -0
- package/src/foundations/Input/styles.ts +226 -0
- package/src/foundations/Input/utils.ts +97 -0
- package/src/foundations/Layout/Card.tsx +108 -0
- package/src/foundations/Layout/FloatingButton.tsx +179 -0
- package/src/foundations/Layout/GridSystem.tsx +137 -0
- package/src/foundations/Layout/Item.tsx +59 -0
- package/src/foundations/Layout/ItemList.tsx +66 -0
- package/src/foundations/Layout/ItemSectionList.tsx +40 -0
- package/src/foundations/Layout/Screen.tsx +644 -0
- package/src/foundations/Layout/Section.tsx +103 -0
- package/src/foundations/Layout/TrackingScope.tsx +18 -0
- package/src/foundations/Layout/index.ts +34 -0
- package/src/foundations/Layout/styles.ts +95 -0
- package/src/foundations/Layout/types.ts +40 -0
- package/src/foundations/Layout/utils.ts +47 -0
- package/src/foundations/Loader/DotLoader.tsx +37 -0
- package/src/foundations/Loader/Loader.tsx +13 -0
- package/src/foundations/Loader/ProgressBar.tsx +45 -0
- package/src/foundations/Loader/Spinner.tsx +29 -0
- package/src/foundations/Loader/index.tsx +6 -0
- package/src/foundations/Loader/styles.ts +10 -0
- package/src/foundations/Loader/types.ts +35 -0
- package/src/foundations/Loader/utils.ts +25 -0
- package/src/foundations/Pagination/Dot.tsx +19 -0
- package/src/foundations/Pagination/PaginationDot.tsx +44 -0
- package/src/foundations/Pagination/PaginationNumber.tsx +31 -0
- package/src/foundations/Pagination/PaginationScroll.tsx +99 -0
- package/src/foundations/Pagination/PaginationWhiteDot.tsx +43 -0
- package/src/foundations/Pagination/index.tsx +25 -0
- package/src/foundations/Pagination/styles.ts +51 -0
- package/src/foundations/Pagination/types.ts +40 -0
- package/src/foundations/Popup/PopupNotify.tsx +276 -0
- package/src/foundations/Popup/PopupPromotion.tsx +118 -0
- package/src/foundations/Popup/index.tsx +4 -0
- package/src/foundations/Popup/types.ts +96 -0
- package/src/foundations/Radio/index.tsx +108 -0
- package/src/foundations/Radio/styles.ts +15 -0
- package/src/foundations/Radio/types.ts +31 -0
- package/src/foundations/Skeleton/index.tsx +118 -0
- package/src/foundations/Skeleton/styles.ts +5 -0
- package/src/foundations/Skeleton/types.ts +6 -0
- package/src/foundations/Switch/index.tsx +68 -0
- package/src/foundations/Switch/styles.ts +25 -0
- package/src/foundations/Switch/types.ts +19 -0
- package/src/foundations/Tag/index.tsx +128 -0
- package/src/foundations/Tag/types.ts +41 -0
- package/src/foundations/Text/index.tsx +241 -0
- package/src/foundations/Text/styles.ts +78 -0
- package/src/foundations/Text/types.ts +53 -0
- package/src/foundations/Text/utils.ts +63 -0
- package/src/foundations/Title/index.tsx +285 -0
- package/src/foundations/Title/styles.ts +55 -0
- package/src/foundations/Title/types.ts +21 -0
- package/src/foundations/index.ts +50 -0
- package/src/foundations/package.json +35 -0
- package/src/foundations/publish.sh +17 -0
- package/src/libs/AutoComplete/index.tsx +88 -0
- package/src/libs/AutoComplete/package.json +16 -0
- package/src/libs/AutoComplete/publish.sh +16 -0
- package/src/libs/AutoComplete/styles.ts +15 -0
- package/src/libs/AutoComplete/types.ts +60 -0
- package/src/libs/Avatar/index.tsx +146 -0
- package/src/libs/Avatar/package.json +16 -0
- package/src/libs/Avatar/publish.sh +20 -0
- package/src/libs/Avatar/styles.ts +18 -0
- package/src/libs/Avatar/types.ts +57 -0
- package/src/libs/Badge/Badge.tsx +70 -0
- package/src/libs/Badge/BadgeDot.tsx +11 -0
- package/src/libs/Badge/BadgeRibbon.tsx +122 -0
- package/src/libs/Badge/Shape.tsx +29 -0
- package/src/libs/Badge/index.tsx +7 -0
- package/src/libs/Badge/package.json +16 -0
- package/src/libs/Badge/publish.sh +18 -0
- package/src/libs/Badge/styles.ts +55 -0
- package/src/libs/Badge/types.ts +63 -0
- package/src/libs/Calendar/CalendarPro.tsx +307 -0
- package/src/libs/Calendar/Day.tsx +150 -0
- package/src/libs/Calendar/HeaderControl.tsx +55 -0
- package/src/libs/Calendar/LunarDateConverter.ts +228 -0
- package/src/libs/Calendar/LunarService.ts +206 -0
- package/src/libs/Calendar/Month.tsx +118 -0
- package/src/libs/Calendar/MonthList.tsx +226 -0
- package/src/libs/Calendar/TabHeader.tsx +91 -0
- package/src/libs/Calendar/Util.ts +288 -0
- package/src/libs/Calendar/holidayData.ts +118 -0
- package/src/libs/Calendar/index.tsx +383 -0
- package/src/libs/Calendar/package.json +18 -0
- package/src/libs/Calendar/publish.sh +18 -0
- package/src/libs/Calendar/styles.ts +122 -0
- package/src/libs/Calendar/types.ts +212 -0
- package/src/libs/Carousel/animation.ts +62 -0
- package/src/libs/Carousel/index.tsx +517 -0
- package/src/libs/Carousel/package.json +18 -0
- package/src/libs/Carousel/publish.sh +16 -0
- package/src/libs/Carousel/types.ts +71 -0
- package/src/libs/Chip/index.tsx +164 -0
- package/src/libs/Chip/package.json +16 -0
- package/src/libs/Chip/publish.sh +16 -0
- package/src/libs/Chip/styles.ts +20 -0
- package/src/libs/Chip/types.ts +72 -0
- package/src/libs/Collapse/index.tsx +305 -0
- package/src/libs/Collapse/package.json +16 -0
- package/src/libs/Collapse/publish.sh +18 -0
- package/src/libs/Collapse/styles.ts +37 -0
- package/src/libs/Collapse/types.ts +84 -0
- package/src/libs/DateTimePicker/WheelPicker.tsx +163 -0
- package/src/libs/DateTimePicker/WheelPickerItem.tsx +58 -0
- package/src/libs/DateTimePicker/index.tsx +188 -0
- package/src/libs/DateTimePicker/package.json +16 -0
- package/src/libs/DateTimePicker/publish.sh +17 -0
- package/src/libs/DateTimePicker/styles.ts +31 -0
- package/src/libs/DateTimePicker/types.ts +102 -0
- package/src/libs/DateTimePicker/utils.ts +114 -0
- package/src/libs/Information/index.tsx +129 -0
- package/src/libs/Information/package.json +16 -0
- package/src/libs/Information/publish.sh +18 -0
- package/src/libs/Information/styles.ts +34 -0
- package/src/libs/Information/types.ts +79 -0
- package/src/libs/Logo/index.tsx +39 -0
- package/src/libs/Logo/package.json +17 -0
- package/src/libs/Logo/publish.sh +16 -0
- package/src/libs/Logo/styles.ts +25 -0
- package/src/libs/Logo/types.ts +13 -0
- package/src/libs/ProgressInfo/ProgressInfoHorizontal.tsx +128 -0
- package/src/libs/ProgressInfo/ProgressInfoIcon.tsx +88 -0
- package/src/libs/ProgressInfo/ProgressInfoVertical.tsx +85 -0
- package/src/libs/ProgressInfo/index.tsx +22 -0
- package/src/libs/ProgressInfo/package.json +16 -0
- package/src/libs/ProgressInfo/publish.sh +16 -0
- package/src/libs/ProgressInfo/styles.ts +46 -0
- package/src/libs/ProgressInfo/types.ts +60 -0
- package/src/libs/ProgressInfo/yarn.lock +8 -0
- package/src/libs/Rating/index.tsx +74 -0
- package/src/libs/Rating/package.json +16 -0
- package/src/libs/Rating/publish.sh +18 -0
- package/src/libs/Rating/type.ts +25 -0
- package/src/libs/Slider/Label.tsx +33 -0
- package/src/libs/Slider/helpers.ts +35 -0
- package/src/libs/Slider/hooks.tsx +218 -0
- package/src/libs/Slider/index.tsx +453 -0
- package/src/libs/Slider/package.json +16 -0
- package/src/libs/Slider/publish.sh +18 -0
- package/src/libs/Slider/styles.ts +36 -0
- package/src/libs/Stepper/NumberView.tsx +64 -0
- package/src/libs/Stepper/StepperButton.tsx +37 -0
- package/src/libs/Stepper/index.tsx +139 -0
- package/src/libs/Stepper/package.json +16 -0
- package/src/libs/Stepper/publish.sh +17 -0
- package/src/libs/Stepper/styles.ts +44 -0
- package/src/libs/Stepper/types.ts +154 -0
- package/src/libs/Steps/StepIcon.tsx +86 -0
- package/src/libs/Steps/StepsHorizontal.tsx +189 -0
- package/src/libs/Steps/StepsVertical.tsx +133 -0
- package/src/libs/Steps/index.tsx +20 -0
- package/src/libs/Steps/package.json +16 -0
- package/src/libs/Steps/publish.sh +16 -0
- package/src/libs/Steps/styles.ts +46 -0
- package/src/libs/Steps/types.ts +159 -0
- package/src/libs/Steps/utils.ts +175 -0
- package/src/libs/SuggestAction/SuggestActionView.tsx +124 -0
- package/src/libs/SuggestAction/index.tsx +3 -0
- package/src/libs/SuggestAction/package.json +16 -0
- package/src/libs/SuggestAction/publish.sh +16 -0
- package/src/libs/SuggestAction/styles.ts +30 -0
- package/src/libs/SuggestAction/types.ts +36 -0
- package/src/libs/Swipe/SwipeView.tsx +151 -0
- package/src/libs/Swipe/index.tsx +5 -0
- package/src/libs/Swipe/package.json +16 -0
- package/src/libs/Swipe/publish.sh +16 -0
- package/src/libs/Swipe/styles.ts +16 -0
- package/src/libs/Swipe/types.ts +109 -0
- package/src/libs/TabView/assets/Path.tsx +29 -0
- package/src/libs/TabView/index.tsx +184 -0
- package/src/libs/TabView/package.json +16 -0
- package/src/libs/TabView/publish.sh +16 -0
- package/src/libs/TabView/styles.ts +96 -0
- package/src/libs/TabView/tabBar/CardTabBar.tsx +137 -0
- package/src/libs/TabView/tabBar/SrollableTabBar.tsx +218 -0
- package/src/libs/TabView/tabBar/TabBar.tsx +67 -0
- package/src/libs/TabView/tabItem/CardTabItem.tsx +118 -0
- package/src/libs/TabView/tabItem/TabItem.tsx +180 -0
- package/src/libs/TabView/types.ts +166 -0
- package/src/libs/Template/HeaderSliderBanner/index.tsx +86 -0
- package/src/libs/Template/HeaderSliderBanner/types.ts +16 -0
- package/src/libs/Template/TrustBanner/CustomAvatar.tsx +39 -0
- package/src/libs/Template/TrustBanner/index.tsx +161 -0
- package/src/libs/Template/TrustBanner/styles.ts +48 -0
- package/src/libs/Template/TrustBanner/types.ts +50 -0
- package/src/libs/Template/index.tsx +4 -0
- package/src/libs/Template/package.json +18 -0
- package/src/libs/Template/publish.sh +17 -0
- package/src/libs/Title/index.tsx +284 -0
- package/src/libs/Title/package.json +17 -0
- package/src/libs/Title/publish.sh +16 -0
- package/src/libs/Title/styles.ts +54 -0
- package/src/libs/Title/types.ts +21 -0
- package/src/libs/Tooltip/TooltipButtons.tsx +54 -0
- package/src/libs/Tooltip/index.tsx +608 -0
- package/src/libs/Tooltip/package.json +16 -0
- package/src/libs/Tooltip/publish.sh +18 -0
- package/src/libs/Tooltip/styles.ts +70 -0
- package/src/libs/Tooltip/types.ts +61 -0
- package/src/libs/Uploader/index.tsx +87 -0
- package/src/libs/Uploader/package.json +17 -0
- package/src/libs/Uploader/publish.sh +18 -0
- package/src/libs/Uploader/styles.ts +30 -0
- package/src/libs/Uploader/types.ts +69 -0
- package/src/native/MoMoNative.podspec +18 -0
- package/src/native/calculator/android/build.gradle +61 -0
- package/src/native/calculator/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/src/native/calculator/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/src/native/calculator/android/gradlew +172 -0
- package/src/native/calculator/android/gradlew.bat +84 -0
- package/src/native/calculator/android/src/main/AndroidManifest.xml +5 -0
- package/src/native/calculator/android/src/main/java/com/calculator/KeyboardViewModule.java +22 -0
- package/src/native/calculator/android/src/main/java/com/calculator/KeyboardViewPackage.java +35 -0
- package/src/native/calculator/android/src/main/java/com/calculator/modules/CalculatorKeyboardModule.java +157 -0
- package/src/native/calculator/android/src/main/java/com/calculator/views/calculatorkeyboard/CalculatorEditText.java +36 -0
- package/src/native/calculator/android/src/main/java/com/calculator/views/calculatorkeyboard/FixedRelativeLayout.java +45 -0
- package/src/native/calculator/android/src/main/java/com/calculator/views/calculatorkeyboard/MomoTextInputCalculatorManager.java +173 -0
- package/src/native/calculator/android/src/main/java/com/calculator/views/customkeyboard/RNCustomKeyboardModule.java +417 -0
- package/src/native/calculator/ios/Helper/MomoHelper.swift +16 -0
- package/src/native/calculator/ios/KeyboardView-Bridging-Header.h +60 -0
- package/src/native/calculator/ios/KeyboardView.h +19 -0
- package/src/native/calculator/ios/KeyboardView.m +56 -0
- package/src/native/calculator/ios/MomoTextInputCalculator.swift +144 -0
- package/src/native/calculator/ios/RNCustomKeyboard/RNCustomKeyboard.h +6 -0
- package/src/native/calculator/ios/RNCustomKeyboard/RNCustomKeyboard.m +143 -0
- package/src/native/package.json +14 -0
- package/src/native/publish.sh +29 -0
- package/src/native/resource/android/build.gradle +57 -0
- package/src/native/resource/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/src/native/resource/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/src/native/resource/android/src/main/AndroidManifest.xml +6 -0
- package/src/native/resource/android/src/main/java/com/resource/RNResourceModule.java +90 -0
- package/src/native/resource/android/src/main/java/com/resource/RNResourcePackage.java +22 -0
- package/src/native/resource/ios/RNResouce.m +71 -0
- package/src/native/resource/ios/RNResource.h +5 -0
- package/example/ios/Example.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/example/ios/Example.xcworkspace/xcuserdata/sophia.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcworkspace/xcuserdata/sophia.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +0 -6
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/Pods-Example.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/SDWebImage.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/SkeletonUI.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/lottie-ios-LottiePrivacyInfo.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/lottie-ios.xcscheme +0 -58
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/sophia.xcuserdatad/xcschemes/xcschememanagement.plist +0 -46
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
package vn.momo.kits.components
|
|
2
|
+
|
|
3
|
+
import androidx.compose.animation.core.Animatable
|
|
4
|
+
import androidx.compose.animation.core.tween
|
|
5
|
+
import androidx.compose.foundation.background
|
|
6
|
+
import androidx.compose.foundation.border
|
|
7
|
+
import androidx.compose.foundation.gestures.detectHorizontalDragGestures
|
|
8
|
+
import androidx.compose.foundation.layout.Box
|
|
9
|
+
import androidx.compose.foundation.layout.Column
|
|
10
|
+
import androidx.compose.foundation.layout.Row
|
|
11
|
+
import androidx.compose.foundation.layout.fillMaxHeight
|
|
12
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
13
|
+
import androidx.compose.foundation.layout.height
|
|
14
|
+
import androidx.compose.foundation.layout.offset
|
|
15
|
+
import androidx.compose.foundation.layout.width
|
|
16
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
17
|
+
import androidx.compose.runtime.Composable
|
|
18
|
+
import androidx.compose.runtime.remember
|
|
19
|
+
import androidx.compose.runtime.rememberCoroutineScope
|
|
20
|
+
import androidx.compose.ui.Alignment
|
|
21
|
+
import androidx.compose.ui.Modifier
|
|
22
|
+
import androidx.compose.ui.draw.clip
|
|
23
|
+
import androidx.compose.ui.graphics.Color
|
|
24
|
+
import androidx.compose.ui.input.pointer.pointerInput
|
|
25
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
26
|
+
import androidx.compose.ui.unit.Dp
|
|
27
|
+
import androidx.compose.ui.unit.IntOffset
|
|
28
|
+
import androidx.compose.ui.unit.dp
|
|
29
|
+
import kotlinx.coroutines.launch
|
|
30
|
+
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
31
|
+
import vn.momo.kits.const.AppTheme
|
|
32
|
+
import vn.momo.kits.const.Colors
|
|
33
|
+
import vn.momo.kits.const.Radius
|
|
34
|
+
import vn.momo.kits.const.Spacing
|
|
35
|
+
import vn.momo.kits.const.Typography
|
|
36
|
+
import vn.momo.kits.modifier.activeOpacityClickable
|
|
37
|
+
import vn.momo.kits.modifier.conditional
|
|
38
|
+
import kotlin.math.roundToInt
|
|
39
|
+
|
|
40
|
+
data class SwipeAction(
|
|
41
|
+
val label: String = "",
|
|
42
|
+
val icon: String = "",
|
|
43
|
+
val onPress: () -> Unit = {},
|
|
44
|
+
val backgroundColor: Color? = null,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
private val ACTION_WIDTH = 56.dp
|
|
48
|
+
|
|
49
|
+
@Composable
|
|
50
|
+
fun Swipe(
|
|
51
|
+
modifier: Modifier = Modifier,
|
|
52
|
+
leftActions: List<SwipeAction> = emptyList(),
|
|
53
|
+
rightActions: List<SwipeAction> = emptyList(),
|
|
54
|
+
height: Dp = 56.dp,
|
|
55
|
+
itemRadius: Dp = 0.dp,
|
|
56
|
+
onSwipeableOpen: () -> Unit = {},
|
|
57
|
+
onSwipeableClose: () -> Unit = {},
|
|
58
|
+
onSwipeableLeftOpen: () -> Unit = {},
|
|
59
|
+
onSwipeableRightOpen: () -> Unit = {},
|
|
60
|
+
content: @Composable () -> Unit = {},
|
|
61
|
+
) {
|
|
62
|
+
val theme = AppTheme.current
|
|
63
|
+
val density = LocalDensity.current
|
|
64
|
+
val scope = rememberCoroutineScope()
|
|
65
|
+
|
|
66
|
+
val left = leftActions.take(3)
|
|
67
|
+
val right = rightActions.take(3)
|
|
68
|
+
|
|
69
|
+
val leftWidthPx = with(density) { (ACTION_WIDTH * left.size).toPx() }
|
|
70
|
+
val rightWidthPx = with(density) { (ACTION_WIDTH * right.size).toPx() }
|
|
71
|
+
|
|
72
|
+
val offsetX = remember { Animatable(0f) }
|
|
73
|
+
|
|
74
|
+
val shape = remember(itemRadius) {
|
|
75
|
+
if (itemRadius > 0.dp) RoundedCornerShape(itemRadius) else RoundedCornerShape(0.dp)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
fun snapToClosest() {
|
|
79
|
+
scope.launch {
|
|
80
|
+
val current = offsetX.value
|
|
81
|
+
val target = when {
|
|
82
|
+
current > leftWidthPx * 0.5f && left.isNotEmpty() -> {
|
|
83
|
+
onSwipeableLeftOpen()
|
|
84
|
+
onSwipeableOpen()
|
|
85
|
+
leftWidthPx
|
|
86
|
+
}
|
|
87
|
+
current < -rightWidthPx * 0.5f && right.isNotEmpty() -> {
|
|
88
|
+
onSwipeableRightOpen()
|
|
89
|
+
onSwipeableOpen()
|
|
90
|
+
-rightWidthPx
|
|
91
|
+
}
|
|
92
|
+
else -> {
|
|
93
|
+
onSwipeableClose()
|
|
94
|
+
0f
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
offsetX.animateTo(target, tween(200))
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
fun close() {
|
|
102
|
+
scope.launch {
|
|
103
|
+
offsetX.animateTo(0f, tween(200))
|
|
104
|
+
onSwipeableClose()
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
Box(
|
|
109
|
+
modifier = modifier
|
|
110
|
+
.fillMaxWidth()
|
|
111
|
+
.height(height)
|
|
112
|
+
.conditional(IsShowBaseLineDebug) { border(1.dp, Colors.blue_03) }
|
|
113
|
+
) {
|
|
114
|
+
// Left actions
|
|
115
|
+
if (left.isNotEmpty()) {
|
|
116
|
+
Row(
|
|
117
|
+
modifier = Modifier
|
|
118
|
+
.align(Alignment.CenterStart)
|
|
119
|
+
.fillMaxHeight()
|
|
120
|
+
) {
|
|
121
|
+
left.forEach { action ->
|
|
122
|
+
SwipeActionButton(
|
|
123
|
+
action = action,
|
|
124
|
+
width = ACTION_WIDTH,
|
|
125
|
+
height = height,
|
|
126
|
+
shape = shape,
|
|
127
|
+
defaultColor = theme.colors.primary,
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Right actions
|
|
134
|
+
if (right.isNotEmpty()) {
|
|
135
|
+
Row(
|
|
136
|
+
modifier = Modifier
|
|
137
|
+
.align(Alignment.CenterEnd)
|
|
138
|
+
.fillMaxHeight()
|
|
139
|
+
) {
|
|
140
|
+
right.forEach { action ->
|
|
141
|
+
SwipeActionButton(
|
|
142
|
+
action = action,
|
|
143
|
+
width = ACTION_WIDTH,
|
|
144
|
+
height = height,
|
|
145
|
+
shape = shape,
|
|
146
|
+
defaultColor = theme.colors.error.primary,
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Main content
|
|
153
|
+
Box(
|
|
154
|
+
modifier = Modifier
|
|
155
|
+
.fillMaxWidth()
|
|
156
|
+
.height(height)
|
|
157
|
+
.offset { IntOffset(offsetX.value.roundToInt(), 0) }
|
|
158
|
+
.clip(shape)
|
|
159
|
+
.background(theme.colors.background.surface)
|
|
160
|
+
.pointerInput(left.size, right.size) {
|
|
161
|
+
detectHorizontalDragGestures(
|
|
162
|
+
onDragEnd = { snapToClosest() },
|
|
163
|
+
onDragCancel = { snapToClosest() },
|
|
164
|
+
) { _, dragAmount ->
|
|
165
|
+
scope.launch {
|
|
166
|
+
val newOffset = offsetX.value + dragAmount
|
|
167
|
+
val clamped = newOffset.coerceIn(-rightWidthPx, leftWidthPx)
|
|
168
|
+
offsetX.snapTo(clamped)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
) {
|
|
173
|
+
content()
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@Composable
|
|
179
|
+
private fun SwipeActionButton(
|
|
180
|
+
action: SwipeAction,
|
|
181
|
+
width: Dp,
|
|
182
|
+
height: Dp,
|
|
183
|
+
shape: RoundedCornerShape,
|
|
184
|
+
defaultColor: Color,
|
|
185
|
+
) {
|
|
186
|
+
val bgColor = action.backgroundColor ?: defaultColor
|
|
187
|
+
|
|
188
|
+
Box(
|
|
189
|
+
modifier = Modifier
|
|
190
|
+
.width(width)
|
|
191
|
+
.height(height)
|
|
192
|
+
.clip(shape)
|
|
193
|
+
.background(bgColor)
|
|
194
|
+
.activeOpacityClickable(onClick = action.onPress),
|
|
195
|
+
contentAlignment = Alignment.Center,
|
|
196
|
+
) {
|
|
197
|
+
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
|
198
|
+
if (action.icon.isNotEmpty()) {
|
|
199
|
+
Icon(
|
|
200
|
+
source = action.icon,
|
|
201
|
+
size = 20.dp,
|
|
202
|
+
color = Colors.black_01,
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
if (action.label.isNotEmpty()) {
|
|
206
|
+
Text(
|
|
207
|
+
text = action.label,
|
|
208
|
+
style = Typography.labelSMedium,
|
|
209
|
+
color = Colors.black_01,
|
|
210
|
+
maxLines = 1,
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
package vn.momo.kits.components
|
|
2
|
+
|
|
3
|
+
import androidx.compose.animation.core.animateDpAsState
|
|
4
|
+
import androidx.compose.animation.core.tween
|
|
5
|
+
import androidx.compose.foundation.ScrollState
|
|
6
|
+
import androidx.compose.foundation.background
|
|
7
|
+
import androidx.compose.foundation.border
|
|
8
|
+
import androidx.compose.foundation.horizontalScroll
|
|
9
|
+
import androidx.compose.foundation.layout.Box
|
|
10
|
+
import androidx.compose.foundation.layout.Column
|
|
11
|
+
import androidx.compose.foundation.layout.Row
|
|
12
|
+
import androidx.compose.foundation.layout.Spacer
|
|
13
|
+
import androidx.compose.foundation.layout.fillMaxWidth
|
|
14
|
+
import androidx.compose.foundation.layout.height
|
|
15
|
+
import androidx.compose.foundation.layout.offset
|
|
16
|
+
import androidx.compose.foundation.layout.padding
|
|
17
|
+
import androidx.compose.foundation.layout.width
|
|
18
|
+
import androidx.compose.foundation.layout.wrapContentWidth
|
|
19
|
+
import androidx.compose.foundation.pager.HorizontalPager
|
|
20
|
+
import androidx.compose.foundation.pager.rememberPagerState
|
|
21
|
+
import androidx.compose.foundation.rememberScrollState
|
|
22
|
+
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
23
|
+
import androidx.compose.runtime.Composable
|
|
24
|
+
import androidx.compose.runtime.LaunchedEffect
|
|
25
|
+
import androidx.compose.runtime.getValue
|
|
26
|
+
import androidx.compose.runtime.mutableStateListOf
|
|
27
|
+
import androidx.compose.runtime.mutableStateOf
|
|
28
|
+
import androidx.compose.runtime.remember
|
|
29
|
+
import androidx.compose.runtime.rememberCoroutineScope
|
|
30
|
+
import androidx.compose.runtime.setValue
|
|
31
|
+
import androidx.compose.runtime.snapshotFlow
|
|
32
|
+
import androidx.compose.ui.Alignment
|
|
33
|
+
import androidx.compose.ui.Modifier
|
|
34
|
+
import androidx.compose.ui.graphics.Color
|
|
35
|
+
import androidx.compose.ui.layout.onGloballyPositioned
|
|
36
|
+
import androidx.compose.ui.layout.positionInParent
|
|
37
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
38
|
+
import androidx.compose.ui.text.style.TextOverflow
|
|
39
|
+
import androidx.compose.ui.unit.Dp
|
|
40
|
+
import androidx.compose.ui.unit.dp
|
|
41
|
+
import kotlinx.coroutines.launch
|
|
42
|
+
import vn.momo.kits.application.IsShowBaseLineDebug
|
|
43
|
+
import vn.momo.kits.const.AppTheme
|
|
44
|
+
import vn.momo.kits.const.Colors
|
|
45
|
+
import vn.momo.kits.const.Radius
|
|
46
|
+
import vn.momo.kits.const.Spacing
|
|
47
|
+
import vn.momo.kits.const.Typography
|
|
48
|
+
import vn.momo.kits.modifier.activeOpacityClickable
|
|
49
|
+
import vn.momo.kits.modifier.conditional
|
|
50
|
+
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Data model
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
|
|
55
|
+
data class TabViewItem(
|
|
56
|
+
val title: String,
|
|
57
|
+
val icon: String? = null,
|
|
58
|
+
val showDot: Boolean = false,
|
|
59
|
+
val dotSize: DotSize = DotSize.Small,
|
|
60
|
+
val badgeValue: String? = null,
|
|
61
|
+
val content: @Composable () -> Unit = {},
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
enum class TabViewType { DEFAULT, CARD }
|
|
65
|
+
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
// Public composable
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
|
|
70
|
+
@Composable
|
|
71
|
+
fun TabView(
|
|
72
|
+
modifier: Modifier = Modifier,
|
|
73
|
+
tabs: List<TabViewItem>,
|
|
74
|
+
initialPage: Int = 0,
|
|
75
|
+
type: TabViewType = TabViewType.DEFAULT,
|
|
76
|
+
scrollable: Boolean = false,
|
|
77
|
+
fitContent: Boolean = false,
|
|
78
|
+
selectedColor: Color? = null,
|
|
79
|
+
unselectedColor: Color? = null,
|
|
80
|
+
onPressTabItem: (Int) -> Unit = {},
|
|
81
|
+
) {
|
|
82
|
+
if (tabs.isEmpty()) return
|
|
83
|
+
|
|
84
|
+
val theme = AppTheme.current
|
|
85
|
+
val resolvedSelectedColor = selectedColor ?: theme.colors.primary
|
|
86
|
+
val resolvedUnselectedColor = unselectedColor ?: theme.colors.text.default
|
|
87
|
+
|
|
88
|
+
val startPage = initialPage.coerceIn(0, tabs.lastIndex)
|
|
89
|
+
var selectedIndex by remember { mutableStateOf(startPage) }
|
|
90
|
+
|
|
91
|
+
// Track which pages have already been visited for lazy rendering
|
|
92
|
+
val lazyRendered = remember { mutableStateListOf(startPage) }
|
|
93
|
+
|
|
94
|
+
val pagerState = if (!fitContent) {
|
|
95
|
+
rememberPagerState(initialPage = startPage) { tabs.size }
|
|
96
|
+
} else null
|
|
97
|
+
|
|
98
|
+
val coroutineScope = rememberCoroutineScope()
|
|
99
|
+
|
|
100
|
+
// Keep selectedIndex in sync when user swipes the pager
|
|
101
|
+
if (pagerState != null) {
|
|
102
|
+
LaunchedEffect(pagerState) {
|
|
103
|
+
snapshotFlow { pagerState.currentPage }.collect { page ->
|
|
104
|
+
if (!lazyRendered.contains(page)) lazyRendered.add(page)
|
|
105
|
+
selectedIndex = page
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
val onTabPressed: (Int) -> Unit = { index ->
|
|
111
|
+
onPressTabItem(index)
|
|
112
|
+
if (!lazyRendered.contains(index)) lazyRendered.add(index)
|
|
113
|
+
selectedIndex = index
|
|
114
|
+
if (pagerState != null) {
|
|
115
|
+
coroutineScope.launch { pagerState.animateScrollToPage(index) }
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
Column(
|
|
120
|
+
modifier = modifier
|
|
121
|
+
.fillMaxWidth()
|
|
122
|
+
.conditional(IsShowBaseLineDebug) { border(1.dp, Colors.blue_03) },
|
|
123
|
+
) {
|
|
124
|
+
// Tab bar
|
|
125
|
+
when {
|
|
126
|
+
type == TabViewType.CARD -> CardTabBar(
|
|
127
|
+
tabs = tabs,
|
|
128
|
+
selectedIndex = selectedIndex,
|
|
129
|
+
selectedColor = resolvedSelectedColor,
|
|
130
|
+
unselectedColor = resolvedUnselectedColor,
|
|
131
|
+
onPressTabItem = onTabPressed,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
scrollable -> ScrollableTabBar(
|
|
135
|
+
tabs = tabs,
|
|
136
|
+
selectedIndex = selectedIndex,
|
|
137
|
+
selectedColor = resolvedSelectedColor,
|
|
138
|
+
unselectedColor = resolvedUnselectedColor,
|
|
139
|
+
onPressTabItem = onTabPressed,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
else -> DefaultTabBar(
|
|
143
|
+
tabs = tabs,
|
|
144
|
+
selectedIndex = selectedIndex,
|
|
145
|
+
selectedColor = resolvedSelectedColor,
|
|
146
|
+
unselectedColor = resolvedUnselectedColor,
|
|
147
|
+
onPressTabItem = onTabPressed,
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Content area
|
|
152
|
+
if (fitContent) {
|
|
153
|
+
Box(modifier = Modifier.fillMaxWidth()) {
|
|
154
|
+
tabs.getOrNull(selectedIndex)?.content?.invoke()
|
|
155
|
+
}
|
|
156
|
+
} else if (pagerState != null) {
|
|
157
|
+
HorizontalPager(
|
|
158
|
+
state = pagerState,
|
|
159
|
+
modifier = Modifier
|
|
160
|
+
.fillMaxWidth()
|
|
161
|
+
.weight(1f),
|
|
162
|
+
userScrollEnabled = false,
|
|
163
|
+
) { page ->
|
|
164
|
+
Box(modifier = Modifier.fillMaxWidth()) {
|
|
165
|
+
if (lazyRendered.contains(page)) {
|
|
166
|
+
tabs[page].content()
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// ---------------------------------------------------------------------------
|
|
175
|
+
// Default fixed-width tab bar
|
|
176
|
+
// ---------------------------------------------------------------------------
|
|
177
|
+
|
|
178
|
+
@Composable
|
|
179
|
+
private fun DefaultTabBar(
|
|
180
|
+
tabs: List<TabViewItem>,
|
|
181
|
+
selectedIndex: Int,
|
|
182
|
+
selectedColor: Color,
|
|
183
|
+
unselectedColor: Color,
|
|
184
|
+
onPressTabItem: (Int) -> Unit,
|
|
185
|
+
) {
|
|
186
|
+
val theme = AppTheme.current
|
|
187
|
+
val density = LocalDensity.current
|
|
188
|
+
var totalWidthPx by remember { mutableStateOf(0) }
|
|
189
|
+
|
|
190
|
+
val itemWidth: Dp = if (totalWidthPx > 0 && tabs.isNotEmpty()) {
|
|
191
|
+
with(density) { (totalWidthPx / tabs.size).toDp() }
|
|
192
|
+
} else 0.dp
|
|
193
|
+
|
|
194
|
+
val indicatorOffsetX: Dp by animateDpAsState(
|
|
195
|
+
targetValue = itemWidth * selectedIndex + Spacing.XS,
|
|
196
|
+
animationSpec = tween(durationMillis = 200),
|
|
197
|
+
label = "DefaultIndicatorX",
|
|
198
|
+
)
|
|
199
|
+
val indicatorWidth: Dp = (itemWidth - Spacing.XS * 2).coerceAtLeast(0.dp)
|
|
200
|
+
|
|
201
|
+
Box(
|
|
202
|
+
modifier = Modifier
|
|
203
|
+
.fillMaxWidth()
|
|
204
|
+
.onGloballyPositioned { totalWidthPx = it.size.width }
|
|
205
|
+
.background(theme.colors.background.surface)
|
|
206
|
+
.border(
|
|
207
|
+
width = 0.5.dp,
|
|
208
|
+
color = theme.colors.border.default,
|
|
209
|
+
shape = RoundedCornerShape(0.dp),
|
|
210
|
+
),
|
|
211
|
+
) {
|
|
212
|
+
Row(modifier = Modifier.fillMaxWidth()) {
|
|
213
|
+
tabs.forEachIndexed { index, tab ->
|
|
214
|
+
TabItemView(
|
|
215
|
+
modifier = Modifier.weight(1f),
|
|
216
|
+
tab = tab,
|
|
217
|
+
active = selectedIndex == index,
|
|
218
|
+
selectedColor = selectedColor,
|
|
219
|
+
unselectedColor = unselectedColor,
|
|
220
|
+
onPress = { onPressTabItem(index) },
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Animated underline indicator
|
|
226
|
+
Box(
|
|
227
|
+
modifier = Modifier
|
|
228
|
+
.align(Alignment.BottomStart)
|
|
229
|
+
.offset(x = indicatorOffsetX)
|
|
230
|
+
.width(indicatorWidth)
|
|
231
|
+
.height(2.dp)
|
|
232
|
+
.background(
|
|
233
|
+
color = selectedColor,
|
|
234
|
+
shape = RoundedCornerShape(topStart = Radius.XXS, topEnd = Radius.XXS),
|
|
235
|
+
),
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// ---------------------------------------------------------------------------
|
|
241
|
+
// Scrollable tab bar
|
|
242
|
+
// ---------------------------------------------------------------------------
|
|
243
|
+
|
|
244
|
+
@Composable
|
|
245
|
+
private fun ScrollableTabBar(
|
|
246
|
+
tabs: List<TabViewItem>,
|
|
247
|
+
selectedIndex: Int,
|
|
248
|
+
selectedColor: Color,
|
|
249
|
+
unselectedColor: Color,
|
|
250
|
+
onPressTabItem: (Int) -> Unit,
|
|
251
|
+
) {
|
|
252
|
+
val theme = AppTheme.current
|
|
253
|
+
val density = LocalDensity.current
|
|
254
|
+
val scrollState: ScrollState = rememberScrollState()
|
|
255
|
+
val coroutineScope = rememberCoroutineScope()
|
|
256
|
+
|
|
257
|
+
// Per-item (widthPx, xPx) measured relative to the scrollable row
|
|
258
|
+
val itemMeasures = remember { mutableStateListOf<Pair<Float, Float>>() }
|
|
259
|
+
|
|
260
|
+
val rawWidth = itemMeasures.getOrNull(selectedIndex)?.first ?: 0f
|
|
261
|
+
val rawX = itemMeasures.getOrNull(selectedIndex)?.second ?: 0f
|
|
262
|
+
|
|
263
|
+
val animatedWidth: Dp by animateDpAsState(
|
|
264
|
+
targetValue = with(density) { rawWidth.toDp() },
|
|
265
|
+
animationSpec = tween(250),
|
|
266
|
+
label = "ScrollableIndicatorWidth",
|
|
267
|
+
)
|
|
268
|
+
val animatedX: Dp by animateDpAsState(
|
|
269
|
+
targetValue = with(density) { rawX.toDp() },
|
|
270
|
+
animationSpec = tween(250),
|
|
271
|
+
label = "ScrollableIndicatorX",
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
// Auto-scroll bar to keep selected item visible
|
|
275
|
+
LaunchedEffect(selectedIndex, itemMeasures.size) {
|
|
276
|
+
val x = itemMeasures.getOrNull(selectedIndex)?.second ?: return@LaunchedEffect
|
|
277
|
+
val target = (x - with(density) { Spacing.S.toPx() }).coerceAtLeast(0f).toInt()
|
|
278
|
+
coroutineScope.launch { scrollState.animateScrollTo(target) }
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
Box(
|
|
282
|
+
modifier = Modifier
|
|
283
|
+
.fillMaxWidth()
|
|
284
|
+
.background(theme.colors.background.surface)
|
|
285
|
+
.border(
|
|
286
|
+
width = 0.5.dp,
|
|
287
|
+
color = theme.colors.border.default,
|
|
288
|
+
shape = RoundedCornerShape(0.dp),
|
|
289
|
+
),
|
|
290
|
+
) {
|
|
291
|
+
Row(
|
|
292
|
+
modifier = Modifier
|
|
293
|
+
.wrapContentWidth()
|
|
294
|
+
.horizontalScroll(scrollState),
|
|
295
|
+
) {
|
|
296
|
+
tabs.forEachIndexed { index, tab ->
|
|
297
|
+
Box(
|
|
298
|
+
modifier = Modifier
|
|
299
|
+
.wrapContentWidth()
|
|
300
|
+
.onGloballyPositioned { coords ->
|
|
301
|
+
val w = coords.size.width.toFloat()
|
|
302
|
+
val x = coords.positionInParent().x
|
|
303
|
+
while (itemMeasures.size <= index) itemMeasures.add(0f to 0f)
|
|
304
|
+
itemMeasures[index] = w to x
|
|
305
|
+
},
|
|
306
|
+
) {
|
|
307
|
+
TabItemView(
|
|
308
|
+
tab = tab,
|
|
309
|
+
active = selectedIndex == index,
|
|
310
|
+
selectedColor = selectedColor,
|
|
311
|
+
unselectedColor = unselectedColor,
|
|
312
|
+
onPress = { onPressTabItem(index) },
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Animated underline indicator aligned to bottom of the bar
|
|
319
|
+
Box(
|
|
320
|
+
modifier = Modifier
|
|
321
|
+
.align(Alignment.BottomStart)
|
|
322
|
+
.offset(x = animatedX + Spacing.XS)
|
|
323
|
+
.width((animatedWidth - Spacing.XS * 2).coerceAtLeast(0.dp))
|
|
324
|
+
.height(2.dp)
|
|
325
|
+
.background(
|
|
326
|
+
color = selectedColor,
|
|
327
|
+
shape = RoundedCornerShape(topStart = Radius.XXS, topEnd = Radius.XXS),
|
|
328
|
+
),
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// ---------------------------------------------------------------------------
|
|
334
|
+
// Card tab bar
|
|
335
|
+
// ---------------------------------------------------------------------------
|
|
336
|
+
|
|
337
|
+
@Composable
|
|
338
|
+
private fun CardTabBar(
|
|
339
|
+
tabs: List<TabViewItem>,
|
|
340
|
+
selectedIndex: Int,
|
|
341
|
+
selectedColor: Color,
|
|
342
|
+
unselectedColor: Color,
|
|
343
|
+
onPressTabItem: (Int) -> Unit,
|
|
344
|
+
) {
|
|
345
|
+
val theme = AppTheme.current
|
|
346
|
+
|
|
347
|
+
Row(
|
|
348
|
+
modifier = Modifier
|
|
349
|
+
.fillMaxWidth()
|
|
350
|
+
.padding(top = Spacing.XS),
|
|
351
|
+
verticalAlignment = Alignment.Bottom,
|
|
352
|
+
) {
|
|
353
|
+
tabs.forEachIndexed { index, tab ->
|
|
354
|
+
val isActive = selectedIndex == index
|
|
355
|
+
|
|
356
|
+
Box(
|
|
357
|
+
modifier = Modifier
|
|
358
|
+
.weight(1f)
|
|
359
|
+
.height(if (isActive) 44.dp else 40.dp)
|
|
360
|
+
.background(
|
|
361
|
+
color = if (isActive) theme.colors.background.surface
|
|
362
|
+
else theme.colors.background.tonal,
|
|
363
|
+
shape = RoundedCornerShape(
|
|
364
|
+
topStart = Radius.M,
|
|
365
|
+
topEnd = Radius.M,
|
|
366
|
+
),
|
|
367
|
+
)
|
|
368
|
+
.activeOpacityClickable { onPressTabItem(index) }
|
|
369
|
+
.padding(horizontal = Spacing.S),
|
|
370
|
+
contentAlignment = Alignment.Center,
|
|
371
|
+
) {
|
|
372
|
+
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
373
|
+
if (tab.icon != null) {
|
|
374
|
+
Icon(
|
|
375
|
+
source = tab.icon,
|
|
376
|
+
size = 18.dp,
|
|
377
|
+
color = if (isActive) selectedColor else unselectedColor,
|
|
378
|
+
)
|
|
379
|
+
Spacer(modifier = Modifier.width(Spacing.XS))
|
|
380
|
+
}
|
|
381
|
+
Text(
|
|
382
|
+
text = tab.title,
|
|
383
|
+
style = if (isActive) Typography.headerSSemibold else Typography.bodyDefaultRegular,
|
|
384
|
+
color = if (isActive) selectedColor else unselectedColor,
|
|
385
|
+
maxLines = 1,
|
|
386
|
+
overflow = TextOverflow.Ellipsis,
|
|
387
|
+
modifier = Modifier.weight(1f, fill = false),
|
|
388
|
+
)
|
|
389
|
+
if (tab.showDot) {
|
|
390
|
+
Spacer(modifier = Modifier.width(Spacing.XS))
|
|
391
|
+
BadgeDot(size = tab.dotSize)
|
|
392
|
+
} else if (!tab.badgeValue.isNullOrEmpty()) {
|
|
393
|
+
Spacer(modifier = Modifier.width(Spacing.XS))
|
|
394
|
+
Badge(label = tab.badgeValue, modifier = Modifier)
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// ---------------------------------------------------------------------------
|
|
403
|
+
// Shared tab item used by DefaultTabBar and ScrollableTabBar
|
|
404
|
+
// ---------------------------------------------------------------------------
|
|
405
|
+
|
|
406
|
+
@Composable
|
|
407
|
+
private fun TabItemView(
|
|
408
|
+
modifier: Modifier = Modifier,
|
|
409
|
+
tab: TabViewItem,
|
|
410
|
+
active: Boolean,
|
|
411
|
+
selectedColor: Color,
|
|
412
|
+
unselectedColor: Color,
|
|
413
|
+
onPress: () -> Unit,
|
|
414
|
+
) {
|
|
415
|
+
val textColor = if (active) selectedColor else unselectedColor
|
|
416
|
+
val textStyle = if (active) Typography.headerSSemibold else Typography.bodyDefaultRegular
|
|
417
|
+
|
|
418
|
+
Row(
|
|
419
|
+
modifier = modifier
|
|
420
|
+
.height(48.dp)
|
|
421
|
+
.activeOpacityClickable { onPress() }
|
|
422
|
+
.padding(horizontal = Spacing.S),
|
|
423
|
+
verticalAlignment = Alignment.CenterVertically,
|
|
424
|
+
) {
|
|
425
|
+
if (tab.icon != null) {
|
|
426
|
+
Icon(
|
|
427
|
+
source = tab.icon,
|
|
428
|
+
size = 18.dp,
|
|
429
|
+
color = textColor,
|
|
430
|
+
)
|
|
431
|
+
Spacer(modifier = Modifier.width(Spacing.XS))
|
|
432
|
+
}
|
|
433
|
+
Text(
|
|
434
|
+
text = tab.title,
|
|
435
|
+
style = textStyle,
|
|
436
|
+
color = textColor,
|
|
437
|
+
maxLines = 1,
|
|
438
|
+
overflow = TextOverflow.Ellipsis,
|
|
439
|
+
modifier = Modifier.weight(1f, fill = false),
|
|
440
|
+
)
|
|
441
|
+
if (tab.showDot) {
|
|
442
|
+
Spacer(modifier = Modifier.width(Spacing.XS))
|
|
443
|
+
BadgeDot(size = tab.dotSize)
|
|
444
|
+
} else if (!tab.badgeValue.isNullOrEmpty()) {
|
|
445
|
+
Spacer(modifier = Modifier.width(Spacing.XS))
|
|
446
|
+
Badge(label = tab.badgeValue, modifier = Modifier)
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|