Skip to content

Commit

Permalink
improvement(UI): Visually indicate selected item in a dropdown for Se…
Browse files Browse the repository at this point in the history
…tting items
  • Loading branch information
AChep committed Nov 27, 2024
1 parent 62d0800 commit 98bc441
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ fun settingClipboardAutoClearProvider(
val text = getAutoClearDurationTitle(timeout, context)
val dropdown = variants
.map { duration ->
val title = getAutoClearDurationTitle(duration, context)
val actionSelected = timeout == duration
val actionTitle = getAutoClearDurationTitle(duration, context)
FlatItemAction(
title = TextHolder.Value(title),
title = TextHolder.Value(actionTitle),
selected = actionSelected,
onClick = {
putClipboardAutoClear(duration)
.launchIn(windowCoroutineScope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ fun settingClipboardAutoRefreshProvider(
val text = getAutoRefreshDurationTitle(timeout, context)
val dropdown = variants
.map { duration ->
val title = getAutoRefreshDurationTitle(duration, context)
val actionSelected = timeout == duration
val actionTitle = getAutoRefreshDurationTitle(duration, context)
FlatItemAction(
title = TextHolder.Value(title),
title = TextHolder.Value(actionTitle),
selected = actionSelected,
onClick = {
putClipboardAutoRefresh(duration)
.launchIn(windowCoroutineScope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ fun settingColorAccentProvider(
val text = getAppColorsTitle(colors, context)
val dropdown = variants
.map { colorsVariant ->
val actionSelected = colorsVariant == colors
val actionTitle = getAppColorsTitle(colorsVariant, context)
FlatItemAction(
title = TextHolder.Value(actionTitle),
selected = actionSelected,
onClick = {
putColors(colorsVariant)
.launchIn(windowCoroutineScope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ fun settingColorSchemeProvider(
val text = getAppThemeTitle(theme, context)
val dropdown = variants
.map { themeVariant ->
val actionSelected = theme == themeVariant
val actionTitle = getAppThemeTitle(themeVariant, context)
FlatItemAction(
title = TextHolder.Value(actionTitle),
selected = actionSelected,
onClick = {
putTheme(themeVariant)
.launchIn(windowCoroutineScope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ fun settingFontProvider(
val text = getAppFontTitle(font, context)
val dropdown = variants
.map { fontVariant ->
val actionSelected = fontVariant == font
val actionTitle = getAppFontTitle(fontVariant, context)
val actionText = getAppFontText(fontVariant, context)
FlatItemAction(
title = TextHolder.Value(actionTitle),
text = actionText?.let(TextHolder::Value),
selected = actionSelected,
onClick = {
putFont(fontVariant)
.launchIn(windowCoroutineScope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ fun settingNavAnimationProvider(
val text = textResource(navAnimation.title, context)
val dropdown = variants
.map { navAnimationVariant ->
val actionSelected = navAnimationVariant == navAnimation
val actionTitle = navAnimationVariant.title.wrap()
FlatItemAction(
title = navAnimationVariant.title.wrap(),
title = actionTitle,
selected = actionSelected,
onClick = {
putNavAnimation(navAnimationVariant)
.launchIn(windowCoroutineScope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ private suspend fun ah(
val text = getRequirePasswordDurationTitle(timeout, context)
val dropdown = variants
.map { duration ->
val title = getRequirePasswordDurationTitle(duration, context)
val actionSelected = duration == timeout
val actionTitle = getRequirePasswordDurationTitle(duration, context)
FlatItemAction(
title = TextHolder.Value(title),
title = TextHolder.Value(actionTitle),
selected = actionSelected,
onClick = {
putBiometricTimeout(duration)
.launchIn(windowCoroutineScope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ fun settingSelectLocaleProvider(
),
)
.map { item ->
val actionSelected = locale == item.locale
FlatItemAction(
// leading = if (item.locale != null) null else icon(Icons.Outlined.AutoAwesome),
title = TextHolder.Value(item.title),
selected = actionSelected,
onClick = {
putLocale(item.locale)
.launchIn(windowCoroutineScope)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ fun settingVaultLockAfterTimeoutProvider(
val text = getLockAfterDurationTitle(timeout, context)
val dropdown = variants
.map { duration ->
val title = getLockAfterDurationTitle(duration, context)
val actionSelected = duration == timeout
val actionTitle = getLockAfterDurationTitle(duration, context)
FlatItemAction(
title = TextHolder.Value(title),
title = TextHolder.Value(actionTitle),
selected = actionSelected,
onClick = {
putVaultLockAfterTimeout(duration)
.launchIn(windowCoroutineScope)
Expand Down

0 comments on commit 98bc441

Please sign in to comment.