@momo-kits/native-kits 0.162.6 → 0.163.1-beta.1
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 +78 -0
- package/example/ios/Example.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/example/ios/Example.xcworkspace/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +5 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/MoMoUIKits.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/Pods-Example.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImage.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SDWebImageSwiftUI.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/SkeletonUI.xcscheme +58 -0
- package/example/ios/Pods/Pods.xcodeproj/xcuserdata/huynhdung.xcuserdatad/xcschemes/xcschememanagement.plist +46 -0
- package/ios/Application/ApplicationEnvironment.swift +0 -1
- package/ios/Application/Components.swift +0 -1
- package/ios/Application/FloatingButton.swift +0 -1
- package/ios/Badge/Badge.swift +0 -1
- package/ios/Badge/BadgeRibbon.swift +0 -2
- package/ios/Button/Button.swift +1 -1
- package/ios/Checkbox/Checkbox.swift +0 -1
- package/ios/Input/Input.swift +0 -1
- package/ios/Input/InputPhoneNumber.swift +0 -1
- package/ios/Input/InputSearch.swift +0 -3
- package/ios/Input/InputTextArea.swift +0 -1
- package/ios/OTPKeyboard/KeyboardButton.swift +1 -1
- package/ios/Popup/PopupDisplay.swift +0 -6
- package/ios/Popup/PopupInput.swift +0 -2
- package/ios/Template/TrustBanner/TrustBanner.swift +0 -2
- package/ios/Typography/Text.swift +7 -13
- package/ios/Typography/Typography.swift +8 -22
- package/package.json +1 -1
- package/ios/Application/FontScaleStore.swift +0 -59
- package/ios/Information/Information.swift +0 -151
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
Guidance for working in this repo. Keep it accurate — update it when structure or commands change.
|
|
4
|
+
|
|
5
|
+
## What this is
|
|
6
|
+
|
|
7
|
+
`momo-native-kits` — MoMo's design-system / UI-kit as a **Kotlin Multiplatform + Compose Multiplatform** library, published for Android (AAR/Maven) and iOS (static framework + CocoaPods). It is the Compose port of the React Native `momo-kits`. Consumed by mini-apps embedded in the host MoMo app.
|
|
8
|
+
|
|
9
|
+
- Artifact: `vn.momo.kits:kits` (version in `gradle.properties`). NPM mirror: `@momo-kits/native-kits`.
|
|
10
|
+
- Targets: `androidTarget` (JVM 17, compile/min/target SDK 36/24/36), `iosArm64`, `iosSimulatorArm64` (framework `baseName = "kits"`, `isStatic = true`).
|
|
11
|
+
- Kotlin 2.3.10, Compose MP 1.10.3.
|
|
12
|
+
|
|
13
|
+
## Modules
|
|
14
|
+
|
|
15
|
+
- `:compose` — the published library. All real code lives here.
|
|
16
|
+
- `:sample:shared` + `:sample:androidApp` — demo app (`UIKitHome` lists all components). iOS demo in `sample/iosApp` (Xcode).
|
|
17
|
+
|
|
18
|
+
## Source layout (`compose/src/commonMain/kotlin/vn/momo/kits/`)
|
|
19
|
+
|
|
20
|
+
- `components/` — ~50 UI components, **one file per component** (`Button.kt`, `Input*.kt`, `PopupNotify.kt`, …).
|
|
21
|
+
- `application/` — app-level context & config: `Context.kt` (CompositionLocals, `MiniAppContext`, `DesignSystemConfig`), `Localize.kt` (i18n: `LocalizationObject`, `Localize`, default dictionary), `Screen.kt`, header pieces. Also holds the **deprecated** `ApplicationContainer`.
|
|
22
|
+
- `navigation/` — `NavigationContainer.kt` (**canonical entry point**), `Navigator.kt`, `Navigation.kt`, `StackScreen.kt`, `bottomtab/`, `component/`, `tracking/`.
|
|
23
|
+
- `const/` — design tokens: `Theme.kt`, `Colors.kt`, `Typography.kt`, `Spacing.kt`, `Radius.kt`.
|
|
24
|
+
- `layout/`, `modifier/`, `utils/`.
|
|
25
|
+
- `platform/` — `Platform.kt` `expect` declarations, actualized in `androidMain` / `iosMain` (`Platform.android.kt`, `Platform.ios.kt`).
|
|
26
|
+
|
|
27
|
+
## Build & verify
|
|
28
|
+
|
|
29
|
+
No unit-test suite is configured. Validate changes by compiling the relevant target(s); use the sample app for visual checks.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
./gradlew :compose:compileCommonMainKotlinMetadata # validate commonMain (fast, do this first)
|
|
33
|
+
./gradlew :compose:compileDebugKotlinAndroid # Android target
|
|
34
|
+
./gradlew :compose:linkDebugFrameworkIosSimulatorArm64 # iOS framework (slow)
|
|
35
|
+
./gradlew :sample:androidApp:installDebug # run demo on device/emulator
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Publishing is automated (`publish.sh` + GitLab CI on `[ci build]` / `main`). Do not publish manually unless asked: `sh publish.sh beta` / `sh publish.sh release` (Maven→GitLab + NPM).
|
|
39
|
+
|
|
40
|
+
## Architecture essentials
|
|
41
|
+
|
|
42
|
+
- **Entry point:** wrap content in `NavigationContainer(...)` from `navigation/`. It builds the `Navigator`, takes a host-supplied `Localize` (falls back to an empty one), and provides the CompositionLocals below. **Do not use** `ApplicationContainer` (`application/NavigationContainer.kt`) — deprecated and does **not** wire `LocalLocalize` / `LocalNavigator` / `LocalMaxApi`.
|
|
43
|
+
- **Configuration flows via CompositionLocals**, not params. Public ones: `AppTheme`, `AppStatusBar`, `AppNavigationBar` (`const/Theme.kt`); `ApplicationContext`, `AppConfig`, `AppLanguage`, `LocalLocalize`, `ScaleSizeMaxRate` (`application/`); `LocalNavigator`, `LocalMaxApi` (`navigation/`). Read with `X.current`.
|
|
44
|
+
- **Platform code** goes through `expect`/`actual` in `platform/` — never reference Android/iOS APIs from `commonMain` directly.
|
|
45
|
+
- **Native bridge:** `IMaxApi` (`vn.momo.maxapi`, exposed as `LocalMaxApi`) is the host-app bridge (dismiss, tracking, device info, language).
|
|
46
|
+
- Navigation uses a runtime `DynamicScreenRegistry`; overlays (modal/bottom-sheet/snackbar) go through `Navigator` + `OverplayComponentRegistry`.
|
|
47
|
+
|
|
48
|
+
## i18n / Localize (port of RN `Localize`)
|
|
49
|
+
|
|
50
|
+
- `application/Localize.kt`: everything i18n. `LocalizationObject` is a data class with required `vi` / `en` maps (`LocalizationObject(vi = mapOf(…), en = mapOf(…))`). `Localize` constructors take a `LocalizationObject` or a `(vi, en)` map pair; the constructor **merges** the kit defaults with the host data (host wins on key clash). Methods: `translate(key)` (missing/empty → returns the key), `translateData(map)` / `translateData(vi, en)`, `addTranslations` (existing keys win), `changeLanguage(lang)`. Default language `"vi"`, `"en"` only on exact match; language is snapshot state so a switch recomposes consumers.
|
|
51
|
+
- The default dictionary lives **inside `Localize`** (companion `defaultLanguage`), **generated 1:1 from `momo-kits` RN `Assets/language.json`** — do not hand-edit that block; edit the RN source and regenerate.
|
|
52
|
+
- The host creates one `Localize` and passes it in: `NavigationContainer(localize = myLocalize, …)`. There is **no** `language` param and `DesignSystemConfig` carries no translations — overrides go through the `Localize` constructor / `addTranslations`. Switch language at runtime with `myLocalize.changeLanguage("en")`.
|
|
53
|
+
- Access in a `@Composable`: `LocalLocalize.current.translate("errorCode")`. Language is host-controlled, never read from the OS locale. `AppLanguage` is still provided (derived from `Localize.currentLanguage`) for older components that read it.
|
|
54
|
+
- Some older components still do ad-hoc `AppLanguage.current` + `Map` lookups; new/changed code should use `LocalLocalize`.
|
|
55
|
+
|
|
56
|
+
## Code conventions
|
|
57
|
+
|
|
58
|
+
- **Tokens, not literals:** use `Colors`, `Typography`, `Spacing`, `Radius` objects and `AppTheme.current` for colors/styles. Per-component sizing is bundled in enums (e.g. `Button.Size(val value: ButtonSpecs)`).
|
|
59
|
+
- **Composable signatures:** required params first, slot lambdas next, `modifier: Modifier = Modifier` **last**; give optional params sensible defaults.
|
|
60
|
+
- **Stability:** annotate token/config data classes `@Stable`/`@Immutable`; memoize derived colors/styles/handlers with `remember(keys) { … }`.
|
|
61
|
+
- **Custom modifiers** are preferred: `conditional(...)`, `setAutomationId(...)`, the `clickable` variants in `modifier/`.
|
|
62
|
+
- Match the surrounding file's style when adding code.
|
|
63
|
+
|
|
64
|
+
## Writing docs in code (follow this)
|
|
65
|
+
|
|
66
|
+
Comments are **sparse and in English**. Document only what is **not obvious from the code** — non-obvious behavior, platform quirks, RN-parity semantics, memoization intent, or important gotchas worth flagging. Do **not**:
|
|
67
|
+
|
|
68
|
+
- write KDoc walls or restate what the signature/code already says;
|
|
69
|
+
- narrate obvious steps or add section-banner noise;
|
|
70
|
+
- use a language other than English in code comments.
|
|
71
|
+
|
|
72
|
+
Prefer one tight line at the surprising spot over a paragraph. Match the (low) comment density already in the codebase.
|
|
73
|
+
|
|
74
|
+
## Gotchas
|
|
75
|
+
|
|
76
|
+
- **Resource qualifier drift:** the generated Compose `Res` namespace is `vn.momo.uikits.resources`, but `utils/Resources.kt` and `platform/Platform.ios.kt` reference `vn.momo.compose.resources`. Keep bundled strings/dictionaries as plain Kotlin (the `defaultLanguage` map in `Localize.kt`), not `composeResources/values`, to avoid iOS framework resource-loading issues.
|
|
77
|
+
- Prefer `NavigationContainer` over the deprecated `ApplicationContainer`; prefer `IMaxApi`/`LocalMaxApi` over the deprecated `PlatformApi`.
|
|
78
|
+
- iOS strings/maps must survive Kotlin/Native framework packaging — keep them compiled-in, not loaded from resource bundles.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>Example.xcscheme_^#shared#^_</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>orderHint</key>
|
|
10
|
+
<integer>0</integer>
|
|
11
|
+
</dict>
|
|
12
|
+
</dict>
|
|
13
|
+
</dict>
|
|
14
|
+
</plist>
|
|
Binary file
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Scheme
|
|
3
|
+
LastUpgradeVersion = "1600"
|
|
4
|
+
version = "1.3">
|
|
5
|
+
<BuildAction
|
|
6
|
+
parallelizeBuildables = "YES"
|
|
7
|
+
buildImplicitDependencies = "YES">
|
|
8
|
+
<BuildActionEntries>
|
|
9
|
+
<BuildActionEntry
|
|
10
|
+
buildForTesting = "YES"
|
|
11
|
+
buildForRunning = "YES"
|
|
12
|
+
buildForProfiling = "YES"
|
|
13
|
+
buildForArchiving = "YES"
|
|
14
|
+
buildForAnalyzing = "YES">
|
|
15
|
+
<BuildableReference
|
|
16
|
+
BuildableIdentifier = "primary"
|
|
17
|
+
BlueprintIdentifier = "3B6FB503A75BF5BC1FA6F30BC06B9D28"
|
|
18
|
+
BuildableName = "MoMoUIKits.framework"
|
|
19
|
+
BlueprintName = "MoMoUIKits"
|
|
20
|
+
ReferencedContainer = "container:Pods.xcodeproj">
|
|
21
|
+
</BuildableReference>
|
|
22
|
+
</BuildActionEntry>
|
|
23
|
+
</BuildActionEntries>
|
|
24
|
+
</BuildAction>
|
|
25
|
+
<TestAction
|
|
26
|
+
buildConfiguration = "Debug"
|
|
27
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
28
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
29
|
+
shouldUseLaunchSchemeArgsEnv = "YES">
|
|
30
|
+
<Testables>
|
|
31
|
+
</Testables>
|
|
32
|
+
</TestAction>
|
|
33
|
+
<LaunchAction
|
|
34
|
+
buildConfiguration = "Debug"
|
|
35
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
36
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
37
|
+
launchStyle = "0"
|
|
38
|
+
useCustomWorkingDirectory = "NO"
|
|
39
|
+
ignoresPersistentStateOnLaunch = "NO"
|
|
40
|
+
debugDocumentVersioning = "YES"
|
|
41
|
+
debugServiceExtension = "internal"
|
|
42
|
+
allowLocationSimulation = "YES">
|
|
43
|
+
</LaunchAction>
|
|
44
|
+
<ProfileAction
|
|
45
|
+
buildConfiguration = "Release"
|
|
46
|
+
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
47
|
+
savedToolIdentifier = ""
|
|
48
|
+
useCustomWorkingDirectory = "NO"
|
|
49
|
+
debugDocumentVersioning = "YES">
|
|
50
|
+
</ProfileAction>
|
|
51
|
+
<AnalyzeAction
|
|
52
|
+
buildConfiguration = "Debug">
|
|
53
|
+
</AnalyzeAction>
|
|
54
|
+
<ArchiveAction
|
|
55
|
+
buildConfiguration = "Release"
|
|
56
|
+
revealArchiveInOrganizer = "YES">
|
|
57
|
+
</ArchiveAction>
|
|
58
|
+
</Scheme>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Scheme
|
|
3
|
+
LastUpgradeVersion = "1600"
|
|
4
|
+
version = "1.3">
|
|
5
|
+
<BuildAction
|
|
6
|
+
parallelizeBuildables = "YES"
|
|
7
|
+
buildImplicitDependencies = "YES">
|
|
8
|
+
<BuildActionEntries>
|
|
9
|
+
<BuildActionEntry
|
|
10
|
+
buildForTesting = "YES"
|
|
11
|
+
buildForRunning = "YES"
|
|
12
|
+
buildForProfiling = "YES"
|
|
13
|
+
buildForArchiving = "YES"
|
|
14
|
+
buildForAnalyzing = "YES">
|
|
15
|
+
<BuildableReference
|
|
16
|
+
BuildableIdentifier = "primary"
|
|
17
|
+
BlueprintIdentifier = "0AEE99A309977BD12A049FF48AF9BA4B"
|
|
18
|
+
BuildableName = "Pods_Example.framework"
|
|
19
|
+
BlueprintName = "Pods-Example"
|
|
20
|
+
ReferencedContainer = "container:Pods.xcodeproj">
|
|
21
|
+
</BuildableReference>
|
|
22
|
+
</BuildActionEntry>
|
|
23
|
+
</BuildActionEntries>
|
|
24
|
+
</BuildAction>
|
|
25
|
+
<TestAction
|
|
26
|
+
buildConfiguration = "Debug"
|
|
27
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
28
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
29
|
+
shouldUseLaunchSchemeArgsEnv = "YES">
|
|
30
|
+
<Testables>
|
|
31
|
+
</Testables>
|
|
32
|
+
</TestAction>
|
|
33
|
+
<LaunchAction
|
|
34
|
+
buildConfiguration = "Debug"
|
|
35
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
36
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
37
|
+
launchStyle = "0"
|
|
38
|
+
useCustomWorkingDirectory = "NO"
|
|
39
|
+
ignoresPersistentStateOnLaunch = "NO"
|
|
40
|
+
debugDocumentVersioning = "YES"
|
|
41
|
+
debugServiceExtension = "internal"
|
|
42
|
+
allowLocationSimulation = "YES">
|
|
43
|
+
</LaunchAction>
|
|
44
|
+
<ProfileAction
|
|
45
|
+
buildConfiguration = "Release"
|
|
46
|
+
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
47
|
+
savedToolIdentifier = ""
|
|
48
|
+
useCustomWorkingDirectory = "NO"
|
|
49
|
+
debugDocumentVersioning = "YES">
|
|
50
|
+
</ProfileAction>
|
|
51
|
+
<AnalyzeAction
|
|
52
|
+
buildConfiguration = "Debug">
|
|
53
|
+
</AnalyzeAction>
|
|
54
|
+
<ArchiveAction
|
|
55
|
+
buildConfiguration = "Release"
|
|
56
|
+
revealArchiveInOrganizer = "YES">
|
|
57
|
+
</ArchiveAction>
|
|
58
|
+
</Scheme>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Scheme
|
|
3
|
+
LastUpgradeVersion = "1600"
|
|
4
|
+
version = "1.3">
|
|
5
|
+
<BuildAction
|
|
6
|
+
parallelizeBuildables = "YES"
|
|
7
|
+
buildImplicitDependencies = "YES">
|
|
8
|
+
<BuildActionEntries>
|
|
9
|
+
<BuildActionEntry
|
|
10
|
+
buildForTesting = "YES"
|
|
11
|
+
buildForRunning = "YES"
|
|
12
|
+
buildForProfiling = "YES"
|
|
13
|
+
buildForArchiving = "YES"
|
|
14
|
+
buildForAnalyzing = "YES">
|
|
15
|
+
<BuildableReference
|
|
16
|
+
BuildableIdentifier = "primary"
|
|
17
|
+
BlueprintIdentifier = "3847153A6E5EEFB86565BA840768F429"
|
|
18
|
+
BuildableName = "SDWebImage.framework"
|
|
19
|
+
BlueprintName = "SDWebImage"
|
|
20
|
+
ReferencedContainer = "container:Pods.xcodeproj">
|
|
21
|
+
</BuildableReference>
|
|
22
|
+
</BuildActionEntry>
|
|
23
|
+
</BuildActionEntries>
|
|
24
|
+
</BuildAction>
|
|
25
|
+
<TestAction
|
|
26
|
+
buildConfiguration = "Debug"
|
|
27
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
28
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
29
|
+
shouldUseLaunchSchemeArgsEnv = "YES">
|
|
30
|
+
<Testables>
|
|
31
|
+
</Testables>
|
|
32
|
+
</TestAction>
|
|
33
|
+
<LaunchAction
|
|
34
|
+
buildConfiguration = "Debug"
|
|
35
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
36
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
37
|
+
launchStyle = "0"
|
|
38
|
+
useCustomWorkingDirectory = "NO"
|
|
39
|
+
ignoresPersistentStateOnLaunch = "NO"
|
|
40
|
+
debugDocumentVersioning = "YES"
|
|
41
|
+
debugServiceExtension = "internal"
|
|
42
|
+
allowLocationSimulation = "YES">
|
|
43
|
+
</LaunchAction>
|
|
44
|
+
<ProfileAction
|
|
45
|
+
buildConfiguration = "Release"
|
|
46
|
+
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
47
|
+
savedToolIdentifier = ""
|
|
48
|
+
useCustomWorkingDirectory = "NO"
|
|
49
|
+
debugDocumentVersioning = "YES">
|
|
50
|
+
</ProfileAction>
|
|
51
|
+
<AnalyzeAction
|
|
52
|
+
buildConfiguration = "Debug">
|
|
53
|
+
</AnalyzeAction>
|
|
54
|
+
<ArchiveAction
|
|
55
|
+
buildConfiguration = "Release"
|
|
56
|
+
revealArchiveInOrganizer = "YES">
|
|
57
|
+
</ArchiveAction>
|
|
58
|
+
</Scheme>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Scheme
|
|
3
|
+
LastUpgradeVersion = "1600"
|
|
4
|
+
version = "1.3">
|
|
5
|
+
<BuildAction
|
|
6
|
+
parallelizeBuildables = "YES"
|
|
7
|
+
buildImplicitDependencies = "YES">
|
|
8
|
+
<BuildActionEntries>
|
|
9
|
+
<BuildActionEntry
|
|
10
|
+
buildForTesting = "YES"
|
|
11
|
+
buildForRunning = "YES"
|
|
12
|
+
buildForProfiling = "YES"
|
|
13
|
+
buildForArchiving = "YES"
|
|
14
|
+
buildForAnalyzing = "YES">
|
|
15
|
+
<BuildableReference
|
|
16
|
+
BuildableIdentifier = "primary"
|
|
17
|
+
BlueprintIdentifier = "92EBFA3E7005B4C18A9C0B44324EB80F"
|
|
18
|
+
BuildableName = "SDWebImageSwiftUI.framework"
|
|
19
|
+
BlueprintName = "SDWebImageSwiftUI"
|
|
20
|
+
ReferencedContainer = "container:Pods.xcodeproj">
|
|
21
|
+
</BuildableReference>
|
|
22
|
+
</BuildActionEntry>
|
|
23
|
+
</BuildActionEntries>
|
|
24
|
+
</BuildAction>
|
|
25
|
+
<TestAction
|
|
26
|
+
buildConfiguration = "Debug"
|
|
27
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
28
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
29
|
+
shouldUseLaunchSchemeArgsEnv = "YES">
|
|
30
|
+
<Testables>
|
|
31
|
+
</Testables>
|
|
32
|
+
</TestAction>
|
|
33
|
+
<LaunchAction
|
|
34
|
+
buildConfiguration = "Debug"
|
|
35
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
36
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
37
|
+
launchStyle = "0"
|
|
38
|
+
useCustomWorkingDirectory = "NO"
|
|
39
|
+
ignoresPersistentStateOnLaunch = "NO"
|
|
40
|
+
debugDocumentVersioning = "YES"
|
|
41
|
+
debugServiceExtension = "internal"
|
|
42
|
+
allowLocationSimulation = "YES">
|
|
43
|
+
</LaunchAction>
|
|
44
|
+
<ProfileAction
|
|
45
|
+
buildConfiguration = "Release"
|
|
46
|
+
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
47
|
+
savedToolIdentifier = ""
|
|
48
|
+
useCustomWorkingDirectory = "NO"
|
|
49
|
+
debugDocumentVersioning = "YES">
|
|
50
|
+
</ProfileAction>
|
|
51
|
+
<AnalyzeAction
|
|
52
|
+
buildConfiguration = "Debug">
|
|
53
|
+
</AnalyzeAction>
|
|
54
|
+
<ArchiveAction
|
|
55
|
+
buildConfiguration = "Release"
|
|
56
|
+
revealArchiveInOrganizer = "YES">
|
|
57
|
+
</ArchiveAction>
|
|
58
|
+
</Scheme>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Scheme
|
|
3
|
+
LastUpgradeVersion = "1600"
|
|
4
|
+
version = "1.3">
|
|
5
|
+
<BuildAction
|
|
6
|
+
parallelizeBuildables = "YES"
|
|
7
|
+
buildImplicitDependencies = "YES">
|
|
8
|
+
<BuildActionEntries>
|
|
9
|
+
<BuildActionEntry
|
|
10
|
+
buildForTesting = "YES"
|
|
11
|
+
buildForRunning = "YES"
|
|
12
|
+
buildForProfiling = "YES"
|
|
13
|
+
buildForArchiving = "YES"
|
|
14
|
+
buildForAnalyzing = "YES">
|
|
15
|
+
<BuildableReference
|
|
16
|
+
BuildableIdentifier = "primary"
|
|
17
|
+
BlueprintIdentifier = "6510766A9670BFA3B251E2A62446FC5D"
|
|
18
|
+
BuildableName = "SkeletonUI.framework"
|
|
19
|
+
BlueprintName = "SkeletonUI"
|
|
20
|
+
ReferencedContainer = "container:Pods.xcodeproj">
|
|
21
|
+
</BuildableReference>
|
|
22
|
+
</BuildActionEntry>
|
|
23
|
+
</BuildActionEntries>
|
|
24
|
+
</BuildAction>
|
|
25
|
+
<TestAction
|
|
26
|
+
buildConfiguration = "Debug"
|
|
27
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
28
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
29
|
+
shouldUseLaunchSchemeArgsEnv = "YES">
|
|
30
|
+
<Testables>
|
|
31
|
+
</Testables>
|
|
32
|
+
</TestAction>
|
|
33
|
+
<LaunchAction
|
|
34
|
+
buildConfiguration = "Debug"
|
|
35
|
+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
|
36
|
+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
|
37
|
+
launchStyle = "0"
|
|
38
|
+
useCustomWorkingDirectory = "NO"
|
|
39
|
+
ignoresPersistentStateOnLaunch = "NO"
|
|
40
|
+
debugDocumentVersioning = "YES"
|
|
41
|
+
debugServiceExtension = "internal"
|
|
42
|
+
allowLocationSimulation = "YES">
|
|
43
|
+
</LaunchAction>
|
|
44
|
+
<ProfileAction
|
|
45
|
+
buildConfiguration = "Release"
|
|
46
|
+
shouldUseLaunchSchemeArgsEnv = "YES"
|
|
47
|
+
savedToolIdentifier = ""
|
|
48
|
+
useCustomWorkingDirectory = "NO"
|
|
49
|
+
debugDocumentVersioning = "YES">
|
|
50
|
+
</ProfileAction>
|
|
51
|
+
<AnalyzeAction
|
|
52
|
+
buildConfiguration = "Debug">
|
|
53
|
+
</AnalyzeAction>
|
|
54
|
+
<ArchiveAction
|
|
55
|
+
buildConfiguration = "Release"
|
|
56
|
+
revealArchiveInOrganizer = "YES">
|
|
57
|
+
</ArchiveAction>
|
|
58
|
+
</Scheme>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>SchemeUserState</key>
|
|
6
|
+
<dict>
|
|
7
|
+
<key>MoMoUIKits.xcscheme</key>
|
|
8
|
+
<dict>
|
|
9
|
+
<key>isShown</key>
|
|
10
|
+
<false />
|
|
11
|
+
<key>orderHint</key>
|
|
12
|
+
<integer>0</integer>
|
|
13
|
+
</dict>
|
|
14
|
+
<key>Pods-Example.xcscheme</key>
|
|
15
|
+
<dict>
|
|
16
|
+
<key>isShown</key>
|
|
17
|
+
<false />
|
|
18
|
+
<key>orderHint</key>
|
|
19
|
+
<integer>1</integer>
|
|
20
|
+
</dict>
|
|
21
|
+
<key>SDWebImage.xcscheme</key>
|
|
22
|
+
<dict>
|
|
23
|
+
<key>isShown</key>
|
|
24
|
+
<false />
|
|
25
|
+
<key>orderHint</key>
|
|
26
|
+
<integer>2</integer>
|
|
27
|
+
</dict>
|
|
28
|
+
<key>SDWebImageSwiftUI.xcscheme</key>
|
|
29
|
+
<dict>
|
|
30
|
+
<key>isShown</key>
|
|
31
|
+
<false />
|
|
32
|
+
<key>orderHint</key>
|
|
33
|
+
<integer>3</integer>
|
|
34
|
+
</dict>
|
|
35
|
+
<key>SkeletonUI.xcscheme</key>
|
|
36
|
+
<dict>
|
|
37
|
+
<key>isShown</key>
|
|
38
|
+
<false />
|
|
39
|
+
<key>orderHint</key>
|
|
40
|
+
<integer>4</integer>
|
|
41
|
+
</dict>
|
|
42
|
+
</dict>
|
|
43
|
+
<key>SuppressBuildableAutocreation</key>
|
|
44
|
+
<dict />
|
|
45
|
+
</dict>
|
|
46
|
+
</plist>
|
|
@@ -245,7 +245,6 @@ public struct Header: View {
|
|
|
245
245
|
} else {
|
|
246
246
|
Text(title)
|
|
247
247
|
.font(.system(size: 17, weight: .bold))
|
|
248
|
-
.ignoreBoldTextSetting()
|
|
249
248
|
.foregroundColor(tintColor ?? Colors.black17)
|
|
250
249
|
.frame(maxWidth: titlePosition == .center ? UIScreen.main.bounds.width - 252 : nil)
|
|
251
250
|
.frame(maxWidth: titlePosition == .center ? .infinity : UIScreen.main.bounds.width - 172, alignment: titlePosition == .center ? .center : .leading)
|
package/ios/Badge/Badge.swift
CHANGED
|
@@ -54,7 +54,6 @@ public struct Badge: View {
|
|
|
54
54
|
public var body: some View {
|
|
55
55
|
Text(formatTitle(label))
|
|
56
56
|
.font(.system(size: scaleSize(10), weight: .bold))
|
|
57
|
-
.ignoreBoldTextSetting()
|
|
58
57
|
.foregroundColor(Colors.black01)
|
|
59
58
|
.padding(.horizontal, Spacing.XS)
|
|
60
59
|
.frame(minWidth: scaleSize(16), minHeight: scaleSize(16))
|
|
@@ -138,7 +138,6 @@ public struct BadgeRibbon: View {
|
|
|
138
138
|
HStack(spacing: 0) {
|
|
139
139
|
Text(label)
|
|
140
140
|
.font(.system(size: scaleSize(12), weight: .medium))
|
|
141
|
-
.ignoreBoldTextSetting()
|
|
142
141
|
.foregroundColor(Colors.black01)
|
|
143
142
|
.lineLimit(1)
|
|
144
143
|
.rotationEffect(rotation)
|
|
@@ -160,7 +159,6 @@ public struct BadgeRibbon: View {
|
|
|
160
159
|
HStack(spacing: 0) {
|
|
161
160
|
Text(label)
|
|
162
161
|
.font(.system(size: scaleSize(12), weight: .medium))
|
|
163
|
-
.ignoreBoldTextSetting()
|
|
164
162
|
.foregroundColor(Colors.black01)
|
|
165
163
|
.lineLimit(1)
|
|
166
164
|
.rotationEffect(rotation)
|
package/ios/Button/Button.swift
CHANGED
|
@@ -200,7 +200,7 @@ public struct Button: View {
|
|
|
200
200
|
.background(bg)
|
|
201
201
|
.overlay(
|
|
202
202
|
RoundedRectangle(cornerRadius: size.radius)
|
|
203
|
-
.
|
|
203
|
+
.stroke(border ?? .clear, lineWidth: border != nil ? borderWidth : 0)
|
|
204
204
|
)
|
|
205
205
|
.clipShape(RoundedRectangle(cornerRadius: size.radius))
|
|
206
206
|
.opacity(loading ? 0.75 : 1)
|
package/ios/Input/Input.swift
CHANGED
|
@@ -157,7 +157,6 @@ public struct Input: View {
|
|
|
157
157
|
})
|
|
158
158
|
.keyboardType(keyboardType)
|
|
159
159
|
.font(fontWeight == .bold ? .action_s_bold : .body_default_regular)
|
|
160
|
-
.ignoreBoldTextSetting()
|
|
161
160
|
.foregroundColor(getTextColor())
|
|
162
161
|
.disabled(disabled || readOnly)
|
|
163
162
|
.applyPrimaryCursorColor()
|
|
@@ -168,7 +168,6 @@ public struct InputSearch: View {
|
|
|
168
168
|
Text(placeholder)
|
|
169
169
|
.foregroundColor(disabled ? Colors.black08 : Colors.black12)
|
|
170
170
|
.font(.system(size: 16, weight: fontWeight))
|
|
171
|
-
.ignoreBoldTextSetting()
|
|
172
171
|
}
|
|
173
172
|
TextField("", text: $text, onEditingChanged: { editing in
|
|
174
173
|
isFocused = editing
|
|
@@ -184,7 +183,6 @@ public struct InputSearch: View {
|
|
|
184
183
|
.disabled(disabled)
|
|
185
184
|
.foregroundColor(disabled ? Colors.black08 : Colors.black17)
|
|
186
185
|
.font(.system(size: 15, weight: fontWeight))
|
|
187
|
-
.ignoreBoldTextSetting()
|
|
188
186
|
.keyboardType(keyboardType)
|
|
189
187
|
}
|
|
190
188
|
|
|
@@ -214,7 +212,6 @@ public struct InputSearch: View {
|
|
|
214
212
|
Text(buttonText)
|
|
215
213
|
.foregroundColor(Colors.black17)
|
|
216
214
|
.font(.system(size: 14, weight: .medium))
|
|
217
|
-
.ignoreBoldTextSetting()
|
|
218
215
|
}
|
|
219
216
|
.padding(.leading, Spacing.L)
|
|
220
217
|
}
|
|
@@ -22,7 +22,7 @@ public struct KeyboardButton: View {
|
|
|
22
22
|
public var body: some View {
|
|
23
23
|
SwiftUI.Button(action: { self.action(key) }) {
|
|
24
24
|
HStack {
|
|
25
|
-
Text(key).font(.system(size: 24, weight: .bold))
|
|
25
|
+
Text(key).font(.system(size: 24, weight: .bold))
|
|
26
26
|
}.frame(maxWidth: CGFloat(width), minHeight: height)
|
|
27
27
|
.background(color)
|
|
28
28
|
.foregroundColor(textColor)
|
|
@@ -24,7 +24,6 @@ extension View {
|
|
|
24
24
|
VStack(spacing: 0) {
|
|
25
25
|
Text("A")
|
|
26
26
|
.font(font)
|
|
27
|
-
.ignoreBoldTextSetting()
|
|
28
27
|
.lineLimit(1)
|
|
29
28
|
.fixedSize()
|
|
30
29
|
.background(
|
|
@@ -36,7 +35,6 @@ extension View {
|
|
|
36
35
|
|
|
37
36
|
Text("A\nA")
|
|
38
37
|
.font(font)
|
|
39
|
-
.ignoreBoldTextSetting()
|
|
40
38
|
.lineLimit(2)
|
|
41
39
|
.fixedSize(horizontal: false, vertical: true)
|
|
42
40
|
.background(
|
|
@@ -223,14 +221,12 @@ public struct PopupDisplay: View {
|
|
|
223
221
|
SwiftUI.Button(action: onPressCloseButton) {
|
|
224
222
|
Text(closeButtonTitle)
|
|
225
223
|
.font(.action2)
|
|
226
|
-
.ignoreBoldTextSetting()
|
|
227
224
|
}.foregroundColor(Colors.black09)
|
|
228
225
|
.padding(.trailing, 12)
|
|
229
226
|
|
|
230
227
|
SwiftUI.Button(action: onPressAction) {
|
|
231
228
|
Text(actionButtonTitle)
|
|
232
229
|
.font(.action2)
|
|
233
|
-
.ignoreBoldTextSetting()
|
|
234
230
|
}.foregroundColor(Colors.primary)
|
|
235
231
|
}
|
|
236
232
|
.frame(maxWidth: .infinity, alignment: .trailing)
|
|
@@ -242,14 +238,12 @@ public struct PopupDisplay: View {
|
|
|
242
238
|
SwiftUI.Button(action: onPressAction) {
|
|
243
239
|
Text(actionButtonTitle)
|
|
244
240
|
.font(.action2)
|
|
245
|
-
.ignoreBoldTextSetting()
|
|
246
241
|
}.foregroundColor(Colors.primary)
|
|
247
242
|
.padding(.bottom, 6)
|
|
248
243
|
|
|
249
244
|
SwiftUI.Button(action: onPressCloseButton) {
|
|
250
245
|
Text(closeButtonTitle)
|
|
251
246
|
.font(.action2)
|
|
252
|
-
.ignoreBoldTextSetting()
|
|
253
247
|
}.foregroundColor(Colors.black09)
|
|
254
248
|
}
|
|
255
249
|
.frame(maxWidth: .infinity, alignment: .trailing)
|
|
@@ -38,14 +38,12 @@ public struct PopupInput: View {
|
|
|
38
38
|
Text(title)
|
|
39
39
|
.foregroundColor(.black)
|
|
40
40
|
.font(.headerText1)
|
|
41
|
-
.ignoreBoldTextSetting()
|
|
42
41
|
.padding(.top, 12)
|
|
43
42
|
.padding(.bottom, 24)
|
|
44
43
|
|
|
45
44
|
Text(description)
|
|
46
45
|
.foregroundColor(.black)
|
|
47
46
|
.font(.paragraph)
|
|
48
|
-
.ignoreBoldTextSetting()
|
|
49
47
|
.opacity(0.6)
|
|
50
48
|
.multilineTextAlignment(.leading)
|
|
51
49
|
.padding(.bottom, 20)
|
|
@@ -79,7 +79,6 @@ public struct TrustBanner: View {
|
|
|
79
79
|
.foregroundColor(Color(hex: "484848"))
|
|
80
80
|
.lineLimit(2)
|
|
81
81
|
.font(.system(size: 13, weight: Font.Weight.regular))
|
|
82
|
-
.ignoreBoldTextSetting()
|
|
83
82
|
.lineSpacing(3)
|
|
84
83
|
.padding(.bottom, 8)
|
|
85
84
|
HStack {
|
|
@@ -87,7 +86,6 @@ public struct TrustBanner: View {
|
|
|
87
86
|
Text(applicationEnvironment.config?.trustBanner?.subContent[language ?? "vi"] as? String ?? defaultBanner.subContent[language ?? "vi"])
|
|
88
87
|
.foregroundColor(Colors.pink03)
|
|
89
88
|
.font(.system(size: 13, weight: .bold))
|
|
90
|
-
.ignoreBoldTextSetting()
|
|
91
89
|
.padding(.trailing, 4)
|
|
92
90
|
|
|
93
91
|
Icon(source: "arrow_chevron_right_small", color: Colors.pink03)
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
3
|
public func scaleSize(_ size: CGFloat, _ scaleRate: CGFloat? = nil) -> CGFloat {
|
|
4
|
-
let config = FontScaleStore.shared.config
|
|
5
4
|
let defaultScreenSize: CGFloat = 375
|
|
6
5
|
let maxFontScale: CGFloat = scaleRate ?? 1.5
|
|
7
6
|
let maxDeviceScale: CGFloat = 5
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return customRate > 1 ? size * customRate : size
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
let deviceScale = UIScreen.main.bounds.width / defaultScreenSize
|
|
8
|
+
let deviceWidth = UIScreen.main.bounds.width
|
|
9
|
+
let deviceScale = deviceWidth / defaultScreenSize
|
|
15
10
|
|
|
16
11
|
let defaultFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
|
|
17
12
|
let scaledFont = UIFontMetrics.default.scaledFont(for: defaultFont)
|
|
18
|
-
let
|
|
13
|
+
let fontScale = scaledFont.pointSize / defaultFont.pointSize
|
|
19
14
|
|
|
20
15
|
var fontSizeDeviceScale = size
|
|
21
16
|
var fontSizeOSScale = size
|
|
22
17
|
|
|
18
|
+
|
|
23
19
|
if deviceScale > 1 {
|
|
24
20
|
fontSizeDeviceScale = min(fontSizeDeviceScale * deviceScale, fontSizeDeviceScale + maxDeviceScale)
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
|
|
23
|
+
if fontScale > 1 {
|
|
24
|
+
fontSizeOSScale = min(fontSizeOSScale * fontScale, fontSizeOSScale * maxFontScale)
|
|
28
25
|
}
|
|
29
26
|
|
|
30
27
|
return max(fontSizeDeviceScale, fontSizeOSScale)
|
|
@@ -121,7 +118,6 @@ public struct MomoText: View {
|
|
|
121
118
|
private let content: String
|
|
122
119
|
private let typography: TypographyStyle
|
|
123
120
|
private let color: Color
|
|
124
|
-
@ObservedObject private var fontScale = FontScaleStore.shared
|
|
125
121
|
|
|
126
122
|
public init(
|
|
127
123
|
_ content: String,
|
|
@@ -134,13 +130,11 @@ public struct MomoText: View {
|
|
|
134
130
|
}
|
|
135
131
|
|
|
136
132
|
public var body: some View {
|
|
137
|
-
_ = fontScale.config
|
|
138
133
|
let text = SwiftUI.Text(content)
|
|
139
134
|
.font(.system(size: scaleSize(typography.fontSize), weight: typography.fontWeight))
|
|
140
135
|
.foregroundColor(color)
|
|
141
136
|
.lineSpacing(scaleSize(typography.lineHeight) - scaleSize(typography.fontSize))
|
|
142
137
|
|
|
143
138
|
return text
|
|
144
|
-
.ignoreBoldTextSetting()
|
|
145
139
|
}
|
|
146
140
|
}
|
|
@@ -1,40 +1,26 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
|
-
public extension View {
|
|
4
|
-
/// Forces SwiftUI to ignore the OS "Bold Text" accessibility setting so the
|
|
5
|
-
/// kit's typography weight stays fixed and matches the Compose implementation
|
|
6
|
-
/// (which does not honor that OS setting). Apply it wherever a `.font(...)` is set.
|
|
7
|
-
func ignoreBoldTextSetting() -> some View {
|
|
8
|
-
environment(\.legibilityWeight, .regular)
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
3
|
public extension Font {
|
|
13
4
|
static func appFont(size: CGFloat) -> Font {
|
|
14
|
-
let config = FontScaleStore.shared.config
|
|
15
5
|
let defaultScreenSize: CGFloat = 375
|
|
16
6
|
let maxFontScale: CGFloat = 1.5
|
|
17
7
|
let maxDeviceScale: CGFloat = 5
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return Font.system(size: scaled)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let deviceScale = UIScreen.main.bounds.width / defaultScreenSize
|
|
26
|
-
|
|
8
|
+
|
|
9
|
+
let deviceWidth = UIScreen.main.bounds.width
|
|
10
|
+
let deviceScale = deviceWidth / defaultScreenSize
|
|
11
|
+
|
|
27
12
|
let defaultFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
|
|
28
13
|
let scaledFont = UIFontMetrics.default.scaledFont(for: defaultFont)
|
|
29
|
-
let
|
|
14
|
+
let fontScale = scaledFont.pointSize / defaultFont.pointSize
|
|
30
15
|
|
|
31
16
|
var fontSize = size
|
|
32
17
|
|
|
33
18
|
if deviceScale > 1 {
|
|
34
19
|
fontSize = min(fontSize * deviceScale, fontSize + maxDeviceScale)
|
|
35
20
|
}
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
|
|
22
|
+
if fontScale > 1 {
|
|
23
|
+
fontSize = min(fontSize * fontScale, fontSize * maxFontScale)
|
|
38
24
|
}
|
|
39
25
|
|
|
40
26
|
return Font.system(size: fontSize)
|
package/package.json
CHANGED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import SwiftUI
|
|
2
|
-
|
|
3
|
-
public struct FontScaleConfig {
|
|
4
|
-
public var useOSFontScale: Bool
|
|
5
|
-
public var userScaleRate: CGFloat?
|
|
6
|
-
|
|
7
|
-
public init(useOSFontScale: Bool = true, userScaleRate: CGFloat? = nil) {
|
|
8
|
-
self.useOSFontScale = useOSFontScale
|
|
9
|
-
self.userScaleRate = userScaleRate
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
public final class FontScaleStore: ObservableObject {
|
|
14
|
-
public static let shared = FontScaleStore()
|
|
15
|
-
|
|
16
|
-
@Published public private(set) var config = FontScaleConfig()
|
|
17
|
-
|
|
18
|
-
private var didBind = false
|
|
19
|
-
private var observerId: String?
|
|
20
|
-
|
|
21
|
-
private init() {}
|
|
22
|
-
|
|
23
|
-
public func update(_ newConfig: FontScaleConfig) {
|
|
24
|
-
if Thread.isMainThread {
|
|
25
|
-
config = newConfig
|
|
26
|
-
} else {
|
|
27
|
-
DispatchQueue.main.async { [weak self] in self?.config = newConfig }
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public func bind(_ api: KitComposeApi?) {
|
|
32
|
-
guard let api = api, !didBind else { return }
|
|
33
|
-
didBind = true
|
|
34
|
-
|
|
35
|
-
apply(api.request(funcName: "getFontScaleConfig", params: nil))
|
|
36
|
-
observerId = api.request(funcName: "observer", params: ["font_scale_config"]) { [weak self] response in
|
|
37
|
-
self?.apply(response)
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private func apply(_ response: String) {
|
|
42
|
-
guard let parsed = FontScaleStore.parse(response) else { return }
|
|
43
|
-
update(parsed)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static func parse(_ response: String) -> FontScaleConfig? {
|
|
47
|
-
guard
|
|
48
|
-
let data = response.data(using: .utf8),
|
|
49
|
-
let json = (try? JSONSerialization.jsonObject(with: data)) as? [String: Any]
|
|
50
|
-
else { return nil }
|
|
51
|
-
|
|
52
|
-
let obj = (json["response"] as? [String: Any]) ?? (json["data"] as? [String: Any]) ?? json
|
|
53
|
-
guard obj["useOSFontScale"] != nil || obj["userScaleRate"] != nil else { return nil }
|
|
54
|
-
|
|
55
|
-
let useOS = (obj["useOSFontScale"] as? Bool) ?? true
|
|
56
|
-
let rate = (obj["userScaleRate"] as? NSNumber).map { CGFloat($0.doubleValue) }
|
|
57
|
-
return FontScaleConfig(useOSFontScale: useOS, userScaleRate: rate)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import SwiftUI
|
|
2
|
-
|
|
3
|
-
public enum InformationState {
|
|
4
|
-
case `default`
|
|
5
|
-
case warning
|
|
6
|
-
case error
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
public struct Information: View {
|
|
10
|
-
private let title: String?
|
|
11
|
-
private let description: String
|
|
12
|
-
private let state: InformationState
|
|
13
|
-
private let image: String?
|
|
14
|
-
private let onPressAction: (() -> Void)?
|
|
15
|
-
private let showIcon: Bool
|
|
16
|
-
private let action: String?
|
|
17
|
-
private let showIconClose: Bool
|
|
18
|
-
private let onPressClose: (() -> Void)?
|
|
19
|
-
|
|
20
|
-
public init(
|
|
21
|
-
title: String? = nil,
|
|
22
|
-
description: String = "Description",
|
|
23
|
-
state: InformationState = .default,
|
|
24
|
-
image: String? = nil,
|
|
25
|
-
onPressAction: (() -> Void)? = nil,
|
|
26
|
-
showIcon: Bool = true,
|
|
27
|
-
action: String? = nil,
|
|
28
|
-
showIconClose: Bool = true,
|
|
29
|
-
onPressClose: (() -> Void)? = nil
|
|
30
|
-
) {
|
|
31
|
-
self.title = title
|
|
32
|
-
self.description = description
|
|
33
|
-
self.state = state
|
|
34
|
-
self.image = image
|
|
35
|
-
self.onPressAction = onPressAction
|
|
36
|
-
self.showIcon = showIcon
|
|
37
|
-
self.action = action
|
|
38
|
-
self.showIconClose = showIconClose
|
|
39
|
-
self.onPressClose = onPressClose
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
private var borderColor: Color {
|
|
43
|
-
switch state {
|
|
44
|
-
case .default: return Colors.blue07
|
|
45
|
-
case .warning: return Colors.yellow06
|
|
46
|
-
case .error: return Colors.red07
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
private var backgroundColor: Color {
|
|
51
|
-
switch state {
|
|
52
|
-
case .default: return Colors.blue10
|
|
53
|
-
case .warning: return Colors.yellow09
|
|
54
|
-
case .error: return Colors.red10
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private var accentColor: Color {
|
|
59
|
-
switch state {
|
|
60
|
-
case .default: return Colors.blue03
|
|
61
|
-
case .warning: return Colors.orange03
|
|
62
|
-
case .error: return Colors.red03
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private var iconSource: String {
|
|
67
|
-
switch state {
|
|
68
|
-
case .default: return "notifications_info"
|
|
69
|
-
case .warning: return "24_notifications_alert_triangle"
|
|
70
|
-
case .error: return "24_notifications_alert_octagon"
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
public var body: some View {
|
|
75
|
-
VStack(alignment: .leading, spacing: 0) {
|
|
76
|
-
HStack(alignment: .top, spacing: 0) {
|
|
77
|
-
if let image {
|
|
78
|
-
ImageView(image)
|
|
79
|
-
.frame(width: 40, height: 40)
|
|
80
|
-
.clipShape(RoundedRectangle(cornerRadius: Radius.S))
|
|
81
|
-
.padding(.trailing, Spacing.S)
|
|
82
|
-
} else if showIcon {
|
|
83
|
-
Icon(source: iconSource, size: 16, color: accentColor)
|
|
84
|
-
.padding(.trailing, Spacing.S)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
VStack(alignment: .leading, spacing: 0) {
|
|
88
|
-
if let title {
|
|
89
|
-
MomoText(title, typography: .labelDefaultMedium)
|
|
90
|
-
}
|
|
91
|
-
MomoText(description, typography: .descriptionDefaultRegular)
|
|
92
|
-
}
|
|
93
|
-
.frame(maxWidth: .infinity, alignment: .leading)
|
|
94
|
-
|
|
95
|
-
if let onPressClose, showIconClose {
|
|
96
|
-
Icon(source: "navigation_close", size: 16, color: Colors.black17)
|
|
97
|
-
.contentShape(Rectangle())
|
|
98
|
-
.onTapGesture(perform: onPressClose)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if let action, let onPressAction {
|
|
103
|
-
MomoText(action, typography: .actionXsBold, color: accentColor)
|
|
104
|
-
.frame(maxWidth: .infinity, alignment: .trailing)
|
|
105
|
-
.contentShape(Rectangle())
|
|
106
|
-
.onTapGesture(perform: onPressAction)
|
|
107
|
-
.padding(.top, Spacing.S)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
.padding(Spacing.M)
|
|
111
|
-
.background(
|
|
112
|
-
RoundedRectangle(cornerRadius: Radius.S)
|
|
113
|
-
.fill(backgroundColor)
|
|
114
|
-
)
|
|
115
|
-
.overlay(
|
|
116
|
-
RoundedRectangle(cornerRadius: Radius.S)
|
|
117
|
-
.stroke(borderColor, lineWidth: 0.5)
|
|
118
|
-
)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// MARK: - Preview
|
|
123
|
-
#if DEBUG
|
|
124
|
-
struct Information_Previews: PreviewProvider {
|
|
125
|
-
static var previews: some View {
|
|
126
|
-
VStack(spacing: 16) {
|
|
127
|
-
Information(
|
|
128
|
-
title: "Information",
|
|
129
|
-
description: "This is a default information message."
|
|
130
|
-
)
|
|
131
|
-
Information(
|
|
132
|
-
title: "Warning",
|
|
133
|
-
description: "This is a warning message.",
|
|
134
|
-
state: .warning
|
|
135
|
-
)
|
|
136
|
-
Information(
|
|
137
|
-
title: "Error",
|
|
138
|
-
description: "This is an error message.",
|
|
139
|
-
state: .error,
|
|
140
|
-
onPressAction: {}, action: "Retry"
|
|
141
|
-
)
|
|
142
|
-
Information(
|
|
143
|
-
description: "Dismissible information.",
|
|
144
|
-
onPressClose: {}
|
|
145
|
-
)
|
|
146
|
-
}
|
|
147
|
-
.padding()
|
|
148
|
-
.previewLayout(.sizeThatFits)
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
#endif
|