mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-03 16:37:32 +01:00
enhancement: immediately apply sort and feed type; update sort and feed type icons
This commit is contained in:
parent
23a4e17b56
commit
54accc8538
@ -206,6 +206,12 @@ internal class SortBottomSheetTop(
|
|||||||
style = MaterialTheme.typography.bodyLarge,
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
color = MaterialTheme.colorScheme.onBackground,
|
color = MaterialTheme.colorScheme.onBackground,
|
||||||
)
|
)
|
||||||
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
Image(
|
||||||
|
imageVector = value.toIcon(),
|
||||||
|
contentDescription = null,
|
||||||
|
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onBackground),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data
|
package com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data
|
||||||
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Domain
|
import androidx.compose.material.icons.filled.CardMembership
|
||||||
import androidx.compose.material.icons.filled.Newspaper
|
import androidx.compose.material.icons.filled.Cottage
|
||||||
import androidx.compose.material.icons.filled.Public
|
import androidx.compose.material.icons.filled.Public
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import com.github.diegoberaldin.raccoonforlemmy.resources.MR
|
import com.github.diegoberaldin.raccoonforlemmy.resources.MR
|
||||||
@ -27,8 +27,8 @@ fun Int.toListingType() = when (this) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun ListingType.toIcon() = when (this) {
|
fun ListingType.toIcon() = when (this) {
|
||||||
ListingType.Local -> Icons.Default.Domain
|
ListingType.Local -> Icons.Default.Cottage
|
||||||
ListingType.Subscribed -> Icons.Default.Newspaper
|
ListingType.Subscribed -> Icons.Default.CardMembership
|
||||||
else -> Icons.Default.Public
|
else -> Icons.Default.Public
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data
|
package com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data
|
||||||
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.AddComment
|
import androidx.compose.material.icons.filled.ElderlyWoman
|
||||||
import androidx.compose.material.icons.filled.History
|
import androidx.compose.material.icons.filled.Forum
|
||||||
import androidx.compose.material.icons.filled.LocalActivity
|
|
||||||
import androidx.compose.material.icons.filled.LocalFireDepartment
|
import androidx.compose.material.icons.filled.LocalFireDepartment
|
||||||
|
import androidx.compose.material.icons.filled.MarkUnreadChatAlt
|
||||||
import androidx.compose.material.icons.filled.MilitaryTech
|
import androidx.compose.material.icons.filled.MilitaryTech
|
||||||
import androidx.compose.material.icons.filled.Reviews
|
import androidx.compose.material.icons.filled.NewReleases
|
||||||
import androidx.compose.material.icons.filled.Rocket
|
import androidx.compose.material.icons.filled.Rocket
|
||||||
import androidx.compose.material.icons.filled.Thunderstorm
|
import androidx.compose.material.icons.filled.Thunderstorm
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@ -74,10 +74,10 @@ fun Int.toSortType() = when (this) {
|
|||||||
fun SortType.toIcon(): ImageVector = when (this) {
|
fun SortType.toIcon(): ImageVector = when (this) {
|
||||||
SortType.Active -> Icons.Default.Rocket
|
SortType.Active -> Icons.Default.Rocket
|
||||||
SortType.Hot -> Icons.Default.LocalFireDepartment
|
SortType.Hot -> Icons.Default.LocalFireDepartment
|
||||||
SortType.MostComments -> Icons.Default.AddComment
|
SortType.MostComments -> Icons.Default.Forum
|
||||||
SortType.New -> Icons.Default.LocalActivity
|
SortType.New -> Icons.Default.NewReleases
|
||||||
SortType.NewComments -> Icons.Default.Reviews
|
SortType.NewComments -> Icons.Default.MarkUnreadChatAlt
|
||||||
SortType.Old -> Icons.Default.History
|
SortType.Old -> Icons.Default.ElderlyWoman
|
||||||
SortType.Controversial -> Icons.Default.Thunderstorm
|
SortType.Controversial -> Icons.Default.Thunderstorm
|
||||||
else -> Icons.Default.MilitaryTech
|
else -> Icons.Default.MilitaryTech
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.repository.PostRepo
|
|||||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.repository.SiteRepository
|
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.repository.SiteRepository
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.IO
|
import kotlinx.coroutines.IO
|
||||||
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
@ -92,6 +93,29 @@ class PostListViewModel(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}.launchIn(this)
|
}.launchIn(this)
|
||||||
|
|
||||||
|
settingsRepository.currentSettings
|
||||||
|
.map { it.defaultListingType }
|
||||||
|
.distinctUntilChanged()
|
||||||
|
.onEach { listingType ->
|
||||||
|
mvi.updateState {
|
||||||
|
it.copy(
|
||||||
|
listingType = listingType.toListingType(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
refresh()
|
||||||
|
}.launchIn(this)
|
||||||
|
settingsRepository.currentSettings
|
||||||
|
.map { it.defaultPostSortType }
|
||||||
|
.distinctUntilChanged()
|
||||||
|
.onEach { sortType ->
|
||||||
|
mvi.updateState {
|
||||||
|
it.copy(
|
||||||
|
sortType = sortType.toSortType(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
refresh()
|
||||||
|
}.launchIn(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
mvi.scope?.launch(Dispatchers.IO) {
|
mvi.scope?.launch(Dispatchers.IO) {
|
||||||
|
@ -26,6 +26,7 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.IO
|
import kotlinx.coroutines.IO
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
@ -83,6 +84,28 @@ class ExploreViewModel(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}.launchIn(this)
|
}.launchIn(this)
|
||||||
|
settingsRepository.currentSettings
|
||||||
|
.map { it.defaultListingType }
|
||||||
|
.distinctUntilChanged()
|
||||||
|
.onEach { listingType ->
|
||||||
|
mvi.updateState {
|
||||||
|
it.copy(
|
||||||
|
listingType = listingType.toListingType(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
refresh()
|
||||||
|
}.launchIn(this)
|
||||||
|
settingsRepository.currentSettings
|
||||||
|
.map { it.defaultPostSortType }
|
||||||
|
.distinctUntilChanged()
|
||||||
|
.onEach { sortType ->
|
||||||
|
mvi.updateState {
|
||||||
|
it.copy(
|
||||||
|
sortType = sortType.toSortType(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
refresh()
|
||||||
|
}.launchIn(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mvi.uiState.value.results.isEmpty()) {
|
if (mvi.uiState.value.results.isEmpty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user