From f3634a6c1dfb7b17408d79a8725c711c07da6669 Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 17 Jul 2024 20:05:42 +0800 Subject: [PATCH] Enable Explicit API mode https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md --- build.gradle.kts | 12 ++++ .../kizitonwose/calendar/compose/Calendar.kt | 16 ++--- .../calendar/compose/CalendarLayoutInfo.kt | 6 +- .../calendar/compose/CalendarState.kt | 28 ++++---- .../calendar/compose/ContentHeightMode.kt | 2 +- .../heatmapcalendar/HeatMapCalendarState.kt | 26 +++---- .../compose/heatmapcalendar/HeatMapWeek.kt | 2 +- .../HeatMapWeekHeaderPosition.kt | 2 +- .../weekcalendar/WeekCalendarLayoutInfo.kt | 6 +- .../compose/weekcalendar/WeekCalendarState.kt | 28 ++++---- .../kizitonwose/calendar/core/CalendarDay.kt | 2 +- .../calendar/core/CalendarMonth.kt | 2 +- .../kizitonwose/calendar/core/DayPosition.kt | 2 +- .../kizitonwose/calendar/core/Extensions.kt | 24 +++---- .../calendar/core/JvmSerializable.kt | 2 +- .../kizitonwose/calendar/core/OutDateStyle.kt | 2 +- .../com/kizitonwose/calendar/core/Week.kt | 2 +- .../com/kizitonwose/calendar/core/WeekDay.kt | 2 +- .../calendar/core/WeekDayPosition.kt | 2 +- .../kizitonwose/calendar/core/YearMonth.kt | 6 +- .../com/kizitonwose/calendar/data/WeekData.kt | 14 ++-- .../calendar/core/Extensions.ios.kt | 2 +- .../kizitonwose/calendar/core/Converters.kt | 4 +- .../calendar/core/Extensions.jvm.kt | 2 +- .../calendar/core/JvmSerializable.jvm.kt | 2 +- .../calendar/core/JvmSerializable.nonJvm.kt | 2 +- .../calendar/core/Extensions.wasmJs.kt | 2 +- .../kizitonwose/calendar/compose/Calendar.kt | 16 ++--- .../calendar/compose/CalendarLayoutInfo.kt | 6 +- .../calendar/compose/CalendarState.kt | 28 ++++---- .../calendar/compose/ContentHeightMode.kt | 2 +- .../heatmapcalendar/HeatMapCalendarState.kt | 26 +++---- .../compose/heatmapcalendar/HeatMapWeek.kt | 2 +- .../HeatMapWeekHeaderPosition.kt | 2 +- .../weekcalendar/WeekCalendarLayoutInfo.kt | 6 +- .../compose/weekcalendar/WeekCalendarState.kt | 28 ++++---- .../kizitonwose/calendar/core/CalendarDay.kt | 2 +- .../calendar/core/CalendarMonth.kt | 2 +- .../kizitonwose/calendar/core/DayPosition.kt | 2 +- .../kizitonwose/calendar/core/Extensions.kt | 12 ++-- .../kizitonwose/calendar/core/OutDateStyle.kt | 2 +- .../com/kizitonwose/calendar/core/Week.kt | 2 +- .../com/kizitonwose/calendar/core/WeekDay.kt | 2 +- .../calendar/core/WeekDayPosition.kt | 2 +- .../kizitonwose/calendar/data/DataStore.kt | 2 +- .../kizitonwose/calendar/data/Extensions.kt | 2 +- .../kizitonwose/calendar/data/MonthData.kt | 12 ++-- .../com/kizitonwose/calendar/data/Utils.kt | 4 +- .../com/kizitonwose/calendar/data/WeekData.kt | 14 ++-- .../com/kizitonwose/calendar/view/Binder.kt | 20 +++--- .../kizitonwose/calendar/view/CalendarView.kt | 68 +++++++++---------- .../com/kizitonwose/calendar/view/DaySize.kt | 2 +- .../kizitonwose/calendar/view/MarginValues.kt | 2 +- .../calendar/view/WeekCalendarView.kt | 68 +++++++++---------- 54 files changed, 275 insertions(+), 263 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 16e41af9..5d2d763e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,7 @@ +import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension +import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin +import org.jetbrains.kotlin.gradle.targets.js.KotlinJsPlugin + plugins { alias(libs.plugins.androidApplication) apply false alias(libs.plugins.androidLibrary) apply false @@ -14,6 +18,14 @@ plugins { allprojects { apply(plugin = rootProject.libs.plugins.kotlinter.get().pluginId) + + plugins.withType().configureEach { + extensions.configure { + if ("sample" !in project.name) { + explicitApi() + } + } + } } apiValidation { diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/Calendar.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/Calendar.kt index 0c5ad92f..981d03e9 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/Calendar.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/Calendar.kt @@ -58,7 +58,7 @@ import kotlinx.datetime.DayOfWeek * customisations are rendered. */ @Composable -fun HorizontalCalendar( +public fun HorizontalCalendar( modifier: Modifier = Modifier, state: CalendarState = rememberCalendarState(), calendarScrollPaged: Boolean = true, @@ -71,7 +71,7 @@ fun HorizontalCalendar( monthBody: (@Composable ColumnScope.(CalendarMonth, content: @Composable () -> Unit) -> Unit)? = null, monthFooter: (@Composable ColumnScope.(CalendarMonth) -> Unit)? = null, monthContainer: (@Composable LazyItemScope.(CalendarMonth, container: @Composable () -> Unit) -> Unit)? = null, -) = Calendar( +): Unit = Calendar( modifier = modifier, state = state, calendarScrollPaged = calendarScrollPaged, @@ -121,7 +121,7 @@ fun HorizontalCalendar( * customisations are rendered. */ @Composable -fun VerticalCalendar( +public fun VerticalCalendar( modifier: Modifier = Modifier, state: CalendarState = rememberCalendarState(), calendarScrollPaged: Boolean = false, @@ -134,7 +134,7 @@ fun VerticalCalendar( monthBody: (@Composable ColumnScope.(CalendarMonth, content: @Composable () -> Unit) -> Unit)? = null, monthFooter: (@Composable ColumnScope.(CalendarMonth) -> Unit)? = null, monthContainer: (@Composable LazyItemScope.(CalendarMonth, container: @Composable () -> Unit) -> Unit)? = null, -) = Calendar( +): Unit = Calendar( modifier = modifier, state = state, calendarScrollPaged = calendarScrollPaged, @@ -232,7 +232,7 @@ private fun Calendar( * placed below each week on the calendar. */ @Composable -fun WeekCalendar( +public fun WeekCalendar( modifier: Modifier = Modifier, state: WeekCalendarState = rememberWeekCalendarState(), calendarScrollPaged: Boolean = true, @@ -242,7 +242,7 @@ fun WeekCalendar( dayContent: @Composable BoxScope.(WeekDay) -> Unit, weekHeader: (@Composable ColumnScope.(Week) -> Unit)? = null, weekFooter: (@Composable ColumnScope.(Week) -> Unit)? = null, -) = WeekCalendarImpl( +): Unit = WeekCalendarImpl( modifier = modifier, state = state, calendarScrollPaged = calendarScrollPaged, @@ -274,7 +274,7 @@ fun WeekCalendar( * placed above each month on the calendar. */ @Composable -fun HeatMapCalendar( +public fun HeatMapCalendar( modifier: Modifier = Modifier, state: HeatMapCalendarState = rememberHeatMapCalendarState(), weekHeaderPosition: HeatMapWeekHeaderPosition = HeatMapWeekHeaderPosition.Start, @@ -283,7 +283,7 @@ fun HeatMapCalendar( dayContent: @Composable ColumnScope.(day: CalendarDay, week: HeatMapWeek) -> Unit, weekHeader: (@Composable ColumnScope.(DayOfWeek) -> Unit)? = null, monthHeader: (@Composable ColumnScope.(CalendarMonth) -> Unit)? = null, -) = HeatMapCalendarImpl( +): Unit = HeatMapCalendarImpl( modifier = modifier, state = state, weekHeaderPosition = weekHeaderPosition, diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/CalendarLayoutInfo.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/CalendarLayoutInfo.kt index d78948da..6fce652c 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/CalendarLayoutInfo.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/CalendarLayoutInfo.kt @@ -11,12 +11,12 @@ import com.kizitonwose.calendar.core.CalendarMonth * Use [CalendarState.layoutInfo] to retrieve this. * @see LazyListLayoutInfo */ -class CalendarLayoutInfo(info: LazyListLayoutInfo, private val month: (Int) -> CalendarMonth) : +public class CalendarLayoutInfo(info: LazyListLayoutInfo, private val month: (Int) -> CalendarMonth) : LazyListLayoutInfo by info { /** * The list of [CalendarItemInfo] representing all the currently visible months. */ - val visibleMonthsInfo: List + public val visibleMonthsInfo: List get() = visibleItemsInfo.map { CalendarItemInfo(it, month(it.index)) } @@ -30,4 +30,4 @@ class CalendarLayoutInfo(info: LazyListLayoutInfo, private val month: (Int) -> C * @see CalendarLayoutInfo * @see LazyListItemInfo */ -class CalendarItemInfo(info: LazyListItemInfo, val month: CalendarMonth) : LazyListItemInfo by info +public class CalendarItemInfo(info: LazyListItemInfo, public val month: CalendarMonth) : LazyListItemInfo by info diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/CalendarState.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/CalendarState.kt index 323930a4..3ae6bd8a 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/CalendarState.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/CalendarState.kt @@ -37,7 +37,7 @@ import kotlinx.datetime.DayOfWeek * @param outDateStyle the initial value for [CalendarState.outDateStyle] */ @Composable -fun rememberCalendarState( +public fun rememberCalendarState( startMonth: YearMonth = YearMonth.now(), endMonth: YearMonth = startMonth, firstVisibleMonth: YearMonth = startMonth, @@ -77,7 +77,7 @@ fun rememberCalendarState( * @param outDateStyle the preferred style for out date generation. */ @Stable -class CalendarState internal constructor( +public class CalendarState internal constructor( startMonth: YearMonth, endMonth: YearMonth, firstDayOfWeek: DayOfWeek, @@ -89,7 +89,7 @@ class CalendarState internal constructor( private var _startMonth by mutableStateOf(startMonth) /** The first month on the calendar. */ - var startMonth: YearMonth + public var startMonth: YearMonth get() = _startMonth set(value) { if (value != startMonth) { @@ -102,7 +102,7 @@ class CalendarState internal constructor( private var _endMonth by mutableStateOf(endMonth) /** The last month on the calendar. */ - var endMonth: YearMonth + public var endMonth: YearMonth get() = _endMonth set(value) { if (value != endMonth) { @@ -115,7 +115,7 @@ class CalendarState internal constructor( private var _firstDayOfWeek by mutableStateOf(firstDayOfWeek) /** The first day of week on the calendar. */ - var firstDayOfWeek: DayOfWeek + public var firstDayOfWeek: DayOfWeek get() = _firstDayOfWeek set(value) { if (value != firstDayOfWeek) { @@ -128,7 +128,7 @@ class CalendarState internal constructor( private var _outDateStyle by mutableStateOf(outDateStyle) /** The preferred style for out date generation. */ - var outDateStyle: OutDateStyle + public var outDateStyle: OutDateStyle get() = _outDateStyle set(value) { if (value != outDateStyle) { @@ -142,7 +142,7 @@ class CalendarState internal constructor( * * @see [lastVisibleMonth] */ - val firstVisibleMonth: com.kizitonwose.calendar.core.CalendarMonth by derivedStateOf { + public val firstVisibleMonth: com.kizitonwose.calendar.core.CalendarMonth by derivedStateOf { store[listState.firstVisibleItemIndex] } @@ -151,7 +151,7 @@ class CalendarState internal constructor( * * @see [firstVisibleMonth] */ - val lastVisibleMonth: com.kizitonwose.calendar.core.CalendarMonth by derivedStateOf { + public val lastVisibleMonth: com.kizitonwose.calendar.core.CalendarMonth by derivedStateOf { store[listState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0] } @@ -173,7 +173,7 @@ class CalendarState internal constructor( * * see [LazyListLayoutInfo] */ - val layoutInfo: CalendarLayoutInfo + public val layoutInfo: CalendarLayoutInfo get() = CalendarLayoutInfo(listState.layoutInfo) { index -> store[index] } /** @@ -181,7 +181,7 @@ class CalendarState internal constructor( * calendar is being dragged. If you want to know whether the fling (or animated scroll) is in * progress, use [isScrollInProgress]. */ - val interactionSource: InteractionSource + public val interactionSource: InteractionSource get() = listState.interactionSource internal val listState = LazyListState( @@ -228,7 +228,7 @@ class CalendarState internal constructor( * * @see [animateScrollToMonth] */ - suspend fun scrollToMonth(month: YearMonth) { + public suspend fun scrollToMonth(month: YearMonth) { listState.scrollToItem(getScrollIndex(month) ?: return) } @@ -238,7 +238,7 @@ class CalendarState internal constructor( * @param month the month to which to scroll. Must be within the * range of [startMonth] and [endMonth]. */ - suspend fun animateScrollToMonth(month: YearMonth) { + public suspend fun animateScrollToMonth(month: YearMonth) { listState.animateScrollToItem(getScrollIndex(month) ?: return) } @@ -261,9 +261,9 @@ class CalendarState internal constructor( override suspend fun scroll( scrollPriority: MutatePriority, block: suspend ScrollScope.() -> Unit, - ) = listState.scroll(scrollPriority, block) + ): Unit = listState.scroll(scrollPriority, block) - companion object { + public companion object { internal val Saver: Saver = listSaver( save = { listOf( diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/ContentHeightMode.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/ContentHeightMode.kt index 370751fe..d7611f71 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/ContentHeightMode.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/ContentHeightMode.kt @@ -8,7 +8,7 @@ import androidx.compose.ui.Modifier /** * Determines how the height of the day content is calculated. */ -enum class ContentHeightMode { +public enum class ContentHeightMode { /** * The day container will wrap its height. This allows you to * use [Modifier.aspectRatio] if you want square day content diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapCalendarState.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapCalendarState.kt index 774a13c3..bbf0fc97 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapCalendarState.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapCalendarState.kt @@ -37,7 +37,7 @@ import kotlinx.datetime.DayOfWeek * @param firstVisibleMonth the initial value for [HeatMapCalendarState.firstVisibleMonth] */ @Composable -fun rememberHeatMapCalendarState( +public fun rememberHeatMapCalendarState( startMonth: YearMonth = YearMonth.now(), endMonth: YearMonth = startMonth, firstVisibleMonth: YearMonth = startMonth, @@ -73,7 +73,7 @@ fun rememberHeatMapCalendarState( * @param firstVisibleMonth the initial value for [HeatMapCalendarState.firstVisibleMonth] */ @Stable -class HeatMapCalendarState internal constructor( +public class HeatMapCalendarState internal constructor( startMonth: YearMonth, endMonth: YearMonth, firstVisibleMonth: YearMonth, @@ -84,7 +84,7 @@ class HeatMapCalendarState internal constructor( private var _startMonth by mutableStateOf(startMonth) /** The first month on the calendar. */ - var startMonth: YearMonth + public var startMonth: YearMonth get() = _startMonth set(value) { if (value != startMonth) { @@ -97,7 +97,7 @@ class HeatMapCalendarState internal constructor( private var _endMonth by mutableStateOf(endMonth) /** The last month on the calendar. */ - var endMonth: YearMonth + public var endMonth: YearMonth get() = _endMonth set(value) { if (value != endMonth) { @@ -110,7 +110,7 @@ class HeatMapCalendarState internal constructor( private var _firstDayOfWeek by mutableStateOf(firstDayOfWeek) /** The first day of week on the calendar. */ - var firstDayOfWeek: DayOfWeek + public var firstDayOfWeek: DayOfWeek get() = _firstDayOfWeek set(value) { if (value != firstDayOfWeek) { @@ -124,7 +124,7 @@ class HeatMapCalendarState internal constructor( * * @see [lastVisibleMonth] */ - val firstVisibleMonth: CalendarMonth by derivedStateOf { + public val firstVisibleMonth: CalendarMonth by derivedStateOf { store[listState.firstVisibleItemIndex] } @@ -133,7 +133,7 @@ class HeatMapCalendarState internal constructor( * * @see [firstVisibleMonth] */ - val lastVisibleMonth: CalendarMonth by derivedStateOf { + public val lastVisibleMonth: CalendarMonth by derivedStateOf { store[listState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0] } @@ -153,7 +153,7 @@ class HeatMapCalendarState internal constructor( * If you want to run some side effects like sending an analytics event or updating a state * based on this value consider using "snapshotFlow". */ - val layoutInfo: CalendarLayoutInfo + public val layoutInfo: CalendarLayoutInfo get() = CalendarLayoutInfo(listState.layoutInfo) { index -> store[index] } /** @@ -161,7 +161,7 @@ class HeatMapCalendarState internal constructor( * calendar is being dragged. If you want to know whether the fling (or animated scroll) is in * progress, use [isScrollInProgress]. */ - val interactionSource: InteractionSource + public val interactionSource: InteractionSource get() = listState.interactionSource internal val listState = LazyListState( @@ -201,7 +201,7 @@ class HeatMapCalendarState internal constructor( * * @see [animateScrollToMonth] */ - suspend fun scrollToMonth(month: YearMonth) { + public suspend fun scrollToMonth(month: YearMonth) { listState.scrollToItem(getScrollIndex(month) ?: return) } @@ -211,7 +211,7 @@ class HeatMapCalendarState internal constructor( * @param month the month to which to scroll. Must be within the * range of [startMonth] and [endMonth]. */ - suspend fun animateScrollToMonth(month: YearMonth) { + public suspend fun animateScrollToMonth(month: YearMonth) { listState.animateScrollToItem(getScrollIndex(month) ?: return) } @@ -234,9 +234,9 @@ class HeatMapCalendarState internal constructor( override suspend fun scroll( scrollPriority: MutatePriority, block: suspend ScrollScope.() -> Unit, - ) = listState.scroll(scrollPriority, block) + ): Unit = listState.scroll(scrollPriority, block) - companion object { + public companion object { internal val Saver: Saver = listSaver( save = { listOf( diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeek.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeek.kt index 99e88ff4..b0ebf682 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeek.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeek.kt @@ -15,4 +15,4 @@ import com.kizitonwose.calendar.core.CalendarDay * @param days the days in this week. */ @Immutable -data class HeatMapWeek(val days: List) +public data class HeatMapWeek(val days: List) diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeekHeaderPosition.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeekHeaderPosition.kt index ef077405..41cebfe0 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeekHeaderPosition.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeekHeaderPosition.kt @@ -6,7 +6,7 @@ import com.kizitonwose.calendar.compose.HeatMapCalendar * Determines the position of the week header * composable (Mon, Tue, Wed...) in the [HeatMapCalendar] */ -enum class HeatMapWeekHeaderPosition { +public enum class HeatMapWeekHeaderPosition { /** * The header is positioned at the start of the calendar. */ diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarLayoutInfo.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarLayoutInfo.kt index b8c7fbac..302e051f 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarLayoutInfo.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarLayoutInfo.kt @@ -12,14 +12,14 @@ import com.kizitonwose.calendar.core.Week * * @see LazyListLayoutInfo */ -class WeekCalendarLayoutInfo( +public class WeekCalendarLayoutInfo( info: LazyListLayoutInfo, private val getIndexData: (Int) -> Week, ) : LazyListLayoutInfo by info { /** * The list of [WeekCalendarItemInfo] representing all the currently visible weeks. */ - val visibleWeeksInfo: List + public val visibleWeeksInfo: List get() = visibleItemsInfo.map { info -> WeekCalendarItemInfo(info, getIndexData(info.index)) } @@ -33,5 +33,5 @@ class WeekCalendarLayoutInfo( * @see WeekCalendarLayoutInfo * @see LazyListItemInfo */ -class WeekCalendarItemInfo(info: LazyListItemInfo, val week: Week) : +public class WeekCalendarItemInfo(info: LazyListItemInfo, public val week: Week) : LazyListItemInfo by info diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarState.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarState.kt index 1982a956..4c2b7c09 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarState.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarState.kt @@ -43,7 +43,7 @@ import kotlinx.datetime.LocalDate * @param firstVisibleWeekDate the date which will have its week visible initially. */ @Composable -fun rememberWeekCalendarState( +public fun rememberWeekCalendarState( startDate: LocalDate = YearMonth.now().atStartOfMonth(), endDate: LocalDate = YearMonth.now().atEndOfMonth(), firstVisibleWeekDate: LocalDate = LocalDate.now(), @@ -83,7 +83,7 @@ fun rememberWeekCalendarState( * @param firstVisibleWeekDate the date which will have its week visible initially. */ @Stable -class WeekCalendarState internal constructor( +public class WeekCalendarState internal constructor( startDate: LocalDate, endDate: LocalDate, firstVisibleWeekDate: LocalDate, @@ -110,7 +110,7 @@ class WeekCalendarState internal constructor( * in the week to which this date belongs, depending on the provided [firstDayOfWeek]. * Such days will have their [WeekDayPosition] set to [WeekDayPosition.InDate] */ - var startDate: LocalDate + public var startDate: LocalDate get() = _startDate set(value) { if (value != _startDate) { @@ -127,7 +127,7 @@ class WeekCalendarState internal constructor( * in the week to which this date belongs. Such days will have their [WeekDayPosition] * set to [WeekDayPosition.OutDate] */ - var endDate: LocalDate + public var endDate: LocalDate get() = _endDate set(value) { if (value != _endDate) { @@ -140,7 +140,7 @@ class WeekCalendarState internal constructor( private var _firstDayOfWeek by mutableStateOf(firstDayOfWeek) /** The first day of week on the calendar. */ - var firstDayOfWeek: DayOfWeek + public var firstDayOfWeek: DayOfWeek get() = _firstDayOfWeek set(value) { if (value != _firstDayOfWeek) { @@ -152,14 +152,14 @@ class WeekCalendarState internal constructor( /** * The first week that is visible. */ - val firstVisibleWeek: Week by derivedStateOf { + public val firstVisibleWeek: Week by derivedStateOf { store[listState.firstVisibleItemIndex] } /** * The last week that is visible. */ - val lastVisibleWeek: Week by derivedStateOf { + public val lastVisibleWeek: Week by derivedStateOf { store[listState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0] } @@ -179,7 +179,7 @@ class WeekCalendarState internal constructor( * If you want to run some side effects like sending an analytics event or updating a state * based on this value consider using "snapshotFlow". */ - val layoutInfo: WeekCalendarLayoutInfo + public val layoutInfo: WeekCalendarLayoutInfo get() = WeekCalendarLayoutInfo(listState.layoutInfo) { index -> store[index] } internal val store = DataStore { offset -> @@ -222,7 +222,7 @@ class WeekCalendarState internal constructor( * * @see [animateScrollToWeek] */ - suspend fun scrollToWeek(date: LocalDate) { + public suspend fun scrollToWeek(date: LocalDate) { listState.scrollToItem(getScrollIndex(date) ?: return) } @@ -231,7 +231,7 @@ class WeekCalendarState internal constructor( * * @param date the week to which to scroll. */ - suspend fun animateScrollToWeek(date: LocalDate) { + public suspend fun animateScrollToWeek(date: LocalDate) { listState.animateScrollToItem(getScrollIndex(date) ?: return) } @@ -240,7 +240,7 @@ class WeekCalendarState internal constructor( * calendar is being dragged. If you want to know whether the fling (or animated scroll) is in * progress, use [isScrollInProgress]. */ - val interactionSource: InteractionSource + public val interactionSource: InteractionSource get() = listState.interactionSource /** @@ -254,7 +254,7 @@ class WeekCalendarState internal constructor( override suspend fun scroll( scrollPriority: MutatePriority, block: suspend ScrollScope.() -> Unit, - ) = listState.scroll(scrollPriority, block) + ): Unit = listState.scroll(scrollPriority, block) private fun getScrollIndex(date: LocalDate): Int? { if (date !in startDateAdjusted..endDateAdjusted) { @@ -264,8 +264,8 @@ class WeekCalendarState internal constructor( return getWeekIndex(startDateAdjusted, date) } - companion object { - val Saver: Saver = listSaver( + public companion object { + public val Saver: Saver = listSaver( save = { listOf( it.startDate.toJvmSerializableLocalDate(), diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/CalendarDay.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/CalendarDay.kt index 5e9f002d..07be0a3f 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/CalendarDay.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/CalendarDay.kt @@ -10,4 +10,4 @@ import kotlinx.datetime.LocalDate * @param position the [DayPosition] for this day. */ @Immutable -data class CalendarDay(val date: LocalDate, val position: DayPosition) +public data class CalendarDay(val date: LocalDate, val position: DayPosition) diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/CalendarMonth.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/CalendarMonth.kt index 511dc03c..5429245c 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/CalendarMonth.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/CalendarMonth.kt @@ -9,7 +9,7 @@ import androidx.compose.runtime.Immutable * @param weekDays the weeks in this month. */ @Immutable -data class CalendarMonth internal constructor( +public data class CalendarMonth internal constructor( val yearMonth: YearMonth, val weekDays: List>, ) { diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/DayPosition.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/DayPosition.kt index 116e5458..53dddafd 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/DayPosition.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/DayPosition.kt @@ -3,7 +3,7 @@ package com.kizitonwose.calendar.core /** * Describes the position of a [CalendarDay] in the month. */ -enum class DayPosition { +public enum class DayPosition { /** * The day is positioned at the start of the month to * ensure proper alignment of the first day of the week. diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/Extensions.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/Extensions.kt index 64bc8577..7c40c5d5 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/Extensions.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/Extensions.kt @@ -20,7 +20,7 @@ import kotlinx.datetime.until * * @see [firstDayOfWeekFromLocale] */ -fun daysOfWeek(firstDayOfWeek: DayOfWeek = firstDayOfWeekFromLocale()): List { +public fun daysOfWeek(firstDayOfWeek: DayOfWeek = firstDayOfWeekFromLocale()): List { val pivot = 7 - firstDayOfWeek.ordinal val daysOfWeek = DayOfWeek.entries // Order `daysOfWeek` array so that firstDayOfWeek is at the start position. @@ -30,33 +30,33 @@ fun daysOfWeek(firstDayOfWeek: DayOfWeek = firstDayOfWeekFromLocale()): List) { +public data class Week internal constructor(val days: List) { override fun equals(other: Any?): Boolean { if (this === other) return true if (other == null || this::class != other::class) return false diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/WeekDay.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/WeekDay.kt index 7b72f8e6..8271341d 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/WeekDay.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/WeekDay.kt @@ -10,4 +10,4 @@ import kotlinx.datetime.LocalDate * @param position the [WeekDayPosition] for this day. */ @Immutable -data class WeekDay(val date: LocalDate, val position: WeekDayPosition) +public data class WeekDay(val date: LocalDate, val position: WeekDayPosition) diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/WeekDayPosition.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/WeekDayPosition.kt index 8dfc6809..6c3c5e47 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/WeekDayPosition.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/WeekDayPosition.kt @@ -3,7 +3,7 @@ package com.kizitonwose.calendar.core /** * Describes the position of a [WeekDay] on the calendar. */ -enum class WeekDayPosition { +public enum class WeekDayPosition { /** * The day is positioned at the start of the calendar to * ensure proper alignment of the first day of the week. diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/YearMonth.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/YearMonth.kt index a48f00e8..03e1fcea 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/YearMonth.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/core/YearMonth.kt @@ -5,8 +5,8 @@ import kotlinx.datetime.Month import kotlinx.datetime.number @Immutable -data class YearMonth(val year: Int, val month: Month) : Comparable, JvmSerializable { - constructor(year: Int, monthNumber: Int) : +public data class YearMonth(val year: Int, val month: Month) : Comparable, JvmSerializable { + public constructor(year: Int, monthNumber: Int) : this(year = year, month = Month(monthNumber)) init { @@ -28,5 +28,5 @@ data class YearMonth(val year: Int, val month: Month) : Comparable, J return cmp } - companion object + public companion object } diff --git a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/data/WeekData.kt b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/data/WeekData.kt index 1015a741..6865c1d8 100644 --- a/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/data/WeekData.kt +++ b/compose-multiplatform/library/src/commonMain/kotlin/com/kizitonwose/calendar/data/WeekData.kt @@ -11,12 +11,12 @@ import com.kizitonwose.calendar.core.weeksUntil import kotlinx.datetime.DayOfWeek import kotlinx.datetime.LocalDate -data class WeekDateRange( +public data class WeekDateRange( val startDateAdjusted: LocalDate, val endDateAdjusted: LocalDate, ) -fun getWeekCalendarAdjustedRange( +public fun getWeekCalendarAdjustedRange( startDate: LocalDate, endDate: LocalDate, firstDayOfWeek: DayOfWeek, @@ -28,7 +28,7 @@ fun getWeekCalendarAdjustedRange( return WeekDateRange(startDateAdjusted = startDateAdjusted, endDateAdjusted = endDateAdjusted) } -fun getWeekCalendarData( +public fun getWeekCalendarData( startDateAdjusted: LocalDate, offset: Int, desiredStartDate: LocalDate, @@ -38,12 +38,12 @@ fun getWeekCalendarData( return WeekData(firstDayInWeek, desiredStartDate, desiredEndDate) } -data class WeekData internal constructor( +public data class WeekData internal constructor( private val firstDayInWeek: LocalDate, private val desiredStartDate: LocalDate, private val desiredEndDate: LocalDate, ) { - val week = Week((0 until 7).map { dayOffset -> getDay(dayOffset) }) + val week: Week = Week((0 until 7).map { dayOffset -> getDay(dayOffset) }) private fun getDay(dayOffset: Int): WeekDay { val date = firstDayInWeek.plusDays(dayOffset) @@ -56,11 +56,11 @@ data class WeekData internal constructor( } } -fun getWeekIndex(startDateAdjusted: LocalDate, date: LocalDate): Int { +public fun getWeekIndex(startDateAdjusted: LocalDate, date: LocalDate): Int { return startDateAdjusted.weeksUntil(date) } -fun getWeekIndicesCount(startDateAdjusted: LocalDate, endDateAdjusted: LocalDate): Int { +public fun getWeekIndicesCount(startDateAdjusted: LocalDate, endDateAdjusted: LocalDate): Int { // Add one to include the start week itself! return getWeekIndex(startDateAdjusted, endDateAdjusted) + 1 } diff --git a/compose-multiplatform/library/src/iosMain/kotlin/com/kizitonwose/calendar/core/Extensions.ios.kt b/compose-multiplatform/library/src/iosMain/kotlin/com/kizitonwose/calendar/core/Extensions.ios.kt index f0a164db..2a03b858 100644 --- a/compose-multiplatform/library/src/iosMain/kotlin/com/kizitonwose/calendar/core/Extensions.ios.kt +++ b/compose-multiplatform/library/src/iosMain/kotlin/com/kizitonwose/calendar/core/Extensions.ios.kt @@ -8,7 +8,7 @@ import platform.Foundation.NSLocale /** * Returns the first day of the week from the provided locale. */ -actual fun firstDayOfWeekFromLocale(locale: Locale): DayOfWeek { +public actual fun firstDayOfWeekFromLocale(locale: Locale): DayOfWeek { val firstWeekday = NSCalendar.currentCalendar.let { it.setLocale(NSLocale(locale.toLanguageTag())) // https://developer.apple.com/documentation/foundation/calendar/2293656-firstweekday diff --git a/compose-multiplatform/library/src/jvmMain/kotlin/com/kizitonwose/calendar/core/Converters.kt b/compose-multiplatform/library/src/jvmMain/kotlin/com/kizitonwose/calendar/core/Converters.kt index b1b278b1..c78263e5 100644 --- a/compose-multiplatform/library/src/jvmMain/kotlin/com/kizitonwose/calendar/core/Converters.kt +++ b/compose-multiplatform/library/src/jvmMain/kotlin/com/kizitonwose/calendar/core/Converters.kt @@ -2,6 +2,6 @@ package com.kizitonwose.calendar.core import java.time.YearMonth as jtYearMonth -fun YearMonth.toJavaYearMonth(): jtYearMonth = jtYearMonth.of(year, month) +public fun YearMonth.toJavaYearMonth(): jtYearMonth = jtYearMonth.of(year, month) -fun jtYearMonth.toKotlinYearMonth(): YearMonth = YearMonth(year, month) +public fun jtYearMonth.toKotlinYearMonth(): YearMonth = YearMonth(year, month) diff --git a/compose-multiplatform/library/src/jvmMain/kotlin/com/kizitonwose/calendar/core/Extensions.jvm.kt b/compose-multiplatform/library/src/jvmMain/kotlin/com/kizitonwose/calendar/core/Extensions.jvm.kt index 1282928e..c99f00dd 100644 --- a/compose-multiplatform/library/src/jvmMain/kotlin/com/kizitonwose/calendar/core/Extensions.jvm.kt +++ b/compose-multiplatform/library/src/jvmMain/kotlin/com/kizitonwose/calendar/core/Extensions.jvm.kt @@ -5,5 +5,5 @@ import java.time.DayOfWeek import java.time.temporal.WeekFields import java.util.Locale as JavaLocale -actual fun firstDayOfWeekFromLocale(locale: Locale): DayOfWeek = +public actual fun firstDayOfWeekFromLocale(locale: Locale): DayOfWeek = WeekFields.of(JavaLocale.forLanguageTag(locale.toLanguageTag())).firstDayOfWeek diff --git a/compose-multiplatform/library/src/jvmMain/kotlin/com/kizitonwose/calendar/core/JvmSerializable.jvm.kt b/compose-multiplatform/library/src/jvmMain/kotlin/com/kizitonwose/calendar/core/JvmSerializable.jvm.kt index 2b9ed644..199695a3 100644 --- a/compose-multiplatform/library/src/jvmMain/kotlin/com/kizitonwose/calendar/core/JvmSerializable.jvm.kt +++ b/compose-multiplatform/library/src/jvmMain/kotlin/com/kizitonwose/calendar/core/JvmSerializable.jvm.kt @@ -1,3 +1,3 @@ package com.kizitonwose.calendar.core -actual typealias JvmSerializable = java.io.Serializable +public actual typealias JvmSerializable = java.io.Serializable diff --git a/compose-multiplatform/library/src/nonJvmMain/kotlin/com/kizitonwose/calendar/core/JvmSerializable.nonJvm.kt b/compose-multiplatform/library/src/nonJvmMain/kotlin/com/kizitonwose/calendar/core/JvmSerializable.nonJvm.kt index bbce3a20..7147a4bd 100644 --- a/compose-multiplatform/library/src/nonJvmMain/kotlin/com/kizitonwose/calendar/core/JvmSerializable.nonJvm.kt +++ b/compose-multiplatform/library/src/nonJvmMain/kotlin/com/kizitonwose/calendar/core/JvmSerializable.nonJvm.kt @@ -1,3 +1,3 @@ package com.kizitonwose.calendar.core -actual interface JvmSerializable +public actual interface JvmSerializable diff --git a/compose-multiplatform/library/src/wasmJsMain/kotlin/com/kizitonwose/calendar/core/Extensions.wasmJs.kt b/compose-multiplatform/library/src/wasmJsMain/kotlin/com/kizitonwose/calendar/core/Extensions.wasmJs.kt index b728b271..de8d954c 100644 --- a/compose-multiplatform/library/src/wasmJsMain/kotlin/com/kizitonwose/calendar/core/Extensions.wasmJs.kt +++ b/compose-multiplatform/library/src/wasmJsMain/kotlin/com/kizitonwose/calendar/core/Extensions.wasmJs.kt @@ -6,7 +6,7 @@ import kotlinx.datetime.DayOfWeek /** * Returns the first day of the week from the provided locale. */ -actual fun firstDayOfWeekFromLocale(locale: Locale): DayOfWeek { +public actual fun firstDayOfWeekFromLocale(locale: Locale): DayOfWeek { return try { val firstDay = jsFirstDayFromTag(locale.toLanguageTag()) daysOfWeek(firstDayOfWeek = DayOfWeek.MONDAY)[firstDay - 1] diff --git a/compose/src/main/java/com/kizitonwose/calendar/compose/Calendar.kt b/compose/src/main/java/com/kizitonwose/calendar/compose/Calendar.kt index a9ba05b1..9d5bee28 100644 --- a/compose/src/main/java/com/kizitonwose/calendar/compose/Calendar.kt +++ b/compose/src/main/java/com/kizitonwose/calendar/compose/Calendar.kt @@ -58,7 +58,7 @@ import java.time.DayOfWeek * customisations are rendered. */ @Composable -fun HorizontalCalendar( +public fun HorizontalCalendar( modifier: Modifier = Modifier, state: CalendarState = rememberCalendarState(), calendarScrollPaged: Boolean = true, @@ -71,7 +71,7 @@ fun HorizontalCalendar( monthBody: (@Composable ColumnScope.(CalendarMonth, content: @Composable () -> Unit) -> Unit)? = null, monthFooter: (@Composable ColumnScope.(CalendarMonth) -> Unit)? = null, monthContainer: (@Composable LazyItemScope.(CalendarMonth, container: @Composable () -> Unit) -> Unit)? = null, -) = Calendar( +): Unit = Calendar( modifier = modifier, state = state, calendarScrollPaged = calendarScrollPaged, @@ -121,7 +121,7 @@ fun HorizontalCalendar( * customisations are rendered. */ @Composable -fun VerticalCalendar( +public fun VerticalCalendar( modifier: Modifier = Modifier, state: CalendarState = rememberCalendarState(), calendarScrollPaged: Boolean = false, @@ -134,7 +134,7 @@ fun VerticalCalendar( monthBody: (@Composable ColumnScope.(CalendarMonth, content: @Composable () -> Unit) -> Unit)? = null, monthFooter: (@Composable ColumnScope.(CalendarMonth) -> Unit)? = null, monthContainer: (@Composable LazyItemScope.(CalendarMonth, container: @Composable () -> Unit) -> Unit)? = null, -) = Calendar( +): Unit = Calendar( modifier = modifier, state = state, calendarScrollPaged = calendarScrollPaged, @@ -232,7 +232,7 @@ private fun Calendar( * placed below each week on the calendar. */ @Composable -fun WeekCalendar( +public fun WeekCalendar( modifier: Modifier = Modifier, state: WeekCalendarState = rememberWeekCalendarState(), calendarScrollPaged: Boolean = true, @@ -242,7 +242,7 @@ fun WeekCalendar( dayContent: @Composable BoxScope.(WeekDay) -> Unit, weekHeader: (@Composable ColumnScope.(Week) -> Unit)? = null, weekFooter: (@Composable ColumnScope.(Week) -> Unit)? = null, -) = WeekCalendarImpl( +): Unit = WeekCalendarImpl( modifier = modifier, state = state, calendarScrollPaged = calendarScrollPaged, @@ -274,7 +274,7 @@ fun WeekCalendar( * placed above each month on the calendar. */ @Composable -fun HeatMapCalendar( +public fun HeatMapCalendar( modifier: Modifier = Modifier, state: HeatMapCalendarState = rememberHeatMapCalendarState(), weekHeaderPosition: HeatMapWeekHeaderPosition = HeatMapWeekHeaderPosition.Start, @@ -283,7 +283,7 @@ fun HeatMapCalendar( dayContent: @Composable ColumnScope.(day: CalendarDay, week: HeatMapWeek) -> Unit, weekHeader: (@Composable ColumnScope.(DayOfWeek) -> Unit)? = null, monthHeader: (@Composable ColumnScope.(CalendarMonth) -> Unit)? = null, -) = HeatMapCalendarImpl( +): Unit = HeatMapCalendarImpl( modifier = modifier, state = state, weekHeaderPosition = weekHeaderPosition, diff --git a/compose/src/main/java/com/kizitonwose/calendar/compose/CalendarLayoutInfo.kt b/compose/src/main/java/com/kizitonwose/calendar/compose/CalendarLayoutInfo.kt index d78948da..6fce652c 100644 --- a/compose/src/main/java/com/kizitonwose/calendar/compose/CalendarLayoutInfo.kt +++ b/compose/src/main/java/com/kizitonwose/calendar/compose/CalendarLayoutInfo.kt @@ -11,12 +11,12 @@ import com.kizitonwose.calendar.core.CalendarMonth * Use [CalendarState.layoutInfo] to retrieve this. * @see LazyListLayoutInfo */ -class CalendarLayoutInfo(info: LazyListLayoutInfo, private val month: (Int) -> CalendarMonth) : +public class CalendarLayoutInfo(info: LazyListLayoutInfo, private val month: (Int) -> CalendarMonth) : LazyListLayoutInfo by info { /** * The list of [CalendarItemInfo] representing all the currently visible months. */ - val visibleMonthsInfo: List + public val visibleMonthsInfo: List get() = visibleItemsInfo.map { CalendarItemInfo(it, month(it.index)) } @@ -30,4 +30,4 @@ class CalendarLayoutInfo(info: LazyListLayoutInfo, private val month: (Int) -> C * @see CalendarLayoutInfo * @see LazyListItemInfo */ -class CalendarItemInfo(info: LazyListItemInfo, val month: CalendarMonth) : LazyListItemInfo by info +public class CalendarItemInfo(info: LazyListItemInfo, public val month: CalendarMonth) : LazyListItemInfo by info diff --git a/compose/src/main/java/com/kizitonwose/calendar/compose/CalendarState.kt b/compose/src/main/java/com/kizitonwose/calendar/compose/CalendarState.kt index a66be734..0f5e901b 100644 --- a/compose/src/main/java/com/kizitonwose/calendar/compose/CalendarState.kt +++ b/compose/src/main/java/com/kizitonwose/calendar/compose/CalendarState.kt @@ -37,7 +37,7 @@ import java.time.YearMonth * @param outDateStyle the initial value for [CalendarState.outDateStyle] */ @Composable -fun rememberCalendarState( +public fun rememberCalendarState( startMonth: YearMonth = YearMonth.now(), endMonth: YearMonth = startMonth, firstVisibleMonth: YearMonth = startMonth, @@ -77,7 +77,7 @@ fun rememberCalendarState( * @param outDateStyle the preferred style for out date generation. */ @Stable -class CalendarState internal constructor( +public class CalendarState internal constructor( startMonth: YearMonth, endMonth: YearMonth, firstDayOfWeek: DayOfWeek, @@ -89,7 +89,7 @@ class CalendarState internal constructor( private var _startMonth by mutableStateOf(startMonth) /** The first month on the calendar. */ - var startMonth: YearMonth + public var startMonth: YearMonth get() = _startMonth set(value) { if (value != startMonth) { @@ -102,7 +102,7 @@ class CalendarState internal constructor( private var _endMonth by mutableStateOf(endMonth) /** The last month on the calendar. */ - var endMonth: YearMonth + public var endMonth: YearMonth get() = _endMonth set(value) { if (value != endMonth) { @@ -115,7 +115,7 @@ class CalendarState internal constructor( private var _firstDayOfWeek by mutableStateOf(firstDayOfWeek) /** The first day of week on the calendar. */ - var firstDayOfWeek: DayOfWeek + public var firstDayOfWeek: DayOfWeek get() = _firstDayOfWeek set(value) { if (value != firstDayOfWeek) { @@ -128,7 +128,7 @@ class CalendarState internal constructor( private var _outDateStyle by mutableStateOf(outDateStyle) /** The preferred style for out date generation. */ - var outDateStyle: OutDateStyle + public var outDateStyle: OutDateStyle get() = _outDateStyle set(value) { if (value != outDateStyle) { @@ -142,7 +142,7 @@ class CalendarState internal constructor( * * @see [lastVisibleMonth] */ - val firstVisibleMonth: CalendarMonth by derivedStateOf { + public val firstVisibleMonth: CalendarMonth by derivedStateOf { store[listState.firstVisibleItemIndex] } @@ -151,7 +151,7 @@ class CalendarState internal constructor( * * @see [firstVisibleMonth] */ - val lastVisibleMonth: CalendarMonth by derivedStateOf { + public val lastVisibleMonth: CalendarMonth by derivedStateOf { store[listState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0] } @@ -173,7 +173,7 @@ class CalendarState internal constructor( * * see [LazyListLayoutInfo] */ - val layoutInfo: CalendarLayoutInfo + public val layoutInfo: CalendarLayoutInfo get() = CalendarLayoutInfo(listState.layoutInfo) { index -> store[index] } /** @@ -181,7 +181,7 @@ class CalendarState internal constructor( * calendar is being dragged. If you want to know whether the fling (or animated scroll) is in * progress, use [isScrollInProgress]. */ - val interactionSource: InteractionSource + public val interactionSource: InteractionSource get() = listState.interactionSource internal val listState = LazyListState( @@ -228,7 +228,7 @@ class CalendarState internal constructor( * * @see [animateScrollToMonth] */ - suspend fun scrollToMonth(month: YearMonth) { + public suspend fun scrollToMonth(month: YearMonth) { listState.scrollToItem(getScrollIndex(month) ?: return) } @@ -238,7 +238,7 @@ class CalendarState internal constructor( * @param month the month to which to scroll. Must be within the * range of [startMonth] and [endMonth]. */ - suspend fun animateScrollToMonth(month: YearMonth) { + public suspend fun animateScrollToMonth(month: YearMonth) { listState.animateScrollToItem(getScrollIndex(month) ?: return) } @@ -261,9 +261,9 @@ class CalendarState internal constructor( override suspend fun scroll( scrollPriority: MutatePriority, block: suspend ScrollScope.() -> Unit, - ) = listState.scroll(scrollPriority, block) + ): Unit = listState.scroll(scrollPriority, block) - companion object { + public companion object { internal val Saver: Saver = listSaver( save = { listOf( diff --git a/compose/src/main/java/com/kizitonwose/calendar/compose/ContentHeightMode.kt b/compose/src/main/java/com/kizitonwose/calendar/compose/ContentHeightMode.kt index 370751fe..d7611f71 100644 --- a/compose/src/main/java/com/kizitonwose/calendar/compose/ContentHeightMode.kt +++ b/compose/src/main/java/com/kizitonwose/calendar/compose/ContentHeightMode.kt @@ -8,7 +8,7 @@ import androidx.compose.ui.Modifier /** * Determines how the height of the day content is calculated. */ -enum class ContentHeightMode { +public enum class ContentHeightMode { /** * The day container will wrap its height. This allows you to * use [Modifier.aspectRatio] if you want square day content diff --git a/compose/src/main/java/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapCalendarState.kt b/compose/src/main/java/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapCalendarState.kt index 9fbcd240..bb13151e 100644 --- a/compose/src/main/java/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapCalendarState.kt +++ b/compose/src/main/java/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapCalendarState.kt @@ -37,7 +37,7 @@ import java.time.YearMonth * @param firstVisibleMonth the initial value for [HeatMapCalendarState.firstVisibleMonth] */ @Composable -fun rememberHeatMapCalendarState( +public fun rememberHeatMapCalendarState( startMonth: YearMonth = YearMonth.now(), endMonth: YearMonth = startMonth, firstVisibleMonth: YearMonth = startMonth, @@ -73,7 +73,7 @@ fun rememberHeatMapCalendarState( * @param firstVisibleMonth the initial value for [HeatMapCalendarState.firstVisibleMonth] */ @Stable -class HeatMapCalendarState internal constructor( +public class HeatMapCalendarState internal constructor( startMonth: YearMonth, endMonth: YearMonth, firstVisibleMonth: YearMonth, @@ -84,7 +84,7 @@ class HeatMapCalendarState internal constructor( private var _startMonth by mutableStateOf(startMonth) /** The first month on the calendar. */ - var startMonth: YearMonth + public var startMonth: YearMonth get() = _startMonth set(value) { if (value != startMonth) { @@ -97,7 +97,7 @@ class HeatMapCalendarState internal constructor( private var _endMonth by mutableStateOf(endMonth) /** The last month on the calendar. */ - var endMonth: YearMonth + public var endMonth: YearMonth get() = _endMonth set(value) { if (value != endMonth) { @@ -110,7 +110,7 @@ class HeatMapCalendarState internal constructor( private var _firstDayOfWeek by mutableStateOf(firstDayOfWeek) /** The first day of week on the calendar. */ - var firstDayOfWeek: DayOfWeek + public var firstDayOfWeek: DayOfWeek get() = _firstDayOfWeek set(value) { if (value != firstDayOfWeek) { @@ -124,7 +124,7 @@ class HeatMapCalendarState internal constructor( * * @see [lastVisibleMonth] */ - val firstVisibleMonth: CalendarMonth by derivedStateOf { + public val firstVisibleMonth: CalendarMonth by derivedStateOf { store[listState.firstVisibleItemIndex] } @@ -133,7 +133,7 @@ class HeatMapCalendarState internal constructor( * * @see [firstVisibleMonth] */ - val lastVisibleMonth: CalendarMonth by derivedStateOf { + public val lastVisibleMonth: CalendarMonth by derivedStateOf { store[listState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0] } @@ -153,7 +153,7 @@ class HeatMapCalendarState internal constructor( * If you want to run some side effects like sending an analytics event or updating a state * based on this value consider using "snapshotFlow". */ - val layoutInfo: CalendarLayoutInfo + public val layoutInfo: CalendarLayoutInfo get() = CalendarLayoutInfo(listState.layoutInfo) { index -> store[index] } /** @@ -161,7 +161,7 @@ class HeatMapCalendarState internal constructor( * calendar is being dragged. If you want to know whether the fling (or animated scroll) is in * progress, use [isScrollInProgress]. */ - val interactionSource: InteractionSource + public val interactionSource: InteractionSource get() = listState.interactionSource internal val listState = LazyListState( @@ -201,7 +201,7 @@ class HeatMapCalendarState internal constructor( * * @see [animateScrollToMonth] */ - suspend fun scrollToMonth(month: YearMonth) { + public suspend fun scrollToMonth(month: YearMonth) { listState.scrollToItem(getScrollIndex(month) ?: return) } @@ -211,7 +211,7 @@ class HeatMapCalendarState internal constructor( * @param month the month to which to scroll. Must be within the * range of [startMonth] and [endMonth]. */ - suspend fun animateScrollToMonth(month: YearMonth) { + public suspend fun animateScrollToMonth(month: YearMonth) { listState.animateScrollToItem(getScrollIndex(month) ?: return) } @@ -234,9 +234,9 @@ class HeatMapCalendarState internal constructor( override suspend fun scroll( scrollPriority: MutatePriority, block: suspend ScrollScope.() -> Unit, - ) = listState.scroll(scrollPriority, block) + ): Unit = listState.scroll(scrollPriority, block) - companion object { + public companion object { internal val Saver: Saver = listSaver( save = { listOf( diff --git a/compose/src/main/java/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeek.kt b/compose/src/main/java/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeek.kt index 355a0e14..ba6b471c 100644 --- a/compose/src/main/java/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeek.kt +++ b/compose/src/main/java/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeek.kt @@ -16,4 +16,4 @@ import java.io.Serializable * @param days the days in this week. */ @Immutable -data class HeatMapWeek(val days: List) : Serializable +public data class HeatMapWeek(val days: List) : Serializable diff --git a/compose/src/main/java/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeekHeaderPosition.kt b/compose/src/main/java/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeekHeaderPosition.kt index ef077405..41cebfe0 100644 --- a/compose/src/main/java/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeekHeaderPosition.kt +++ b/compose/src/main/java/com/kizitonwose/calendar/compose/heatmapcalendar/HeatMapWeekHeaderPosition.kt @@ -6,7 +6,7 @@ import com.kizitonwose.calendar.compose.HeatMapCalendar * Determines the position of the week header * composable (Mon, Tue, Wed...) in the [HeatMapCalendar] */ -enum class HeatMapWeekHeaderPosition { +public enum class HeatMapWeekHeaderPosition { /** * The header is positioned at the start of the calendar. */ diff --git a/compose/src/main/java/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarLayoutInfo.kt b/compose/src/main/java/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarLayoutInfo.kt index b8c7fbac..302e051f 100644 --- a/compose/src/main/java/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarLayoutInfo.kt +++ b/compose/src/main/java/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarLayoutInfo.kt @@ -12,14 +12,14 @@ import com.kizitonwose.calendar.core.Week * * @see LazyListLayoutInfo */ -class WeekCalendarLayoutInfo( +public class WeekCalendarLayoutInfo( info: LazyListLayoutInfo, private val getIndexData: (Int) -> Week, ) : LazyListLayoutInfo by info { /** * The list of [WeekCalendarItemInfo] representing all the currently visible weeks. */ - val visibleWeeksInfo: List + public val visibleWeeksInfo: List get() = visibleItemsInfo.map { info -> WeekCalendarItemInfo(info, getIndexData(info.index)) } @@ -33,5 +33,5 @@ class WeekCalendarLayoutInfo( * @see WeekCalendarLayoutInfo * @see LazyListItemInfo */ -class WeekCalendarItemInfo(info: LazyListItemInfo, val week: Week) : +public class WeekCalendarItemInfo(info: LazyListItemInfo, public val week: Week) : LazyListItemInfo by info diff --git a/compose/src/main/java/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarState.kt b/compose/src/main/java/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarState.kt index 9a271885..32bf2721 100644 --- a/compose/src/main/java/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarState.kt +++ b/compose/src/main/java/com/kizitonwose/calendar/compose/weekcalendar/WeekCalendarState.kt @@ -39,7 +39,7 @@ import java.time.YearMonth * @param firstVisibleWeekDate the date which will have its week visible initially. */ @Composable -fun rememberWeekCalendarState( +public fun rememberWeekCalendarState( startDate: LocalDate = YearMonth.now().atStartOfMonth(), endDate: LocalDate = YearMonth.now().atEndOfMonth(), firstVisibleWeekDate: LocalDate = LocalDate.now(), @@ -79,7 +79,7 @@ fun rememberWeekCalendarState( * @param firstVisibleWeekDate the date which will have its week visible initially. */ @Stable -class WeekCalendarState internal constructor( +public class WeekCalendarState internal constructor( startDate: LocalDate, endDate: LocalDate, firstVisibleWeekDate: LocalDate, @@ -106,7 +106,7 @@ class WeekCalendarState internal constructor( * in the week to which this date belongs, depending on the provided [firstDayOfWeek]. * Such days will have their [WeekDayPosition] set to [WeekDayPosition.InDate] */ - var startDate: LocalDate + public var startDate: LocalDate get() = _startDate set(value) { if (value != _startDate) { @@ -123,7 +123,7 @@ class WeekCalendarState internal constructor( * in the week to which this date belongs. Such days will have their [WeekDayPosition] * set to [WeekDayPosition.OutDate] */ - var endDate: LocalDate + public var endDate: LocalDate get() = _endDate set(value) { if (value != _endDate) { @@ -136,7 +136,7 @@ class WeekCalendarState internal constructor( private var _firstDayOfWeek by mutableStateOf(firstDayOfWeek) /** The first day of week on the calendar. */ - var firstDayOfWeek: DayOfWeek + public var firstDayOfWeek: DayOfWeek get() = _firstDayOfWeek set(value) { if (value != _firstDayOfWeek) { @@ -148,14 +148,14 @@ class WeekCalendarState internal constructor( /** * The first week that is visible. */ - val firstVisibleWeek: Week by derivedStateOf { + public val firstVisibleWeek: Week by derivedStateOf { store[listState.firstVisibleItemIndex] } /** * The last week that is visible. */ - val lastVisibleWeek: Week by derivedStateOf { + public val lastVisibleWeek: Week by derivedStateOf { store[listState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0] } @@ -175,7 +175,7 @@ class WeekCalendarState internal constructor( * If you want to run some side effects like sending an analytics event or updating a state * based on this value consider using "snapshotFlow". */ - val layoutInfo: WeekCalendarLayoutInfo + public val layoutInfo: WeekCalendarLayoutInfo get() = WeekCalendarLayoutInfo(listState.layoutInfo) { index -> store[index] } internal val store = DataStore { offset -> @@ -218,7 +218,7 @@ class WeekCalendarState internal constructor( * * @see [animateScrollToWeek] */ - suspend fun scrollToWeek(date: LocalDate) { + public suspend fun scrollToWeek(date: LocalDate) { listState.scrollToItem(getScrollIndex(date) ?: return) } @@ -227,7 +227,7 @@ class WeekCalendarState internal constructor( * * @param date the week to which to scroll. */ - suspend fun animateScrollToWeek(date: LocalDate) { + public suspend fun animateScrollToWeek(date: LocalDate) { listState.animateScrollToItem(getScrollIndex(date) ?: return) } @@ -236,7 +236,7 @@ class WeekCalendarState internal constructor( * calendar is being dragged. If you want to know whether the fling (or animated scroll) is in * progress, use [isScrollInProgress]. */ - val interactionSource: InteractionSource + public val interactionSource: InteractionSource get() = listState.interactionSource /** @@ -250,7 +250,7 @@ class WeekCalendarState internal constructor( override suspend fun scroll( scrollPriority: MutatePriority, block: suspend ScrollScope.() -> Unit, - ) = listState.scroll(scrollPriority, block) + ): Unit = listState.scroll(scrollPriority, block) private fun getScrollIndex(date: LocalDate): Int? { if (date !in startDateAdjusted..endDateAdjusted) { @@ -260,8 +260,8 @@ class WeekCalendarState internal constructor( return getWeekIndex(startDateAdjusted, date) } - companion object { - val Saver: Saver = listSaver( + public companion object { + public val Saver: Saver = listSaver( save = { listOf( it.startDate, diff --git a/core/src/main/java/com/kizitonwose/calendar/core/CalendarDay.kt b/core/src/main/java/com/kizitonwose/calendar/core/CalendarDay.kt index d5e2a44b..619b610c 100644 --- a/core/src/main/java/com/kizitonwose/calendar/core/CalendarDay.kt +++ b/core/src/main/java/com/kizitonwose/calendar/core/CalendarDay.kt @@ -11,4 +11,4 @@ import java.time.LocalDate * @param position the [DayPosition] for this day. */ @Immutable -data class CalendarDay(val date: LocalDate, val position: DayPosition) : Serializable +public data class CalendarDay(val date: LocalDate, val position: DayPosition) : Serializable diff --git a/core/src/main/java/com/kizitonwose/calendar/core/CalendarMonth.kt b/core/src/main/java/com/kizitonwose/calendar/core/CalendarMonth.kt index cf5ed175..62511279 100644 --- a/core/src/main/java/com/kizitonwose/calendar/core/CalendarMonth.kt +++ b/core/src/main/java/com/kizitonwose/calendar/core/CalendarMonth.kt @@ -11,7 +11,7 @@ import java.time.YearMonth * @param weekDays the weeks in this month. */ @Immutable -data class CalendarMonth( +public data class CalendarMonth( val yearMonth: YearMonth, val weekDays: List>, ) : Serializable { diff --git a/core/src/main/java/com/kizitonwose/calendar/core/DayPosition.kt b/core/src/main/java/com/kizitonwose/calendar/core/DayPosition.kt index 116e5458..53dddafd 100644 --- a/core/src/main/java/com/kizitonwose/calendar/core/DayPosition.kt +++ b/core/src/main/java/com/kizitonwose/calendar/core/DayPosition.kt @@ -3,7 +3,7 @@ package com.kizitonwose.calendar.core /** * Describes the position of a [CalendarDay] in the month. */ -enum class DayPosition { +public enum class DayPosition { /** * The day is positioned at the start of the month to * ensure proper alignment of the first day of the week. diff --git a/core/src/main/java/com/kizitonwose/calendar/core/Extensions.kt b/core/src/main/java/com/kizitonwose/calendar/core/Extensions.kt index 7df1adfb..eb90a58f 100644 --- a/core/src/main/java/com/kizitonwose/calendar/core/Extensions.kt +++ b/core/src/main/java/com/kizitonwose/calendar/core/Extensions.kt @@ -13,7 +13,7 @@ import java.util.Locale * @see [firstDayOfWeekFromLocale] */ @JvmOverloads -fun daysOfWeek(firstDayOfWeek: DayOfWeek = firstDayOfWeekFromLocale()): List { +public fun daysOfWeek(firstDayOfWeek: DayOfWeek = firstDayOfWeekFromLocale()): List { val pivot = 7 - firstDayOfWeek.ordinal val daysOfWeek = DayOfWeek.entries // Order `daysOfWeek` array so that firstDayOfWeek is at the start position. @@ -24,20 +24,20 @@ fun daysOfWeek(firstDayOfWeek: DayOfWeek = firstDayOfWeekFromLocale()): List) : Serializable { +public data class Week(val days: List) : Serializable { override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false diff --git a/core/src/main/java/com/kizitonwose/calendar/core/WeekDay.kt b/core/src/main/java/com/kizitonwose/calendar/core/WeekDay.kt index c7e367e1..4ff93452 100644 --- a/core/src/main/java/com/kizitonwose/calendar/core/WeekDay.kt +++ b/core/src/main/java/com/kizitonwose/calendar/core/WeekDay.kt @@ -11,4 +11,4 @@ import java.time.LocalDate * @param position the [WeekDayPosition] for this day. */ @Immutable -data class WeekDay(val date: LocalDate, val position: WeekDayPosition) : Serializable +public data class WeekDay(val date: LocalDate, val position: WeekDayPosition) : Serializable diff --git a/core/src/main/java/com/kizitonwose/calendar/core/WeekDayPosition.kt b/core/src/main/java/com/kizitonwose/calendar/core/WeekDayPosition.kt index 8dfc6809..6c3c5e47 100644 --- a/core/src/main/java/com/kizitonwose/calendar/core/WeekDayPosition.kt +++ b/core/src/main/java/com/kizitonwose/calendar/core/WeekDayPosition.kt @@ -3,7 +3,7 @@ package com.kizitonwose.calendar.core /** * Describes the position of a [WeekDay] on the calendar. */ -enum class WeekDayPosition { +public enum class WeekDayPosition { /** * The day is positioned at the start of the calendar to * ensure proper alignment of the first day of the week. diff --git a/data/src/main/java/com/kizitonwose/calendar/data/DataStore.kt b/data/src/main/java/com/kizitonwose/calendar/data/DataStore.kt index 7445bd89..13b08dcf 100644 --- a/data/src/main/java/com/kizitonwose/calendar/data/DataStore.kt +++ b/data/src/main/java/com/kizitonwose/calendar/data/DataStore.kt @@ -4,7 +4,7 @@ package com.kizitonwose.calendar.data * Basically [MutableMap.getOrPut] but allows us read the map * in multiple places without calling `getOrPut` everywhere. */ -class DataStore( +public class DataStore( private val store: MutableMap = HashMap(), private val create: (offset: Int) -> V, ) : MutableMap by store { diff --git a/data/src/main/java/com/kizitonwose/calendar/data/Extensions.kt b/data/src/main/java/com/kizitonwose/calendar/data/Extensions.kt index 69303a3b..eb53661f 100644 --- a/data/src/main/java/com/kizitonwose/calendar/data/Extensions.kt +++ b/data/src/main/java/com/kizitonwose/calendar/data/Extensions.kt @@ -3,4 +3,4 @@ package com.kizitonwose.calendar.data import java.time.DayOfWeek // E.g DayOfWeek.SATURDAY.daysUntil(DayOfWeek.TUESDAY) = 3 -fun DayOfWeek.daysUntil(other: DayOfWeek) = (7 + (other.value - value)) % 7 +public fun DayOfWeek.daysUntil(other: DayOfWeek): Int = (7 + (other.value - value)) % 7 diff --git a/data/src/main/java/com/kizitonwose/calendar/data/MonthData.kt b/data/src/main/java/com/kizitonwose/calendar/data/MonthData.kt index 5b38d842..1eab49ca 100644 --- a/data/src/main/java/com/kizitonwose/calendar/data/MonthData.kt +++ b/data/src/main/java/com/kizitonwose/calendar/data/MonthData.kt @@ -12,7 +12,7 @@ import java.time.DayOfWeek import java.time.YearMonth import java.time.temporal.ChronoUnit -data class MonthData internal constructor( +public data class MonthData internal constructor( private val month: YearMonth, private val inDays: Int, private val outDays: Int, @@ -27,7 +27,7 @@ data class MonthData internal constructor( private val nextMonth = month.nextMonth - val calendarMonth = + val calendarMonth: CalendarMonth = CalendarMonth(month, rows.map { week -> week.map { dayOffset -> getDay(dayOffset) } }) private fun getDay(dayOffset: Int): CalendarDay { @@ -42,7 +42,7 @@ data class MonthData internal constructor( } } -fun getCalendarMonthData( +public fun getCalendarMonthData( startMonth: YearMonth, offset: Int, firstDayOfWeek: DayOfWeek, @@ -64,7 +64,7 @@ fun getCalendarMonthData( return MonthData(month, inDays, outDays) } -fun getHeatMapCalendarMonthData( +public fun getHeatMapCalendarMonthData( startMonth: YearMonth, offset: Int, firstDayOfWeek: DayOfWeek, @@ -82,11 +82,11 @@ fun getHeatMapCalendarMonthData( return MonthData(month, inDays, outDays) } -fun getMonthIndex(startMonth: YearMonth, targetMonth: YearMonth): Int { +public fun getMonthIndex(startMonth: YearMonth, targetMonth: YearMonth): Int { return ChronoUnit.MONTHS.between(startMonth, targetMonth).toInt() } -fun getMonthIndicesCount(startMonth: YearMonth, endMonth: YearMonth): Int { +public fun getMonthIndicesCount(startMonth: YearMonth, endMonth: YearMonth): Int { // Add one to include the start month itself! return getMonthIndex(startMonth, endMonth) + 1 } diff --git a/data/src/main/java/com/kizitonwose/calendar/data/Utils.kt b/data/src/main/java/com/kizitonwose/calendar/data/Utils.kt index 33ff3376..ab9cfc8f 100644 --- a/data/src/main/java/com/kizitonwose/calendar/data/Utils.kt +++ b/data/src/main/java/com/kizitonwose/calendar/data/Utils.kt @@ -3,13 +3,13 @@ package com.kizitonwose.calendar.data import java.time.LocalDate import java.time.YearMonth -fun checkDateRange(startMonth: YearMonth, endMonth: YearMonth) { +public fun checkDateRange(startMonth: YearMonth, endMonth: YearMonth) { check(endMonth >= startMonth) { "startMonth: $startMonth is greater than endMonth: $endMonth" } } -fun checkDateRange(startDate: LocalDate, endDate: LocalDate) { +public fun checkDateRange(startDate: LocalDate, endDate: LocalDate) { check(endDate >= startDate) { "startDate: $startDate is greater than endDate: $endDate" } diff --git a/data/src/main/java/com/kizitonwose/calendar/data/WeekData.kt b/data/src/main/java/com/kizitonwose/calendar/data/WeekData.kt index 8652bb7e..006383cd 100644 --- a/data/src/main/java/com/kizitonwose/calendar/data/WeekData.kt +++ b/data/src/main/java/com/kizitonwose/calendar/data/WeekData.kt @@ -7,12 +7,12 @@ import java.time.DayOfWeek import java.time.LocalDate import java.time.temporal.ChronoUnit -data class WeekDateRange( +public data class WeekDateRange( val startDateAdjusted: LocalDate, val endDateAdjusted: LocalDate, ) -fun getWeekCalendarAdjustedRange( +public fun getWeekCalendarAdjustedRange( startDate: LocalDate, endDate: LocalDate, firstDayOfWeek: DayOfWeek, @@ -25,7 +25,7 @@ fun getWeekCalendarAdjustedRange( return WeekDateRange(startDateAdjusted = startDateAdjusted, endDateAdjusted = endDateAdjusted) } -fun getWeekCalendarData( +public fun getWeekCalendarData( startDateAdjusted: LocalDate, offset: Int, desiredStartDate: LocalDate, @@ -35,12 +35,12 @@ fun getWeekCalendarData( return WeekData(firstDayInWeek, desiredStartDate, desiredEndDate) } -data class WeekData internal constructor( +public data class WeekData internal constructor( private val firstDayInWeek: LocalDate, private val desiredStartDate: LocalDate, private val desiredEndDate: LocalDate, ) { - val week = Week((0 until 7).map { dayOffset -> getDay(dayOffset) }) + val week: Week = Week((0 until 7).map { dayOffset -> getDay(dayOffset) }) private fun getDay(dayOffset: Int): WeekDay { val date = firstDayInWeek.plusDays(dayOffset.toLong()) @@ -53,11 +53,11 @@ data class WeekData internal constructor( } } -fun getWeekIndex(startDateAdjusted: LocalDate, date: LocalDate): Int { +public fun getWeekIndex(startDateAdjusted: LocalDate, date: LocalDate): Int { return ChronoUnit.WEEKS.between(startDateAdjusted, date).toInt() } -fun getWeekIndicesCount(startDateAdjusted: LocalDate, endDateAdjusted: LocalDate): Int { +public fun getWeekIndicesCount(startDateAdjusted: LocalDate, endDateAdjusted: LocalDate): Int { // Add one to include the start week itself! return getWeekIndex(startDateAdjusted, endDateAdjusted) + 1 } diff --git a/view/src/main/java/com/kizitonwose/calendar/view/Binder.kt b/view/src/main/java/com/kizitonwose/calendar/view/Binder.kt index 68912bbf..f47504be 100644 --- a/view/src/main/java/com/kizitonwose/calendar/view/Binder.kt +++ b/view/src/main/java/com/kizitonwose/calendar/view/Binder.kt @@ -6,7 +6,7 @@ import com.kizitonwose.calendar.core.CalendarMonth import com.kizitonwose.calendar.core.Week import com.kizitonwose.calendar.core.WeekDay -open class ViewContainer(val view: View) +public open class ViewContainer(public val view: View) /** * Responsible for managing a view for a given [Data]. @@ -14,19 +14,19 @@ open class ViewContainer(val view: View) * be called whenever the view needs to be used to * bind an instance of the associated [Data]. */ -interface Binder { - fun create(view: View): Container - fun bind(container: Container, data: Data) +public interface Binder { + public fun create(view: View): Container + public fun bind(container: Container, data: Data) } -interface WeekDayBinder : Binder +public interface WeekDayBinder : Binder -interface WeekHeaderFooterBinder : Binder +public interface WeekHeaderFooterBinder : Binder -interface MonthDayBinder : Binder +public interface MonthDayBinder : Binder -interface MonthHeaderFooterBinder : Binder +public interface MonthHeaderFooterBinder : Binder -typealias MonthScrollListener = (CalendarMonth) -> Unit +public typealias MonthScrollListener = (CalendarMonth) -> Unit -typealias WeekScrollListener = (Week) -> Unit +public typealias WeekScrollListener = (Week) -> Unit diff --git a/view/src/main/java/com/kizitonwose/calendar/view/CalendarView.kt b/view/src/main/java/com/kizitonwose/calendar/view/CalendarView.kt index 7e877edf..ec6f77de 100644 --- a/view/src/main/java/com/kizitonwose/calendar/view/CalendarView.kt +++ b/view/src/main/java/com/kizitonwose/calendar/view/CalendarView.kt @@ -19,12 +19,12 @@ import java.time.DayOfWeek import java.time.LocalDate import java.time.YearMonth -open class CalendarView : RecyclerView { +public open class CalendarView : RecyclerView { /** * The [MonthDayBinder] instance used for managing day * cell view creation and reuse on the calendar. */ - var dayBinder: MonthDayBinder<*>? = null + public var dayBinder: MonthDayBinder<*>? = null set(value) { field = value invalidateViewHolders() @@ -34,7 +34,7 @@ open class CalendarView : RecyclerView { * The [MonthHeaderFooterBinder] instance used for managing header views. * The header view is shown above each month on the Calendar. */ - var monthHeaderBinder: MonthHeaderFooterBinder<*>? = null + public var monthHeaderBinder: MonthHeaderFooterBinder<*>? = null set(value) { field = value invalidateViewHolders() @@ -44,7 +44,7 @@ open class CalendarView : RecyclerView { * The [MonthHeaderFooterBinder] instance used for managing footer views. * The footer view is shown below each month on the Calendar. */ - var monthFooterBinder: MonthHeaderFooterBinder<*>? = null + public var monthFooterBinder: MonthHeaderFooterBinder<*>? = null set(value) { field = value invalidateViewHolders() @@ -54,13 +54,13 @@ open class CalendarView : RecyclerView { * Called when the calendar scrolls to a new month. * Mostly beneficial if [scrollPaged] is `true`. */ - var monthScrollListener: MonthScrollListener? = null + public var monthScrollListener: MonthScrollListener? = null /** * The xml resource that is inflated and used as the day cell view. * This must be provided. */ - var dayViewResource = 0 + public var dayViewResource: Int = 0 set(value) { if (field != value) { check(value != 0) { "Invalid 'dayViewResource' value." } @@ -73,7 +73,7 @@ open class CalendarView : RecyclerView { * The xml resource that is inflated and used as a header for every month. * Set zero to disable. */ - var monthHeaderResource = 0 + public var monthHeaderResource: Int = 0 set(value) { if (field != value) { field = value @@ -85,7 +85,7 @@ open class CalendarView : RecyclerView { * The xml resource that is inflated and used as a footer for every month. * Set zero to disable. */ - var monthFooterResource = 0 + public var monthFooterResource: Int = 0 set(value) { if (field != value) { field = value @@ -100,7 +100,7 @@ open class CalendarView : RecyclerView { * **You should exclude the name and constructor of this class from code * obfuscation if enabled**. */ - var monthViewClass: String? = null + public var monthViewClass: String? = null set(value) { if (field != value) { field = value @@ -113,7 +113,7 @@ open class CalendarView : RecyclerView { * This determines the scroll direction of the calendar. */ @Orientation - var orientation: Int = HORIZONTAL + public var orientation: Int = HORIZONTAL set(value) { if (field != value) { field = value @@ -127,7 +127,7 @@ open class CalendarView : RecyclerView { * snap to the nearest month after a scroll or swipe action. * If `false`, the calendar scrolls normally. */ - var scrollPaged = false + public var scrollPaged: Boolean = false set(value) { if (field != value) { field = value @@ -141,7 +141,7 @@ open class CalendarView : RecyclerView { * * @see [DayPosition] */ - var outDateStyle = OutDateStyle.EndOfRow + public var outDateStyle: OutDateStyle = OutDateStyle.EndOfRow set(value) { if (field != value) { field = value @@ -153,7 +153,7 @@ open class CalendarView : RecyclerView { * Determines how the size of each day on the calendar is calculated. * Can be [DaySize.Square], [DaySize.SeventhWidth] or [DaySize.FreeForm]. */ - var daySize: DaySize = DaySize.Square + public var daySize: DaySize = DaySize.Square set(value) { if (field != value) { field = value @@ -165,7 +165,7 @@ open class CalendarView : RecyclerView { * The margins, in pixels to be applied on each month view. * this can be used to add a space between two months. */ - var monthMargins = MarginValues() + public var monthMargins: MarginValues = MarginValues() set(value) { if (field != value) { field = value @@ -190,13 +190,13 @@ open class CalendarView : RecyclerView { private var endMonth: YearMonth? = null private var firstDayOfWeek: DayOfWeek? = null - constructor(context: Context) : super(context) + public constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { + public constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { init(attrs, 0, 0) } - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : + public constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { init(attrs, defStyleAttr, defStyleAttr) } @@ -282,7 +282,7 @@ open class CalendarView : RecyclerView { * shows the view for the month without any animations. * For a smooth scrolling effect, use [smoothScrollToMonth] */ - fun scrollToMonth(month: YearMonth) { + public fun scrollToMonth(month: YearMonth) { calendarLayoutManager.scrollToIndex(month) } @@ -290,7 +290,7 @@ open class CalendarView : RecyclerView { * Scroll to a specific month on the calendar using a smooth scrolling animation. * Just like [scrollToMonth], but with a smooth scrolling animation. */ - fun smoothScrollToMonth(month: YearMonth) { + public fun smoothScrollToMonth(month: YearMonth) { calendarLayoutManager.smoothScrollToIndex(month) } @@ -301,7 +301,7 @@ open class CalendarView : RecyclerView { * in horizontal mode. No animation is performed. * For a smooth scrolling effect, use [smoothScrollToDay]. */ - fun scrollToDay(day: CalendarDay) { + public fun scrollToDay(day: CalendarDay) { calendarLayoutManager.scrollToDay(day) } @@ -309,7 +309,7 @@ open class CalendarView : RecyclerView { * Shortcut for [scrollToDay] with a [LocalDate] instance. */ @JvmOverloads - fun scrollToDate(date: LocalDate, position: DayPosition = DayPosition.MonthDate) { + public fun scrollToDate(date: LocalDate, position: DayPosition = DayPosition.MonthDate) { scrollToDay(CalendarDay(date, position)) } @@ -317,7 +317,7 @@ open class CalendarView : RecyclerView { * Scroll to a specific [CalendarDay] using a smooth scrolling animation. * Just like [scrollToDay], but with a smooth scrolling animation. */ - fun smoothScrollToDay(day: CalendarDay) { + public fun smoothScrollToDay(day: CalendarDay) { calendarLayoutManager.smoothScrollToDay(day) } @@ -325,7 +325,7 @@ open class CalendarView : RecyclerView { * Shortcut for [smoothScrollToDay] with a [LocalDate] instance. */ @JvmOverloads - fun smoothScrollToDate(date: LocalDate, position: DayPosition = DayPosition.MonthDate) { + public fun smoothScrollToDate(date: LocalDate, position: DayPosition = DayPosition.MonthDate) { smoothScrollToDay(CalendarDay(date, position)) } @@ -334,7 +334,7 @@ open class CalendarView : RecyclerView { * This causes [MonthDayBinder.bind] to be called with the [ViewContainer] * at this position. Use this to reload a date cell on the Calendar. */ - fun notifyDayChanged(day: CalendarDay) { + public fun notifyDayChanged(day: CalendarDay) { calendarAdapter.reloadDay(day) } @@ -342,7 +342,7 @@ open class CalendarView : RecyclerView { * Shortcut for [notifyDayChanged] with a [LocalDate] instance. */ @JvmOverloads - fun notifyDateChanged(date: LocalDate, position: DayPosition = DayPosition.MonthDate) { + public fun notifyDateChanged(date: LocalDate, position: DayPosition = DayPosition.MonthDate) { notifyDayChanged(CalendarDay(date, position)) } @@ -357,7 +357,7 @@ open class CalendarView : RecyclerView { * specified day positions. This causes [MonthDayBinder.bind] to be called * with the [ViewContainer] at the relevant [DayPosition] values. */ - fun notifyDateChanged( + public fun notifyDateChanged( date: LocalDate, vararg position: DayPosition, ) { @@ -375,7 +375,7 @@ open class CalendarView : RecyclerView { * [MonthHeaderFooterBinder.bind] will be called for this month's header view if available. * [MonthHeaderFooterBinder.bind] will be called for this month's footer view if available. */ - fun notifyMonthChanged(month: YearMonth) { + public fun notifyMonthChanged(month: YearMonth) { calendarAdapter.reloadMonth(month) } @@ -383,7 +383,7 @@ open class CalendarView : RecyclerView { * Notify the CalendarView to reload all months. * @see [notifyMonthChanged]. */ - fun notifyCalendarChanged() { + public fun notifyCalendarChanged() { calendarAdapter.reloadCalendar() } @@ -392,7 +392,7 @@ open class CalendarView : RecyclerView { * * @return The first visible month or null if not found. */ - fun findFirstVisibleMonth(): CalendarMonth? { + public fun findFirstVisibleMonth(): CalendarMonth? { return calendarAdapter.findFirstVisibleMonth() } @@ -401,7 +401,7 @@ open class CalendarView : RecyclerView { * * @return The last visible month or null if not found. */ - fun findLastVisibleMonth(): CalendarMonth? { + public fun findLastVisibleMonth(): CalendarMonth? { return calendarAdapter.findLastVisibleMonth() } @@ -411,7 +411,7 @@ open class CalendarView : RecyclerView { * * @return The first visible day or null if not found. */ - fun findFirstVisibleDay(): CalendarDay? { + public fun findFirstVisibleDay(): CalendarDay? { return calendarAdapter.findFirstVisibleDay() } @@ -421,7 +421,7 @@ open class CalendarView : RecyclerView { * * @return The last visible day or null if not found. */ - fun findLastVisibleDay(): CalendarDay? { + public fun findLastVisibleDay(): CalendarDay? { return calendarAdapter.findLastVisibleDay() } @@ -433,7 +433,7 @@ open class CalendarView : RecyclerView { * @param endMonth The last month on the calendar. * @param firstDayOfWeek A [DayOfWeek] to be the first day of week. */ - fun setup(startMonth: YearMonth, endMonth: YearMonth, firstDayOfWeek: DayOfWeek) { + public fun setup(startMonth: YearMonth, endMonth: YearMonth, firstDayOfWeek: DayOfWeek) { checkDateRange(startMonth = startMonth, endMonth = endMonth) this.startMonth = startMonth this.endMonth = endMonth @@ -459,7 +459,7 @@ open class CalendarView : RecyclerView { * the calendar with a large date range instead of updating the range frequently. */ @JvmOverloads - fun updateMonthData( + public fun updateMonthData( startMonth: YearMonth = requireStartMonth(), endMonth: YearMonth = requireEndMonth(), firstDayOfWeek: DayOfWeek = requireFirstDayOfWeek(), diff --git a/view/src/main/java/com/kizitonwose/calendar/view/DaySize.kt b/view/src/main/java/com/kizitonwose/calendar/view/DaySize.kt index a9e9acab..11746da8 100644 --- a/view/src/main/java/com/kizitonwose/calendar/view/DaySize.kt +++ b/view/src/main/java/com/kizitonwose/calendar/view/DaySize.kt @@ -5,7 +5,7 @@ import android.view.ViewGroup /** * Determines how the size of each day on the calendar is calculated. */ -enum class DaySize { +public enum class DaySize { /** * Each day will have both width and height matching * the width of the calendar divided by 7. diff --git a/view/src/main/java/com/kizitonwose/calendar/view/MarginValues.kt b/view/src/main/java/com/kizitonwose/calendar/view/MarginValues.kt index 5c5f8dfc..fc1d7d5d 100644 --- a/view/src/main/java/com/kizitonwose/calendar/view/MarginValues.kt +++ b/view/src/main/java/com/kizitonwose/calendar/view/MarginValues.kt @@ -2,7 +2,7 @@ package com.kizitonwose.calendar.view import androidx.annotation.Px -data class MarginValues( +public data class MarginValues( @Px val start: Int = 0, @Px val top: Int = 0, @Px val end: Int = 0, diff --git a/view/src/main/java/com/kizitonwose/calendar/view/WeekCalendarView.kt b/view/src/main/java/com/kizitonwose/calendar/view/WeekCalendarView.kt index dfc6a935..e4fc63f4 100644 --- a/view/src/main/java/com/kizitonwose/calendar/view/WeekCalendarView.kt +++ b/view/src/main/java/com/kizitonwose/calendar/view/WeekCalendarView.kt @@ -14,12 +14,12 @@ import com.kizitonwose.calendar.view.internal.weekcalendar.WeekCalendarLayoutMan import java.time.DayOfWeek import java.time.LocalDate -open class WeekCalendarView : RecyclerView { +public open class WeekCalendarView : RecyclerView { /** * The [WeekDayBinder] instance used for managing day * cell view creation and reuse. */ - var dayBinder: WeekDayBinder<*>? = null + public var dayBinder: WeekDayBinder<*>? = null set(value) { field = value invalidateViewHolders() @@ -29,7 +29,7 @@ open class WeekCalendarView : RecyclerView { * The [WeekHeaderFooterBinder] instance used for managing header views. * The header view is shown above each week on the Calendar. */ - var weekHeaderBinder: WeekHeaderFooterBinder<*>? = null + public var weekHeaderBinder: WeekHeaderFooterBinder<*>? = null set(value) { field = value invalidateViewHolders() @@ -39,7 +39,7 @@ open class WeekCalendarView : RecyclerView { * The [WeekHeaderFooterBinder] instance used for managing footer views. * The footer view is shown below each week on the Calendar. */ - var weekFooterBinder: WeekHeaderFooterBinder<*>? = null + public var weekFooterBinder: WeekHeaderFooterBinder<*>? = null set(value) { field = value invalidateViewHolders() @@ -49,13 +49,13 @@ open class WeekCalendarView : RecyclerView { * Called when the calendar scrolls to a new week. * Mostly beneficial if [scrollPaged] is `true`. */ - var weekScrollListener: WeekScrollListener? = null + public var weekScrollListener: WeekScrollListener? = null /** * The xml resource that is inflated and used as the day cell view. * This must be provided. */ - var dayViewResource = 0 + public var dayViewResource: Int = 0 set(value) { if (field != value) { check(value != 0) { "Invalid 'dayViewResource' value." } @@ -68,7 +68,7 @@ open class WeekCalendarView : RecyclerView { * The xml resource that is inflated and used as a header for every week. * Set zero to disable. */ - var weekHeaderResource = 0 + public var weekHeaderResource: Int = 0 set(value) { if (field != value) { field = value @@ -80,7 +80,7 @@ open class WeekCalendarView : RecyclerView { * The xml resource that is inflated and used as a footer for every week. * Set zero to disable. */ - var weekFooterResource = 0 + public var weekFooterResource: Int = 0 set(value) { if (field != value) { field = value @@ -95,7 +95,7 @@ open class WeekCalendarView : RecyclerView { * **You should exclude the name and constructor of this class from code * obfuscation if enabled**. */ - var weekViewClass: String? = null + public var weekViewClass: String? = null set(value) { if (field != value) { field = value @@ -108,7 +108,7 @@ open class WeekCalendarView : RecyclerView { * snap to the nearest week after a scroll or swipe action. * If `false`, the calendar scrolls normally. */ - var scrollPaged = true + public var scrollPaged: Boolean = true set(value) { if (field != value) { field = value @@ -120,7 +120,7 @@ open class WeekCalendarView : RecyclerView { * Determines how the size of each day on the calendar is calculated. * Can be [DaySize.Square], [DaySize.SeventhWidth] or [DaySize.FreeForm]. */ - var daySize: DaySize = DaySize.Square + public var daySize: DaySize = DaySize.Square set(value) { if (field != value) { field = value @@ -132,7 +132,7 @@ open class WeekCalendarView : RecyclerView { * The margins, in pixels to be applied each week view. * this can be used to add a space between two weeks. */ - var weekMargins = MarginValues() + public var weekMargins: MarginValues = MarginValues() set(value) { if (field != value) { field = value @@ -155,13 +155,13 @@ open class WeekCalendarView : RecyclerView { private var endDate: LocalDate? = null private var firstDayOfWeek: DayOfWeek? = null - constructor(context: Context) : super(context) + public constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { + public constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { init(attrs, 0, 0) } - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : + public constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { init(attrs, defStyleAttr, defStyleAttr) } @@ -224,7 +224,7 @@ open class WeekCalendarView : RecyclerView { * This instantly shows the view for the week without any animations. * For a smooth scrolling effect, use [smoothScrollToWeek] */ - fun scrollToWeek(date: LocalDate) { + public fun scrollToWeek(date: LocalDate) { calendarLayoutManager.scrollToIndex(date) } @@ -233,7 +233,7 @@ open class WeekCalendarView : RecyclerView { * using a smooth scrolling animation. * Just like [scrollToWeek], but with a smooth scrolling animation. */ - fun smoothScrollToWeek(date: LocalDate) { + public fun smoothScrollToWeek(date: LocalDate) { calendarLayoutManager.smoothScrollToIndex(date) } @@ -243,7 +243,7 @@ open class WeekCalendarView : RecyclerView { * No animation is performed. * For a smooth scrolling effect, use [smoothScrollToDate]. */ - fun scrollToDate(date: LocalDate) { + public fun scrollToDate(date: LocalDate) { calendarLayoutManager.scrollToDay(date) } @@ -251,7 +251,7 @@ open class WeekCalendarView : RecyclerView { * Scroll to a specific date using a smooth scrolling animation. * Just like [scrollToDate], but with a smooth scrolling animation. */ - fun smoothScrollToDate(date: LocalDate) { + public fun smoothScrollToDate(date: LocalDate) { calendarLayoutManager.smoothScrollToDay(date) } @@ -260,7 +260,7 @@ open class WeekCalendarView : RecyclerView { * This instantly shows the view for the week without any animations. * For a smooth scrolling effect, use [smoothScrollToWeek] */ - fun scrollToWeek(day: WeekDay) { + public fun scrollToWeek(day: WeekDay) { scrollToWeek(day.date) } @@ -269,7 +269,7 @@ open class WeekCalendarView : RecyclerView { * using a smooth scrolling animation. * Just like [scrollToWeek], but with a smooth scrolling animation. */ - fun smoothScrollToWeek(day: WeekDay) { + public fun smoothScrollToWeek(day: WeekDay) { smoothScrollToWeek(day.date) } @@ -279,7 +279,7 @@ open class WeekCalendarView : RecyclerView { * No animation is performed. * For a smooth scrolling effect, use [smoothScrollToDay]. */ - fun scrollToDay(day: WeekDay) { + public fun scrollToDay(day: WeekDay) { scrollToDate(day.date) } @@ -287,7 +287,7 @@ open class WeekCalendarView : RecyclerView { * Scroll to a specific [WeekDay] using a smooth scrolling animation. * Just like [scrollToDay], but with a smooth scrolling animation. */ - fun smoothScrollToDay(day: WeekDay) { + public fun smoothScrollToDay(day: WeekDay) { smoothScrollToDate(day.date) } @@ -296,7 +296,7 @@ open class WeekCalendarView : RecyclerView { * This causes [WeekDayBinder.bind] to be called with the [ViewContainer] * at this position. Use this to reload a date cell on the Calendar. */ - fun notifyDateChanged(date: LocalDate) { + public fun notifyDateChanged(date: LocalDate) { calendarAdapter.reloadDay(date) } @@ -305,7 +305,7 @@ open class WeekCalendarView : RecyclerView { * This causes [WeekDayBinder.bind] to be called with the [ViewContainer] * at this position. Use this to reload a date cell on the Calendar. */ - fun notifyDayChanged(day: WeekDay) { + public fun notifyDayChanged(day: WeekDay) { notifyDateChanged(day.date) } @@ -316,7 +316,7 @@ open class WeekCalendarView : RecyclerView { * [WeekHeaderFooterBinder.bind] will be called for this week's header view if available. * [WeekHeaderFooterBinder.bind] will be called for this week's footer view if available. */ - fun notifyWeekChanged(date: LocalDate) { + public fun notifyWeekChanged(date: LocalDate) { calendarAdapter.reloadWeek(date) } @@ -327,7 +327,7 @@ open class WeekCalendarView : RecyclerView { * [WeekHeaderFooterBinder.bind] will be called for this week's header view if available. * [WeekHeaderFooterBinder.bind] will be called for this week's footer view if available. */ - fun notifyWeekChanged(day: WeekDay) { + public fun notifyWeekChanged(day: WeekDay) { notifyWeekChanged(day.date) } @@ -336,7 +336,7 @@ open class WeekCalendarView : RecyclerView { * * @see [notifyWeekChanged] */ - fun notifyCalendarChanged() { + public fun notifyCalendarChanged() { calendarAdapter.reloadCalendar() } @@ -345,7 +345,7 @@ open class WeekCalendarView : RecyclerView { * * @return The first visible week or null if not found. */ - fun findFirstVisibleWeek(): Week? { + public fun findFirstVisibleWeek(): Week? { return calendarAdapter.findFirstVisibleWeek() } @@ -354,7 +354,7 @@ open class WeekCalendarView : RecyclerView { * * @return The last visible week or null if not found. */ - fun findLastVisibleWeek(): Week? { + public fun findLastVisibleWeek(): Week? { return calendarAdapter.findLastVisibleWeek() } @@ -364,7 +364,7 @@ open class WeekCalendarView : RecyclerView { * * @return The first visible day or null if not found. */ - fun findFirstVisibleDay(): WeekDay? { + public fun findFirstVisibleDay(): WeekDay? { return calendarAdapter.findFirstVisibleDay() } @@ -374,7 +374,7 @@ open class WeekCalendarView : RecyclerView { * * @return The last visible day or null if not found. */ - fun findLastVisibleDay(): WeekDay? { + public fun findLastVisibleDay(): WeekDay? { return calendarAdapter.findLastVisibleDay() } @@ -386,7 +386,7 @@ open class WeekCalendarView : RecyclerView { * @param endDate A date in the last week on the calendar. * @param firstDayOfWeek A [DayOfWeek] to be the first day of week. */ - fun setup(startDate: LocalDate, endDate: LocalDate, firstDayOfWeek: DayOfWeek) { + public fun setup(startDate: LocalDate, endDate: LocalDate, firstDayOfWeek: DayOfWeek) { checkDateRange(startDate = startDate, endDate = endDate) this.startDate = startDate this.endDate = endDate @@ -411,7 +411,7 @@ open class WeekCalendarView : RecyclerView { * the calendar with a large date range instead of updating the range frequently. */ @JvmOverloads - fun updateWeekData( + public fun updateWeekData( startDate: LocalDate = requireStartDate(), endDate: LocalDate = requireEndDate(), firstDayOfWeek: DayOfWeek = requireFirstDayOfWeek(),