@momo-kits/native-kits 0.163.1-sp.8 → 0.163.2-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/.codegraph/.gitignore +5 -0
- package/CLAUDE.md +0 -10
- package/build.gradle.kts +11 -0
- package/compose/build.gradle.kts +190 -0
- package/compose/build.gradle.kts.backup +190 -0
- package/compose/compose.podspec +47 -0
- package/compose/src/androidMain/kotlin/vn/momo/kits/navigation/ScrollToTop.android.kt +6 -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 +150 -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 +52 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Context.kt +106 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/FloatingButton.kt +183 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Header.kt +207 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/HeaderAnimated.kt +39 -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 +293 -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 +826 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Localize.kt +269 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/NavigationContainer.kt +110 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/Screen.kt +378 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/application/WidgetContainer.kt +56 -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 +82 -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 +356 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Carousel.kt +113 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CheckBox.kt +89 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Chip.kt +128 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Collapse.kt +209 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/CupertinoOverscroll.kt +542 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Divider.kt +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 +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Image.kt +231 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Information.kt +112 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +477 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputDropDown.kt +114 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputMoney.kt +214 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputOTP.kt +240 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputPhoneNumber.kt +216 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +259 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +182 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/LazyColumnWithBouncing.kt +343 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Loader.kt +108 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationDot.kt +56 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationNumber.kt +41 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationScroll.kt +84 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PaginationWhiteDot.kt +40 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupNotify.kt +328 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/PopupPromotion.kt +97 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ProgressInfo.kt +310 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Radio.kt +59 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Rating.kt +87 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/ScaleSizeScope.kt +21 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Skeleton.kt +90 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Slider.kt +323 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Stepper.kt +217 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Steps.kt +473 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/SuggestAction.kt +122 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Swipe.kt +199 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Switch.kt +91 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/TabView.kt +470 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Tag.kt +88 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Text.kt +131 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +203 -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 +175 -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 +234 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/datetimepicker/WheelPicker.kt +188 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Colors.kt +325 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitFontScale.kt +22 -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 +276 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +52 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +38 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Section.kt +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/AutomationId.kt +52 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Clickable.kt +66 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Conditional.kt +11 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/DeprecatedModifier.kt +104 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Shadow.kt +48 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/modifier/Size.kt +51 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/BottomSheet.kt +299 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/ModalScreen.kt +129 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigation.kt +100 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +172 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +372 -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 +581 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTab.kt +156 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/bottomtab/BottomTabBar.kt +225 -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 +169 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +320 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +81 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +309 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderTitle.kt +34 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +360 -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 +127 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/ComposeLottieAnimation.kt +91 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/OsFontScale.kt +9 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/platform/Platform.kt +69 -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 +105 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/navigation/ScrollToTop.ios.kt +32 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/OsFontScale.ios.kt +66 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +207 -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 +69 -0
- package/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/gradle.properties +26 -0
- package/gradlew +252 -0
- package/gradlew.bat +94 -0
- package/ios/Application/ApplicationEnvironment.swift +4 -6
- package/ios/Application/HeaderRight.swift +17 -1
- package/ios/Application/Localize.swift +4 -73
- package/ios/Application/Navigation/NavigationContainer.swift +18 -25
- package/ios/Application/Navigation/Navigator.swift +29 -91
- package/ios/Application/StackScreen.swift +21 -18
- package/ios/Badge/BadgeRibbon.swift +1 -4
- package/ios/Button/Button.swift +61 -41
- package/ios/Icon/Icon.swift +4 -13
- package/ios/native-kits.podspec +1 -2
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/README.md +120 -0
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/ButtonDemo.swift +8 -8
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/CheckboxDemo.swift +2 -3
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/Home.swift +12 -5
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/LocalizeDemo.swift +4 -51
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/NavigationDemo.swift +2 -14
- package/ios-demo/Sources/MoMoUIKitsDemo/SwiftUIDemoBrowserView.swift +1 -3
- package/local.properties +8 -0
- package/package.json +1 -1
- package/settings.gradle.kts +64 -0
- package/.claude/settings.local.json +0 -158
- package/ios/Application/LanguageSource.swift +0 -93
- package/ios/Application/LocalizeModifier.swift +0 -30
- package/ios/Application/Navigation/NavigatorManager.swift +0 -49
- package/ios/Application/Navigation/component/NavigationFooter.swift +0 -90
- package/ios/Layout/GridContext.swift +0 -30
- package/ios/Layout/Item.swift +0 -42
- package/ios/Layout/Section.swift +0 -134
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/IconDemo.swift +0 -104
- package/ios-demo/Sources/MoMoUIKitsDemo/SampleDemos/SectionDemo.swift +0 -100
package/gradlew
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
#
|
|
4
|
+
# Copyright © 2015-2021 the original authors.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
##############################################################################
|
|
22
|
+
#
|
|
23
|
+
# Gradle start up script for POSIX generated by Gradle.
|
|
24
|
+
#
|
|
25
|
+
# Important for running:
|
|
26
|
+
#
|
|
27
|
+
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
28
|
+
# noncompliant, but you have some other compliant shell such as ksh or
|
|
29
|
+
# bash, then to run this script, type that shell name before the whole
|
|
30
|
+
# command line, like:
|
|
31
|
+
#
|
|
32
|
+
# ksh Gradle
|
|
33
|
+
#
|
|
34
|
+
# Busybox and similar reduced shells will NOT work, because this script
|
|
35
|
+
# requires all of these POSIX shell features:
|
|
36
|
+
# * functions;
|
|
37
|
+
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
38
|
+
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
39
|
+
# * compound commands having a testable exit status, especially «case»;
|
|
40
|
+
# * various built-in commands including «command», «set», and «ulimit».
|
|
41
|
+
#
|
|
42
|
+
# Important for patching:
|
|
43
|
+
#
|
|
44
|
+
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
45
|
+
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
46
|
+
#
|
|
47
|
+
# The "traditional" practice of packing multiple parameters into a
|
|
48
|
+
# space-separated string is a well documented source of bugs and security
|
|
49
|
+
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
50
|
+
# options in "$@", and eventually passing that to Java.
|
|
51
|
+
#
|
|
52
|
+
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
53
|
+
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
54
|
+
# see the in-line comments for details.
|
|
55
|
+
#
|
|
56
|
+
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
57
|
+
# Darwin, MinGW, and NonStop.
|
|
58
|
+
#
|
|
59
|
+
# (3) This script is generated from the Groovy template
|
|
60
|
+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
61
|
+
# within the Gradle project.
|
|
62
|
+
#
|
|
63
|
+
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
64
|
+
#
|
|
65
|
+
##############################################################################
|
|
66
|
+
|
|
67
|
+
# Attempt to set APP_HOME
|
|
68
|
+
|
|
69
|
+
# Resolve links: $0 may be a link
|
|
70
|
+
app_path=$0
|
|
71
|
+
|
|
72
|
+
# Need this for daisy-chained symlinks.
|
|
73
|
+
while
|
|
74
|
+
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
|
75
|
+
[ -h "$app_path" ]
|
|
76
|
+
do
|
|
77
|
+
ls=$( ls -ld "$app_path" )
|
|
78
|
+
link=${ls#*' -> '}
|
|
79
|
+
case $link in #(
|
|
80
|
+
/*) app_path=$link ;; #(
|
|
81
|
+
*) app_path=$APP_HOME$link ;;
|
|
82
|
+
esac
|
|
83
|
+
done
|
|
84
|
+
|
|
85
|
+
# This is normally unused
|
|
86
|
+
# shellcheck disable=SC2034
|
|
87
|
+
APP_BASE_NAME=${0##*/}
|
|
88
|
+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
|
89
|
+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
|
90
|
+
' "$PWD" ) || exit
|
|
91
|
+
|
|
92
|
+
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
93
|
+
MAX_FD=maximum
|
|
94
|
+
|
|
95
|
+
warn () {
|
|
96
|
+
echo "$*"
|
|
97
|
+
} >&2
|
|
98
|
+
|
|
99
|
+
die () {
|
|
100
|
+
echo
|
|
101
|
+
echo "$*"
|
|
102
|
+
echo
|
|
103
|
+
exit 1
|
|
104
|
+
} >&2
|
|
105
|
+
|
|
106
|
+
# OS specific support (must be 'true' or 'false').
|
|
107
|
+
cygwin=false
|
|
108
|
+
msys=false
|
|
109
|
+
darwin=false
|
|
110
|
+
nonstop=false
|
|
111
|
+
case "$( uname )" in #(
|
|
112
|
+
CYGWIN* ) cygwin=true ;; #(
|
|
113
|
+
Darwin* ) darwin=true ;; #(
|
|
114
|
+
MSYS* | MINGW* ) msys=true ;; #(
|
|
115
|
+
NONSTOP* ) nonstop=true ;;
|
|
116
|
+
esac
|
|
117
|
+
|
|
118
|
+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
# Determine the Java command to use to start the JVM.
|
|
122
|
+
if [ -n "$JAVA_HOME" ] ; then
|
|
123
|
+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
124
|
+
# IBM's JDK on AIX uses strange locations for the executables
|
|
125
|
+
JAVACMD=$JAVA_HOME/jre/sh/java
|
|
126
|
+
else
|
|
127
|
+
JAVACMD=$JAVA_HOME/bin/java
|
|
128
|
+
fi
|
|
129
|
+
if [ ! -x "$JAVACMD" ] ; then
|
|
130
|
+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
131
|
+
|
|
132
|
+
Please set the JAVA_HOME variable in your environment to match the
|
|
133
|
+
location of your Java installation."
|
|
134
|
+
fi
|
|
135
|
+
else
|
|
136
|
+
JAVACMD=java
|
|
137
|
+
if ! command -v java >/dev/null 2>&1
|
|
138
|
+
then
|
|
139
|
+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
140
|
+
|
|
141
|
+
Please set the JAVA_HOME variable in your environment to match the
|
|
142
|
+
location of your Java installation."
|
|
143
|
+
fi
|
|
144
|
+
fi
|
|
145
|
+
|
|
146
|
+
# Increase the maximum file descriptors if we can.
|
|
147
|
+
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
148
|
+
case $MAX_FD in #(
|
|
149
|
+
max*)
|
|
150
|
+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
|
151
|
+
# shellcheck disable=SC2039,SC3045
|
|
152
|
+
MAX_FD=$( ulimit -H -n ) ||
|
|
153
|
+
warn "Could not query maximum file descriptor limit"
|
|
154
|
+
esac
|
|
155
|
+
case $MAX_FD in #(
|
|
156
|
+
'' | soft) :;; #(
|
|
157
|
+
*)
|
|
158
|
+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
|
159
|
+
# shellcheck disable=SC2039,SC3045
|
|
160
|
+
ulimit -n "$MAX_FD" ||
|
|
161
|
+
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
162
|
+
esac
|
|
163
|
+
fi
|
|
164
|
+
|
|
165
|
+
# Collect all arguments for the java command, stacking in reverse order:
|
|
166
|
+
# * args from the command line
|
|
167
|
+
# * the main class name
|
|
168
|
+
# * -classpath
|
|
169
|
+
# * -D...appname settings
|
|
170
|
+
# * --module-path (only if needed)
|
|
171
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
172
|
+
|
|
173
|
+
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
174
|
+
if "$cygwin" || "$msys" ; then
|
|
175
|
+
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
176
|
+
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
177
|
+
|
|
178
|
+
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
179
|
+
|
|
180
|
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
181
|
+
for arg do
|
|
182
|
+
if
|
|
183
|
+
case $arg in #(
|
|
184
|
+
-*) false ;; # don't mess with options #(
|
|
185
|
+
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
186
|
+
[ -e "$t" ] ;; #(
|
|
187
|
+
*) false ;;
|
|
188
|
+
esac
|
|
189
|
+
then
|
|
190
|
+
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
191
|
+
fi
|
|
192
|
+
# Roll the args list around exactly as many times as the number of
|
|
193
|
+
# args, so each arg winds up back in the position where it started, but
|
|
194
|
+
# possibly modified.
|
|
195
|
+
#
|
|
196
|
+
# NB: a `for` loop captures its iteration list before it begins, so
|
|
197
|
+
# changing the positional parameters here affects neither the number of
|
|
198
|
+
# iterations, nor the values presented in `arg`.
|
|
199
|
+
shift # remove old arg
|
|
200
|
+
set -- "$@" "$arg" # push replacement arg
|
|
201
|
+
done
|
|
202
|
+
fi
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
206
|
+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
207
|
+
|
|
208
|
+
# Collect all arguments for the java command:
|
|
209
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
210
|
+
# and any embedded shellness will be escaped.
|
|
211
|
+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
212
|
+
# treated as '${Hostname}' itself on the command line.
|
|
213
|
+
|
|
214
|
+
set -- \
|
|
215
|
+
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
216
|
+
-classpath "$CLASSPATH" \
|
|
217
|
+
org.gradle.wrapper.GradleWrapperMain \
|
|
218
|
+
"$@"
|
|
219
|
+
|
|
220
|
+
# Stop when "xargs" is not available.
|
|
221
|
+
if ! command -v xargs >/dev/null 2>&1
|
|
222
|
+
then
|
|
223
|
+
die "xargs is not available"
|
|
224
|
+
fi
|
|
225
|
+
|
|
226
|
+
# Use "xargs" to parse quoted args.
|
|
227
|
+
#
|
|
228
|
+
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
229
|
+
#
|
|
230
|
+
# In Bash we could simply go:
|
|
231
|
+
#
|
|
232
|
+
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
233
|
+
# set -- "${ARGS[@]}" "$@"
|
|
234
|
+
#
|
|
235
|
+
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
236
|
+
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
237
|
+
# character that might be a shell metacharacter, then use eval to reverse
|
|
238
|
+
# that process (while maintaining the separation between arguments), and wrap
|
|
239
|
+
# the whole thing up as a single "set" statement.
|
|
240
|
+
#
|
|
241
|
+
# This will of course break if any of these variables contains a newline or
|
|
242
|
+
# an unmatched quote.
|
|
243
|
+
#
|
|
244
|
+
|
|
245
|
+
eval "set -- $(
|
|
246
|
+
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
247
|
+
xargs -n1 |
|
|
248
|
+
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
249
|
+
tr '\n' ' '
|
|
250
|
+
)" '"$@"'
|
|
251
|
+
|
|
252
|
+
exec "$JAVACMD" "$@"
|
package/gradlew.bat
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
@rem
|
|
2
|
+
@rem Copyright 2015 the original author or authors.
|
|
3
|
+
@rem
|
|
4
|
+
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
@rem you may not use this file except in compliance with the License.
|
|
6
|
+
@rem You may obtain a copy of the License at
|
|
7
|
+
@rem
|
|
8
|
+
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
@rem
|
|
10
|
+
@rem Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
@rem See the License for the specific language governing permissions and
|
|
14
|
+
@rem limitations under the License.
|
|
15
|
+
@rem
|
|
16
|
+
@rem SPDX-License-Identifier: Apache-2.0
|
|
17
|
+
@rem
|
|
18
|
+
|
|
19
|
+
@if "%DEBUG%"=="" @echo off
|
|
20
|
+
@rem ##########################################################################
|
|
21
|
+
@rem
|
|
22
|
+
@rem Gradle startup script for Windows
|
|
23
|
+
@rem
|
|
24
|
+
@rem ##########################################################################
|
|
25
|
+
|
|
26
|
+
@rem Set local scope for the variables with windows NT shell
|
|
27
|
+
if "%OS%"=="Windows_NT" setlocal
|
|
28
|
+
|
|
29
|
+
set DIRNAME=%~dp0
|
|
30
|
+
if "%DIRNAME%"=="" set DIRNAME=.
|
|
31
|
+
@rem This is normally unused
|
|
32
|
+
set APP_BASE_NAME=%~n0
|
|
33
|
+
set APP_HOME=%DIRNAME%
|
|
34
|
+
|
|
35
|
+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
36
|
+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
37
|
+
|
|
38
|
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
39
|
+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
|
40
|
+
|
|
41
|
+
@rem Find java.exe
|
|
42
|
+
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
43
|
+
|
|
44
|
+
set JAVA_EXE=java.exe
|
|
45
|
+
%JAVA_EXE% -version >NUL 2>&1
|
|
46
|
+
if %ERRORLEVEL% equ 0 goto execute
|
|
47
|
+
|
|
48
|
+
echo. 1>&2
|
|
49
|
+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
|
50
|
+
echo. 1>&2
|
|
51
|
+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
52
|
+
echo location of your Java installation. 1>&2
|
|
53
|
+
|
|
54
|
+
goto fail
|
|
55
|
+
|
|
56
|
+
:findJavaFromJavaHome
|
|
57
|
+
set JAVA_HOME=%JAVA_HOME:"=%
|
|
58
|
+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
59
|
+
|
|
60
|
+
if exist "%JAVA_EXE%" goto execute
|
|
61
|
+
|
|
62
|
+
echo. 1>&2
|
|
63
|
+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
|
64
|
+
echo. 1>&2
|
|
65
|
+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
66
|
+
echo location of your Java installation. 1>&2
|
|
67
|
+
|
|
68
|
+
goto fail
|
|
69
|
+
|
|
70
|
+
:execute
|
|
71
|
+
@rem Setup the command line
|
|
72
|
+
|
|
73
|
+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@rem Execute Gradle
|
|
77
|
+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
|
78
|
+
|
|
79
|
+
:end
|
|
80
|
+
@rem End local scope for the variables with windows NT shell
|
|
81
|
+
if %ERRORLEVEL% equ 0 goto mainEnd
|
|
82
|
+
|
|
83
|
+
:fail
|
|
84
|
+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
85
|
+
rem the _cmd.exe /c_ return code!
|
|
86
|
+
set EXIT_CODE=%ERRORLEVEL%
|
|
87
|
+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
|
88
|
+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
89
|
+
exit /b %EXIT_CODE%
|
|
90
|
+
|
|
91
|
+
:mainEnd
|
|
92
|
+
if "%OS%"=="Windows_NT" endlocal
|
|
93
|
+
|
|
94
|
+
:omega
|
|
@@ -38,12 +38,10 @@ public class KitConfig {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
public class ApplicationEnvironment: ObservableObject {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
public let maxApi: MaxApi?
|
|
46
|
-
// AI-GENERATED END: expose the host bridge to modules outside MoMoUIKits (e.g. the demo pod)
|
|
41
|
+
let applicationContext: MiniAppContext?
|
|
42
|
+
let composeApi: KitComposeApi?
|
|
43
|
+
let config: KitConfig?
|
|
44
|
+
let maxApi: MaxApi?
|
|
47
45
|
|
|
48
46
|
public init(applicationContext: MiniAppContext? = nil, composeApi: KitComposeApi? = nil, config: KitConfig? = nil, maxApi: MaxApi? = nil) {
|
|
49
47
|
self.applicationContext = applicationContext
|
|
@@ -105,9 +105,25 @@ struct ToolkitHeaderRight: View {
|
|
|
105
105
|
|
|
106
106
|
// MARK: - Actions
|
|
107
107
|
private func onPressShortcut() {
|
|
108
|
+
// onToolAction needs the app context (appId/code) so the host knows which app to (un)favorite;
|
|
109
|
+
// without it the favorite is a no-op. Mirrors onPressMore below and the Compose HeaderRight.
|
|
110
|
+
let context = environment.applicationContext
|
|
108
111
|
environment.composeApi?.request(
|
|
109
112
|
funcName: "onToolAction",
|
|
110
|
-
params: [
|
|
113
|
+
params: [
|
|
114
|
+
"item": ["key": "onFavorite"],
|
|
115
|
+
"context": [
|
|
116
|
+
"appId": context?.appId,
|
|
117
|
+
"code": context?.appCode,
|
|
118
|
+
"name": context?.appName,
|
|
119
|
+
"icon": context?.appIcon,
|
|
120
|
+
"description": context?.description,
|
|
121
|
+
"support": context?.support,
|
|
122
|
+
"toolkitConfig": context?.toolkitConfig,
|
|
123
|
+
"providerId": context?.providerId,
|
|
124
|
+
"permissions": context?.permissions
|
|
125
|
+
]
|
|
126
|
+
]
|
|
111
127
|
) { _ in
|
|
112
128
|
isFavorite.toggle()
|
|
113
129
|
}
|
|
@@ -28,69 +28,16 @@ public final class Localize: ObservableObject {
|
|
|
28
28
|
public static let VI = "vi"
|
|
29
29
|
public static let EN = "en"
|
|
30
30
|
|
|
31
|
-
// AI-GENERATED START: follow the host app language and publish dictionary changes
|
|
32
|
-
/// App-wide instance bound to the host language; the environment default uses it too,
|
|
33
|
-
/// so every screen agrees on one language.
|
|
34
|
-
public static let shared = Localize()
|
|
35
|
-
// AI-GENERATED END: follow the host app language and publish dictionary changes
|
|
36
|
-
|
|
37
31
|
private var assets: LocalizationObject
|
|
38
32
|
@Published public private(set) var currentLanguage: String = Localize.VI
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
/// Bumped by `addTranslations` — `assets` is not published, so without this the dictionary
|
|
42
|
-
/// can change without any consumer re-rendering.
|
|
43
|
-
@Published public private(set) var revision: Int = 0
|
|
44
|
-
|
|
45
|
-
private let languageSource: LanguageSource?
|
|
46
|
-
|
|
47
|
-
/// `NavigationContainer` uses this to skip its legacy one-shot `MaxApi` pull.
|
|
48
|
-
var observesAppLanguage: Bool { languageSource != nil }
|
|
49
|
-
|
|
50
|
-
/// Pass `languageSource: nil` to opt out and keep the old "starts at vi" behavior.
|
|
51
|
-
public init(
|
|
52
|
-
_ translations: LocalizationObject = LocalizationObject(),
|
|
53
|
-
languageSource: LanguageSource? = UserDefaultsLanguageSource()
|
|
54
|
-
) {
|
|
34
|
+
public init(_ translations: LocalizationObject = LocalizationObject()) {
|
|
55
35
|
self.assets = Localize.merge(base: Localize.defaultLanguage, override: translations)
|
|
56
|
-
self.languageSource = languageSource
|
|
57
|
-
guard let languageSource else { return }
|
|
58
|
-
// Seed synchronously so the first frame is already correct (no vi -> en flash).
|
|
59
|
-
currentLanguage = languageSource.currentLanguage
|
|
60
|
-
languageSource.startObserving { [weak self] language in self?.apply(language) }
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
deinit {
|
|
64
|
-
languageSource?.stopObserving()
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/// Host values are sometimes legacy JSON-quoted (`"\"vi\""`); anything that is not `en` is `vi`.
|
|
68
|
-
public static func normalize(_ raw: String?) -> String {
|
|
69
|
-
let cleaned = (raw ?? "")
|
|
70
|
-
.replacingOccurrences(of: "\"", with: "")
|
|
71
|
-
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
72
|
-
.lowercased()
|
|
73
|
-
return cleaned == Localize.EN ? Localize.EN : Localize.VI
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
private func apply(_ language: String) {
|
|
77
|
-
// KVO and didChangeNotification both fire for one write; publish once, on main.
|
|
78
|
-
onMain {
|
|
79
|
-
guard self.currentLanguage != language else { return }
|
|
80
|
-
self.currentLanguage = language
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/// Synchronous when already on main — an async hop would defer the switch by a frame.
|
|
85
|
-
private func onMain(_ work: @escaping () -> Void) {
|
|
86
|
-
if Thread.isMainThread { work() } else { DispatchQueue.main.async(execute: work) }
|
|
87
36
|
}
|
|
88
37
|
|
|
89
|
-
/// A local override: the next host language change supersedes it.
|
|
90
38
|
public func changeLanguage(_ language: String?) {
|
|
91
|
-
|
|
39
|
+
currentLanguage = (language == Localize.EN) ? Localize.EN : Localize.VI
|
|
92
40
|
}
|
|
93
|
-
// AI-GENERATED END: follow the host app language and publish dictionary changes
|
|
94
41
|
|
|
95
42
|
public func translate(_ key: String) -> String {
|
|
96
43
|
let dictionary = currentLanguage == Localize.EN ? assets.en : assets.vi
|
|
@@ -111,9 +58,6 @@ public final class Localize: ObservableObject {
|
|
|
111
58
|
/// Existing keys win (mirrors Compose: `merge(translations, assets)`).
|
|
112
59
|
public func addTranslations(_ translations: LocalizationObject) {
|
|
113
60
|
assets = Localize.merge(base: translations, override: assets)
|
|
114
|
-
// AI-GENERATED START: publish dictionary changes so consumers re-render
|
|
115
|
-
onMain { self.revision &+= 1 }
|
|
116
|
-
// AI-GENERATED END: publish dictionary changes so consumers re-render
|
|
117
61
|
}
|
|
118
62
|
|
|
119
63
|
private static func merge(base: LocalizationObject, override: LocalizationObject) -> LocalizationObject {
|
|
@@ -339,22 +283,14 @@ public final class Localize: ObservableObject {
|
|
|
339
283
|
private struct LocalizeBox: Equatable {
|
|
340
284
|
let localize: Localize
|
|
341
285
|
let language: String
|
|
342
|
-
// AI-GENERATED START: invalidate consumers when the dictionary changes, not just the language
|
|
343
|
-
let revision: Int
|
|
344
|
-
// AI-GENERATED END: invalidate consumers when the dictionary changes, not just the language
|
|
345
286
|
|
|
346
287
|
init(_ localize: Localize) {
|
|
347
288
|
self.localize = localize
|
|
348
289
|
self.language = localize.currentLanguage
|
|
349
|
-
// AI-GENERATED START: invalidate consumers when the dictionary changes, not just the language
|
|
350
|
-
self.revision = localize.revision
|
|
351
|
-
// AI-GENERATED END: invalidate consumers when the dictionary changes, not just the language
|
|
352
290
|
}
|
|
353
291
|
|
|
354
292
|
static func == (lhs: LocalizeBox, rhs: LocalizeBox) -> Bool {
|
|
355
|
-
|
|
356
|
-
lhs.localize === rhs.localize && lhs.language == rhs.language && lhs.revision == rhs.revision
|
|
357
|
-
// AI-GENERATED END: invalidate consumers when the dictionary changes, not just the language
|
|
293
|
+
lhs.localize === rhs.localize && lhs.language == rhs.language
|
|
358
294
|
}
|
|
359
295
|
}
|
|
360
296
|
|
|
@@ -362,12 +298,7 @@ private struct LocalizeKey: EnvironmentKey {
|
|
|
362
298
|
/// A default-constructed `Localize` already carries the full kit dictionary, so a
|
|
363
299
|
/// consumer that never injects one renders untranslated-but-correct text instead of
|
|
364
300
|
/// trapping the way `@EnvironmentObject` does.
|
|
365
|
-
|
|
366
|
-
/// `defaultValue` is a `static let`, so this box is never rebuilt: without a provider the
|
|
367
|
-
/// language is right on first render but does not live-update. Wrap the root in
|
|
368
|
-
/// `.momoLocalize()` (or use `NavigationContainer`) to get updates.
|
|
369
|
-
static let defaultValue = LocalizeBox(Localize.shared)
|
|
370
|
-
// AI-GENERATED END: default to the app-language-observing shared instance
|
|
301
|
+
static let defaultValue = LocalizeBox(Localize())
|
|
371
302
|
}
|
|
372
303
|
|
|
373
304
|
public extension EnvironmentValues {
|
|
@@ -46,9 +46,7 @@ public struct NavigationContainer<Initial: View>: View {
|
|
|
46
46
|
maxApi: maxApi
|
|
47
47
|
)
|
|
48
48
|
)
|
|
49
|
-
|
|
50
|
-
_localize = StateObject(wrappedValue: localize ?? Localize.shared)
|
|
51
|
-
// AI-GENERATED END: default to the app-language-observing shared Localize
|
|
49
|
+
_localize = StateObject(wrappedValue: localize ?? Localize())
|
|
52
50
|
self.composeApi = composeApi
|
|
53
51
|
self.maxApi = maxApi
|
|
54
52
|
self.setNavigator = setNavigator
|
|
@@ -64,17 +62,15 @@ public struct NavigationContainer<Initial: View>: View {
|
|
|
64
62
|
.environmentObject(navigator)
|
|
65
63
|
.environmentObject(applicationEnvironment)
|
|
66
64
|
.environment(\.applicationEnvironment, applicationEnvironment)
|
|
67
|
-
|
|
68
|
-
.
|
|
69
|
-
// AI-GENERATED END: route Localize injection through the observing modifier
|
|
65
|
+
.environmentObject(localize)
|
|
66
|
+
.environment(\.localize, localize)
|
|
70
67
|
.fullScreenCover(item: $navigator.presented) { route in
|
|
71
68
|
screenView(forDialog: route)
|
|
72
69
|
.environmentObject(navigator)
|
|
73
70
|
.environmentObject(applicationEnvironment)
|
|
74
71
|
.environment(\.applicationEnvironment, applicationEnvironment)
|
|
75
|
-
|
|
76
|
-
.
|
|
77
|
-
// AI-GENERATED END: route Localize injection through the observing modifier
|
|
72
|
+
.environmentObject(localize)
|
|
73
|
+
.environment(\.localize, localize)
|
|
78
74
|
}
|
|
79
75
|
.overlay {
|
|
80
76
|
if let item = navigator.overplay {
|
|
@@ -82,9 +78,8 @@ public struct NavigationContainer<Initial: View>: View {
|
|
|
82
78
|
.environmentObject(navigator)
|
|
83
79
|
.environmentObject(applicationEnvironment)
|
|
84
80
|
.environment(\.applicationEnvironment, applicationEnvironment)
|
|
85
|
-
|
|
86
|
-
.
|
|
87
|
-
// AI-GENERATED END: route Localize injection through the observing modifier
|
|
81
|
+
.environmentObject(localize)
|
|
82
|
+
.environment(\.localize, localize)
|
|
88
83
|
}
|
|
89
84
|
}
|
|
90
85
|
.onAppear {
|
|
@@ -92,21 +87,13 @@ public struct NavigationContainer<Initial: View>: View {
|
|
|
92
87
|
navigator.composeApi = composeApi
|
|
93
88
|
}
|
|
94
89
|
setNavigator?(navigator)
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
NavigatorManager.shared.push(navigator)
|
|
98
|
-
// AI-GENERATED START: demote the MaxApi language pull to a seed of last resort
|
|
99
|
-
// Only a seed: a Localize with a language source already tracks the host in both
|
|
100
|
-
// directions, so asking maxApi would just race it. `changeLanguage` normalizes the
|
|
101
|
-
// raw response and hops to main itself.
|
|
102
|
-
guard !localize.observesAppLanguage else { return }
|
|
90
|
+
// Mirrors Compose's LaunchedEffect(maxApi, resolvedLocalize): host-reported
|
|
91
|
+
// language wins over the default "vi" only when it resolves to English.
|
|
103
92
|
maxApi?.getLanguage { data in
|
|
104
|
-
|
|
93
|
+
if parseLanguage(data) == Localize.EN {
|
|
94
|
+
localize.changeLanguage(Localize.EN)
|
|
95
|
+
}
|
|
105
96
|
}
|
|
106
|
-
// AI-GENERATED END: demote the MaxApi language pull to a seed of last resort
|
|
107
|
-
}
|
|
108
|
-
.onDisappear {
|
|
109
|
-
NavigatorManager.shared.remove(navigator)
|
|
110
97
|
}
|
|
111
98
|
}
|
|
112
99
|
|
|
@@ -208,3 +195,9 @@ private func safeAreaBottomInset() -> CGFloat {
|
|
|
208
195
|
.compactMap { ($0 as? UIWindowScene)?.keyWindow?.safeAreaInsets.bottom }
|
|
209
196
|
.first ?? 0
|
|
210
197
|
}
|
|
198
|
+
|
|
199
|
+
private func parseLanguage(_ raw: [String: Any?]?) -> String? {
|
|
200
|
+
guard let response = (raw?["response"] as? String)?.trimmingCharacters(in: .whitespaces).lowercased(),
|
|
201
|
+
!response.isEmpty else { return nil }
|
|
202
|
+
return response.hasPrefix(Localize.EN) ? Localize.EN : Localize.VI
|
|
203
|
+
}
|