@momo-kits/native-kits 0.89.33-beta.38 → 0.89.33-beta.41
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.
|
@@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.Box
|
|
|
10
10
|
import androidx.compose.foundation.layout.BoxWithConstraints
|
|
11
11
|
import androidx.compose.foundation.layout.Row
|
|
12
12
|
import androidx.compose.foundation.layout.Spacer
|
|
13
|
-
import androidx.compose.foundation.layout.fillMaxSize
|
|
14
13
|
import androidx.compose.foundation.layout.fillMaxWidth
|
|
15
14
|
import androidx.compose.foundation.layout.height
|
|
16
15
|
import androidx.compose.foundation.layout.padding
|
|
@@ -67,7 +66,6 @@ data class AnimatedHeader(
|
|
|
67
66
|
@Composable
|
|
68
67
|
fun HeaderBackground(
|
|
69
68
|
headerType: HeaderType = HeaderType.DEFAULT,
|
|
70
|
-
headerBanner: String? = null,
|
|
71
69
|
scrollState: Int
|
|
72
70
|
) {
|
|
73
71
|
val statusBarHeight = AppStatusBar.current ?: getStatusBarHeight()
|
|
@@ -75,7 +73,6 @@ fun HeaderBackground(
|
|
|
75
73
|
targetValue = (1 - (scrollState / 200f)).coerceIn(0f, 1f),
|
|
76
74
|
)
|
|
77
75
|
|
|
78
|
-
|
|
79
76
|
val backgroundColor = if (scrollState == 0) {
|
|
80
77
|
Color.Transparent
|
|
81
78
|
} else {
|
|
@@ -112,7 +109,7 @@ fun HeaderBackground(
|
|
|
112
109
|
)
|
|
113
110
|
if (AppTheme.current.assets.headerBackground != null) {
|
|
114
111
|
Image(
|
|
115
|
-
source =
|
|
112
|
+
source = AppTheme.current.assets.headerBackground!!,
|
|
116
113
|
modifier = Modifier.fillMaxWidth().height(height),
|
|
117
114
|
options = Options(
|
|
118
115
|
contentScale = ContentScale.FillWidth
|
|
@@ -125,33 +122,33 @@ fun HeaderBackground(
|
|
|
125
122
|
|
|
126
123
|
HeaderType.EXTENDED -> {
|
|
127
124
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
)
|
|
125
|
+
Box(
|
|
126
|
+
modifier = Modifier.fillMaxWidth().height(154.dp)
|
|
127
|
+
.alpha(opacityAni)
|
|
128
|
+
.background(
|
|
129
|
+
Brush.linearGradient(
|
|
130
|
+
colors = listOf(
|
|
131
|
+
Color(0xFFFDCADE),
|
|
132
|
+
Color(0x00FDCADE)
|
|
133
|
+
),
|
|
134
|
+
start = Offset(0f, 0f),
|
|
135
|
+
end = Offset(0f, with(LocalDensity.current) { 154.dp.toPx() })
|
|
140
136
|
)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
137
|
+
)
|
|
138
|
+
) {
|
|
139
|
+
if (AppTheme.current.assets.headerBackground != null) {
|
|
140
|
+
Box(
|
|
141
|
+
modifier = Modifier.fillMaxWidth()
|
|
142
|
+
.background(backgroundColor)
|
|
143
|
+
) {
|
|
144
|
+
Image(
|
|
145
|
+
source = AppTheme.current.assets.headerBackground!!,
|
|
146
|
+
modifier = Modifier.fillMaxWidth().height(154.dp),
|
|
147
|
+
options = Options(
|
|
148
|
+
contentScale = ContentScale.FillWidth
|
|
153
149
|
)
|
|
154
|
-
|
|
150
|
+
)
|
|
151
|
+
}
|
|
155
152
|
}
|
|
156
153
|
}
|
|
157
154
|
}
|
|
@@ -263,7 +260,7 @@ fun Header(
|
|
|
263
260
|
}
|
|
264
261
|
if (inputSearchProps != null) {
|
|
265
262
|
InputSearch(inputSearchProps = inputSearchProps.copy(backgroundColor = backgroundSearch))
|
|
266
|
-
} else{
|
|
263
|
+
} else {
|
|
267
264
|
Box(
|
|
268
265
|
Modifier.weight(1f).graphicsLayer {
|
|
269
266
|
alpha = if (animatedHeader !== null) opacity ?: 1f else 1f
|
|
@@ -2,10 +2,19 @@ package vn.momo.kits.application
|
|
|
2
2
|
|
|
3
3
|
import androidx.compose.runtime.Composable
|
|
4
4
|
import androidx.compose.runtime.CompositionLocalProvider
|
|
5
|
+
import androidx.compose.runtime.LaunchedEffect
|
|
6
|
+
import androidx.compose.runtime.getValue
|
|
7
|
+
import androidx.compose.runtime.mutableStateOf
|
|
8
|
+
import androidx.compose.runtime.remember
|
|
9
|
+
import androidx.compose.runtime.setValue
|
|
5
10
|
import androidx.compose.runtime.staticCompositionLocalOf
|
|
11
|
+
import kotlinx.serialization.json.Json
|
|
12
|
+
import kotlinx.serialization.json.jsonObject
|
|
13
|
+
import kotlinx.serialization.json.jsonPrimitive
|
|
6
14
|
import vn.momo.kits.const.AppStatusBar
|
|
7
15
|
import vn.momo.kits.const.AppTheme
|
|
8
16
|
import vn.momo.kits.const.Theme
|
|
17
|
+
import vn.momo.kits.const.ThemeAssets
|
|
9
18
|
import vn.momo.kits.const.defaultTheme
|
|
10
19
|
import vn.momo.kits.platform.disableOverscroll
|
|
11
20
|
import vn.momo.kits.platform.getStatusBarHeight
|
|
@@ -57,13 +66,35 @@ interface ComposeApi {
|
|
|
57
66
|
|
|
58
67
|
@Composable
|
|
59
68
|
fun ApplicationContainer(
|
|
60
|
-
theme: Theme =
|
|
69
|
+
theme: Theme? = null,
|
|
61
70
|
composeApi: ComposeApi,
|
|
62
71
|
content: @Composable () -> Unit,
|
|
63
72
|
) {
|
|
73
|
+
val platformApi = PlatformApi.current
|
|
74
|
+
var appTheme by remember { mutableStateOf(defaultTheme) }
|
|
75
|
+
|
|
76
|
+
LaunchedEffect(Unit) {
|
|
77
|
+
platformApi?.request("getConfig", "DESIGN_SYSTEM") {
|
|
78
|
+
val json = Json { ignoreUnknownKeys = true }
|
|
79
|
+
val response = json.parseToJsonElement(it).jsonObject
|
|
80
|
+
val headerBar = response["response"]
|
|
81
|
+
?.jsonObject
|
|
82
|
+
?.get("headerBar")
|
|
83
|
+
?.jsonPrimitive
|
|
84
|
+
?.content
|
|
85
|
+
if (headerBar != null) {
|
|
86
|
+
appTheme = defaultTheme.copy(
|
|
87
|
+
assets = ThemeAssets(
|
|
88
|
+
headerBackground = headerBar
|
|
89
|
+
)
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
64
95
|
disableOverscroll()
|
|
65
96
|
CompositionLocalProvider(
|
|
66
|
-
AppTheme provides theme,
|
|
97
|
+
AppTheme provides (theme ?: appTheme),
|
|
67
98
|
PlatformApi provides composeApi,
|
|
68
99
|
AppNavigator provides Navigator(),
|
|
69
100
|
AppStatusBar provides getStatusBarHeight(),
|
|
@@ -32,8 +32,6 @@ import androidx.compose.ui.unit.Dp
|
|
|
32
32
|
import androidx.compose.ui.unit.dp
|
|
33
33
|
import androidx.compose.ui.unit.min
|
|
34
34
|
import androidx.compose.ui.zIndex
|
|
35
|
-
import kotlinx.serialization.Serializable
|
|
36
|
-
import kotlinx.serialization.json.Json
|
|
37
35
|
import vn.momo.kits.components.InputSearchProps
|
|
38
36
|
import vn.momo.kits.const.AppStatusBar
|
|
39
37
|
import vn.momo.kits.const.AppTheme
|
|
@@ -49,9 +47,6 @@ enum class HeaderType {
|
|
|
49
47
|
NONE
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
@Serializable
|
|
53
|
-
data class ConfigData(val headerBanner: String? = null)
|
|
54
|
-
|
|
55
50
|
@Composable
|
|
56
51
|
fun Screen(
|
|
57
52
|
backgroundColor: Color? = null,
|
|
@@ -84,11 +79,6 @@ fun Screen(
|
|
|
84
79
|
else -> 0.dp
|
|
85
80
|
}
|
|
86
81
|
|
|
87
|
-
val platformApi = PlatformApi.current
|
|
88
|
-
val rawData = platformApi?.request("GetConfig", "DESIGN_SYSTEM")
|
|
89
|
-
val json = Json { ignoreUnknownKeys = true }
|
|
90
|
-
val headerBanner = rawData?.let { json.decodeFromString<ConfigData>(it).headerBanner }
|
|
91
|
-
|
|
92
82
|
val indicator = WindowInsets.systemBars.asPaddingValues().calculateBottomPadding()
|
|
93
83
|
val bottomPadding = min(indicator, 21.dp)
|
|
94
84
|
|
|
@@ -110,7 +100,6 @@ fun Screen(
|
|
|
110
100
|
HeaderBackground(
|
|
111
101
|
headerType = headerType,
|
|
112
102
|
scrollState = scrollState.value,
|
|
113
|
-
headerBanner = headerBanner
|
|
114
103
|
)
|
|
115
104
|
} else {
|
|
116
105
|
Box(
|
|
@@ -120,7 +109,7 @@ fun Screen(
|
|
|
120
109
|
) {
|
|
121
110
|
HeaderBackground(
|
|
122
111
|
headerType = headerType,
|
|
123
|
-
scrollState = scrollState.value
|
|
112
|
+
scrollState = scrollState.value,
|
|
124
113
|
)
|
|
125
114
|
}
|
|
126
115
|
}
|