Split function into separate files.
This commit is contained in:
committed by
Benoit Marty
parent
812d1503a8
commit
811527e789
@@ -7,29 +7,20 @@
|
||||
|
||||
package io.element.android.libraries.designsystem.theme.components
|
||||
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.NavigationBarDefaults
|
||||
import androidx.compose.material3.NavigationBarItemColors
|
||||
import androidx.compose.material3.NavigationBarItemDefaults
|
||||
import androidx.compose.material3.contentColorFor
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.compound.tokens.generated.CompoundIcons
|
||||
import io.element.android.libraries.designsystem.atomic.atoms.CounterAtom
|
||||
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewGroup
|
||||
import androidx.compose.material3.NavigationBarItem as MaterialNavigationBarItem
|
||||
|
||||
@Composable
|
||||
fun NavigationBar(
|
||||
@@ -64,72 +55,6 @@ object ElementNavigationBarDefaults {
|
||||
@Composable get() = NavigationBarDefaults.windowInsets
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun RowScope.NavigationBarItem(
|
||||
selected: Boolean,
|
||||
onClick: () -> Unit,
|
||||
icon: @Composable () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
enabled: Boolean = true,
|
||||
label: @Composable (() -> Unit)? = null,
|
||||
alwaysShowLabel: Boolean = true,
|
||||
colors: NavigationBarItemColors = ElementNavigationBarItemDefaultsDefaults.colors(),
|
||||
interactionSource: MutableInteractionSource? = null
|
||||
) {
|
||||
MaterialNavigationBarItem(
|
||||
selected = selected,
|
||||
onClick = onClick,
|
||||
icon = icon,
|
||||
modifier = modifier,
|
||||
enabled = enabled,
|
||||
label = label,
|
||||
alwaysShowLabel = alwaysShowLabel,
|
||||
colors = colors,
|
||||
interactionSource = interactionSource,
|
||||
)
|
||||
}
|
||||
|
||||
object ElementNavigationBarItemDefaultsDefaults {
|
||||
@Composable
|
||||
fun colors() = NavigationBarItemDefaults.colors().copy(
|
||||
selectedIconColor = ElementTheme.colors.iconPrimary,
|
||||
selectedTextColor = ElementTheme.colors.textPrimary,
|
||||
unselectedIconColor = ElementTheme.colors.iconTertiary,
|
||||
unselectedTextColor = ElementTheme.colors.textDisabled,
|
||||
selectedIndicatorColor = Color.Transparent,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun NavigationBarIcon(
|
||||
imageVector: ImageVector,
|
||||
count: Int,
|
||||
isCritical: Boolean,
|
||||
) {
|
||||
Box {
|
||||
Icon(
|
||||
imageVector = imageVector,
|
||||
contentDescription = null,
|
||||
)
|
||||
CounterAtom(
|
||||
modifier = Modifier.offset(11.dp, (-11).dp),
|
||||
textStyle = ElementTheme.typography.fontBodyXsMedium,
|
||||
count = count,
|
||||
isCritical = isCritical,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun NavigationBarText(
|
||||
text: String,
|
||||
) {
|
||||
Text(
|
||||
text = text,
|
||||
style = ElementTheme.typography.fontBodySmMedium,
|
||||
)
|
||||
}
|
||||
|
||||
@Preview(group = PreviewGroup.AppBars)
|
||||
@Composable
|
||||
internal fun NavigationBarPreview() = ElementThemedPreview {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.designsystem.theme.components
|
||||
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.unit.dp
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
import io.element.android.libraries.designsystem.atomic.atoms.CounterAtom
|
||||
|
||||
@Composable
|
||||
fun NavigationBarIcon(
|
||||
imageVector: ImageVector,
|
||||
count: Int,
|
||||
isCritical: Boolean,
|
||||
) {
|
||||
Box {
|
||||
Icon(
|
||||
imageVector = imageVector,
|
||||
contentDescription = null,
|
||||
)
|
||||
CounterAtom(
|
||||
modifier = Modifier.Companion.offset(11.dp, (-11).dp),
|
||||
textStyle = ElementTheme.typography.fontBodyXsMedium,
|
||||
count = count,
|
||||
isCritical = isCritical,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.designsystem.theme.components
|
||||
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.material3.NavigationBarItem
|
||||
import androidx.compose.material3.NavigationBarItemColors
|
||||
import androidx.compose.material3.NavigationBarItemDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
|
||||
@Composable
|
||||
fun RowScope.NavigationBarItem(
|
||||
selected: Boolean,
|
||||
onClick: () -> Unit,
|
||||
icon: @Composable () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
enabled: Boolean = true,
|
||||
label: @Composable (() -> Unit)? = null,
|
||||
alwaysShowLabel: Boolean = true,
|
||||
colors: NavigationBarItemColors = ElementNavigationBarItemDefaultsDefaults.colors(),
|
||||
interactionSource: MutableInteractionSource? = null
|
||||
) {
|
||||
NavigationBarItem(
|
||||
selected = selected,
|
||||
onClick = onClick,
|
||||
icon = icon,
|
||||
modifier = modifier,
|
||||
enabled = enabled,
|
||||
label = label,
|
||||
alwaysShowLabel = alwaysShowLabel,
|
||||
colors = colors,
|
||||
interactionSource = interactionSource,
|
||||
)
|
||||
}
|
||||
|
||||
object ElementNavigationBarItemDefaultsDefaults {
|
||||
@Composable
|
||||
fun colors() = NavigationBarItemDefaults.colors().copy(
|
||||
selectedIconColor = ElementTheme.colors.iconPrimary,
|
||||
selectedTextColor = ElementTheme.colors.textPrimary,
|
||||
unselectedIconColor = ElementTheme.colors.iconTertiary,
|
||||
unselectedTextColor = ElementTheme.colors.textDisabled,
|
||||
selectedIndicatorColor = Color.Companion.Transparent,
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2025 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.libraries.designsystem.theme.components
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import io.element.android.compound.theme.ElementTheme
|
||||
|
||||
@Composable
|
||||
fun NavigationBarText(
|
||||
text: String,
|
||||
) {
|
||||
Text(
|
||||
text = text,
|
||||
style = ElementTheme.typography.fontBodySmMedium,
|
||||
)
|
||||
}
|
||||
@@ -34,8 +34,6 @@ class KonsistComposableTest {
|
||||
// Add some exceptions...
|
||||
"InvisibleButton",
|
||||
"OutlinedButton",
|
||||
"NavigationBarIcon",
|
||||
"NavigationBarText",
|
||||
"SimpleAlertDialogContent",
|
||||
"TextButton",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user