@momo-kits/native-kits 0.167.1-duo.20-debug → 0.167.1-duo.21-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/application/LiteScreen.kt +5 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/Header.kt +9 -1
- package/compose/src/commonMain/kotlin/vn/momo/kits/navigation/component/HeaderRight.kt +22 -2
- package/ios/Navigation/Component/HeaderRight.swift +25 -6
- package/package.json +1 -1
package/compose/build.gradle.kts
CHANGED
|
@@ -20,6 +20,7 @@ import androidx.compose.foundation.text.KeyboardActions
|
|
|
20
20
|
import androidx.compose.foundation.text.KeyboardOptions
|
|
21
21
|
import androidx.compose.foundation.verticalScroll
|
|
22
22
|
import androidx.compose.runtime.Composable
|
|
23
|
+
import androidx.compose.runtime.CompositionLocalProvider
|
|
23
24
|
import androidx.compose.runtime.LaunchedEffect
|
|
24
25
|
import androidx.compose.runtime.MutableState
|
|
25
26
|
import androidx.compose.runtime.Stable
|
|
@@ -84,6 +85,7 @@ import vn.momo.kits.modifier.setAutomationId
|
|
|
84
85
|
import vn.momo.kits.navigation.component.headerFontFamily
|
|
85
86
|
import vn.momo.kits.navigation.component.HEADER_HEIGHT
|
|
86
87
|
import vn.momo.kits.navigation.component.HeaderColor
|
|
88
|
+
import vn.momo.kits.navigation.component.LocalHeaderColor
|
|
87
89
|
import vn.momo.kits.navigation.component.HeaderRight
|
|
88
90
|
import vn.momo.kits.navigation.component.SideBarButton
|
|
89
91
|
import vn.momo.kits.navigation.component.TitlePosition
|
|
@@ -438,7 +440,9 @@ private fun LiteScreenLayout(
|
|
|
438
440
|
.then(animationOpacityModifier)
|
|
439
441
|
) {
|
|
440
442
|
if (headerRight != null) {
|
|
441
|
-
|
|
443
|
+
CompositionLocalProvider(LocalHeaderColor provides headerColor) {
|
|
444
|
+
headerRight()
|
|
445
|
+
}
|
|
442
446
|
} else {
|
|
443
447
|
Toolkit(
|
|
444
448
|
headerRight = toolkit,
|
|
@@ -18,6 +18,8 @@ import androidx.compose.foundation.layout.width
|
|
|
18
18
|
import androidx.compose.foundation.layout.wrapContentHeight
|
|
19
19
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
20
20
|
import androidx.compose.runtime.Composable
|
|
21
|
+
import androidx.compose.runtime.CompositionLocalProvider
|
|
22
|
+
import androidx.compose.runtime.compositionLocalOf
|
|
21
23
|
import androidx.compose.runtime.getValue
|
|
22
24
|
import androidx.compose.ui.Alignment
|
|
23
25
|
import androidx.compose.ui.Modifier
|
|
@@ -233,7 +235,9 @@ internal fun Header(onBackHandler: (() -> Unit)? = null) {
|
|
|
233
235
|
headerColor = headerColor,
|
|
234
236
|
layout = ToolkitLayout.SideBarRow,
|
|
235
237
|
)
|
|
236
|
-
else ->
|
|
238
|
+
else -> CompositionLocalProvider(LocalHeaderColor provides headerColor) {
|
|
239
|
+
HeaderRight(headerRight, options.tintColor, headerColor)
|
|
240
|
+
}
|
|
237
241
|
}
|
|
238
242
|
}
|
|
239
243
|
}
|
|
@@ -415,6 +419,10 @@ data class HeaderBackProps(
|
|
|
415
419
|
|
|
416
420
|
@InternalApi
|
|
417
421
|
data class HeaderColor(val tintIconColor: Color, val backgroundButton: Color, val borderColor: Color)
|
|
422
|
+
|
|
423
|
+
// The enclosing header's colors, so a custom header right follows the bar (SwiftUI `\.headerColor`).
|
|
424
|
+
internal val LocalHeaderColor = compositionLocalOf<HeaderColor?> { null }
|
|
425
|
+
|
|
418
426
|
internal fun getHeaderColor(headerType: HeaderType, opacity: Float, tintColor: Color?, defaultColor: Color): HeaderColor{
|
|
419
427
|
return if(headerType is HeaderType.Animated) {
|
|
420
428
|
if (opacity == 1f || !headerType.isSurface)
|
|
@@ -256,16 +256,36 @@ internal fun Toolkit(
|
|
|
256
256
|
|
|
257
257
|
|
|
258
258
|
|
|
259
|
+
// Colors follow the enclosing header, so it fits a `HeaderRight.Custom` next to the toolkit.
|
|
260
|
+
@Composable
|
|
261
|
+
fun NavigationButton(
|
|
262
|
+
icon: String,
|
|
263
|
+
onClick: () -> Unit,
|
|
264
|
+
showBadge: Boolean = false,
|
|
265
|
+
disabled: Boolean = false,
|
|
266
|
+
modifier: Modifier = Modifier,
|
|
267
|
+
) {
|
|
268
|
+
NavigationButton(
|
|
269
|
+
disabled = disabled,
|
|
270
|
+
icon = icon,
|
|
271
|
+
showBadge = showBadge,
|
|
272
|
+
onClick = onClick,
|
|
273
|
+
headerColor = LocalHeaderColor.current ?: getHeaderColor(HeaderType.Default(), 1f, null, Colors.black_17),
|
|
274
|
+
modifier = modifier,
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
|
|
259
278
|
@Composable
|
|
260
279
|
internal fun NavigationButton(
|
|
261
280
|
disabled: Boolean,
|
|
262
281
|
icon: String,
|
|
263
282
|
showBadge: Boolean? = false,
|
|
264
283
|
onClick: () -> Unit,
|
|
265
|
-
headerColor: HeaderColor
|
|
284
|
+
headerColor: HeaderColor,
|
|
285
|
+
modifier: Modifier = Modifier,
|
|
266
286
|
) {
|
|
267
287
|
Box(
|
|
268
|
-
modifier =
|
|
288
|
+
modifier = modifier
|
|
269
289
|
.size(28.dp)
|
|
270
290
|
.activeOpacityClickable(enabled = !disabled, onClick = onClick)
|
|
271
291
|
) {
|
|
@@ -349,20 +349,39 @@ struct Toolkit: View {
|
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
/// Mirrors Compose's `NavigationButton`: the 28pt circular shortcut / more button.
|
|
352
|
-
struct NavigationButton: View {
|
|
352
|
+
public struct NavigationButton: View {
|
|
353
353
|
var disabled: Bool
|
|
354
354
|
var icon: String
|
|
355
355
|
var showBadge: Bool
|
|
356
|
-
var headerColor: HeaderColor
|
|
356
|
+
var headerColor: HeaderColor?
|
|
357
357
|
var onClick: () -> Void
|
|
358
358
|
|
|
359
|
-
|
|
359
|
+
@Environment(\.headerColor) private var barColor
|
|
360
|
+
|
|
361
|
+
/// Colors follow the enclosing header, so it fits a custom header right next to the toolkit.
|
|
362
|
+
public init(icon: String, showBadge: Bool = false, disabled: Bool = false, onClick: @escaping () -> Void) {
|
|
363
|
+
self.init(disabled: disabled, icon: icon, showBadge: showBadge, headerColor: nil, onClick: onClick)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
init(disabled: Bool, icon: String, showBadge: Bool, headerColor: HeaderColor?, onClick: @escaping () -> Void) {
|
|
367
|
+
self.disabled = disabled
|
|
368
|
+
self.icon = icon
|
|
369
|
+
self.showBadge = showBadge
|
|
370
|
+
self.headerColor = headerColor
|
|
371
|
+
self.onClick = onClick
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
private var colors: HeaderColor {
|
|
375
|
+
headerColor ?? barColor ?? getHeaderColor(isAnimated: false, isSurface: true, opacity: 1, tintColor: nil)
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
public var body: some View {
|
|
360
379
|
SwiftUI.Button(action: onClick) {
|
|
361
380
|
ZStack {
|
|
362
381
|
Circle()
|
|
363
|
-
.fill(
|
|
364
|
-
.overlay(Circle().stroke(
|
|
365
|
-
Icon(source: icon, size: 20, color:
|
|
382
|
+
.fill(colors.backgroundButton)
|
|
383
|
+
.overlay(Circle().stroke(colors.borderColor, lineWidth: 0.2))
|
|
384
|
+
Icon(source: icon, size: 20, color: colors.tintIconColor)
|
|
366
385
|
}
|
|
367
386
|
.frame(width: 28, height: 28)
|
|
368
387
|
.overlay(alignment: .topTrailing) {
|