parent
cd803974de
commit
930897f1d6
@ -49,6 +49,7 @@ fun FavoritesTagSelector(
|
||||
reverse: Boolean,
|
||||
onSelectTag: (String?) -> Unit,
|
||||
scrollState: ScrollState,
|
||||
compact: Boolean,
|
||||
expanded: Boolean,
|
||||
onExpand: (Boolean) -> Unit,
|
||||
) {
|
||||
@ -86,14 +87,26 @@ fun FavoritesTagSelector(
|
||||
),
|
||||
selected = selectedTag == null,
|
||||
onClick = { onSelectTag(null) },
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
imageVector = Icons.Rounded.Star,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(FilterChipDefaults.IconSize),
|
||||
)
|
||||
leadingIcon = if (compact) null else {
|
||||
{
|
||||
Icon(
|
||||
imageVector = Icons.Rounded.Star,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(FilterChipDefaults.IconSize),
|
||||
)
|
||||
}
|
||||
},
|
||||
label = { Text(stringResource(R.string.favorites)) }
|
||||
label = {
|
||||
if (compact) {
|
||||
Icon(
|
||||
imageVector = Icons.Rounded.Star,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(FilterChipDefaults.IconSize),
|
||||
)
|
||||
} else {
|
||||
Text(stringResource(R.string.favorites))
|
||||
}
|
||||
}
|
||||
)
|
||||
for (tag in tags) {
|
||||
TagChip(
|
||||
@ -112,6 +125,7 @@ fun FavoritesTagSelector(
|
||||
onSelectTag(tag.tag)
|
||||
}
|
||||
},
|
||||
compact = compact,
|
||||
onLongClick = {
|
||||
sheetManager.showEditTagSheet(tag.tag)
|
||||
}
|
||||
@ -164,24 +178,43 @@ fun FavoritesTagSelector(
|
||||
FilterChip(
|
||||
modifier = Modifier
|
||||
.padding(end = 8.dp)
|
||||
.sharedBounds(rememberSharedContentState("favorites"), this@AnimatedContent),
|
||||
.sharedBounds(
|
||||
rememberSharedContentState("favorites"),
|
||||
this@AnimatedContent
|
||||
),
|
||||
selected = selectedTag == null,
|
||||
onClick = { onSelectTag(null) },
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
imageVector = Icons.Rounded.Star,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(FilterChipDefaults.IconSize),
|
||||
)
|
||||
leadingIcon = if (compact) null else {
|
||||
{
|
||||
Icon(
|
||||
imageVector = Icons.Rounded.Star,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(FilterChipDefaults.IconSize),
|
||||
)
|
||||
}
|
||||
},
|
||||
label = { Text(stringResource(R.string.favorites)) }
|
||||
label = {
|
||||
if (compact) {
|
||||
Icon(
|
||||
imageVector = Icons.Rounded.Star,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(FilterChipDefaults.IconSize),
|
||||
)
|
||||
} else {
|
||||
Text(stringResource(R.string.favorites))
|
||||
}
|
||||
}
|
||||
)
|
||||
for (tag in tags) {
|
||||
TagChip(
|
||||
modifier = Modifier
|
||||
.padding(end = 8.dp)
|
||||
.sharedBounds(rememberSharedContentState("tag-${tag.tag}"), this@AnimatedContent),
|
||||
.sharedBounds(
|
||||
rememberSharedContentState("tag-${tag.tag}"),
|
||||
this@AnimatedContent
|
||||
),
|
||||
tag = tag,
|
||||
compact = compact,
|
||||
selected = selectedTag == tag.tag,
|
||||
onClick = {
|
||||
if (selectedTag == tag.tag) {
|
||||
@ -207,7 +240,10 @@ fun FavoritesTagSelector(
|
||||
IconButton(
|
||||
modifier = Modifier
|
||||
.rotate(rot)
|
||||
.sharedBounds(rememberSharedContentState("expand"), this@AnimatedContent),
|
||||
.sharedBounds(
|
||||
rememberSharedContentState("expand"),
|
||||
this@AnimatedContent
|
||||
),
|
||||
onClick = { onExpand(false) }
|
||||
) {
|
||||
Icon(Icons.Rounded.ExpandLess, null)
|
||||
@ -216,7 +252,10 @@ fun FavoritesTagSelector(
|
||||
if (editButton) {
|
||||
SmallFloatingActionButton(
|
||||
modifier = Modifier
|
||||
.sharedBounds(rememberSharedContentState("edit"), this@AnimatedContent),
|
||||
.sharedBounds(
|
||||
rememberSharedContentState("edit"),
|
||||
this@AnimatedContent
|
||||
),
|
||||
elevation = FloatingActionButtonDefaults.bottomAppBarFabElevation(),
|
||||
onClick = { sheetManager.showEditFavoritesSheet() }
|
||||
) {
|
||||
|
||||
@ -27,6 +27,7 @@ abstract class FavoritesVM : ViewModel(), KoinComponent {
|
||||
|
||||
val showEditButton = settings.showEditButton.stateIn(viewModelScope, SharingStarted.Lazily, false)
|
||||
abstract val tagsExpanded: Flow<Boolean>
|
||||
abstract val compactTags: Flow<Boolean>
|
||||
|
||||
val pinnedTags = favoritesService.getFavorites(
|
||||
includeTypes = listOf("tag"),
|
||||
|
||||
@ -105,6 +105,7 @@ fun SearchColumn(
|
||||
|
||||
val pinnedTags by favoritesVM.pinnedTags.collectAsState(emptyList())
|
||||
val selectedTag by favoritesVM.selectedTag.collectAsState(null)
|
||||
val compactTags by favoritesVM.compactTags.collectAsState(false)
|
||||
val favoritesEditButton by favoritesVM.showEditButton.collectAsState(false)
|
||||
val favoritesTagsExpanded by favoritesVM.tagsExpanded.collectAsState(false)
|
||||
|
||||
@ -168,6 +169,7 @@ fun SearchColumn(
|
||||
onExpandTags = {
|
||||
favoritesVM.setTagsExpanded(it)
|
||||
},
|
||||
compactTags = compactTags,
|
||||
editButton = favoritesEditButton
|
||||
)
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ fun LazyListScope.SearchFavorites(
|
||||
favorites: List<SavableSearchable>,
|
||||
pinnedTags: List<Tag>,
|
||||
selectedTag: String?,
|
||||
compactTags: Boolean,
|
||||
tagsExpanded: Boolean,
|
||||
onExpandTags: (Boolean) -> Unit,
|
||||
onSelectTag: (String?) -> Unit,
|
||||
@ -72,6 +73,7 @@ fun LazyListScope.SearchFavorites(
|
||||
onSelectTag = onSelectTag,
|
||||
scrollState = rememberScrollState(),
|
||||
expanded = tagsExpanded,
|
||||
compact = compactTags,
|
||||
onExpand = onExpandTags,
|
||||
)
|
||||
}
|
||||
|
||||
@ -19,4 +19,6 @@ class SearchFavoritesVM : FavoritesVM() {
|
||||
uiState.setFavoritesTagsExpanded(expanded)
|
||||
}
|
||||
|
||||
override val compactTags: Flow<Boolean> = settings.compactTags
|
||||
|
||||
}
|
||||
@ -207,6 +207,14 @@ fun ColumnScope.ConfigureFavoritesWidget(
|
||||
onWidgetUpdated(widget.copy(config = widget.config.copy(editButton = it)))
|
||||
}
|
||||
)
|
||||
SwitchPreference(
|
||||
title = stringResource(R.string.preference_compact_tags),
|
||||
iconPadding = false,
|
||||
value = widget.config.compactTags,
|
||||
onValueChanged = {
|
||||
onWidgetUpdated(widget.copy(config = widget.config.copy(compactTags = it)))
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
TextButton(
|
||||
|
||||
@ -32,6 +32,7 @@ fun FavoritesWidget(widget: FavoritesWidget) {
|
||||
val favorites by remember { viewModel.favorites }.collectAsState(emptyList())
|
||||
val pinnedTags by viewModel.pinnedTags.collectAsState(emptyList())
|
||||
val selectedTag by viewModel.selectedTag.collectAsState(null)
|
||||
val compactTags by viewModel.compactTags.collectAsState(false)
|
||||
val favoritesEditButton = widget.config.editButton
|
||||
|
||||
val tagsExpanded by viewModel.tagsExpanded.collectAsState(false)
|
||||
@ -61,6 +62,7 @@ fun FavoritesWidget(widget: FavoritesWidget) {
|
||||
onSelectTag = { viewModel.selectTag(it) },
|
||||
scrollState = rememberScrollState(),
|
||||
expanded = tagsExpanded,
|
||||
compact = compactTags,
|
||||
onExpand = { viewModel.setTagsExpanded(it) }
|
||||
)
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import de.mm20.launcher2.preferences.ui.UiSettings
|
||||
import de.mm20.launcher2.services.widgets.WidgetsService
|
||||
import de.mm20.launcher2.ui.common.FavoritesVM
|
||||
import de.mm20.launcher2.widgets.FavoritesWidget
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.map
|
||||
@ -20,6 +21,7 @@ class FavoritesWidgetVM : FavoritesVM() {
|
||||
|
||||
private val widget = MutableStateFlow<FavoritesWidget?>(null)
|
||||
override val tagsExpanded = widget.map { it?.config?.tagsMultiline == true }
|
||||
override val compactTags: Flow<Boolean> = widget.map { it?.config?.compactTags == true }
|
||||
|
||||
private val isTopWidget = widgetsService.isFavoritesWidgetFirst()
|
||||
private val clockWidgetFavSlots =
|
||||
|
||||
@ -83,6 +83,7 @@ fun FavoritesSettingsScreen() {
|
||||
}
|
||||
item {
|
||||
val editButton by viewModel.editButton.collectAsState()
|
||||
val compactTags by viewModel.compactTags.collectAsState()
|
||||
PreferenceCategory {
|
||||
SwitchPreference(
|
||||
title = stringResource(R.string.preference_edit_button),
|
||||
@ -93,6 +94,14 @@ fun FavoritesSettingsScreen() {
|
||||
},
|
||||
icon = Icons.Rounded.Edit
|
||||
)
|
||||
SwitchPreference(
|
||||
title = stringResource(R.string.preference_compact_tags),
|
||||
summary = stringResource(R.string.preference_compact_tags_summary),
|
||||
value = compactTags == true,
|
||||
onValueChanged = {
|
||||
viewModel.setCompactTags(it)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,4 +39,10 @@ class FavoritesSettingsScreenVM: ViewModel(), KoinComponent {
|
||||
fun setSearchResultWeightFactor(searchResultWeightFactor: WeightFactor) {
|
||||
rankingSettings.setWeightFactor(searchResultWeightFactor)
|
||||
}
|
||||
|
||||
val compactTags = favoritesSettings.compactTags
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), null)
|
||||
fun setCompactTags(compactTags: Boolean) {
|
||||
favoritesSettings.setCompactTags(compactTags)
|
||||
}
|
||||
}
|
||||
@ -652,6 +652,8 @@
|
||||
<string name="preference_favorites_frequently_used_summary">Show frequently used items in favorites</string>
|
||||
<string name="preference_edit_button">Edit button</string>
|
||||
<string name="preference_favorites_edit_button_summary">Show a button to rearrange the favorites</string>
|
||||
<string name="preference_compact_tags">Compact tags</string>
|
||||
<string name="preference_compact_tags_summary">Hide tag labels or icons to reduce the space occupied by tags</string>
|
||||
<string name="preference_widgets_edit_button_summary">Show a button to add, remove and rearrange widgets</string>
|
||||
<string name="preference_screen_homescreen">Home screen</string>
|
||||
<string name="preference_screen_homescreen_summary">Clock, search bar, wallpaper, system bars</string>
|
||||
|
||||
@ -48,6 +48,7 @@ data class LauncherSettingsData internal constructor(
|
||||
val favoritesFrequentlyUsed: Boolean = true,
|
||||
val favoritesFrequentlyUsedRows: Int = 1,
|
||||
val favoritesEditButton: Boolean = true,
|
||||
val favoritesCompactTags: Boolean = false,
|
||||
|
||||
val fileSearchProviders: Set<String> = setOf("local"),
|
||||
|
||||
|
||||
@ -41,4 +41,11 @@ class FavoritesSettings internal constructor(
|
||||
fun setFrequentlyUsedRows(frequentlyUsedRows: Int) {
|
||||
dataStore.update { it.copy(favoritesFrequentlyUsedRows = frequentlyUsedRows) }
|
||||
}
|
||||
|
||||
val compactTags: Flow<Boolean>
|
||||
get() = dataStore.data.map { it.favoritesCompactTags }.distinctUntilChanged()
|
||||
|
||||
fun setCompactTags(compactTags: Boolean) {
|
||||
dataStore.update { it.copy(favoritesCompactTags = compactTags) }
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,7 @@ import java.util.UUID
|
||||
data class FavoritesWidgetConfig(
|
||||
val editButton: Boolean = true,
|
||||
val tagsMultiline: Boolean = false,
|
||||
val compactTags: Boolean = false,
|
||||
)
|
||||
|
||||
data class FavoritesWidget(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user