Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private fun DefaultRoomListTopBar(
isVisible = !areSearchResultsDisplayed,
)
.statusBarsPadding(),
colors = TopAppBarDefaults.mediumTopAppBarColors(
colors = TopAppBarDefaults.topAppBarColors(
containerColor = Color.Transparent,
scrolledContainerColor = Color.Transparent,
),
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ media3 = "1.8.0"
camera = "1.5.1"

# Compose
compose_bom = "2025.07.00"
compose_bom = "2025.10.00"

# Coroutines
coroutines = "1.10.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExposedDropdownMenuAnchorType
import androidx.compose.material3.ExposedDropdownMenuBox
import androidx.compose.material3.ExposedDropdownMenuDefaults
import androidx.compose.material3.MenuAnchorType
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -120,7 +120,7 @@ private fun <T : DropdownOption> DropdownTrailingContent(
modifier = modifier,
) {
Row(
modifier = Modifier.menuAnchor(MenuAnchorType.PrimaryNotEditable),
modifier = Modifier.menuAnchor(ExposedDropdownMenuAnchorType.PrimaryNotEditable),
verticalAlignment = Alignment.CenterVertically,
) {
Text(
Expand All @@ -134,7 +134,7 @@ private fun <T : DropdownOption> DropdownTrailingContent(
ExposedDropdownMenu(
expanded = expanded,
onDismissRequest = { onExpandedChange(false) },
matchTextFieldWidth = false,
matchAnchorWidth = false,
) {
options.forEach { option ->
DropdownMenuItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package io.element.android.libraries.designsystem.components.tooltip

import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.TooltipAnchorPosition
import androidx.compose.material3.TooltipDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
Expand Down Expand Up @@ -40,8 +41,9 @@ object ElementTooltipDefaults {
windowPadding: Dp = 12.dp,
): PopupPositionProvider {
val windowPaddingPx = with(LocalDensity.current) { windowPadding.roundToPx() }
val plainTooltipPositionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(
spacingBetweenTooltipAndAnchor = spacingBetweenTooltipAndAnchor,
val plainTooltipPositionProvider = TooltipDefaults.rememberTooltipPositionProvider(
positioning = TooltipAnchorPosition.Above,
spacingBetweenTooltipAndAnchor = spacingBetweenTooltipAndAnchor
)
return remember(windowPaddingPx, plainTooltipPositionProvider) {
object : PopupPositionProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.SheetState
import androidx.compose.material3.SheetValue
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalDensity

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun sheetStateForPreview() = SheetState(
skipPartiallyExpanded = true,
positionalThreshold = { 0.5f },
velocityThreshold = { 400f },
initialValue = SheetValue.Expanded,
density = LocalDensity.current,
)
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fun MediumTopAppBar(
navigationIcon: @Composable () -> Unit = {},
actions: @Composable RowScope.() -> Unit = {},
windowInsets: WindowInsets = TopAppBarDefaults.windowInsets,
colors: TopAppBarColors = TopAppBarDefaults.mediumTopAppBarColors(),
colors: TopAppBarColors = TopAppBarDefaults.topAppBarColors(),
scrollBehavior: TopAppBarScrollBehavior? = null
) {
androidx.compose.material3.MediumTopAppBar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.SearchBar
import androidx.compose.material3.SearchBarColors
import androidx.compose.material3.SearchBarDefaults
import androidx.compose.material3.TextFieldColors
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
Expand All @@ -44,6 +44,9 @@ import io.element.android.libraries.designsystem.preview.ElementThemedPreview
import io.element.android.libraries.designsystem.preview.PreviewGroup
import io.element.android.libraries.ui.strings.CommonStrings

/**
* Ref: https://www.figma.com/design/G1xy0HDZKJf5TCRFmKb5d5/Compound-Android-Components?node-id=1992-8350
*/
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun <T> SearchBar(
Expand All @@ -62,14 +65,12 @@ fun <T> SearchBar(
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
inactiveBarColors: SearchBarColors = ElementSearchBarDefaults.inactiveColors(),
activeBarColors: SearchBarColors = ElementSearchBarDefaults.activeColors(),
inactiveTextInputColors: TextFieldColors = ElementSearchBarDefaults.inactiveInputFieldColors(),
activeTextInputColors: TextFieldColors = ElementSearchBarDefaults.activeInputFieldColors(),
contentPrefix: @Composable ColumnScope.() -> Unit = {},
contentSuffix: @Composable ColumnScope.() -> Unit = {},
resultHandler: @Composable ColumnScope.(T) -> Unit = {},
) {
val focusManager = LocalFocusManager.current

val colors = if (active) activeBarColors else inactiveBarColors
val updatedOnQueryChange by rememberUpdatedState(onQueryChange)
LaunchedEffect(active) {
if (!active) {
Expand Down Expand Up @@ -106,28 +107,25 @@ fun <T> SearchBar(
}
}
}

!active -> {
{
Icon(
imageVector = CompoundIcons.Search(),
contentDescription = stringResource(CommonStrings.action_search),
tint = ElementTheme.colors.iconTertiary,
)
}
}

else -> null
},
interactionSource = interactionSource,
colors = if (active) activeTextInputColors else inactiveTextInputColors,
colors = colors.inputFieldColors,
)
},
expanded = active,
onExpandedChange = onActiveChange,
modifier = modifier.padding(horizontal = if (!active) 16.dp else 0.dp),
shape = shape,
colors = if (active) activeBarColors else inactiveBarColors,
colors = colors,
tonalElevation = tonalElevation,
windowInsets = windowInsets,
content = {
Expand Down Expand Up @@ -162,35 +160,43 @@ object ElementSearchBarDefaults {
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun inactiveColors() = SearchBarDefaults.colors(
containerColor = ElementTheme.materialColors.surfaceVariant,
dividerColor = ElementTheme.materialColors.outline,
containerColor = Color.Transparent,
dividerColor = ElementTheme.colors.borderInteractivePrimary,
inputFieldColors = inactiveInputFieldColors(),
)

@Composable
fun inactiveInputFieldColors() = TextFieldDefaults.colors(
unfocusedPlaceholderColor = ElementTheme.colors.textDisabled,
focusedPlaceholderColor = ElementTheme.colors.textDisabled,
unfocusedLeadingIconColor = ElementTheme.materialColors.primary,
focusedLeadingIconColor = ElementTheme.materialColors.primary,
unfocusedTrailingIconColor = ElementTheme.materialColors.primary,
focusedTrailingIconColor = ElementTheme.materialColors.primary,
unfocusedTrailingIconColor = ElementTheme.colors.iconDisabled,
focusedTrailingIconColor = ElementTheme.colors.iconDisabled,
focusedContainerColor = ElementTheme.colors.bgSubtleSecondary,
unfocusedContainerColor = ElementTheme.colors.bgSubtleSecondary,
disabledContainerColor = ElementTheme.colors.bgSubtleSecondary,
errorContainerColor = ElementTheme.colors.bgSubtleSecondary,
)

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun activeColors() = SearchBarDefaults.colors(
containerColor = Color.Transparent,
dividerColor = ElementTheme.materialColors.outline,
dividerColor = ElementTheme.colors.borderInteractivePrimary,
inputFieldColors = activeInputFieldColors(),
)

@Composable
fun activeInputFieldColors() = TextFieldDefaults.colors(
unfocusedPlaceholderColor = ElementTheme.colors.textDisabled,
focusedPlaceholderColor = ElementTheme.colors.textDisabled,
unfocusedLeadingIconColor = ElementTheme.materialColors.primary,
focusedLeadingIconColor = ElementTheme.materialColors.primary,
unfocusedTrailingIconColor = ElementTheme.materialColors.primary,
focusedTrailingIconColor = ElementTheme.materialColors.primary,
unfocusedPlaceholderColor = ElementTheme.colors.textSecondary,
focusedPlaceholderColor = ElementTheme.colors.textSecondary,
unfocusedLeadingIconColor = ElementTheme.colors.iconPrimary,
focusedLeadingIconColor = ElementTheme.colors.iconPrimary,
unfocusedTrailingIconColor = ElementTheme.colors.iconTertiary,
focusedTrailingIconColor = ElementTheme.colors.iconTertiary,
focusedContainerColor = Color.Transparent,
unfocusedContainerColor = Color.Transparent,
disabledContainerColor = Color.Transparent,
errorContainerColor = Color.Transparent,
)
}

Expand Down Expand Up @@ -294,6 +300,7 @@ private fun ContentToPreview(
resultHandler: @Composable ColumnScope.(String) -> Unit = {},
) {
SearchBar(
modifier = Modifier.heightIn(max = 200.dp),
query = query,
active = active,
resultState = resultState,
Expand Down
Loading