feat : Add setting to toggle app version visibility in grid popup (#1843)
* Add gridAppVersion setting and wiring * Implement app version visibility toggle in grid popup * Add hideAppDetails setting and wiring * feat : add hideAppDetails toggle and remove gridShowAppVersion
This commit is contained in:
@@ -17,11 +17,13 @@ import de.mm20.launcher2.preferences.MeasurementSystem
|
||||
import de.mm20.launcher2.preferences.TimeFormat
|
||||
import de.mm20.launcher2.preferences.ui.GridSettings
|
||||
import de.mm20.launcher2.preferences.ui.LocaleSettings
|
||||
import de.mm20.launcher2.preferences.ui.SearchUiSettings
|
||||
import de.mm20.launcher2.preferences.ui.UiSettings
|
||||
import de.mm20.launcher2.ui.component.ProvideIconShape
|
||||
import de.mm20.launcher2.ui.locals.LocalCalendarSystemIds
|
||||
import de.mm20.launcher2.ui.locals.LocalCalendarSystems
|
||||
import de.mm20.launcher2.ui.locals.LocalFavoritesEnabled
|
||||
import de.mm20.launcher2.ui.locals.LocalHideAppDetails
|
||||
import de.mm20.launcher2.ui.locals.LocalGridSettings
|
||||
import de.mm20.launcher2.ui.locals.LocalMeasurementSystem
|
||||
import de.mm20.launcher2.ui.locals.LocalTimeFormat
|
||||
@@ -39,6 +41,7 @@ fun ProvideSettings(
|
||||
val context = LocalContext.current
|
||||
|
||||
val settings: UiSettings = koinInject()
|
||||
val searchUiSettings: SearchUiSettings = koinInject()
|
||||
val widgetRepository: WidgetRepository = koinInject()
|
||||
val localeSettings: LocaleSettings = koinInject()
|
||||
|
||||
@@ -57,6 +60,10 @@ fun ProvideSettings(
|
||||
settings.gridSettings.distinctUntilChanged()
|
||||
}.collectAsState(GridSettings())
|
||||
|
||||
val hideAppDetails by remember {
|
||||
searchUiSettings.hideAppDetails.distinctUntilChanged()
|
||||
}.collectAsState(false)
|
||||
|
||||
val timeFormat by remember(context) {
|
||||
localeSettings.timeFormat
|
||||
.map {
|
||||
@@ -116,6 +123,7 @@ fun ProvideSettings(
|
||||
|
||||
CompositionLocalProvider(
|
||||
LocalFavoritesEnabled provides favoritesEnabled,
|
||||
LocalHideAppDetails provides hideAppDetails,
|
||||
LocalGridSettings provides gridSettings,
|
||||
LocalTimeFormat provides timeFormat!!,
|
||||
LocalMeasurementSystem provides measurementSystem!!,
|
||||
|
||||
@@ -65,6 +65,7 @@ import de.mm20.launcher2.ui.launcher.search.common.SearchableItemVM
|
||||
import de.mm20.launcher2.ui.launcher.search.listItemViewModel
|
||||
import de.mm20.launcher2.ui.launcher.sheets.LocalBottomSheetManager
|
||||
import de.mm20.launcher2.ui.locals.LocalFavoritesEnabled
|
||||
import de.mm20.launcher2.ui.locals.LocalHideAppDetails
|
||||
import de.mm20.launcher2.ui.locals.LocalGridSettings
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@@ -80,6 +81,7 @@ fun AppItem(
|
||||
|
||||
val badge by viewModel.badge.collectAsStateWithLifecycle(null)
|
||||
val icon by viewModel.icon.collectAsStateWithLifecycle()
|
||||
val hideAppDetails = LocalHideAppDetails.current
|
||||
|
||||
LaunchedEffect(app) {
|
||||
viewModel.init(app, iconSize.toInt())
|
||||
@@ -122,23 +124,24 @@ fun AppItem(
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
app.versionName?.let {
|
||||
if (!hideAppDetails) {
|
||||
app.versionName?.let {
|
||||
Text(
|
||||
text = stringResource(R.string.app_info_version, it),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
modifier = Modifier.padding(top = 4.dp),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = stringResource(R.string.app_info_version, it),
|
||||
text = app.componentName.packageName,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
modifier = Modifier.padding(top = 4.dp),
|
||||
modifier = Modifier.padding(top = 1.dp),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = app.componentName.packageName,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
modifier = Modifier.padding(top = 1.dp),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
} else {
|
||||
Text(
|
||||
stringResource(R.string.profile_private_profile_state_locked),
|
||||
|
||||
@@ -21,6 +21,8 @@ val LocalCardStyle = compositionLocalOf { CardStyle() }
|
||||
|
||||
val LocalFavoritesEnabled = compositionLocalOf { true }
|
||||
|
||||
val LocalHideAppDetails = compositionLocalOf { false }
|
||||
|
||||
val LocalGridSettings = compositionLocalOf { GridSettings() }
|
||||
|
||||
val LocalTimeFormat = staticCompositionLocalOf { TimeFormat.TwentyFourHour }
|
||||
|
||||
@@ -22,6 +22,7 @@ fun AppSearchSettingsScreen() {
|
||||
val viewModel = viewModel<AppSearchSettingsScreenVM>()
|
||||
|
||||
val allApps by viewModel.allApps.collectAsStateWithLifecycle()
|
||||
val hideAppDetails by viewModel.hideAppDetails.collectAsStateWithLifecycle()
|
||||
val showList by viewModel.showList.collectAsStateWithLifecycle()
|
||||
val showListIcons by viewModel.showListIcons.collectAsStateWithLifecycle()
|
||||
|
||||
@@ -39,6 +40,14 @@ fun AppSearchSettingsScreen() {
|
||||
viewModel.setAllApps(it)
|
||||
}
|
||||
)
|
||||
SwitchPreference(
|
||||
title = stringResource(R.string.preference_search_apps_hide_details),
|
||||
summary = stringResource(R.string.preference_search_apps_hide_details_summary),
|
||||
value = hideAppDetails == true,
|
||||
onValueChanged = {
|
||||
viewModel.setHideAppDetails(it)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
item {
|
||||
|
||||
@@ -17,10 +17,17 @@ class AppSearchSettingsScreenVM: ViewModel(), KoinComponent {
|
||||
val allApps = searchUiSettings.allApps
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
|
||||
|
||||
val hideAppDetails = searchUiSettings.hideAppDetails
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
|
||||
|
||||
fun setAllApps(allApps: Boolean) {
|
||||
searchUiSettings.setAllApps(allApps)
|
||||
}
|
||||
|
||||
fun setHideAppDetails(hideAppDetails: Boolean) {
|
||||
searchUiSettings.setHideAppDetails(hideAppDetails)
|
||||
}
|
||||
|
||||
val showList = uiSettings.gridSettings.map { it.showList }
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user