Skip to content

Commit

Permalink
added setting for opening feeds drawer when pressing FAB
Browse files Browse the repository at this point in the history
fixes #425

Signed-off-by: Jonas Kalderstam <jonas@cowboyprogrammer.org>
  • Loading branch information
spacecowboy committed Dec 3, 2024
1 parent e2a4ebf commit cd8f70b
Show file tree
Hide file tree
Showing 7 changed files with 259 additions and 221 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ class Repository(override val di: DI) : DIAware {

fun setShowTitleUnreadCount(value: Boolean) = settingsStore.setShowTitleUnreadCount(value)

val isOpenDrawerOnFab = settingsStore.isOpenDrawerOnFab

fun setOpenDrawerOnFab(value: Boolean) = settingsStore.setOpenDrawerOnFab(value)

/**
* Returns true if the latest sync timestamp is within the last 10 seconds
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,14 @@ class SettingsStore(override val di: DI) : DIAware {
sp.edit().putBoolean(PREF_SHOW_TITLE_UNREAD_COUNT, value).apply()
}

private val _openDrawerOnFab = MutableStateFlow(sp.getBoolean(PREF_OPEN_DRAWER_ON_FAB, false))
val isOpenDrawerOnFab = _openDrawerOnFab.asStateFlow()

fun setOpenDrawerOnFab(value: Boolean) {
_openDrawerOnFab.value = value
sp.edit().putBoolean(PREF_OPEN_DRAWER_ON_FAB, value).apply()
}

fun getAllSettings(): Map<String, String> {
val all = sp.all ?: emptyMap()

Expand Down Expand Up @@ -599,6 +607,8 @@ const val PREF_LIST_SHOW_ONLY_TITLES = "prefs_list_show_only_titles"

const val PREF_LIST_SHOW_READING_TIME = "pref_show_reading_time"

const val PREF_OPEN_DRAWER_ON_FAB = "pref_open_drawer_on_fab"

/**
* Read Aloud Settings
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.activity.compose.BackHandler
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
Expand Down Expand Up @@ -906,7 +905,6 @@ fun FeedScreen(

@OptIn(
ExperimentalMaterial3Api::class,
ExperimentalAnimationApi::class,
)
@Composable
fun FeedScreen(
Expand Down Expand Up @@ -957,7 +955,9 @@ fun FeedScreen(
FloatingActionButton(
onClick = {
onMarkAllAsRead()
onOpenNavDrawer()
if (viewState.isOpenDrawerOnFab) {
onOpenNavDrawer()
}
},
modifier =
Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ class FeedViewModel(
repository.showReadingTime,
repository.showTitleUnreadCount,
repository.syncWorkerRunning,
// 25
repository.isOpenDrawerOnFab,
) { params: Array<Any> ->
val haveVisibleFeedItems = (params[7] as Int) > 0
val currentFeedOrTag = params[13] as FeedOrTag
Expand Down Expand Up @@ -286,6 +288,7 @@ class FeedViewModel(
showOnlyTitle = params[21] as Boolean,
showReadingTime = params[22] as Boolean,
showTitleUnreadCount = params[23] as Boolean,
isOpenDrawerOnFab = params[25] as Boolean,
)
}
.stateIn(
Expand Down Expand Up @@ -417,6 +420,7 @@ data class FeedState(
override val filter: FeedListFilter = emptyFeedListFilter,
val isArticleOpen: Boolean = false,
override val showTitleUnreadCount: Boolean = false,
override val isOpenDrawerOnFab: Boolean = false,
) : FeedScreenViewState

@Immutable
Expand Down Expand Up @@ -445,6 +449,7 @@ interface FeedScreenViewState {
val filter: FeedListFilter
val showFilterMenu: Boolean
val showTitleUnreadCount: Boolean
val isOpenDrawerOnFab: Boolean
}

@Immutable
Expand Down
Loading

0 comments on commit cd8f70b

Please sign in to comment.