Hide top row of favorites in favorites widget if it is directly below the clock widget favorites part
This commit is contained in:
@@ -16,7 +16,7 @@ import org.koin.core.component.inject
|
||||
abstract class FavoritesVM : ViewModel(), KoinComponent {
|
||||
|
||||
private val favoritesRepository: FavoritesRepository by inject()
|
||||
private val widgetRepository: WidgetRepository by inject()
|
||||
internal val widgetRepository: WidgetRepository by inject()
|
||||
private val customAttributesRepository: CustomAttributesRepository by inject()
|
||||
internal val dataStore: LauncherDataStore by inject()
|
||||
|
||||
@@ -33,7 +33,7 @@ abstract class FavoritesVM : ViewModel(), KoinComponent {
|
||||
it.filterIsInstance<Tag>()
|
||||
}
|
||||
|
||||
val favorites: Flow<List<SavableSearchable>> = selectedTag.flatMapLatest { tag ->
|
||||
open val favorites: Flow<List<SavableSearchable>> = selectedTag.flatMapLatest { tag ->
|
||||
if (tag == null) {
|
||||
val columns = dataStore.data.map { it.grid.columnCount }
|
||||
val excludeCalendar = widgetRepository.isCalendarWidgetEnabled()
|
||||
|
||||
+21
-1
@@ -1,17 +1,37 @@
|
||||
package de.mm20.launcher2.ui.launcher.widgets.favorites
|
||||
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import de.mm20.launcher2.preferences.Settings.ClockWidgetSettings.ClockWidgetLayout
|
||||
import de.mm20.launcher2.ui.common.FavoritesVM
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.shareIn
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class FavoritesWidgetVM: FavoritesVM() {
|
||||
class FavoritesWidgetVM : FavoritesVM() {
|
||||
|
||||
override val tagsExpanded: Flow<Boolean> = dataStore.data.map { it.ui.widgetTagsMultiline }
|
||||
.shareIn(viewModelScope, SharingStarted.Lazily)
|
||||
|
||||
private val isTopWidget = widgetRepository.isFavoritesWidgetFirst()
|
||||
private val clockWidgetFavSlots = dataStore.data.combine(isTopWidget) { data, isTop ->
|
||||
if (!isTop) 0
|
||||
else {
|
||||
if (data.clockWidget.layout == ClockWidgetLayout.Horizontal) data.grid.columnCount - 2
|
||||
else data.grid.columnCount
|
||||
}
|
||||
}
|
||||
|
||||
override val favorites = super.favorites.combine(clockWidgetFavSlots) { favs, slots ->
|
||||
if (selectedTag.value == null) {
|
||||
favs.subList(slots, favs.size)
|
||||
} else {
|
||||
favs
|
||||
}
|
||||
}
|
||||
|
||||
override fun setTagsExpanded(expanded: Boolean) {
|
||||
viewModelScope.launch {
|
||||
dataStore.updateData {
|
||||
|
||||
Reference in New Issue
Block a user