@momo-kits/native-kits 0.159.1-beta.6-debug → 0.159.1-beta.7-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/compose/build.gradle.kts +1 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/const/Typography.kt +32 -2
- package/gradle/libs.versions.toml +1 -1
- package/gradle.properties +1 -1
- package/ios/Typography/Text.swift +24 -1
- package/ios/Typography/Typography.swift +25 -4
- package/package.json +1 -1
package/compose/build.gradle.kts
CHANGED
|
@@ -7,10 +7,16 @@ import androidx.compose.ui.text.TextStyle
|
|
|
7
7
|
import androidx.compose.ui.text.font.FontFamily
|
|
8
8
|
import androidx.compose.ui.text.font.FontWeight
|
|
9
9
|
import androidx.compose.ui.text.style.TextDecoration
|
|
10
|
-
import androidx.compose.ui.unit
|
|
10
|
+
import androidx.compose.ui.unit.Dp
|
|
11
|
+
import androidx.compose.ui.unit.TextUnit
|
|
12
|
+
import androidx.compose.ui.unit.TextUnitType
|
|
13
|
+
import androidx.compose.ui.unit.dp
|
|
14
|
+
import androidx.compose.ui.unit.sp
|
|
11
15
|
import org.jetbrains.compose.resources.Font
|
|
12
16
|
import org.jetbrains.compose.resources.FontResource
|
|
13
17
|
import org.jetbrains.compose.resources.InternalResourceApi
|
|
18
|
+
import vn.momo.kits.application.ScaleSizeMaxRate
|
|
19
|
+
import vn.momo.kits.platform.getScreenDimensions
|
|
14
20
|
import vn.momo.uikits.resources.Res
|
|
15
21
|
import vn.momo.uikits.resources.momosignature
|
|
16
22
|
import vn.momo.uikits.resources.momotrustdisplay
|
|
@@ -23,6 +29,8 @@ import vn.momo.uikits.resources.sfprotext_regular
|
|
|
23
29
|
import vn.momo.uikits.resources.sfprotext_semibold
|
|
24
30
|
import vn.momo.uikits.resources.sfprotext_thin
|
|
25
31
|
import vn.momo.uikits.resources.sfprotext_ultralight
|
|
32
|
+
import kotlin.math.max
|
|
33
|
+
import kotlin.math.min
|
|
26
34
|
|
|
27
35
|
const val DEFAULT_SCREEN_SIZE = 375f
|
|
28
36
|
const val MAX_FONT_SCALE = 1.2f
|
|
@@ -30,7 +38,29 @@ const val MAX_DEVICE_SCALE = 5
|
|
|
30
38
|
|
|
31
39
|
@Composable
|
|
32
40
|
fun scaleSize(size: Float): Float {
|
|
33
|
-
|
|
41
|
+
val scaleSizeMaxRate: Float = ScaleSizeMaxRate.current ?: MAX_FONT_SCALE
|
|
42
|
+
val deviceWidth = getScreenDimensions().width
|
|
43
|
+
val deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE
|
|
44
|
+
|
|
45
|
+
val density = LocalDensity.current
|
|
46
|
+
val fontScale = density.fontScale
|
|
47
|
+
|
|
48
|
+
var fontSizeScaleDevice = size
|
|
49
|
+
var fontSizeScaleOS = size
|
|
50
|
+
|
|
51
|
+
if (deviceScale > 1) {
|
|
52
|
+
fontSizeScaleDevice =
|
|
53
|
+
min(deviceScale * fontSizeScaleDevice, fontSizeScaleDevice + MAX_DEVICE_SCALE)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (fontScale > 1) {
|
|
57
|
+
fontSizeScaleOS = min(fontScale * fontSizeScaleOS, fontSizeScaleOS * scaleSizeMaxRate)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return max(
|
|
61
|
+
fontSizeScaleDevice,
|
|
62
|
+
fontSizeScaleOS
|
|
63
|
+
)
|
|
34
64
|
}
|
|
35
65
|
|
|
36
66
|
@Composable
|
package/gradle.properties
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
import SwiftUI
|
|
2
2
|
|
|
3
3
|
public func scaleSize(_ size: CGFloat, _ scaleRate: CGFloat? = nil) -> CGFloat {
|
|
4
|
-
|
|
4
|
+
let defaultScreenSize: CGFloat = 375
|
|
5
|
+
let maxFontScale: CGFloat = scaleRate ?? 1.2
|
|
6
|
+
let maxDeviceScale: CGFloat = 5
|
|
7
|
+
|
|
8
|
+
let deviceWidth = UIScreen.main.bounds.width
|
|
9
|
+
let deviceScale = deviceWidth / defaultScreenSize
|
|
10
|
+
|
|
11
|
+
let defaultFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
|
|
12
|
+
let scaledFont = UIFontMetrics.default.scaledFont(for: defaultFont)
|
|
13
|
+
let fontScale = scaledFont.pointSize / defaultFont.pointSize
|
|
14
|
+
|
|
15
|
+
var fontSizeDeviceScale = size
|
|
16
|
+
var fontSizeOSScale = size
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
if deviceScale > 1 {
|
|
20
|
+
fontSizeDeviceScale = min(fontSizeDeviceScale * deviceScale, fontSizeDeviceScale + maxDeviceScale)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if fontScale > 1 {
|
|
24
|
+
fontSizeOSScale = min(fontSizeOSScale * fontScale, fontSizeOSScale * maxFontScale)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return max(fontSizeDeviceScale, fontSizeOSScale)
|
|
5
28
|
}
|
|
6
29
|
|
|
7
30
|
public enum TypographyStyle {
|
|
@@ -2,9 +2,30 @@ import SwiftUI
|
|
|
2
2
|
|
|
3
3
|
public extension Font {
|
|
4
4
|
static func appFont(size: CGFloat) -> Font {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
let defaultScreenSize: CGFloat = 375
|
|
6
|
+
let maxFontScale: CGFloat = 1.5
|
|
7
|
+
let maxDeviceScale: CGFloat = 5
|
|
8
|
+
|
|
9
|
+
let deviceWidth = UIScreen.main.bounds.width
|
|
10
|
+
let deviceScale = deviceWidth / defaultScreenSize
|
|
11
|
+
|
|
12
|
+
let defaultFont = UIFont.systemFont(ofSize: UIFont.labelFontSize)
|
|
13
|
+
let scaledFont = UIFontMetrics.default.scaledFont(for: defaultFont)
|
|
14
|
+
let fontScale = scaledFont.pointSize / defaultFont.pointSize
|
|
15
|
+
|
|
16
|
+
var fontSize = size
|
|
17
|
+
|
|
18
|
+
if deviceScale > 1 {
|
|
19
|
+
fontSize = min(fontSize * deviceScale, fontSize + maxDeviceScale)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if fontScale > 1 {
|
|
23
|
+
fontSize = min(fontSize * fontScale, fontSize * maxFontScale)
|
|
24
|
+
}
|
|
7
25
|
|
|
26
|
+
return Font.system(size: fontSize)
|
|
27
|
+
}
|
|
28
|
+
|
|
8
29
|
// New supported typography styles
|
|
9
30
|
static let headline_default_bold = appFont(size: 24).weight(.bold)
|
|
10
31
|
static let header_m_bold = appFont(size: 18).weight(.bold)
|
|
@@ -22,7 +43,7 @@ public extension Font {
|
|
|
22
43
|
static let action_s_bold = appFont(size: 14).weight(.bold)
|
|
23
44
|
static let action_xs_bold = appFont(size: 12).weight(.bold)
|
|
24
45
|
static let action_xxs_bold = appFont(size: 10).weight(.bold)
|
|
25
|
-
|
|
46
|
+
|
|
26
47
|
// Legacy styles
|
|
27
48
|
static let headline_default = appFont(size: 28).weight(.semibold)
|
|
28
49
|
static let headline_s = appFont(size: 24).weight(.semibold)
|
|
@@ -47,7 +68,7 @@ public extension Font {
|
|
|
47
68
|
static let action_xxs = appFont(size: 10).weight(.bold)
|
|
48
69
|
static let action_xs = appFont(size: 12).weight(.bold)
|
|
49
70
|
static let action_s = appFont(size: 15).weight(.bold)
|
|
50
|
-
|
|
71
|
+
|
|
51
72
|
// deprecated
|
|
52
73
|
static let h1 = appFont(size: 36).weight(.semibold) //headline_xl
|
|
53
74
|
static let h2 = appFont(size: 32).weight(.semibold)
|