Move hidden items button to search bar
This commit is contained in:
parent
dbc2c6f62e
commit
77254015a5
@ -208,6 +208,7 @@ fun AssistantScaffold(
|
|||||||
viewModel.setSearchbarFocus(it)
|
viewModel.setSearchbarFocus(it)
|
||||||
},
|
},
|
||||||
actions = actions,
|
actions = actions,
|
||||||
|
showHiddenItemsButton = true,
|
||||||
value = { value },
|
value = { value },
|
||||||
onValueChange = { searchVM.search(it) },
|
onValueChange = { searchVM.search(it) },
|
||||||
darkColors = LocalPreferDarkContentOverWallpaper.current && searchBarColor == Settings.SearchBarSettings.SearchBarColors.Auto || searchBarColor == Settings.SearchBarSettings.SearchBarColors.Dark,
|
darkColors = LocalPreferDarkContentOverWallpaper.current && searchBarColor == Settings.SearchBarSettings.SearchBarColors.Auto || searchBarColor == Settings.SearchBarSettings.SearchBarColors.Dark,
|
||||||
|
|||||||
@ -451,6 +451,7 @@ fun PagerScaffold(
|
|||||||
viewModel.setSearchbarFocus(it)
|
viewModel.setSearchbarFocus(it)
|
||||||
},
|
},
|
||||||
actions = actions,
|
actions = actions,
|
||||||
|
showHiddenItemsButton = isSearchOpen,
|
||||||
value = { value },
|
value = { value },
|
||||||
onValueChange = { searchVM.search(it) },
|
onValueChange = { searchVM.search(it) },
|
||||||
darkColors = LocalPreferDarkContentOverWallpaper.current && searchBarColor == SearchBarColors.Auto || searchBarColor == SearchBarColors.Dark,
|
darkColors = LocalPreferDarkContentOverWallpaper.current && searchBarColor == SearchBarColors.Auto || searchBarColor == SearchBarColors.Dark,
|
||||||
|
|||||||
@ -424,6 +424,7 @@ fun PullDownScaffold(
|
|||||||
viewModel.setSearchbarFocus(it)
|
viewModel.setSearchbarFocus(it)
|
||||||
},
|
},
|
||||||
actions = actions,
|
actions = actions,
|
||||||
|
showHiddenItemsButton = isSearchOpen,
|
||||||
value = { value },
|
value = { value },
|
||||||
onValueChange = { searchVM.search(it) },
|
onValueChange = { searchVM.search(it) },
|
||||||
darkColors = LocalPreferDarkContentOverWallpaper.current && searchBarColor == Settings.SearchBarSettings.SearchBarColors.Auto || searchBarColor == Settings.SearchBarSettings.SearchBarColors.Dark,
|
darkColors = LocalPreferDarkContentOverWallpaper.current && searchBarColor == Settings.SearchBarSettings.SearchBarColors.Auto || searchBarColor == Settings.SearchBarSettings.SearchBarColors.Dark,
|
||||||
|
|||||||
@ -360,9 +360,6 @@ fun SearchColumn(
|
|||||||
reverse = reverse,
|
reverse = reverse,
|
||||||
key = "files"
|
key = "files"
|
||||||
)
|
)
|
||||||
item {
|
|
||||||
HiddenResults()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showEditFavoritesDialog) {
|
if (showEditFavoritesDialog) {
|
||||||
|
|||||||
@ -1,15 +1,31 @@
|
|||||||
package de.mm20.launcher2.ui.launcher.searchbar
|
package de.mm20.launcher2.ui.launcher.searchbar
|
||||||
|
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.animation.core.tween
|
||||||
|
import androidx.compose.animation.scaleIn
|
||||||
|
import androidx.compose.animation.scaleOut
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.rounded.VisibilityOff
|
||||||
|
import androidx.compose.material3.FilledIconButton
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButtonDefaults
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.livedata.observeAsState
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
import androidx.compose.ui.platform.LocalFocusManager
|
import androidx.compose.ui.platform.LocalFocusManager
|
||||||
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||||
import de.mm20.launcher2.preferences.Settings
|
import de.mm20.launcher2.preferences.Settings
|
||||||
import de.mm20.launcher2.searchactions.actions.SearchAction
|
import de.mm20.launcher2.searchactions.actions.SearchAction
|
||||||
import de.mm20.launcher2.ui.component.SearchBar
|
import de.mm20.launcher2.ui.component.SearchBar
|
||||||
import de.mm20.launcher2.ui.component.SearchBarLevel
|
import de.mm20.launcher2.ui.component.SearchBarLevel
|
||||||
|
import de.mm20.launcher2.ui.launcher.modals.HiddenItemsSheet
|
||||||
|
import de.mm20.launcher2.ui.launcher.search.SearchVM
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LauncherSearchBar(
|
fun LauncherSearchBar(
|
||||||
@ -21,12 +37,19 @@ fun LauncherSearchBar(
|
|||||||
focused: Boolean,
|
focused: Boolean,
|
||||||
onFocusChange: (Boolean) -> Unit,
|
onFocusChange: (Boolean) -> Unit,
|
||||||
actions: List<SearchAction>,
|
actions: List<SearchAction>,
|
||||||
|
showHiddenItemsButton: Boolean = false,
|
||||||
reverse: Boolean = false,
|
reverse: Boolean = false,
|
||||||
darkColors: Boolean = false,
|
darkColors: Boolean = false,
|
||||||
) {
|
) {
|
||||||
val focusManager = LocalFocusManager.current
|
val focusManager = LocalFocusManager.current
|
||||||
val focusRequester = remember { FocusRequester() }
|
val focusRequester = remember { FocusRequester() }
|
||||||
|
|
||||||
|
val searchVM: SearchVM = viewModel()
|
||||||
|
|
||||||
|
var showHiddenItemsSheet by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
|
val hiddenItems by searchVM.hiddenResults.observeAsState(emptyList())
|
||||||
|
|
||||||
|
|
||||||
LaunchedEffect(focused) {
|
LaunchedEffect(focused) {
|
||||||
if (focused) focusRequester.requestFocus()
|
if (focused) focusRequester.requestFocus()
|
||||||
@ -41,6 +64,18 @@ fun LauncherSearchBar(
|
|||||||
reverse = reverse,
|
reverse = reverse,
|
||||||
darkColors = darkColors,
|
darkColors = darkColors,
|
||||||
menu = {
|
menu = {
|
||||||
|
AnimatedVisibility(
|
||||||
|
showHiddenItemsButton && hiddenItems.isNotEmpty(),
|
||||||
|
enter = scaleIn(tween(100)),
|
||||||
|
exit = scaleOut(tween(100))
|
||||||
|
) {
|
||||||
|
FilledIconButton(
|
||||||
|
onClick = { showHiddenItemsSheet = !showHiddenItemsSheet },
|
||||||
|
colors = if (showHiddenItemsSheet) IconButtonDefaults.filledTonalIconButtonColors() else IconButtonDefaults.iconButtonColors()
|
||||||
|
) {
|
||||||
|
Icon(imageVector = Icons.Rounded.VisibilityOff, contentDescription = null)
|
||||||
|
}
|
||||||
|
}
|
||||||
SearchBarMenu(searchBarValue = _value, onSearchBarValueChange = onValueChange)
|
SearchBarMenu(searchBarValue = _value, onSearchBarValueChange = onValueChange)
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
@ -50,4 +85,8 @@ fun LauncherSearchBar(
|
|||||||
onFocus = { onFocusChange(true) },
|
onFocus = { onFocusChange(true) },
|
||||||
onUnfocus = { onFocusChange(false) },
|
onUnfocus = { onFocusChange(false) },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (showHiddenItemsSheet) {
|
||||||
|
HiddenItemsSheet(hiddenItems, onDismiss = { showHiddenItemsSheet = false })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user