Skip to content

Commit

Permalink
change(design) : add preview for PreferenceDropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
ganfra committed Jan 16, 2025
1 parent bc45004 commit db3a0a9
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package io.element.android.libraries.designsystem.components.preferences

import androidx.annotation.DrawableRes
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.ExperimentalMaterial3Api
Expand All @@ -24,15 +25,20 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.tooling.preview.Preview
import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.libraries.designsystem.components.list.ListItemContent
import io.element.android.libraries.designsystem.components.preferences.components.preferenceIcon
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
import io.element.android.libraries.designsystem.preview.PreviewGroup
import io.element.android.libraries.designsystem.theme.components.DropdownMenuItem
import io.element.android.libraries.designsystem.theme.components.ListItem
import io.element.android.libraries.designsystem.theme.components.Text
import io.element.android.libraries.designsystem.toEnabledColor
import io.element.android.libraries.designsystem.toSecondaryEnabledColor
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList

@Composable
fun <T : DropdownOption> PreferenceDropdown(
Expand Down Expand Up @@ -146,3 +152,38 @@ private fun <T : DropdownOption> DropdownTrailingContent(
}
}
}

@Preview(group = PreviewGroup.Preferences)
@Composable
internal fun PreferenceDropdownPreview() = ElementThemedPreview {
val options = listOf(
object : DropdownOption {
override val text = "Option 1"
},
object : DropdownOption {
override val text = "Option 2"
},
object : DropdownOption {
override val text = "Option 3"
},
).toImmutableList()

Column {
PreferenceDropdown(
title = "Dropdown",
supportingText = "Options for dropdown",
icon = CompoundIcons.Threads(),
selectedOption = null,
options = options,
onSelectOption = {},
)
PreferenceDropdown(
title = "Dropdown",
supportingText = "Options for dropdown",
icon = CompoundIcons.Threads(),
selectedOption = options.first(),
options = options,
onSelectOption = {},
)
}
}

0 comments on commit db3a0a9

Please sign in to comment.