diff --git a/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/animation/CalendarAnimator.kt b/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/animation/CalendarAnimator.kt index 5edcb26..2ae814a 100644 --- a/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/animation/CalendarAnimator.kt +++ b/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/animation/CalendarAnimator.kt @@ -39,7 +39,7 @@ class CalendarAnimator(private val startDate: LocalDate) { pageOffsetFraction: Float = 0f, animationSpec: AnimationSpec = spring(stiffness = Spring.StiffnessMediumLow), ) { - val initialPage = pagerState?.initialPage ?: INITIAL_PAGE_INDEX + val initialPage = INITIAL_PAGE_INDEX val currentDate = when (mode) { AnimationMode.MONTH -> diff --git a/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/config/CalendarConstants.kt b/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/config/CalendarConstants.kt index ebe86eb..b971fe8 100644 --- a/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/config/CalendarConstants.kt +++ b/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/config/CalendarConstants.kt @@ -1,5 +1,8 @@ package io.wojciechosak.calendar.config object CalendarConstants { - internal const val INITIAL_PAGE_INDEX = Int.MAX_VALUE / 2 + // Compose 1.6.1 bug: https://issuetracker.google.com/issues/311414925, let's use fixed numbers for now. + // internal const val MAX_PAGES = Int.MAX_VALUE + internal const val MAX_PAGES = 100000 + internal const val INITIAL_PAGE_INDEX = MAX_PAGES / 2 } diff --git a/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/HorizontalCalendarView.kt b/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/HorizontalCalendarView.kt index 6ace79a..86d2362 100644 --- a/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/HorizontalCalendarView.kt +++ b/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/HorizontalCalendarView.kt @@ -1,58 +1,54 @@ package io.wojciechosak.calendar.view import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.gestures.Orientation import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.PageSize -import androidx.compose.foundation.pager.PagerDefaults +import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.ui.Modifier -import androidx.compose.ui.input.nestedscroll.NestedScrollConnection import androidx.compose.ui.unit.dp import io.wojciechosak.calendar.animation.CalendarAnimator import io.wojciechosak.calendar.config.CalendarConstants.INITIAL_PAGE_INDEX +import io.wojciechosak.calendar.config.CalendarConstants.MAX_PAGES import kotlinx.datetime.LocalDate @OptIn(ExperimentalFoundationApi::class) @Composable fun HorizontalCalendarView( startDate: LocalDate, + pagerState: PagerState = + rememberPagerState( + initialPage = INITIAL_PAGE_INDEX, + pageCount = { MAX_PAGES }, + initialPageOffsetFraction = 0f, + ), modifier: Modifier = Modifier, pageSize: PageSize = PageSize.Fill, beyondBoundsPageCount: Int = 0, contentPadding: PaddingValues = PaddingValues(0.dp), - pageNestedScrollConnection: NestedScrollConnection = - PagerDefaults.pageNestedScrollConnection( - Orientation.Horizontal, - ), calendarAnimator: CalendarAnimator = CalendarAnimator(startDate), calendarView: @Composable (monthOffset: Int) -> Unit, ) { - val pagerState = - rememberPagerState( - initialPage = INITIAL_PAGE_INDEX, - pageCount = { Int.MAX_VALUE }, - ) - HorizontalPager( state = pagerState, modifier = modifier, pageSize = pageSize, beyondBoundsPageCount = beyondBoundsPageCount, - pageNestedScrollConnection = pageNestedScrollConnection, contentPadding = contentPadding, ) { - val index = it - INITIAL_PAGE_INDEX - calendarAnimator.updatePagerState(pagerState) - LaunchedEffect(Unit) { - calendarAnimator.setAnimationMode(CalendarAnimator.AnimationMode.MONTH) - } - Column { - calendarView(index) + if (pagerState.currentPage == it) { + val index = it - INITIAL_PAGE_INDEX + calendarAnimator.updatePagerState(pagerState) + LaunchedEffect(Unit) { + calendarAnimator.setAnimationMode(CalendarAnimator.AnimationMode.MONTH) + } + Column { + calendarView(index) + } } } } diff --git a/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/VerticalCalendarView.kt b/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/VerticalCalendarView.kt index d3d4cea..1d8235f 100644 --- a/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/VerticalCalendarView.kt +++ b/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/VerticalCalendarView.kt @@ -12,6 +12,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import io.wojciechosak.calendar.animation.CalendarAnimator import io.wojciechosak.calendar.config.CalendarConstants.INITIAL_PAGE_INDEX +import io.wojciechosak.calendar.config.CalendarConstants.MAX_PAGES import kotlinx.datetime.LocalDate @OptIn(ExperimentalFoundationApi::class) @@ -27,7 +28,7 @@ fun VerticalCalendarView( val pagerState = rememberPagerState( initialPage = INITIAL_PAGE_INDEX, - pageCount = { Int.MAX_VALUE }, + pageCount = { MAX_PAGES }, ) LaunchedEffect(pagerState) { calendarAnimator.setAnimationMode(CalendarAnimator.AnimationMode.MONTH) diff --git a/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/WeekView.kt b/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/WeekView.kt index 1eb861c..b1cac58 100644 --- a/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/WeekView.kt +++ b/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/WeekView.kt @@ -16,6 +16,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import io.wojciechosak.calendar.animation.CalendarAnimator import io.wojciechosak.calendar.config.CalendarConstants.INITIAL_PAGE_INDEX +import io.wojciechosak.calendar.config.CalendarConstants.MAX_PAGES import io.wojciechosak.calendar.config.DayState import io.wojciechosak.calendar.utils.copy import io.wojciechosak.calendar.utils.daySimpleName @@ -61,7 +62,7 @@ fun WeekView( }, ) { val minIndex = if (showDaysBesideRange) 0 else minDate.daysUntil(startDate) - val maxIndex = if (showDaysBesideRange) Int.MAX_VALUE else startDate.daysUntil(maxDate) + val maxIndex = if (showDaysBesideRange) MAX_PAGES else startDate.daysUntil(maxDate) val initialPageIndex = if (showDaysBesideRange) INITIAL_PAGE_INDEX else minIndex + daysOffset LaunchedEffect(Unit) { calendarAnimator.setAnimationMode(CalendarAnimator.AnimationMode.WEEK) diff --git a/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/YearPicker.kt b/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/YearPicker.kt index a647252..d32fbcb 100644 --- a/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/YearPicker.kt +++ b/calendar/src/commonMain/kotlin/io/wojciechosak/calendar/view/YearPicker.kt @@ -16,6 +16,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import io.wojciechosak.calendar.config.CalendarConstants +import io.wojciechosak.calendar.config.CalendarConstants.MAX_PAGES import io.wojciechosak.calendar.modifiers.passTouchGesture import io.wojciechosak.calendar.utils.today import kotlinx.datetime.LocalDate @@ -38,7 +39,7 @@ fun YearPicker( val pagerState = rememberPagerState( initialPage = CalendarConstants.INITIAL_PAGE_INDEX, - pageCount = { Int.MAX_VALUE }, + pageCount = { MAX_PAGES }, ) when (mode) { YearPickerMode.VERTICAL -> { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d4f1bab..0a6c9c2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,12 +1,12 @@ [versions] kotlin = "1.9.21" -compose = "1.5.11" -agp = "8.2.0" +compose = "1.6.1" +agp = "8.2.2" androidx-appcompat = "1.6.1" -androidx-activityCompose = "1.8.1" -compose-uitooling = "1.5.4" -kotlinx-coroutines = "1.7.3" +androidx-activityCompose = "1.8.2" +compose-uitooling = "1.6.4" +kotlinx-coroutines = "1.8.0" composeIcons = "1.1.0" kotlinx-datetime = "0.5.0" voyager = "1.0.0" diff --git a/readme/info.png b/readme/info.png index 3ec971a..3e6732a 100644 Binary files a/readme/info.png and b/readme/info.png differ diff --git a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/App.kt b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/App.kt index 6ca8960..fda5464 100644 --- a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/App.kt +++ b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/App.kt @@ -1,14 +1,68 @@ package io.wojciechosak.calendar.calendar import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.safeContentPadding +import androidx.compose.foundation.layout.padding +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.automirrored.filled.ArrowBackIos +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.SmallTopAppBar +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.sp +import cafe.adriel.voyager.navigator.CurrentScreen +import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.Navigator +import io.wojciechosak.calendar.calendar.screens.NamedScreen +@OptIn(ExperimentalMaterial3Api::class) @Composable internal fun App() { - Box(modifier = Modifier.safeContentPadding()) { - Navigator(MenuScreen()) + Box { + Navigator(MenuScreen()) { + Scaffold( + topBar = { + val navigator = LocalNavigator.current + SmallTopAppBar( + colors = + TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.primary, + titleContentColor = Color.White, + ), + title = { + if (navigator?.canPop == true) { + Text((navigator.lastItem as? NamedScreen)?.name ?: "", fontSize = 14.sp) + } else { + Text("KMP Calendar Demo", fontSize = 14.sp) + } + }, + navigationIcon = { + if (navigator?.canPop == true) { + IconButton( + onClick = { navigator.pop() }, + ) { + Icon( + imageVector = Icons.AutoMirrored.Filled.ArrowBackIos, + contentDescription = "Back", + tint = Color.White, + ) + } + } + }, + ) + }, + content = { padding -> + Box(Modifier.padding(padding)) { + CurrentScreen() + } + }, + ) + } } } diff --git a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/MenuScreen.kt b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/MenuScreen.kt index 343f8e6..1000771 100644 --- a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/MenuScreen.kt +++ b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/MenuScreen.kt @@ -34,7 +34,7 @@ class MenuScreen : Screen { item { ScreenButton(AnimationScreen(), "Animations") } item { ScreenButton(RangeSelectionScreen(), "Range selection") } item { ScreenButton(FullDateScreen(), "Full date selector (day/month/year)") } - item { Text("Lib version: 0.0.5") } + item { Text("Lib version: 0.0.8") } } } diff --git a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/AnimationScreen.kt b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/AnimationScreen.kt index 9552915..db2079a 100644 --- a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/AnimationScreen.kt +++ b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/AnimationScreen.kt @@ -14,7 +14,6 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import cafe.adriel.voyager.core.screen.Screen import io.wojciechosak.calendar.animation.CalendarAnimator import io.wojciechosak.calendar.config.rememberCalendarState import io.wojciechosak.calendar.utils.daySimpleName @@ -27,7 +26,10 @@ import kotlinx.coroutines.launch import kotlinx.datetime.LocalDate import kotlinx.datetime.Month -class AnimationScreen : Screen { +class AnimationScreen : NamedScreen { + override val name: String + get() = "Animations" + @OptIn(ExperimentalFoundationApi::class) @Composable override fun Content() { diff --git a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/CalendarViewScreen.kt b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/CalendarViewScreen.kt index 0037d98..21fe1d2 100644 --- a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/CalendarViewScreen.kt +++ b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/CalendarViewScreen.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.aspectRatio import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.safeGesturesPadding import androidx.compose.foundation.layout.size import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.OutlinedButton @@ -17,7 +18,6 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import cafe.adriel.voyager.core.screen.Screen import io.wojciechosak.calendar.config.MonthYear import io.wojciechosak.calendar.config.rememberCalendarState import io.wojciechosak.calendar.config.toLocalDate @@ -26,27 +26,32 @@ import kotlinx.datetime.LocalDate import kotlinx.datetime.Month import kotlin.random.Random -class CalendarViewScreen : Screen { +class CalendarViewScreen : NamedScreen { + override val name: String + get() = "CalendarView" + @Composable override fun Content() { - CalendarView( - day = { state -> - DayView( - date = state.date, - isDotVisible = state.isActiveDay || Random.nextBoolean(), - onClick = { }, - ) - }, - config = - rememberCalendarState( - startDate = MonthYear(year = 1994, month = Month.APRIL).toLocalDate(), - monthOffset = 0, - showNextMonthDays = false, - showPreviousMonthDays = false, - showHeader = false, - showWeekdays = false, - ), - ) + Box(Modifier.safeGesturesPadding()) { + CalendarView( + day = { state -> + DayView( + date = state.date, + isDotVisible = state.isActiveDay || Random.nextBoolean(), + onClick = { }, + ) + }, + config = + rememberCalendarState( + startDate = MonthYear(year = 1994, month = Month.APRIL).toLocalDate(), + monthOffset = 0, + showNextMonthDays = false, + showPreviousMonthDays = false, + showHeader = false, + showWeekdays = false, + ), + ) + } } } diff --git a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/DateRangeScreen.kt b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/DateRangeScreen.kt index a8a8238..8e47782 100644 --- a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/DateRangeScreen.kt +++ b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/DateRangeScreen.kt @@ -1,9 +1,11 @@ package io.wojciechosak.calendar.calendar.screens import androidx.compose.runtime.Composable -import cafe.adriel.voyager.core.screen.Screen -class DateRangeScreen : Screen { +class DateRangeScreen : NamedScreen { + override val name: String + get() = "Date range" + @Composable override fun Content() { TODO("Not yet implemented") diff --git a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/FullDateScreen.kt b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/FullDateScreen.kt index 699ee30..0ffa8d5 100644 --- a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/FullDateScreen.kt +++ b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/FullDateScreen.kt @@ -13,7 +13,6 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign -import cafe.adriel.voyager.core.screen.Screen import io.wojciechosak.calendar.config.SelectionMode import io.wojciechosak.calendar.config.rememberCalendarState import io.wojciechosak.calendar.utils.copy @@ -25,7 +24,10 @@ import io.wojciechosak.calendar.view.MonthPicker import io.wojciechosak.calendar.view.YearPicker import kotlinx.datetime.LocalDate -class FullDateScreen : Screen { +class FullDateScreen : NamedScreen { + override val name: String + get() = "Full date selector" + @OptIn(ExperimentalFoundationApi::class) @Composable override fun Content() { diff --git a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/HorizontalCalendarScreen.kt b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/HorizontalCalendarScreen.kt index 8ae5134..6b303fe 100644 --- a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/HorizontalCalendarScreen.kt +++ b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/HorizontalCalendarScreen.kt @@ -15,7 +15,6 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp -import cafe.adriel.voyager.core.screen.Screen import io.wojciechosak.calendar.config.rememberCalendarState import io.wojciechosak.calendar.utils.today import io.wojciechosak.calendar.view.CalendarDay @@ -23,7 +22,10 @@ import io.wojciechosak.calendar.view.CalendarView import io.wojciechosak.calendar.view.HorizontalCalendarView import kotlinx.datetime.LocalDate -class HorizontalCalendarScreen : Screen { +class HorizontalCalendarScreen : NamedScreen { + override val name: String + get() = "Horizontal calendar" + @OptIn(ExperimentalFoundationApi::class) @Composable override fun Content() { diff --git a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/MultipleSelectionScreen.kt b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/MultipleSelectionScreen.kt index ecc8248..d9a0708 100644 --- a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/MultipleSelectionScreen.kt +++ b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/MultipleSelectionScreen.kt @@ -10,7 +10,6 @@ import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import cafe.adriel.voyager.core.screen.Screen import io.wojciechosak.calendar.config.SelectionMode import io.wojciechosak.calendar.config.rememberCalendarState import io.wojciechosak.calendar.utils.today @@ -18,7 +17,10 @@ import io.wojciechosak.calendar.view.CalendarView import io.wojciechosak.calendar.view.HorizontalCalendarView import kotlinx.datetime.LocalDate -class MultipleSelectionScreen : Screen { +class MultipleSelectionScreen : NamedScreen { + override val name: String + get() = "Multiple dates selector" + @OptIn(ExperimentalFoundationApi::class) @Composable override fun Content() { diff --git a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/NamedScreen.kt b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/NamedScreen.kt new file mode 100644 index 0000000..d0cd054 --- /dev/null +++ b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/NamedScreen.kt @@ -0,0 +1,7 @@ +package io.wojciechosak.calendar.calendar.screens + +import cafe.adriel.voyager.core.screen.Screen + +interface NamedScreen : Screen { + val name: String +} diff --git a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/RangeSelectionScreen.kt b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/RangeSelectionScreen.kt index 627d080..7340e78 100644 --- a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/RangeSelectionScreen.kt +++ b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/RangeSelectionScreen.kt @@ -9,19 +9,21 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp -import cafe.adriel.voyager.core.screen.Screen import io.wojciechosak.calendar.config.SelectionMode import io.wojciechosak.calendar.config.rememberCalendarState import io.wojciechosak.calendar.range.RangeConfig -import io.wojciechosak.calendar.range.UnderlineIllustrator +import io.wojciechosak.calendar.range.RoundedRangeIllustrator +import io.wojciechosak.calendar.utils.Pallete import io.wojciechosak.calendar.utils.today import io.wojciechosak.calendar.view.CalendarView import io.wojciechosak.calendar.view.HorizontalCalendarView import kotlinx.datetime.LocalDate -class RangeSelectionScreen : Screen { +class RangeSelectionScreen : NamedScreen { + override val name: String + get() = "Range selection" + @OptIn(ExperimentalFoundationApi::class) @Composable override fun Content() { @@ -44,7 +46,7 @@ class RangeSelectionScreen : Screen { }, rangeConfig = RangeConfig( - rangeIllustrator = UnderlineIllustrator(Color.Green), + rangeIllustrator = RoundedRangeIllustrator(Pallete.LightGreen), ), ) } diff --git a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/SingleSelectionScreen.kt b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/SingleSelectionScreen.kt index 831dd23..ddeb3fd 100644 --- a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/SingleSelectionScreen.kt +++ b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/SingleSelectionScreen.kt @@ -12,7 +12,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import cafe.adriel.voyager.core.screen.Screen import io.wojciechosak.calendar.config.rememberCalendarState import io.wojciechosak.calendar.utils.today import io.wojciechosak.calendar.view.CalendarDay @@ -20,7 +19,10 @@ import io.wojciechosak.calendar.view.CalendarView import io.wojciechosak.calendar.view.HorizontalCalendarView import kotlinx.datetime.LocalDate -class SingleSelectionScreen : Screen { +class SingleSelectionScreen : NamedScreen { + override val name: String + get() = "Single date selection" + @OptIn(ExperimentalFoundationApi::class) @Composable override fun Content() { diff --git a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/VerticalCalendarScreen.kt b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/VerticalCalendarScreen.kt index 816c2f7..507bf75 100644 --- a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/VerticalCalendarScreen.kt +++ b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/VerticalCalendarScreen.kt @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.pager.PageSize import androidx.compose.runtime.Composable import androidx.compose.ui.unit.dp -import cafe.adriel.voyager.core.screen.Screen import io.wojciechosak.calendar.config.rememberCalendarState import io.wojciechosak.calendar.utils.today import io.wojciechosak.calendar.view.CalendarDay @@ -13,7 +12,10 @@ import io.wojciechosak.calendar.view.CalendarView import io.wojciechosak.calendar.view.VerticalCalendarView import kotlinx.datetime.LocalDate -class VerticalCalendarScreen : Screen { +class VerticalCalendarScreen : NamedScreen { + override val name: String + get() = "Vertical calendar" + @OptIn(ExperimentalFoundationApi::class) @Composable override fun Content() { diff --git a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/WeekViewScreen.kt b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/WeekViewScreen.kt index e61728b..7d43011 100644 --- a/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/WeekViewScreen.kt +++ b/sample/composeApp/src/commonMain/kotlin/io/wojciechosak/calendar/calendar/screens/WeekViewScreen.kt @@ -1,8 +1,5 @@ -@file:OptIn(ExperimentalFoundationApi::class) - package io.wojciechosak.calendar.calendar.screens -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth @@ -18,7 +15,6 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp -import cafe.adriel.voyager.core.screen.Screen import io.wojciechosak.calendar.utils.today import io.wojciechosak.calendar.view.CalendarDay import io.wojciechosak.calendar.view.WeekView @@ -27,7 +23,10 @@ import kotlinx.datetime.LocalDate import kotlinx.datetime.minus import kotlinx.datetime.plus -class WeekViewScreen : Screen { +class WeekViewScreen : NamedScreen { + override val name: String + get() = "Week calendar" + @Composable override fun Content() { Column(modifier = Modifier.padding(10.dp)) {