@momo-kits/native-kits 0.162.17 → 0.162.18
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
CHANGED
|
@@ -40,7 +40,7 @@ Publishing is automated (`publish.sh` + GitLab CI on `[ci build]` / `main`). Do
|
|
|
40
40
|
## Architecture essentials
|
|
41
41
|
|
|
42
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
|
|
43
|
+
- **Configuration flows via CompositionLocals**, not params. Public ones: `AppTheme`, `AppStatusBar`, `AppNavigationBar` (`const/Theme.kt`); `ApplicationContext`, `AppConfig`, `AppLanguage`, `LocalLocalize` (`application/`); `LocalNavigator`, `LocalMaxApi` (`navigation/`). Read with `X.current`.
|
|
44
44
|
- **Platform code** goes through `expect`/`actual` in `platform/` — never reference Android/iOS APIs from `commonMain` directly.
|
|
45
45
|
- **Native bridge:** `IMaxApi` (`vn.momo.maxapi`, exposed as `LocalMaxApi`) is the host-app bridge (dismiss, tracking, device info, language).
|
|
46
46
|
- Navigation uses a runtime `DynamicScreenRegistry`; overlays (modal/bottom-sheet/snackbar) go through `Navigator` + `OverplayComponentRegistry`.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import CoreGraphics
|
|
2
|
+
|
|
3
|
+
/// App-wide font-scale preference for the SwiftUI kit. An exported holder the host writes once at
|
|
4
|
+
/// app startup (from the cache-backed `FontScaleProvider`); `scaleSize`/`appFont` read the snapshot.
|
|
5
|
+
/// No realtime: the SwiftUI kit has no navigation container to scope reactive updates, so a startup
|
|
6
|
+
/// snapshot is enough. When `useOSScaleRate` is false the kit applies `userScaleRate` instead of the
|
|
7
|
+
/// OS Dynamic Type factor.
|
|
8
|
+
public final class FontScaleStore {
|
|
9
|
+
public static let shared = FontScaleStore()
|
|
10
|
+
private init() {}
|
|
11
|
+
|
|
12
|
+
public private(set) var userScaleRate: CGFloat = 1
|
|
13
|
+
public private(set) var useOSScaleRate: Bool = true
|
|
14
|
+
|
|
15
|
+
public func update(userScaleRate: CGFloat, useOSScaleRate: Bool) {
|
|
16
|
+
self.userScaleRate = userScaleRate
|
|
17
|
+
self.useOSScaleRate = useOSScaleRate
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
3
|
public func scaleSize(_ size: CGFloat, _ scaleRate: CGFloat? = nil) -> CGFloat {
|
|
4
|
+
if !FontScaleStore.shared.useOSScaleRate {
|
|
5
|
+
return size * FontScaleStore.shared.userScaleRate
|
|
6
|
+
}
|
|
4
7
|
let defaultScreenSize: CGFloat = 375
|
|
5
8
|
let maxFontScale: CGFloat = scaleRate ?? 1.5
|
|
6
9
|
let maxDeviceScale: CGFloat = 5
|
|
@@ -11,6 +11,9 @@ public extension View {
|
|
|
11
11
|
|
|
12
12
|
public extension Font {
|
|
13
13
|
static func appFont(size: CGFloat) -> Font {
|
|
14
|
+
if !FontScaleStore.shared.useOSScaleRate {
|
|
15
|
+
return Font.system(size: size * FontScaleStore.shared.userScaleRate)
|
|
16
|
+
}
|
|
14
17
|
let defaultScreenSize: CGFloat = 375
|
|
15
18
|
let maxFontScale: CGFloat = 1.5
|
|
16
19
|
let maxDeviceScale: CGFloat = 5
|