@momo-kits/native-kits 0.167.1-beta.13 → 0.167.1-beta.14-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 +4 -6
- 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/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 +151 -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 +124 -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 +831 -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 +49 -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 +189 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Input.kt +475 -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 +266 -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 +223 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputSearch.kt +264 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/InputTextArea.kt +185 -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 +220 -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 +552 -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 +125 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/components/Title.kt +207 -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 +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/HostFont.kt +16 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/KitDesignSystem.kt +18 -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 +194 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +282 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Card.kt +54 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/layout/Item.kt +51 -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 +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/HostBackGestureBridge.kt +58 -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 +106 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/NavigationContainer.kt +201 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/Navigator.kt +393 -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 +595 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/StackTransition.kt +148 -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 +184 -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 +357 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderBackground.kt +83 -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 +75 -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 +39 -0
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderUser.kt +364 -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/BackGesture.kt +12 -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 +71 -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/const/HostFont.ios.kt +40 -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 +32 -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 +66 -0
- package/compose/src/iosMain/kotlin/vn/momo/kits/platform/Platform.ios.kt +213 -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 +6 -13
- package/ios/Template/TrustBanner/TrustBanner.swift +7 -39
- package/ios/Typography/FontScale.swift +11 -14
- package/ios/Typography/FontScaleStore.swift +58 -0
- package/ios/Typography/KitDesignSystem.swift +17 -0
- package/ios/Typography/Text.swift +7 -19
- package/ios/Typography/Typography.swift +2 -2
- package/ios/native-kits.podspec +1 -1
- package/ios-demo/MoMoUIKitsDemo.podspec +1 -1
- package/ios-demo/README.md +120 -0
- package/local.properties +8 -0
- package/package.json +1 -1
- package/settings.gradle.kts +64 -0
- package/ios/Application/DesignSystemKits.swift +0 -100
- package/ios/Application/DesignSystemKitsPayload.swift +0 -68
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
|
|
@@ -17,8 +17,8 @@ public class MiniAppContext {
|
|
|
17
17
|
public var toolkitConfig: [String: Any] = [:]
|
|
18
18
|
public var providerId: String = "momo"
|
|
19
19
|
public var permissions: [[String: Any]] = []
|
|
20
|
-
// Per-mini-app font-scale override; nil falls back to
|
|
21
|
-
// MiniAppContext.userScaleRate / useOSScaleRate, which win per field over
|
|
20
|
+
// Per-mini-app font-scale override; nil falls back to FontScaleStore. Mirrors Compose's
|
|
21
|
+
// MiniAppContext.userScaleRate / useOSScaleRate, which win per field over KitFontScale.
|
|
22
22
|
public var userScaleRate: CGFloat? = nil
|
|
23
23
|
public var useOSScaleRate: Bool? = nil
|
|
24
24
|
|
|
@@ -37,17 +37,10 @@ public class MiniAppContext {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
public
|
|
42
|
-
public var
|
|
43
|
-
public var
|
|
44
|
-
public var headerGradient: String?
|
|
45
|
-
|
|
46
|
-
public init(trustBanner: TrustBannerData? = nil, headerBar: String? = nil, headerGradient: String? = nil) {
|
|
47
|
-
self.trustBanner = trustBanner
|
|
48
|
-
self.headerBar = headerBar
|
|
49
|
-
self.headerGradient = headerGradient
|
|
50
|
-
}
|
|
40
|
+
public class KitConfig {
|
|
41
|
+
public var trustBanner: TrustBannerData? = nil
|
|
42
|
+
public var headerBar: String? = nil
|
|
43
|
+
public var headerGradient: String? = nil
|
|
51
44
|
}
|
|
52
45
|
|
|
53
46
|
public class ApplicationEnvironment: ObservableObject {
|
|
@@ -11,7 +11,7 @@ import SDWebImageSwiftUI
|
|
|
11
11
|
|
|
12
12
|
let jsonUrl = "https://static.momocdn.net/app/json/component-kits/design_system.json"
|
|
13
13
|
|
|
14
|
-
public struct TrustBannerData: Decodable
|
|
14
|
+
public struct TrustBannerData: Decodable {
|
|
15
15
|
let content: [String: String]
|
|
16
16
|
let subContent: [String: String]
|
|
17
17
|
let pciImage: String
|
|
@@ -50,41 +50,9 @@ let defaultBanner = TrustBannerData(
|
|
|
50
50
|
momoImage: "https://static.momocdn.net/app/img/kits/trustBanner/ic_secu.png"
|
|
51
51
|
)
|
|
52
52
|
|
|
53
|
-
// AI-GENERATED START: public init so the host can push its remote trust banner config
|
|
54
|
-
public extension TrustBannerData {
|
|
55
|
-
/// Missing images / url fall back to the kit's default banner, like the view does per field.
|
|
56
|
-
init(
|
|
57
|
-
content: [String: String],
|
|
58
|
-
subContent: [String: String],
|
|
59
|
-
pciImage: String?,
|
|
60
|
-
sslImage: String?,
|
|
61
|
-
urlConfig: String?,
|
|
62
|
-
icons: [String]?,
|
|
63
|
-
momoImage: String?
|
|
64
|
-
) {
|
|
65
|
-
self.init(
|
|
66
|
-
content: content,
|
|
67
|
-
subContent: subContent,
|
|
68
|
-
pciImage: pciImage ?? defaultBanner.pciImage,
|
|
69
|
-
sslImage: sslImage ?? defaultBanner.sslImage,
|
|
70
|
-
urlConfig: urlConfig ?? defaultBanner.urlConfig,
|
|
71
|
-
icons: icons ?? defaultBanner.icons,
|
|
72
|
-
momoImage: momoImage ?? defaultBanner.momoImage
|
|
73
|
-
)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// AI-GENERATED END: public init so the host can push its remote trust banner config
|
|
77
|
-
|
|
78
53
|
public struct TrustBanner: View {
|
|
79
54
|
@Environment(\.applicationEnvironment) var applicationEnvironment
|
|
80
55
|
@Environment(\.localize) private var localize
|
|
81
|
-
// AI-GENERATED START: container config wins, else the host-pushed DesignSystemKits config (Compose parity)
|
|
82
|
-
@Environment(\.designSystemKitsConfigs) private var designSystemKitsConfigs
|
|
83
|
-
|
|
84
|
-
private var trustBanner: TrustBannerData? {
|
|
85
|
-
(applicationEnvironment.config ?? designSystemKitsConfigs.designSystemConfig)?.trustBanner
|
|
86
|
-
}
|
|
87
|
-
// AI-GENERATED END: container config wins, else the host-pushed DesignSystemKits config (Compose parity)
|
|
88
56
|
|
|
89
57
|
var onPress: ((String)->Void)?
|
|
90
58
|
|
|
@@ -94,19 +62,19 @@ public struct TrustBanner: View {
|
|
|
94
62
|
|
|
95
63
|
func onPressSecurity() {
|
|
96
64
|
if (onPress != nil) {
|
|
97
|
-
onPress!(trustBanner?.urlConfig ?? defaultBanner.urlConfig)
|
|
65
|
+
onPress!(applicationEnvironment.config?.trustBanner?.urlConfig ?? defaultBanner.urlConfig)
|
|
98
66
|
}
|
|
99
67
|
}
|
|
100
68
|
|
|
101
69
|
|
|
102
70
|
public var body: some View {
|
|
103
71
|
HStack(alignment: .center, spacing: 8) {
|
|
104
|
-
WebImage(url: URL(string: trustBanner?.momoImage ?? defaultBanner.momoImage))
|
|
72
|
+
WebImage(url: URL(string: applicationEnvironment.config?.trustBanner?.momoImage ?? defaultBanner.momoImage))
|
|
105
73
|
.resizable()
|
|
106
74
|
.scaledToFit()
|
|
107
75
|
.frame(width: 64, height: 64)
|
|
108
76
|
VStack(alignment: .leading){
|
|
109
|
-
Text(trustBanner?.content[localize.currentLanguage]
|
|
77
|
+
Text(applicationEnvironment.config?.trustBanner?.content[localize.currentLanguage]
|
|
110
78
|
?? localize.translateData(defaultBanner.content))
|
|
111
79
|
.foregroundColor(Color(hex: "484848"))
|
|
112
80
|
.lineLimit(2)
|
|
@@ -116,7 +84,7 @@ public struct TrustBanner: View {
|
|
|
116
84
|
.padding(.bottom, 8)
|
|
117
85
|
HStack {
|
|
118
86
|
HStack(spacing: 0) {
|
|
119
|
-
Text(trustBanner?.subContent[localize.currentLanguage]
|
|
87
|
+
Text(applicationEnvironment.config?.trustBanner?.subContent[localize.currentLanguage]
|
|
120
88
|
?? localize.translateData(defaultBanner.subContent))
|
|
121
89
|
.foregroundColor(Colors.pink03)
|
|
122
90
|
.font(.system(size: 13, weight: .bold))
|
|
@@ -130,11 +98,11 @@ public struct TrustBanner: View {
|
|
|
130
98
|
|
|
131
99
|
Spacer()
|
|
132
100
|
HStack{
|
|
133
|
-
WebImage(url: URL(string: trustBanner?.pciImage ?? defaultBanner.pciImage))
|
|
101
|
+
WebImage(url: URL(string: applicationEnvironment.config?.trustBanner?.pciImage ?? defaultBanner.pciImage))
|
|
134
102
|
.resizable()
|
|
135
103
|
.scaledToFit()
|
|
136
104
|
.frame(width: 24, height: 20)
|
|
137
|
-
WebImage(url: URL(string: trustBanner?.sslImage ?? defaultBanner.sslImage))
|
|
105
|
+
WebImage(url: URL(string: applicationEnvironment.config?.trustBanner?.sslImage ?? defaultBanner.sslImage))
|
|
138
106
|
.resizable()
|
|
139
107
|
.scaledToFit()
|
|
140
108
|
.frame(width: 52, height: 20)
|
|
@@ -52,7 +52,7 @@ public struct FontScale: Equatable {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/// A host-pushed mini-app context wins per field, matching Compose's
|
|
55
|
-
/// `context?.useOSScaleRate ?:
|
|
55
|
+
/// `context?.useOSScaleRate ?: KitFontScale.useOSScaleRate`.
|
|
56
56
|
public func overriding(userScaleRate: CGFloat?, useOSScaleRate: Bool?) -> FontScale {
|
|
57
57
|
guard userScaleRate != nil || useOSScaleRate != nil else { return self }
|
|
58
58
|
return FontScale(
|
|
@@ -66,7 +66,7 @@ public struct FontScale: Equatable {
|
|
|
66
66
|
private struct FontScaleKey: EnvironmentKey {
|
|
67
67
|
/// Computed, never stored: a bare `UIHostingController` root that never got `.momoFontScale()`
|
|
68
68
|
/// still reads the live store instead of a value frozen at first access.
|
|
69
|
-
static var defaultValue: FontScale {
|
|
69
|
+
static var defaultValue: FontScale { FontScaleStore.shared.snapshot }
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
public extension EnvironmentValues {
|
|
@@ -77,10 +77,9 @@ public extension EnvironmentValues {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
public extension View {
|
|
80
|
-
/// Injects a Dynamic-Type-observing font scale
|
|
81
|
-
/// and re-renders this subtree on change.
|
|
80
|
+
/// Injects a Dynamic-Type-observing font scale and re-renders this subtree on change.
|
|
82
81
|
/// Use at every `UIHostingController` root that is not inside a `NavigationContainer`.
|
|
83
|
-
func momoFontScale(_ store:
|
|
82
|
+
func momoFontScale(_ store: FontScaleStore = .shared, context: MiniAppContext? = nil) -> some View {
|
|
84
83
|
modifier(MomoFontScaleModifier(store: store, context: context))
|
|
85
84
|
}
|
|
86
85
|
}
|
|
@@ -88,19 +87,17 @@ public extension View {
|
|
|
88
87
|
/// `@ObservedObject` is load-bearing, same as `MomoLocalizeModifier`: `@Environment(\.momoFontScale)`
|
|
89
88
|
/// only invalidates when the boxed snapshot changes, which requires *this* body to re-run on publish.
|
|
90
89
|
private struct MomoFontScaleModifier: ViewModifier {
|
|
91
|
-
@ObservedObject var store:
|
|
90
|
+
@ObservedObject var store: FontScaleStore
|
|
92
91
|
let context: MiniAppContext?
|
|
93
92
|
|
|
94
93
|
func body(content: Content) -> some View {
|
|
95
|
-
content
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
useOSScaleRate: context?.useOSScaleRate
|
|
101
|
-
)
|
|
94
|
+
content.environment(
|
|
95
|
+
\.momoFontScale,
|
|
96
|
+
store.snapshot.overriding(
|
|
97
|
+
userScaleRate: context?.userScaleRate,
|
|
98
|
+
useOSScaleRate: context?.useOSScaleRate
|
|
102
99
|
)
|
|
103
|
-
|
|
100
|
+
)
|
|
104
101
|
}
|
|
105
102
|
}
|
|
106
103
|
// AI-GENERATED END: reactive font-scale snapshot injected through the environment
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import SwiftUI
|
|
2
|
+
|
|
3
|
+
/// App-wide font-scale inputs for the SwiftUI kit, and the single place they publish from.
|
|
4
|
+
/// The host writes `update(...)` at startup (from the cache-backed `FontScaleProvider`) and again
|
|
5
|
+
/// whenever the in-app font-size preference changes; the OS Dynamic Type factor is tracked here.
|
|
6
|
+
/// Mirrors Compose's `KitFontScale` + `ProvideOsFontScale` pair, including its live behaviour —
|
|
7
|
+
/// views re-render on change as long as the subtree got `.momoFontScale()` (`NavigationContainer`
|
|
8
|
+
/// applies it). When `useOSScaleRate` is false the kit applies `userScaleRate` instead of the OS factor.
|
|
9
|
+
public final class FontScaleStore: ObservableObject {
|
|
10
|
+
public static let shared = FontScaleStore()
|
|
11
|
+
|
|
12
|
+
@Published public private(set) var userScaleRate: CGFloat = 1
|
|
13
|
+
@Published public private(set) var useOSScaleRate: Bool = true
|
|
14
|
+
@Published public private(set) var osFontScale: CGFloat = FontScaleStore.currentOsFontScale()
|
|
15
|
+
|
|
16
|
+
private init() {
|
|
17
|
+
NotificationCenter.default.addObserver(
|
|
18
|
+
self,
|
|
19
|
+
selector: #selector(contentSizeCategoryDidChange),
|
|
20
|
+
name: UIContentSizeCategory.didChangeNotification,
|
|
21
|
+
object: nil
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public var snapshot: FontScale {
|
|
26
|
+
FontScale(
|
|
27
|
+
userScaleRate: userScaleRate,
|
|
28
|
+
useOSScaleRate: useOSScaleRate,
|
|
29
|
+
osFontScale: osFontScale
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public func update(userScaleRate: CGFloat, useOSScaleRate: Bool) {
|
|
34
|
+
onMain {
|
|
35
|
+
// Re-assigning an unchanged value would still publish and invalidate every kit subtree.
|
|
36
|
+
if self.userScaleRate != userScaleRate { self.userScaleRate = userScaleRate }
|
|
37
|
+
if self.useOSScaleRate != useOSScaleRate { self.useOSScaleRate = useOSScaleRate }
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@objc private func contentSizeCategoryDidChange() {
|
|
42
|
+
let next = Self.currentOsFontScale()
|
|
43
|
+
guard next != osFontScale else { return }
|
|
44
|
+
osFontScale = next
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// Same factor Compose's iOS `ProvideOsFontScale` derives from
|
|
48
|
+
/// `UIFont.preferredFont(forTextStyle: .body).pointSize / 17`, so both iOS surfaces scale alike.
|
|
49
|
+
static func currentOsFontScale() -> CGFloat {
|
|
50
|
+
let base = UIFont.systemFont(ofSize: UIFont.labelFontSize)
|
|
51
|
+
return UIFontMetrics.default.scaledFont(for: base).pointSize / base.pointSize
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/// Synchronous when already on main — an async hop would defer the change by a frame.
|
|
55
|
+
private func onMain(_ work: @escaping () -> Void) {
|
|
56
|
+
if Thread.isMainThread { work() } else { DispatchQueue.main.async(execute: work) }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/// Design-system rollout flag for the SwiftUI kit, mirroring Compose's `KitDesignSystem`.
|
|
4
|
+
/// The kit is sandboxed and can't read the host config, so the host writes `update(_:)` once at
|
|
5
|
+
/// startup from `DesignSystemConfig`. Startup-only and non-reactive, like `FontScaleStore` was
|
|
6
|
+
/// before it gained live updates: there is no SwiftUI navigation container to re-render from.
|
|
7
|
+
public final class KitDesignSystem {
|
|
8
|
+
public static let shared = KitDesignSystem()
|
|
9
|
+
|
|
10
|
+
public private(set) var isWhiteList: Bool = false
|
|
11
|
+
|
|
12
|
+
private init() {}
|
|
13
|
+
|
|
14
|
+
public func update(isWhiteList: Bool) {
|
|
15
|
+
self.isWhiteList = isWhiteList
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -4,7 +4,7 @@ import SwiftUI
|
|
|
4
4
|
/// free functions). Inside a SwiftUI view prefer `@Environment(\.momoFontScale)` so the view
|
|
5
5
|
/// re-renders when Dynamic Type or the host preference changes.
|
|
6
6
|
public func scaleSize(_ size: CGFloat) -> CGFloat {
|
|
7
|
-
|
|
7
|
+
FontScaleStore.shared.snapshot(size)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
@available(*, deprecated, message: "Max font scale is fixed at 1.5; this override is no longer applied. Drop the second argument.")
|
|
@@ -99,9 +99,9 @@ public extension TypographyStyle {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
private func momoFontName(family: String, weight: Font.Weight
|
|
102
|
+
private func momoFontName(family: String, weight: Font.Weight) -> String? {
|
|
103
103
|
// Ngoai whitelist thi tra nil de momoFont() roi ve .system(...), dung nhu truoc DS-791.
|
|
104
|
-
guard isWhiteList else { return nil }
|
|
104
|
+
guard KitDesignSystem.shared.isWhiteList else { return nil }
|
|
105
105
|
guard family == "MomoTrustSans" else { return nil }
|
|
106
106
|
switch weight {
|
|
107
107
|
case .ultraLight, .thin: return "MomoTrustSans-ExtraLight"
|
|
@@ -115,8 +115,8 @@ private func momoFontName(family: String, weight: Font.Weight, isWhiteList: Bool
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
private func momoFont(size: CGFloat, weight: Font.Weight, family: String
|
|
119
|
-
guard let name = momoFontName(family: family, weight: weight
|
|
118
|
+
private func momoFont(size: CGFloat, weight: Font.Weight, family: String) -> Font {
|
|
119
|
+
guard let name = momoFontName(family: family, weight: weight),
|
|
120
120
|
UIFont(name: name, size: size) != nil else {
|
|
121
121
|
return .system(size: size, weight: weight)
|
|
122
122
|
}
|
|
@@ -126,8 +126,6 @@ private func momoFont(size: CGFloat, weight: Font.Weight, family: String, isWhit
|
|
|
126
126
|
public struct MomoText: View {
|
|
127
127
|
@Environment(\.appTheme) private var theme
|
|
128
128
|
@Environment(\.momoFontScale) private var fontScale
|
|
129
|
-
// From the environment, not DesignSystemKits.shared, so a whitelist flip re-renders the text.
|
|
130
|
-
@Environment(\.designSystemKitsConfigs) private var designSystemKitsConfigs
|
|
131
129
|
private let content: String
|
|
132
130
|
private let typography: TypographyStyle
|
|
133
131
|
private let color: Color?
|
|
@@ -188,12 +186,7 @@ public struct MomoText: View {
|
|
|
188
186
|
private var baseText: SwiftUI.Text {
|
|
189
187
|
let keywords = highlightText.filter { !$0.isEmpty }.sorted { $0.count > $1.count }
|
|
190
188
|
guard !keywords.isEmpty else { return SwiftUI.Text(content) }
|
|
191
|
-
let highlightFont = momoFont(
|
|
192
|
-
size: fontScale(typography.fontSize),
|
|
193
|
-
weight: TypographyStyle.headerXsSemibold.fontWeight,
|
|
194
|
-
family: theme.font,
|
|
195
|
-
isWhiteList: designSystemKitsConfigs.isWhiteList
|
|
196
|
-
)
|
|
189
|
+
let highlightFont = momoFont(size: fontScale(typography.fontSize), weight: TypographyStyle.headerXsSemibold.fontWeight, family: theme.font)
|
|
197
190
|
func isWordChar(_ character: Character?) -> Bool {
|
|
198
191
|
guard let character else { return false }
|
|
199
192
|
return character.isLetter || character.isNumber || character == "_"
|
|
@@ -230,12 +223,7 @@ public struct MomoText: View {
|
|
|
230
223
|
let isStrikethrough = strikethrough || typography.isStrikethrough
|
|
231
224
|
|
|
232
225
|
var text = baseText
|
|
233
|
-
.font(momoFont(
|
|
234
|
-
size: fontScale(typography.fontSize),
|
|
235
|
-
weight: typography.fontWeight,
|
|
236
|
-
family: theme.font,
|
|
237
|
-
isWhiteList: designSystemKitsConfigs.isWhiteList
|
|
238
|
-
))
|
|
226
|
+
.font(momoFont(size: fontScale(typography.fontSize), weight: typography.fontWeight, family: theme.font))
|
|
239
227
|
.foregroundColor(textColor)
|
|
240
228
|
.strikethrough(isStrikethrough, color: textColor)
|
|
241
229
|
.underline(underline, color: textColor)
|