diff --git a/CHANGELOG.md b/CHANGELOG.md index 83b3d13..a881f24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- The slide-out panel now has a "View" section to switch between Month, + Week, and Day, mirroring the top-bar switcher pill — tapping a view + selects it and closes the drawer. The current view is highlighted + ### Fixed - Typing in the event title, location, and description fields no longer makes the cursor jump around: the form state's round-trip to the UI was diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/CalendarDrawer.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/CalendarDrawer.kt index e85213a..e0f9a9c 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/CalendarDrawer.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/CalendarDrawer.kt @@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Settings -import androidx.compose.material.icons.filled.Today import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -27,16 +26,19 @@ import de.jeanlucmakiola.calendula.ui.filter.CalendarFilterList * Visual language (kept deliberately small so sizes don't drift): * - Drawer title — `titleLarge` * - Section headers (e.g. "Calendars") — `titleSmall`, primary, text only - * - Nav items (Today / Settings) — Material `NavigationDrawerItem` + * - Nav items (the views, Today / Settings) — Material `NavigationDrawerItem` * (`labelLarge` label + a single 24dp leading icon) * - * Hosts the per-calendar visibility filter (M3) inline — the calendar list with - * its checkboxes lives here rather than in a separate sheet — plus the "today" - * jump and a Settings entry (M4). The host screen owns the drawer state. + * The "View" section mirrors the top-bar switcher pill: tapping a view here + * selects it (and closes the drawer) rather than cycling. Also hosts the + * per-calendar visibility filter (M3) inline — the calendar list with its + * checkboxes lives here rather than in a separate sheet — plus a Settings + * entry (M4). The host screen owns the drawer state. */ @Composable fun CalendarDrawer( - onToday: () -> Unit, + currentView: CalendarView, + onSelectView: (CalendarView) -> Unit, onSettings: () -> Unit, ) { ModalDrawerSheet { @@ -47,14 +49,17 @@ fun CalendarDrawer( modifier = Modifier.padding(horizontal = 28.dp, vertical = 24.dp), ) HorizontalDivider() - Spacer(Modifier.height(8.dp)) - NavigationDrawerItem( - icon = { Icon(Icons.Filled.Today, contentDescription = null) }, - label = { Text(stringResource(R.string.month_today_action)) }, - selected = false, - onClick = onToday, - modifier = Modifier.padding(horizontal = 12.dp), - ) + + DrawerSectionHeader(stringResource(R.string.view_section)) + IMPLEMENTED_VIEWS.forEach { view -> + NavigationDrawerItem( + icon = { Icon(view.icon, contentDescription = null) }, + label = { Text(stringResource(view.labelRes)) }, + selected = view == currentView, + onClick = { onSelectView(view) }, + modifier = Modifier.padding(horizontal = 12.dp), + ) + } Spacer(Modifier.height(8.dp)) HorizontalDivider() diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/CalendarView.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/CalendarView.kt index c0cf9d8..b5766d5 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/CalendarView.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/CalendarView.kt @@ -1,5 +1,13 @@ package de.jeanlucmakiola.calendula.ui.common +import androidx.annotation.StringRes +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.CalendarViewDay +import androidx.compose.material.icons.filled.CalendarViewMonth +import androidx.compose.material.icons.filled.CalendarViewWeek +import androidx.compose.ui.graphics.vector.ImageVector +import de.jeanlucmakiola.calendula.R + /** * The top-level calendar views the user can switch between (spec M1). * Day is declared but not yet implemented (v0.5) — see [IMPLEMENTED_VIEWS]. @@ -10,6 +18,23 @@ enum class CalendarView { Day, } +/** Switcher label, shared by the top-bar pill and the drawer's View section. */ +@get:StringRes +val CalendarView.labelRes: Int + get() = when (this) { + CalendarView.Month -> R.string.view_month + CalendarView.Week -> R.string.view_week + CalendarView.Day -> R.string.view_day + } + +/** Leading icon for the view in the drawer's View section. */ +val CalendarView.icon: ImageVector + get() = when (this) { + CalendarView.Month -> Icons.Filled.CalendarViewMonth + CalendarView.Week -> Icons.Filled.CalendarViewWeek + CalendarView.Day -> Icons.Filled.CalendarViewDay + } + /** * Views that actually have a screen today. The view-switcher pill cycles * through these in order. diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/ViewSwitcherPill.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/ViewSwitcherPill.kt index 5895e3d..18a1f3d 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/ViewSwitcherPill.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/common/ViewSwitcherPill.kt @@ -6,7 +6,6 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource -import de.jeanlucmakiola.calendula.R /** * Top-bar pill that shows the current view and cycles to the next one on tap @@ -18,16 +17,11 @@ fun ViewSwitcherPill( onCycle: () -> Unit, modifier: Modifier = Modifier, ) { - val labelRes = when (current) { - CalendarView.Month -> R.string.view_month - CalendarView.Week -> R.string.view_week - CalendarView.Day -> R.string.view_day - } FilledTonalButton( onClick = onCycle, shape = MaterialTheme.shapes.large, modifier = modifier, ) { - Text(stringResource(labelRes)) + Text(stringResource(current.labelRes)) } } diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/day/DayScreen.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/day/DayScreen.kt index 5f93c40..04f67b0 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/day/DayScreen.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/day/DayScreen.kt @@ -157,7 +157,11 @@ fun DayScreen( gesturesEnabled = drawerState.isOpen, drawerContent = { CalendarDrawer( - onToday = { jumpToToday(); scope.launch { drawerState.close() } }, + currentView = selectedView, + onSelectView = { view -> + onSelectView(view) + scope.launch { drawerState.close() } + }, onSettings = { onOpenSettings() scope.launch { drawerState.close() } diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/month/MonthScreen.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/month/MonthScreen.kt index f6a4da0..432cf08 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/month/MonthScreen.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/month/MonthScreen.kt @@ -130,8 +130,9 @@ fun MonthScreen( gesturesEnabled = drawerState.isOpen, drawerContent = { CalendarDrawer( - onToday = { - jumpToToday() + currentView = selectedView, + onSelectView = { view -> + onSelectView(view) scope.launch { drawerState.close() } }, onSettings = { diff --git a/app/src/main/java/de/jeanlucmakiola/calendula/ui/week/WeekScreen.kt b/app/src/main/java/de/jeanlucmakiola/calendula/ui/week/WeekScreen.kt index cf423c2..32f95c2 100644 --- a/app/src/main/java/de/jeanlucmakiola/calendula/ui/week/WeekScreen.kt +++ b/app/src/main/java/de/jeanlucmakiola/calendula/ui/week/WeekScreen.kt @@ -162,7 +162,11 @@ fun WeekScreen( gesturesEnabled = drawerState.isOpen, drawerContent = { CalendarDrawer( - onToday = { jumpToToday(); scope.launch { drawerState.close() } }, + currentView = selectedView, + onSelectView = { view -> + onSelectView(view) + scope.launch { drawerState.close() } + }, onSettings = { onOpenSettings() scope.launch { drawerState.close() } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 7760b06..01d8422 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -187,6 +187,7 @@ Monat Woche Tag + Ansicht Kalender diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 17b589a..44aff51 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -188,6 +188,7 @@ Month Week Day + View Calendars