@momo-kits/native-kits 0.300.7 → 0.300.8-beta.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/CLAUDE.md +12 -8
- package/README.md +8 -7
- package/build.gradle.kts +13 -0
- package/compose/build.gradle.kts +195 -0
- package/compose/build.gradle.kts.backup +195 -0
- package/compose/compose.podspec +47 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/const/HostFont.android.kt +19 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/BackGesture.android.kt +12 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/OsFontScale.android.kt +7 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/Platform.android.kt +154 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReduceMotion.android.kt +17 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/platform/ReservedRegions.android.kt +6 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +110 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/DesignSystemKits.kt +61 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsBinding.kt +60 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/KitsHost.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/LiteScreen.kt +1067 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +268 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +55 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Avatar.kt +157 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Badge.kt +81 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeDot.kt +32 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BadgeRibbon.kt +338 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/BaselineView.kt +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Button.kt +354 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +115 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +130 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +482 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +49 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Icon.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/IconButton.kt +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +224 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +137 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +473 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +113 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +262 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +237 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +228 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +280 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +183 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +342 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +40 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +82 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +362 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +304 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +88 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +308 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +218 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +456 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +205 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +542 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +86 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +175 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +201 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tooltip.kt +498 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TrustBanner.kt +176 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Uploader.kt +182 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePicker.kt +193 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerTypes.kt +29 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/DateTimePickerUtils.kt +208 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +180 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/HostFont.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Radius.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Spacing.kt +16 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Theme.kt +194 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +291 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/HeaderLayout.kt +71 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +50 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ModalLayout.kt +184 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/ScreenLayout.kt +315 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +54 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +397 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/HostBackGestureBridge.kt +58 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +153 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +118 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +212 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +422 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ScrollToTop.kt +8 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackScreen.kt +750 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +152 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/SwipeBackHaptic.kt +35 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +244 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +398 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/CurvedContainer.kt +103 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoBarCompression.kt +93 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/DuoTabBar.kt +208 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/TabBarMetrics.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/FloatingButton.kt +167 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +446 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +105 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderJourney.kt +106 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderLocation.kt +74 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +387 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +363 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HelpCenterRequest.kt +33 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SideBar.kt +197 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/SnackBar.kt +133 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/ToolkitRequests.kt +38 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/tracking/ScreenTracker.kt +135 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/BackGesture.kt +12 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +114 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +76 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReduceMotion.kt +7 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ReservedRegions.kt +21 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Icons.kt +1329 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Resources.kt +55 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Tracking.kt +15 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/utils/Utils.kt +117 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/application/KitsHostTest.kt +44 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/HelpCenterRequestTest.kt +39 -0
- package/compose/src/commonTest/kotlin/vn/momo/kits/navigation/component/ToolkitRequestsTest.kt +53 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/const/HostFont.ios.kt +42 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/HostBackGesture.ios.kt +45 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +31 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/BackGesture.ios.kt +38 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +65 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +217 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReduceMotion.ios.kt +48 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/ReservedRegions.ios.kt +143 -0
- package/gradle/libs.versions.toml +66 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/gradle.properties +24 -0
- package/gradlew +252 -0
- package/gradlew.bat +94 -0
- package/ios/Application/ApplicationEnvironment.swift +6 -4
- package/ios/Application/DesignSystemKits.swift +59 -13
- package/ios/Application/DesignSystemKitsPayload.swift +0 -8
- package/ios/Application/LanguageSource.swift +2 -11
- package/ios/Application/Localize.swift +8 -35
- package/ios/Application/LocalizeModifier.swift +2 -11
- package/ios/Application/MaxApi.swift +3 -11
- package/ios/Avatar/Avatar.swift +0 -1
- package/ios/Badge/Badge.swift +5 -8
- package/ios/Badge/BadgeRibbon.swift +2 -5
- package/ios/Button/Button.swift +4 -8
- package/ios/CalculatorKeyboard/CalculatorKeyboard.swift +5 -7
- package/ios/Carousel/Carousel.swift +4 -17
- package/ios/Checkbox/Checkbox.swift +0 -2
- package/ios/Collapse/Collapse.swift +17 -11
- package/ios/Colors+Radius+Spacing/Theme.swift +0 -7
- package/ios/DateTimePicker/DateTimePicker.swift +4 -10
- package/ios/DateTimePicker/DateTimePickerTypes.swift +1 -3
- package/ios/DateTimePicker/DateTimePickerUtils.swift +0 -3
- package/ios/DateTimePicker/WheelPicker.swift +2 -4
- package/ios/Extensions/ActiveOpacityButtonStyle.swift +2 -3
- package/ios/Extensions/Color++.swift +2 -4
- package/ios/Extensions/SkeletonUICompat.swift +0 -8
- package/ios/Icon/Icon.swift +3 -6
- package/ios/IconButton/IconButton.swift +2 -5
- package/ios/Input/ErrorView.swift +0 -7
- package/ios/Input/Input.swift +9 -20
- package/ios/Input/InputPhoneNumber.swift +37 -20
- package/ios/Input/InputSearch.swift +23 -12
- package/ios/Input/InputTextArea.swift +4 -13
- package/ios/InputDropDown/InputDropDown.swift +1 -11
- package/ios/InputMoney/InputMoney.swift +9 -28
- package/ios/InputOTP/InputOTP.swift +2 -9
- package/ios/Layout/HeaderLayout.swift +72 -0
- package/ios/Layout/Item.swift +1 -2
- package/ios/Layout/ModalLayout.swift +144 -0
- package/ios/Layout/ScreenLayout.swift +48 -31
- package/ios/Layout/Section.swift +2 -3
- package/ios/Loader/Loader.swift +3 -12
- package/ios/Lottie/LottieView.swift +0 -11
- package/ios/Navigation/BottomSheet.swift +73 -94
- package/ios/Navigation/BottomTab/BottomTab.swift +58 -73
- package/ios/Navigation/BottomTab/BottomTabBar.swift +286 -121
- package/ios/Navigation/BottomTab/CurvedContainer.swift +52 -54
- package/ios/Navigation/BottomTab/DuoBarCompression.swift +5 -12
- package/ios/Navigation/BottomTab/DuoTabBar.swift +67 -202
- package/ios/Navigation/BottomTab/TabBarMetrics.swift +97 -0
- package/ios/Navigation/Component/FloatingButton.swift +4 -11
- package/ios/Navigation/Component/Header.swift +35 -54
- package/ios/Navigation/Component/HeaderBackground.swift +2 -8
- package/ios/Navigation/Component/HeaderJourney.swift +4 -8
- package/ios/Navigation/Component/HeaderLocation.swift +4 -8
- package/ios/Navigation/Component/HeaderRight.swift +20 -22
- package/ios/Navigation/Component/HeaderTitle.swift +1 -6
- package/ios/Navigation/Component/HeaderUser.swift +4 -10
- package/ios/Navigation/Component/SideBar.swift +6 -21
- package/ios/Navigation/Component/SnackBar.swift +9 -13
- package/ios/Navigation/HostBackGestureBridge.swift +2 -9
- package/ios/Navigation/ModalScreen.swift +24 -13
- package/ios/Navigation/Navigation.swift +35 -19
- package/ios/Navigation/NavigationContainer.swift +4 -15
- package/ios/Navigation/Navigator.swift +21 -39
- package/ios/Navigation/StackScreen.swift +64 -51
- package/ios/Navigation/StackTransition.swift +7 -14
- package/ios/Navigation/SwipeBackHaptic.swift +2 -7
- package/ios/Navigation/Tracking/ScreenTracker.swift +2 -7
- package/ios/Pagination/PaginationDot.swift +0 -9
- package/ios/Pagination/PaginationNumber.swift +1 -9
- package/ios/Pagination/PaginationScroll.swift +2 -14
- package/ios/Pagination/PaginationWhiteDot.swift +1 -10
- package/ios/Popup/PopupDisplay.swift +7 -5
- package/ios/Popup/PopupInput.swift +6 -4
- package/ios/Popup/PopupLayout.swift +17 -9
- package/ios/Popup/PopupNotify.swift +32 -25
- package/ios/PopupView/FullscreenPopup.swift +3 -4
- package/ios/PopupView/PopupView.swift +2 -2
- package/ios/PopupView/Utils++.swift +1 -2
- package/ios/ProgressInfo/ProgressInfo.swift +2 -13
- package/ios/Skeleton/Skeleton.swift +5 -16
- package/ios/Slider/Slider.swift +5 -12
- package/ios/StatusBarTap/StatusBarTap.h +2 -3
- package/ios/StatusBarTap/StatusBarTap.m +3 -16
- package/ios/Stepper/Stepper.swift +8 -27
- package/ios/Steps/Steps.swift +29 -26
- package/ios/Swipeable/SwipeCell.swift +2 -2
- package/ios/Swipeable/SwipeCellModel.swift +3 -6
- package/ios/TabView/TabView.swift +14 -28
- package/ios/Template/TrustBanner/TrustBanner.swift +2 -9
- package/ios/Title/Title.swift +1 -3
- package/ios/Tooltip/Tooltip.swift +4 -9
- package/ios/Typography/FontScale.swift +79 -24
- package/ios/Typography/Text.swift +6 -12
- package/ios/Typography/Typography.swift +8 -11
- package/ios/Uploader/Uploader.swift +2 -17
- package/ios-demo/README.md +120 -0
- 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/AnimatedHeaderDemo.swift +11 -2
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/BottomTabDemo.swift +296 -59
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/InputPhoneNumberDemo.swift +15 -4
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +0 -8
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +114 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/PopupNotifyDemo.swift +29 -1
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/TypographyDemo.swift +16 -0
- package/package.json +1 -1
- package/publish.sh +8 -2
- package/scripts/ci/build-swiftui.sh +22 -0
- package/scripts/ci/resolve-version.mjs +144 -0
- package/settings.gradle.kts +63 -0
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
// File: ios/Application/LocalizeModifier.swift
|
|
2
|
-
// Created At: 2026-07-29 10:00:00 +07:00
|
|
3
|
-
// Created By: AI
|
|
4
|
-
// AI Agent: Claude Code
|
|
5
|
-
// Model: claude-opus-5[1m]
|
|
6
|
-
|
|
7
|
-
// AI-GENERATED START: inject a language-observing Localize into any SwiftUI subtree
|
|
8
1
|
import SwiftUI
|
|
9
2
|
|
|
10
3
|
public extension View {
|
|
@@ -15,9 +8,8 @@ public extension View {
|
|
|
15
8
|
}
|
|
16
9
|
}
|
|
17
10
|
|
|
18
|
-
/// `@ObservedObject` is load-bearing: `@Environment(\.localize)` only
|
|
19
|
-
///
|
|
20
|
-
/// set `\.localize` would inject a snapshot that never updates.
|
|
11
|
+
/// `@ObservedObject` is load-bearing: `@Environment(\.localize)` invalidates only when *this* body re-runs on a
|
|
12
|
+
/// publish; a helper that just set `\.localize` would inject a snapshot that never updates.
|
|
21
13
|
private struct MomoLocalizeModifier: ViewModifier {
|
|
22
14
|
@ObservedObject var localize: Localize
|
|
23
15
|
|
|
@@ -27,4 +19,3 @@ private struct MomoLocalizeModifier: ViewModifier {
|
|
|
27
19
|
.environment(\.localize, localize)
|
|
28
20
|
}
|
|
29
21
|
}
|
|
30
|
-
// AI-GENERATED END: inject a language-observing Localize into any SwiftUI subtree
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// MoMoUIKits
|
|
4
|
-
//
|
|
5
|
-
// Swift mirror of the host-app bridge exposed on Kotlin as `vn.momo.maxapi.IMaxApi`
|
|
6
|
-
// (`LocalMaxApi`). `IMaxApi` itself is an external compiled dependency with no
|
|
7
|
-
// source in this repo, so this protocol intentionally exposes only the methods
|
|
8
|
-
// this kit's Kotlin source actually calls — not a full guess at IMaxApi's real surface.
|
|
9
|
-
// Callbacks carry IMaxApi's `["response": …]` payload.
|
|
10
|
-
//
|
|
1
|
+
// Swift mirror of the host bridge `vn.momo.maxapi.IMaxApi` (`LocalMaxApi`). IMaxApi is an external
|
|
2
|
+
// binary, so only the methods the kit calls are declared; callbacks carry its `["response": …]` payload.
|
|
11
3
|
|
|
12
4
|
import UIKit
|
|
13
5
|
|
|
@@ -32,7 +24,7 @@ public extension MaxApi {
|
|
|
32
24
|
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
|
33
25
|
}
|
|
34
26
|
|
|
35
|
-
// Hosts that don't bridge the toolkit keep it inert
|
|
27
|
+
// Hosts that don't bridge the toolkit keep it inert.
|
|
36
28
|
func isFavoriteApp(_ params: [String: Any?], callback: @escaping ([String: Any?]?) -> Void) {}
|
|
37
29
|
func onToolAction(_ params: [String: Any?], callback: @escaping ([String: Any?]?) -> Void) {}
|
|
38
30
|
func showTools(_ params: [String: Any?], callback: @escaping ([String: Any?]?) -> Void) {}
|
package/ios/Avatar/Avatar.swift
CHANGED
package/ios/Badge/Badge.swift
CHANGED
|
@@ -41,17 +41,14 @@ public struct Badge: View {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
private var badgeColor: Color {
|
|
44
|
-
//
|
|
45
|
-
let defaultColor: Color = isNumber(label)
|
|
46
|
-
? theme.colors.error.primary
|
|
47
|
-
: theme.colors.warning.primary
|
|
48
|
-
|
|
49
|
-
// Mirror Compose: only apply backgroundColor when it is one of the
|
|
50
|
-
// allowed primaryColors; otherwise fall back to the label-based default.
|
|
44
|
+
// Mirrors Compose: backgroundColor applies only when it is one of primaryColors.
|
|
51
45
|
if let bgColor = backgroundColor, primaryColors.contains(bgColor) {
|
|
52
46
|
return bgColor
|
|
53
47
|
}
|
|
54
|
-
|
|
48
|
+
if isNumber(label) {
|
|
49
|
+
return theme.colors.error.primary
|
|
50
|
+
}
|
|
51
|
+
return theme.colors.warning.primary
|
|
55
52
|
}
|
|
56
53
|
|
|
57
54
|
public var body: some View {
|
|
@@ -198,10 +198,8 @@ public struct BadgeRibbon: View {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
///
|
|
202
|
-
///
|
|
203
|
-
/// rotation) — the label gets the same scale applied a second time so it stays right-reading
|
|
204
|
-
/// while only the ribbon shape flips.
|
|
201
|
+
/// Compose's `RoundedBadgeRibbon`: a ribbon sized to its text, mirrored per corner with
|
|
202
|
+
/// scaleX/scaleY (never rotated); the label is scaled again so only the shape flips.
|
|
205
203
|
public struct RoundedBadgeRibbon: View {
|
|
206
204
|
@Environment(\.appTheme) private var theme
|
|
207
205
|
@Environment(\.momoFontScale) private var fontScale
|
|
@@ -312,7 +310,6 @@ extension String {
|
|
|
312
310
|
struct BadgeRibbon_Previews: PreviewProvider {
|
|
313
311
|
static var previews: some View {
|
|
314
312
|
VStack(spacing: 30) {
|
|
315
|
-
// Basic ribbon examples
|
|
316
313
|
BadgeRibbon(position: .topRight, label: "New")
|
|
317
314
|
BadgeRibbon(position: .topLeft, label: "Hot", isRound: true)
|
|
318
315
|
BadgeRibbon(position: .bottomLeft, label: "Sale")
|
package/ios/Button/Button.swift
CHANGED
|
@@ -229,9 +229,8 @@ public struct Button: View {
|
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
///
|
|
233
|
-
/// horizontal inset and the whole button
|
|
234
|
-
/// matching `animatedPadding`/`alpha` in Button.kt.
|
|
232
|
+
/// Compose's press feedback (`animatedPadding` / `alpha` in Button.kt): the background shrinks by an animated
|
|
233
|
+
/// horizontal inset and the whole button fades to 0.5.
|
|
235
234
|
private struct ButtonPressFeedbackStyle: ButtonStyle {
|
|
236
235
|
let isEnabled: Bool
|
|
237
236
|
let background: Color
|
|
@@ -264,11 +263,8 @@ private struct ButtonPressFeedbackStyle: ButtonStyle {
|
|
|
264
263
|
}
|
|
265
264
|
}
|
|
266
265
|
|
|
267
|
-
///
|
|
268
|
-
/// the
|
|
269
|
-
/// the content even when `isFull == false`. iOS 17 fixed the label to hug its
|
|
270
|
-
/// content, so only legacy OSes need the `fixedSize` clamp (kept off on 17+ to
|
|
271
|
-
/// preserve tail truncation of long titles).
|
|
266
|
+
/// The style label takes the full proposed width before iOS 17, stretching the background
|
|
267
|
+
/// past the content; `fixedSize` there only, as on 17+ it would stop long titles truncating.
|
|
272
268
|
private struct HugContentOnLegacyOS: ViewModifier {
|
|
273
269
|
let isFull: Bool
|
|
274
270
|
|
|
@@ -52,8 +52,8 @@ public struct CalculatorKeyboard: View {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
/// Integer `+ - * /` with the usual precedence
|
|
56
|
-
///
|
|
55
|
+
/// Integer `+ - * /` with the usual precedence. Not NSExpression: it crashes when a number or
|
|
56
|
+
/// result leaves `Int` range, where this returns nil.
|
|
57
57
|
static func evaluate(_ expression: String) -> Int? {
|
|
58
58
|
var numbers: [Int] = []
|
|
59
59
|
var operators: [Character] = []
|
|
@@ -92,11 +92,9 @@ public struct CalculatorKeyboard: View {
|
|
|
92
92
|
|
|
93
93
|
var result = terms[0]
|
|
94
94
|
for (sign, term) in zip(signs, terms.dropFirst()) {
|
|
95
|
-
let
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if overflow { return nil }
|
|
99
|
-
result = next
|
|
95
|
+
let step = sign == "+" ? result.addingReportingOverflow(term) : result.subtractingReportingOverflow(term)
|
|
96
|
+
if step.overflow { return nil }
|
|
97
|
+
result = step.partialValue
|
|
100
98
|
}
|
|
101
99
|
return result
|
|
102
100
|
}
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
-
///
|
|
4
|
-
///
|
|
5
|
-
/// Mirrors the Compose API: a paging horizontal carousel driven by an
|
|
6
|
-
/// `itemCount` and a `content` builder that receives the real (modulo) index.
|
|
7
|
-
/// Supports infinite `loop`, `autoplay` with a configurable interval,
|
|
8
|
-
/// inactive-slide `opacity`/`scale` effects, optional `contentPadding`,
|
|
9
|
-
/// snap behavior, and scroll enable/disable. Snap / scroll-index callbacks
|
|
10
|
-
/// report the real item index.
|
|
11
|
-
///
|
|
12
|
-
/// Uses a custom drag-driven pager (not a ScrollView) so behavior is identical
|
|
13
|
-
/// across versions and supports the loop virtualization + transform effects
|
|
14
|
-
/// that `TabView(.page)` cannot express.
|
|
3
|
+
/// Compose `Carousel`; `content` and the snap / scroll-index callbacks get the real (modulo) index. A drag-driven
|
|
4
|
+
/// pager, as ScrollView and `TabView(.page)` can't express the loop virtualization or inactive-slide effects.
|
|
15
5
|
public struct Carousel<Content: View>: View {
|
|
16
6
|
// MARK: Lifecycle
|
|
17
7
|
|
|
@@ -93,11 +83,8 @@ public struct Carousel<Content: View>: View {
|
|
|
93
83
|
// Offset so the current page is centered within the viewport padding.
|
|
94
84
|
let baseOffset = -CGFloat(currentPage) * step + contentPadding
|
|
95
85
|
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
// eager views, a real memory/perf regression versus Compose's lazy `HorizontalPager`.
|
|
99
|
-
// Clear spacers of the skipped width keep the HStack's total layout size (and thus
|
|
100
|
-
// the existing `baseOffset` math) unchanged.
|
|
86
|
+
// Only a window around `currentPage` renders (`loop` means `itemCount * 1000` slides; Compose's
|
|
87
|
+
// pager is lazy); clear spacers of the skipped width keep the HStack size for `baseOffset`.
|
|
101
88
|
let windowRadius = 3
|
|
102
89
|
let windowStart = max(0, currentPage - windowRadius)
|
|
103
90
|
let windowEnd = min(virtualPageCount - 1, currentPage + windowRadius)
|
|
@@ -29,7 +29,6 @@ public struct Checkbox: View{
|
|
|
29
29
|
|
|
30
30
|
public var body: some View {
|
|
31
31
|
HStack(spacing: Spacing.S) {
|
|
32
|
-
// Checkbox
|
|
33
32
|
SwiftUI.Button(action: onCheck) {
|
|
34
33
|
ZStack {
|
|
35
34
|
RoundedRectangle(cornerRadius: Radius.XS)
|
|
@@ -50,7 +49,6 @@ public struct Checkbox: View{
|
|
|
50
49
|
.buttonStyle(ActiveOpacityButtonStyle(activeOpacity: 0.8))
|
|
51
50
|
.disabled(disabled)
|
|
52
51
|
|
|
53
|
-
// Title
|
|
54
52
|
if !title.isEmpty {
|
|
55
53
|
MomoText(title, typography: .descriptionDefaultRegular)
|
|
56
54
|
}
|
|
@@ -94,11 +94,7 @@ public struct Collapse<Content: View>: View {
|
|
|
94
94
|
content()
|
|
95
95
|
}
|
|
96
96
|
.frame(maxWidth: .infinity)
|
|
97
|
-
.overlay(
|
|
98
|
-
showBorder
|
|
99
|
-
? Rectangle().strokeBorder(theme.colors.border.default, lineWidth: 1)
|
|
100
|
-
: nil
|
|
101
|
-
)
|
|
97
|
+
.overlay(contentBorder)
|
|
102
98
|
.transition(.move(edge: .top))
|
|
103
99
|
}
|
|
104
100
|
}
|
|
@@ -108,17 +104,27 @@ public struct Collapse<Content: View>: View {
|
|
|
108
104
|
.frame(maxWidth: .infinity)
|
|
109
105
|
.background(resolvedBackgroundColor)
|
|
110
106
|
.clipShape(RoundedRectangle(cornerRadius: Radius.S, style: .continuous))
|
|
111
|
-
.overlay(
|
|
112
|
-
showBorder
|
|
113
|
-
? RoundedRectangle(cornerRadius: Radius.S, style: .continuous)
|
|
114
|
-
.strokeBorder(theme.colors.border.default, lineWidth: 1)
|
|
115
|
-
: nil
|
|
116
|
-
)
|
|
107
|
+
.overlay(containerBorder)
|
|
117
108
|
// `.contain` keeps the children's own identifiers instead of overriding them.
|
|
118
109
|
.accessibilityElement(children: .contain)
|
|
119
110
|
.accessibilityIdentifier(automationId)
|
|
120
111
|
}
|
|
121
112
|
|
|
113
|
+
@ViewBuilder
|
|
114
|
+
private var contentBorder: some View {
|
|
115
|
+
if showBorder {
|
|
116
|
+
Rectangle().strokeBorder(theme.colors.border.default, lineWidth: 1)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@ViewBuilder
|
|
121
|
+
private var containerBorder: some View {
|
|
122
|
+
if showBorder {
|
|
123
|
+
RoundedRectangle(cornerRadius: Radius.S, style: .continuous)
|
|
124
|
+
.strokeBorder(theme.colors.border.default, lineWidth: 1)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
122
128
|
private var header: some View {
|
|
123
129
|
SwiftUI.Button(action: {
|
|
124
130
|
onPress?(expanded)
|
|
@@ -7,12 +7,8 @@ private let datePickerWithLabelsHeight: CGFloat = 238
|
|
|
7
7
|
|
|
8
8
|
// MARK: - DateTimePicker
|
|
9
9
|
|
|
10
|
-
///
|
|
11
|
-
///
|
|
12
|
-
/// The `format` string drives which columns are shown:
|
|
13
|
-
/// - `DD` day, `MM` month, `YYYY` year, `HH` hour, `mm` minute.
|
|
14
|
-
/// - `"HH:mm"` shows hour + minute; a lone `"HH"` switches the hour wheel to a
|
|
15
|
-
/// 12-hour clock with an AM/PM column.
|
|
10
|
+
/// Wheel date/time picker matching Compose `DateTimePicker`. `format` picks the columns (`DD`, `MM`,
|
|
11
|
+
/// `YYYY`, `HH`, `mm`); a lone `"HH"` switches the hour wheel to a 12-hour clock with an AM/PM column.
|
|
16
12
|
public struct DateTimePicker: View {
|
|
17
13
|
@Environment(\.appTheme) private var theme
|
|
18
14
|
|
|
@@ -39,7 +35,6 @@ public struct DateTimePicker: View {
|
|
|
39
35
|
let effectiveMin = minDate ?? DateTimePickerUtils.createRelativeDate(years: -10)
|
|
40
36
|
let effectiveMax = maxDate ?? DateTimePickerUtils.createRelativeDate(years: 10)
|
|
41
37
|
|
|
42
|
-
// needCheckRange is true only when the caller supplied no bounds.
|
|
43
38
|
let needCheckRange = (minDate == nil && maxDate == nil)
|
|
44
39
|
|
|
45
40
|
self._currentData = State(initialValue: Self.pickerData(
|
|
@@ -222,9 +217,8 @@ public struct DateTimePicker: View {
|
|
|
222
217
|
emitIfValid()
|
|
223
218
|
}
|
|
224
219
|
|
|
225
|
-
///
|
|
226
|
-
///
|
|
227
|
-
/// `snapshotFlow.mapNotNull` filter.
|
|
220
|
+
/// Emits `onChange` only for a valid date, range-checked only when no bounds were supplied
|
|
221
|
+
/// (Compose's `snapshotFlow.mapNotNull` filter).
|
|
228
222
|
private func emitIfValid() {
|
|
229
223
|
guard let date = currentData.toDate() else { return }
|
|
230
224
|
if !needCheckRange {
|
|
@@ -2,8 +2,7 @@ import Foundation
|
|
|
2
2
|
|
|
3
3
|
// MARK: - PickerData
|
|
4
4
|
|
|
5
|
-
///
|
|
6
|
-
/// Mirrors Compose `PickerData`.
|
|
5
|
+
/// The picker's current selection (Compose `PickerData`).
|
|
7
6
|
public struct DateTimePickerData: Equatable {
|
|
8
7
|
public var day: Int
|
|
9
8
|
public var month: Int
|
|
@@ -28,7 +27,6 @@ public struct DateTimePickerData: Equatable {
|
|
|
28
27
|
self.timeMode = timeMode
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
/// Convert to a `DateComponents` based value. Returns `nil` if the date is invalid.
|
|
32
30
|
public func toDate(calendar: Calendar = Calendar.current) -> Date? {
|
|
33
31
|
var components = DateComponents()
|
|
34
32
|
components.year = year
|
|
@@ -38,7 +38,6 @@ public enum DateTimePickerUtils {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/// Number of days in a given month/year.
|
|
42
41
|
private static func daysInMonth(year: Int, month: Int) -> Int {
|
|
43
42
|
switch month {
|
|
44
43
|
case 1, 3, 5, 7, 8, 10, 12: return 31
|
|
@@ -90,7 +89,6 @@ public enum DateTimePickerUtils {
|
|
|
90
89
|
return (startMonth...endMonth).map { paddingNum($0) }
|
|
91
90
|
}
|
|
92
91
|
|
|
93
|
-
/// Get a list of year strings between min and max date.
|
|
94
92
|
public static func getYears(minDate: DateComponents, maxDate: DateComponents) -> [String] {
|
|
95
93
|
let startYear = minDate.year ?? 0
|
|
96
94
|
let endYear = maxDate.year ?? 0
|
|
@@ -120,7 +118,6 @@ public enum DateTimePickerUtils {
|
|
|
120
118
|
return minutes
|
|
121
119
|
}
|
|
122
120
|
|
|
123
|
-
/// Today's date.
|
|
124
121
|
public static func getCurrentDateTime() -> Date {
|
|
125
122
|
return Date()
|
|
126
123
|
}
|
|
@@ -8,10 +8,8 @@ private let wheelPickerBorderWidth: CGFloat = 1
|
|
|
8
8
|
|
|
9
9
|
// MARK: - WheelPicker
|
|
10
10
|
|
|
11
|
-
///
|
|
12
|
-
///
|
|
13
|
-
/// Five rows tall with the selection in the middle row. A drag always settles on a row
|
|
14
|
-
/// (Compose snaps once the scroll stops) and then reports it via `onChange(name, value)`.
|
|
11
|
+
/// Single-column wheel (Compose `WheelPicker.kt`), five rows tall with the selection in the middle.
|
|
12
|
+
/// A drag always settles on a row (Compose snaps once the scroll stops), then reports it via `onChange`.
|
|
15
13
|
public struct WheelPicker: View {
|
|
16
14
|
@Environment(\.appTheme) private var theme
|
|
17
15
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
-
///
|
|
4
|
-
///
|
|
5
|
-
/// relying on a platform-default press indication.
|
|
3
|
+
/// Compose's `Modifier.activeOpacityClickable(activeOpacity:)`: the whole tappable subtree fades to `activeOpacity`
|
|
4
|
+
/// while pressed, instead of a platform-default press indication.
|
|
6
5
|
struct ActiveOpacityButtonStyle: ButtonStyle {
|
|
7
6
|
var activeOpacity: Double = 0.2
|
|
8
7
|
|
|
@@ -4,16 +4,14 @@ import Foundation
|
|
|
4
4
|
private final class MoMoUIKitsBundleToken {}
|
|
5
5
|
|
|
6
6
|
enum MoMoUIKitsResources {
|
|
7
|
+
|
|
7
8
|
static let bundle: Bundle = {
|
|
8
9
|
let bundleName = "MoMoUIKitsResources"
|
|
9
10
|
let tokenBundle = Bundle(for: MoMoUIKitsBundleToken.self)
|
|
10
|
-
let frameworkBundle = Bundle(identifier: "org.cocoapods.MoMoUIKits")
|
|
11
11
|
let candidates = [
|
|
12
12
|
Bundle.main.resourceURL,
|
|
13
13
|
tokenBundle.resourceURL,
|
|
14
|
-
tokenBundle.bundleURL
|
|
15
|
-
frameworkBundle?.resourceURL,
|
|
16
|
-
frameworkBundle?.bundleURL
|
|
14
|
+
tokenBundle.bundleURL
|
|
17
15
|
]
|
|
18
16
|
|
|
19
17
|
for candidate in candidates {
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
// File: ios/Extensions/SkeletonUICompat.swift
|
|
2
|
-
// Created At: 2026-10-07 12:03:28 +07:00
|
|
3
|
-
// Created By: AI
|
|
4
|
-
// AI Agent: Claude Code
|
|
5
|
-
// Model: claude-opus-5-5
|
|
6
|
-
|
|
7
|
-
// AI-GENERATED START: keep SkeletonUI extensions visible to MoMoUIKits clients
|
|
8
1
|
// Unused here on purpose: Swift 5 exposes extension members of every module a dependency imports, so clients
|
|
9
2
|
// that only `import MoMoUIKits` rely on SkeletonUI's (e.g. `Text(String?)` in NativeWidget). Removing it breaks them.
|
|
10
3
|
import SkeletonUI
|
|
11
|
-
// AI-GENERATED END: keep SkeletonUI extensions visible to MoMoUIKits clients
|
package/ios/Icon/Icon.swift
CHANGED
|
@@ -16,12 +16,10 @@ let iconSources: [String: String] = {
|
|
|
16
16
|
return kitIcons.merging(hostIcons.mapValues(\.uri)) { kit, _ in kit }
|
|
17
17
|
}()
|
|
18
18
|
|
|
19
|
-
// Compose defaults `color` to the theme text color
|
|
20
|
-
//
|
|
21
|
-
// unrepresentable sentinel: omitted -> theme text color, `nil` -> untinted.
|
|
19
|
+
// Compose defaults `color` to the theme text color, `null` meaning no tint. Swift can't tell an omitted argument
|
|
20
|
+
// from `nil`, so the default is this unrepresentable sentinel: omitted -> theme text color, `nil` -> untinted.
|
|
22
21
|
public let iconThemeColor = Color(.sRGB, red: -1, green: -1, blue: -1, opacity: -1)
|
|
23
22
|
|
|
24
|
-
// Icon ViewModel
|
|
25
23
|
public struct Icon: View {
|
|
26
24
|
@Environment(\.appTheme) private var theme
|
|
27
25
|
|
|
@@ -55,8 +53,7 @@ public struct Icon: View {
|
|
|
55
53
|
.scaledToFit()
|
|
56
54
|
.foregroundColor(resolvedColor)
|
|
57
55
|
.frame(width: size, height: size)
|
|
58
|
-
//
|
|
59
|
-
// when no explicit label is provided.
|
|
56
|
+
// Compose's auto-generated `contentDescription = "img|$iconUrl"` when no label is given.
|
|
60
57
|
.accessibilityLabel(accessibilityLabel ?? "img|\(uri)")
|
|
61
58
|
} else {
|
|
62
59
|
// Compose keeps the sized box for an unknown key, so layouts don't collapse.
|
|
@@ -8,7 +8,6 @@ public enum IconSize {
|
|
|
8
8
|
case medium
|
|
9
9
|
case small
|
|
10
10
|
|
|
11
|
-
/// Container width/height of the button.
|
|
12
11
|
var containerSize: CGFloat {
|
|
13
12
|
switch self {
|
|
14
13
|
case .large: return 48
|
|
@@ -17,7 +16,6 @@ public enum IconSize {
|
|
|
17
16
|
}
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
/// Glyph size of the icon inside the button.
|
|
21
19
|
var iconSize: CGFloat {
|
|
22
20
|
switch self {
|
|
23
21
|
case .large: return 24
|
|
@@ -120,9 +118,8 @@ public struct IconButton: View {
|
|
|
120
118
|
}
|
|
121
119
|
}
|
|
122
120
|
|
|
123
|
-
///
|
|
124
|
-
///
|
|
125
|
-
/// erasure at the deployment target's iOS 15 floor.
|
|
121
|
+
/// Compose's `IconShape.toShape()` (`Circle` or a `Radius.S` rounded rect), type-erased by hand: `AnyShape` needs
|
|
122
|
+
/// iOS 17+ and the pod supports iOS 15.
|
|
126
123
|
private struct IconButtonShape: InsettableShape {
|
|
127
124
|
let shape: IconShape
|
|
128
125
|
var insetAmount: CGFloat = 0
|
package/ios/Input/Input.swift
CHANGED
|
@@ -101,10 +101,8 @@ public struct Input: View {
|
|
|
101
101
|
let textBinding = Binding<String>(
|
|
102
102
|
get: { self.text },
|
|
103
103
|
set: { newValue in
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
-
// render with the untrimmed value that a separate `.onChange` correction
|
|
107
|
-
// would otherwise briefly show.
|
|
104
|
+
// Trimmed before publishing, like Compose's `newText.take(maxLength)`: an `.onChange`
|
|
105
|
+
// correction would briefly render the untrimmed value.
|
|
108
106
|
let limited = limitText(newValue)
|
|
109
107
|
self.text = limited
|
|
110
108
|
self.onChangeText?(limited)
|
|
@@ -112,15 +110,12 @@ public struct Input: View {
|
|
|
112
110
|
)
|
|
113
111
|
|
|
114
112
|
VStack(alignment: .leading, spacing: 0) {
|
|
115
|
-
// Input container
|
|
116
113
|
HStack(alignment: .center, spacing: 0) {
|
|
117
|
-
// Leading icon
|
|
118
114
|
if !leadingIcon.isEmpty {
|
|
119
115
|
Icon(source: leadingIcon, size: size == .small ? 24 : 32, color: leadingIconColor ?? theme.colors.text.hint)
|
|
120
116
|
.padding(.trailing, Spacing.M)
|
|
121
117
|
}
|
|
122
118
|
|
|
123
|
-
// Text input field
|
|
124
119
|
ZStack(alignment: .leading) {
|
|
125
120
|
if text.isEmpty {
|
|
126
121
|
MomoText(
|
|
@@ -162,16 +157,12 @@ public struct Input: View {
|
|
|
162
157
|
.onAppear {
|
|
163
158
|
if autofocus { isFieldFocused = true }
|
|
164
159
|
}
|
|
165
|
-
// SwiftUI reads
|
|
166
|
-
//
|
|
167
|
-
// change is silently dropped. The secure path can call
|
|
168
|
-
// `reloadInputViews()` in `updateUIView`; here the only lever
|
|
169
|
-
// is to force a rebuild.
|
|
160
|
+
// SwiftUI reads UIKit input traits only when it builds the UITextField, so a later
|
|
161
|
+
// `keyboardType` change is dropped; force a rebuild.
|
|
170
162
|
.id(keyboardType.rawValue)
|
|
171
163
|
}
|
|
172
164
|
}
|
|
173
165
|
|
|
174
|
-
// Clear button (only show when focused and has text)
|
|
175
166
|
if isFocused && !text.isEmpty {
|
|
176
167
|
SwiftUI.Button(action: {
|
|
177
168
|
text = ""
|
|
@@ -183,7 +174,6 @@ public struct Input: View {
|
|
|
183
174
|
.accessibilityIdentifier("ic_clear")
|
|
184
175
|
}
|
|
185
176
|
|
|
186
|
-
// Loading indicator
|
|
187
177
|
if loading {
|
|
188
178
|
ActivityIndicator(isAnimating: .constant(true), style: .medium, color: getRightIconColor())
|
|
189
179
|
.frame(width: 16, height: 16)
|
|
@@ -220,7 +210,6 @@ public struct Input: View {
|
|
|
220
210
|
)
|
|
221
211
|
.overlay(alignment: .topLeading) { floatingLabel }
|
|
222
212
|
|
|
223
|
-
// Error or hint
|
|
224
213
|
ErrorView(
|
|
225
214
|
errorMessage: error,
|
|
226
215
|
errorSpacing: errorSpacing,
|
|
@@ -252,7 +241,9 @@ public struct Input: View {
|
|
|
252
241
|
}
|
|
253
242
|
.padding(.horizontal, Spacing.S)
|
|
254
243
|
.background(theme.colors.background.surface)
|
|
255
|
-
|
|
244
|
+
// A zero-height frame on the top edge centers the label on the border, re-laid out with font scale.
|
|
245
|
+
.fixedSize(horizontal: false, vertical: true)
|
|
246
|
+
.frame(height: 0)
|
|
256
247
|
.offset(x: Spacing.S)
|
|
257
248
|
}
|
|
258
249
|
}
|
|
@@ -407,10 +398,8 @@ private struct SecureInputField: UIViewRepresentable {
|
|
|
407
398
|
self.parent = parent
|
|
408
399
|
}
|
|
409
400
|
|
|
410
|
-
//
|
|
411
|
-
//
|
|
412
|
-
// replace ALL of it. Re-inserting via insertText() puts it back into an
|
|
413
|
-
// "active editing" state (and moves the caret to the end).
|
|
401
|
+
// A secure field regaining focus (or turning secure mid-edit) marks its text committed, so
|
|
402
|
+
// the next keystroke would replace all of it; re-inserting resumes editing, caret at the end.
|
|
414
403
|
func reinsertText(in textField: UITextField) {
|
|
415
404
|
let existingText = textField.text ?? ""
|
|
416
405
|
guard !existingText.isEmpty else { return }
|