feat(#517): move the per-view hide entry from the top bar into the drawer

This commit is contained in:
makiolaj committed 2026-11-14 11:52:48 +01:00
1 parent d5b51f2c01
commit 1aa66ffc99
6 files changed
+46 -43

No files matched your search

@@ -42,7 +42,6 @@ import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.positionInWindow
import androidx.compose.ui.platform.LocalDensity
import androidx.hilt.navigation.compose.hiltViewModel
import de.jeanlucmakiola.calendula.ui.filter.FilterUiState
import de.jeanlucmakiola.calendula.ui.filter.FilterViewModel
import de.jeanlucmakiola.calendula.ui.filter.ViewCalendarsPicker
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -195,7 +194,7 @@ fun CalendarHost(
var detailKey by rememberSaveable { mutableStateOf<LongArray?>(null) }
val onOpenDetail: (EventInstance) -> Unit = { event -> detailKey = event.occurrenceKey() }
// The top bar's view-calendars picker (#517). It is its own window over
// The drawer's "Hide in this view" picker (#517). It is its own window over
// everything here, so each external request below closes it first.
var showViewCalendars by rememberSaveable { mutableStateOf(false) }
@@ -220,7 +219,6 @@ fun CalendarHost(
// the detail on top and backing out returns to the results.
var showSearch by rememberSaveable { mutableStateOf(false) }
val filterViewModel: FilterViewModel = hiltViewModel()
val filterState by filterViewModel.state.collectAsStateWithLifecycle()
val onOpenSearch = { showSearch = true }
// Calendar manager (reached from Settings) — its own overlay so it slides
@@ -572,6 +570,7 @@ fun CalendarHost(
LocalManageCalendars provides remember { { showCalendars = true } },
) {
if (showViewCalendars) {
val filterState by filterViewModel.state.collectAsStateWithLifecycle()
ViewCalendarsPicker(
view = view,
state = filterState,
@@ -609,6 +608,10 @@ fun CalendarHost(
onOpenSettings()
switchScope.launch { drawerState.close() }
},
onHideInView = {
showViewCalendars = true
switchScope.launch { drawerState.close() }
},
)
},
) {
@@ -622,10 +625,6 @@ fun CalendarHost(
onOpenDrawer = { switchScope.launch { drawerState.open() } },
onOpenSearch = onOpenSearch,
showTodayButton = todayInToolbar,
hiddenInView = remember(filterState, view) {
(filterState as? FilterUiState.Success)?.hiddenOnlyIn(view) ?: 0
},
onOpenViewCalendars = { showViewCalendars = true },
)
},
floatingActionButton = {
@@ -14,11 +14,8 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.FilterList
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material.icons.filled.Search
import androidx.compose.material3.Badge
import androidx.compose.material3.BadgedBox
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@@ -37,7 +34,6 @@ import androidx.compose.runtime.Stable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import de.jeanlucmakiola.calendula.R
import de.jeanlucmakiola.calendula.domain.EventInstance
@@ -181,8 +177,6 @@ fun CalendarTopBar(
onOpenDrawer: () -> Unit,
onOpenSearch: () -> Unit,
showTodayButton: Boolean,
hiddenInView: Int,
onOpenViewCalendars: () -> Unit,
) {
val effects = MaterialTheme.motionScheme.fastEffectsSpec<Float>()
AnimatedContent(
@@ -205,8 +199,6 @@ fun CalendarTopBar(
onOpenDrawer = onOpenDrawer,
onOpenSearch = onOpenSearch,
showTodayButton = showTodayButton,
hiddenInView = hiddenInView,
onOpenViewCalendars = onOpenViewCalendars,
)
}
}
@@ -222,8 +214,6 @@ private fun ViewTopBar(
onOpenDrawer: () -> Unit,
onOpenSearch: () -> Unit,
showTodayButton: Boolean,
hiddenInView: Int,
onOpenViewCalendars: () -> Unit,
) {
val chrome = host.chrome
TopAppBar(
@@ -253,7 +243,6 @@ private fun ViewTopBar(
contentDescription = stringResource(R.string.search_action),
)
}
ViewCalendarsAction(hiddenInView = hiddenInView, onClick = onOpenViewCalendars)
ViewSwitcherPill(
current = selectedView,
cycle = quickSwitchViews,
@@ -270,24 +259,6 @@ private fun ViewTopBar(
)
}
/**
* Opens the calendars hidden in the view on show (#517). A dot marks a view
* that hides any, so missing events have a visible reason.
*/
@Composable
private fun ViewCalendarsAction(hiddenInView: Int, onClick: () -> Unit) {
val description = if (hiddenInView > 0) {
pluralStringResource(R.plurals.view_calendars_action_hidden, hiddenInView, hiddenInView)
} else {
stringResource(R.string.view_calendars_action)
}
IconButton(onClick = onClick) {
BadgedBox(badge = { if (hiddenInView > 0) Badge() }) {
Icon(imageVector = Icons.Default.FilterList, contentDescription = description)
}
}
}
/**
* The FAB column every calendar screen shares. While an event is selected the
* FAB is [selection]'s toggle instead, and it steps aside mid-gesture.
@@ -70,6 +70,7 @@ fun CalendarDrawer(
onSelectView: (CalendarView) -> Unit,
onJumpToDate: (LocalDate) -> Unit,
onSettings: () -> Unit,
onHideInView: () -> Unit,
viewOrder: List<CalendarView> = IMPLEMENTED_VIEWS,
) {
var showDatePicker by remember { mutableStateOf(false) }
@@ -112,7 +113,7 @@ fun CalendarDrawer(
Spacer(Modifier.height(16.dp))
DrawerSectionHeader(stringResource(R.string.filter_title))
CalendarFilterList(currentView = currentView)
CalendarFilterList(currentView = currentView, onHideInView = onHideInView)
Spacer(Modifier.height(16.dp))
GroupedRow(
@@ -4,15 +4,22 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.FilterList
import androidx.compose.material3.Checkbox
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.pluralStringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
@@ -28,6 +35,7 @@ import de.jeanlucmakiola.calendula.ui.common.accountGroupTitle
import de.jeanlucmakiola.calendula.ui.common.orUnnamed
import de.jeanlucmakiola.floret.components.GroupedListInset
import de.jeanlucmakiola.floret.components.GroupedRow
import de.jeanlucmakiola.floret.components.Position
import de.jeanlucmakiola.floret.components.positionOf
/**
@@ -40,6 +48,7 @@ import de.jeanlucmakiola.floret.components.positionOf
@Composable
fun CalendarFilterList(
currentView: CalendarView,
onHideInView: () -> Unit,
modifier: Modifier = Modifier,
viewModel: FilterViewModel = hiltViewModel(),
) {
@@ -51,6 +60,8 @@ fun CalendarFilterList(
groups = s.groups,
hidden = s.hidden,
hiddenInView = s.hiddenViews.calendarsHiddenIn(currentView),
hiddenOnlyHere = s.hiddenOnlyIn(currentView),
onHideInView = onHideInView,
onSetVisible = viewModel::setVisible,
modifier = modifier,
)
@@ -67,6 +78,8 @@ private fun FilterList(
groups: List<CalendarAccountGroup>,
hidden: Set<Long>,
hiddenInView: Set<Long>,
hiddenOnlyHere: Int,
onHideInView: () -> Unit,
onSetVisible: (Long, Boolean) -> Unit,
modifier: Modifier = Modifier,
) {
@@ -101,6 +114,25 @@ private fun FilterList(
)
}
}
// The per-view hide (#517): the drawer filter above hides everywhere, this only here.
Spacer(Modifier.height(8.dp))
GroupedRow(
title = stringResource(R.string.view_calendars_title),
summary = if (hiddenOnlyHere > 0) {
pluralStringResource(R.plurals.drawer_hidden_in_view_count, hiddenOnlyHere, hiddenOnlyHere)
} else {
stringResource(R.string.drawer_hidden_in_view_none)
},
position = Position.Alone,
minHeight = 56.dp,
selected = hiddenOnlyHere > 0,
leading = {
Box(Modifier.size(40.dp), contentAlignment = Alignment.Center) {
Icon(Icons.Filled.FilterList, contentDescription = null)
}
},
onClick = onHideInView,
)
}
}
+4 -4
View File
@@ -868,12 +868,12 @@
<string name="calendars_hide_in_views_none">Shown in every view</string>
<string name="calendars_hidden_in">Hidden in %1$s</string>
<string name="filter_hidden_in_view">Hidden in this view</string>
<string name="view_calendars_action">Hide calendars in this view</string>
<string name="view_calendars_title">Hide in this view</string>
<plurals name="view_calendars_action_hidden">
<item quantity="one">Hide calendars in this view, %d hidden</item>
<item quantity="other">Hide calendars in this view, %d hidden</item>
<plurals name="drawer_hidden_in_view_count">
<item quantity="one">%d calendar hidden in this view</item>
<item quantity="other">%d calendars hidden in this view</item>
</plurals>
<string name="drawer_hidden_in_view_none">Leave calendars out of this view only</string>
<string name="view_calendars_hint">Checked calendars stay out of this view only. Reminders, search and widgets still include them.</string>
<string name="view_calendars_hidden_everywhere">Hidden in every view from the menu</string>
<string name="color_name_mauve">Mauve</string>
+2 -2
View File
@@ -393,8 +393,8 @@ separate in-app declutter that never touches reminders. Narrower still is the pe
(`SettingsPrefs.perCalendarHiddenViews`, #270): each view model asks for its
events through `instancesWithout(range, calendarsHiddenIn(view, …))`, which drops
the calendars hidden in that one view on top of the repository's filters; reminders, search and widgets read
the repository and never see it. The top bar's filter action (#517) edits the same set for
the view on show, and its dot and the drawer's "Hidden in this view" read it too.
the repository and never see it. The drawer's "Hide in this view" entry (#517) edits the same
set for the view on show, and the drawer's per-row "Hidden in this view" notes read it.
Deliberately absent: a fallback to the provider's `EVENT_REMINDER` broadcast.
Keeping both would double-post wherever the provider works, and Etar's way out —