-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): grey out read articles even if read
- Loading branch information
1 parent
f1baa9c
commit 06a645c
Showing
8 changed files
with
118 additions
and
75 deletions.
There are no files selected for viewing
42 changes: 0 additions & 42 deletions
42
...e/ash/reader/infrastructure/preference/FlowArticleListAlwaysHighlightStarredPreference.kt
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
...c/main/java/me/ash/reader/infrastructure/preference/FlowArticleReadIndicatorPreference.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package me.ash.reader.infrastructure.preference | ||
|
||
import android.content.Context | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.datastore.preferences.core.Preferences | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.launch | ||
import me.ash.reader.R | ||
import me.ash.reader.ui.ext.DataStoreKeys | ||
import me.ash.reader.ui.ext.dataStore | ||
import me.ash.reader.ui.ext.put | ||
|
||
sealed class FlowArticleReadIndicatorPreference(val value: Boolean) : Preference() { | ||
object ExcludingStarred : FlowArticleReadIndicatorPreference(true) | ||
object AllRead : FlowArticleReadIndicatorPreference(false) | ||
|
||
override fun put(context: Context, scope: CoroutineScope) { | ||
scope.launch { | ||
context.dataStore.put( | ||
DataStoreKeys.FlowArticleListReadIndicator, | ||
value | ||
) | ||
} | ||
} | ||
|
||
val description: String | ||
@Composable get() { | ||
return when (this) { | ||
AllRead -> stringResource(id = R.string.all_read) | ||
ExcludingStarred -> stringResource(id = R.string.read_excluding_starred) | ||
} | ||
} | ||
|
||
companion object { | ||
|
||
val default = ExcludingStarred | ||
val values = listOf(ExcludingStarred, AllRead) | ||
|
||
fun fromPreferences(preferences: Preferences) = | ||
when (preferences[DataStoreKeys.FlowArticleListReadIndicator.key]) { | ||
true -> ExcludingStarred | ||
false -> AllRead | ||
else -> default | ||
} | ||
|
||
} | ||
} | ||
|
||
operator fun FlowArticleReadIndicatorPreference.not(): FlowArticleReadIndicatorPreference = | ||
when (value) { | ||
true -> FlowArticleReadIndicatorPreference.AllRead | ||
false -> FlowArticleReadIndicatorPreference.ExcludingStarred | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters