Fix enter to launch in pager scaffold
This commit is contained in:
parent
1e303a62c0
commit
9c318fecf4
@ -44,6 +44,8 @@ fun AssistantScaffold(
|
||||
) {
|
||||
val viewModel: LauncherScaffoldVM = viewModel()
|
||||
|
||||
val context = LocalContext.current
|
||||
|
||||
var searchBarFocused by remember { mutableStateOf(false) }
|
||||
|
||||
val lifecycleOwner = LocalLifecycleOwner.current
|
||||
@ -179,6 +181,8 @@ fun AssistantScaffold(
|
||||
val searchBarColor by viewModel.searchBarColor.observeAsState(Settings.SearchBarSettings.SearchBarColors.Auto)
|
||||
val searchBarStyle by viewModel.searchBarStyle.observeAsState(Settings.SearchBarSettings.SearchBarStyle.Transparent)
|
||||
|
||||
val launchOnEnter by searchVM.launchOnEnter.collectAsState(false)
|
||||
|
||||
LauncherSearchBar(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
@ -206,7 +210,10 @@ fun AssistantScaffold(
|
||||
onValueChange = { searchVM.search(it) },
|
||||
darkColors = LocalPreferDarkContentOverWallpaper.current && searchBarColor == Settings.SearchBarSettings.SearchBarColors.Auto || searchBarColor == Settings.SearchBarSettings.SearchBarColors.Dark,
|
||||
style = searchBarStyle,
|
||||
reverse = bottomSearchBar
|
||||
reverse = bottomSearchBar,
|
||||
onKeyboardActionGo = if (launchOnEnter) {
|
||||
{ searchVM.launchBestMatchOrAction(context) }
|
||||
} else null
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -56,8 +56,6 @@ class LauncherScaffoldVM : ViewModel(), KoinComponent {
|
||||
val statusBarColor = dataStore.data.map { it.systemBars.statusBarColor }.asLiveData()
|
||||
val navBarColor = dataStore.data.map { it.systemBars.statusBarColor }.asLiveData()
|
||||
|
||||
val launchOnEnter = dataStore.data.map { it.searchBar.launchOnEnter }.asLiveData()
|
||||
|
||||
val hideNavBar = dataStore.data.map { it.systemBars.hideNavBar }.asLiveData()
|
||||
val hideStatusBar = dataStore.data.map { it.systemBars.hideStatusBar }.asLiveData()
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
@ -58,6 +59,7 @@ import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalLayoutDirection
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
@ -97,6 +99,8 @@ fun PagerScaffold(
|
||||
val viewModel: LauncherScaffoldVM = viewModel()
|
||||
val searchVM: SearchVM = viewModel()
|
||||
|
||||
val context = LocalContext.current
|
||||
|
||||
val isSearchOpen by viewModel.isSearchOpen.observeAsState(false)
|
||||
val isWidgetEditMode by viewModel.isWidgetEditMode.observeAsState(false)
|
||||
|
||||
@ -485,6 +489,8 @@ fun PagerScaffold(
|
||||
val searchBarColor by viewModel.searchBarColor.observeAsState(SearchBarColors.Auto)
|
||||
val searchBarStyle by viewModel.searchBarStyle.observeAsState(SearchBarStyle.Transparent)
|
||||
|
||||
val launchOnEnter by searchVM.launchOnEnter.collectAsState(false)
|
||||
|
||||
LauncherSearchBar(
|
||||
modifier = Modifier
|
||||
.align(if (bottomSearchBar) Alignment.BottomCenter else Alignment.TopCenter)
|
||||
@ -511,7 +517,10 @@ fun PagerScaffold(
|
||||
onValueChange = { searchVM.search(it) },
|
||||
darkColors = LocalPreferDarkContentOverWallpaper.current && searchBarColor == SearchBarColors.Auto || searchBarColor == SearchBarColors.Dark,
|
||||
style = searchBarStyle,
|
||||
reverse = bottomSearchBar
|
||||
reverse = bottomSearchBar,
|
||||
onKeyboardActionGo = if (launchOnEnter) {
|
||||
{ searchVM.launchBestMatchOrAction(context) }
|
||||
} else null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,6 +40,7 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
@ -91,7 +92,6 @@ fun PullDownScaffold(
|
||||
bottomSearchBar: Boolean = false,
|
||||
reverseSearchResults: Boolean = false,
|
||||
fixedSearchBar: Boolean = false,
|
||||
launchOnEnter: Boolean = false
|
||||
) {
|
||||
val viewModel: LauncherScaffoldVM = viewModel()
|
||||
val searchVM: SearchVM = viewModel()
|
||||
@ -528,6 +528,8 @@ fun PullDownScaffold(
|
||||
|
||||
val context = LocalContext.current
|
||||
|
||||
val launchOnEnter by searchVM.launchOnEnter.collectAsState(false)
|
||||
|
||||
LauncherSearchBar(
|
||||
modifier = Modifier
|
||||
.align(if (bottomSearchBar) Alignment.BottomCenter else Alignment.TopCenter)
|
||||
|
||||
@ -194,7 +194,6 @@ abstract class SharedLauncherActivity(
|
||||
when (layout) {
|
||||
Settings.LayoutSettings.Layout.PullDown -> {
|
||||
key(bottomSearchBar, reverseSearchResults) {
|
||||
val launchOnEnter by viewModel.launchOnEnter.observeAsState(false)
|
||||
PullDownScaffold(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
@ -210,7 +209,6 @@ abstract class SharedLauncherActivity(
|
||||
bottomSearchBar = bottomSearchBar,
|
||||
reverseSearchResults = reverseSearchResults,
|
||||
fixedSearchBar = fixedSearchBar,
|
||||
launchOnEnter = launchOnEnter
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ class SearchVM : ViewModel(), KoinComponent {
|
||||
private val permissionsManager: PermissionsManager by inject()
|
||||
private val dataStore: LauncherDataStore by inject()
|
||||
|
||||
private val launchOnEnter = dataStore.data.map { it.searchBar.launchOnEnter }
|
||||
val launchOnEnter = dataStore.data.map { it.searchBar.launchOnEnter }
|
||||
.stateIn(viewModelScope, SharingStarted.Eagerly, false)
|
||||
|
||||
private val searchService: SearchService by inject()
|
||||
@ -128,7 +128,9 @@ class SearchVM : ViewModel(), KoinComponent {
|
||||
results.calculators,
|
||||
results.unitConverters,
|
||||
results.searchActions,
|
||||
).flatten().sortedBy { (it as? SavableSearchable) }
|
||||
).flatten()
|
||||
.sortedBy { (it as? SavableSearchable) }
|
||||
.distinctBy { if (it is SavableSearchable) it.key else it }
|
||||
}
|
||||
|
||||
hiddenItemKeys.collectLatest { hiddenKeys ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user