Skip to content

Commit

Permalink
Enable Explicit API mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler authored and kizitonwose committed Jul 18, 2024
1 parent 09fae52 commit 2881ba6
Show file tree
Hide file tree
Showing 54 changed files with 274 additions and 263 deletions.
11 changes: 11 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin

plugins {
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidLibrary) apply false
Expand All @@ -14,6 +17,14 @@ plugins {

allprojects {
apply(plugin = rootProject.libs.plugins.kotlinter.get().pluginId)

plugins.withType<KotlinBasePlugin>().configureEach {
extensions.configure<KotlinProjectExtension> {
if ("sample" !in project.name) {
explicitApi()
}
}
}
}

apiValidation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -121,7 +121,7 @@ fun HorizontalCalendar(
* customisations are rendered.
*/
@Composable
fun VerticalCalendar(
public fun VerticalCalendar(
modifier: Modifier = Modifier,
state: CalendarState = rememberCalendarState(),
calendarScrollPaged: Boolean = false,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CalendarItemInfo>
public val visibleMonthsInfo: List<CalendarItemInfo>
get() = visibleItemsInfo.map {
CalendarItemInfo(it, month(it.index))
}
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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]
}

Expand All @@ -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]
}

Expand All @@ -173,15 +173,15 @@ class CalendarState internal constructor(
*
* see [LazyListLayoutInfo]
*/
val layoutInfo: CalendarLayoutInfo
public val layoutInfo: CalendarLayoutInfo
get() = CalendarLayoutInfo(listState.layoutInfo) { index -> store[index] }

/**
* [InteractionSource] that will be used to dispatch drag events when this
* 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(
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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<CalendarState, Any> = listSaver(
save = {
listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -124,7 +124,7 @@ class HeatMapCalendarState internal constructor(
*
* @see [lastVisibleMonth]
*/
val firstVisibleMonth: CalendarMonth by derivedStateOf {
public val firstVisibleMonth: CalendarMonth by derivedStateOf {
store[listState.firstVisibleItemIndex]
}

Expand All @@ -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]
}

Expand All @@ -153,15 +153,15 @@ 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] }

/**
* [InteractionSource] that will be used to dispatch drag events when this
* 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(
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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<HeatMapCalendarState, Any> = listSaver(
save = {
listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ import com.kizitonwose.calendar.core.CalendarDay
* @param days the days in this week.
*/
@Immutable
data class HeatMapWeek(val days: List<CalendarDay>)
public data class HeatMapWeek(val days: List<CalendarDay>)
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<WeekCalendarItemInfo>
public val visibleWeeksInfo: List<WeekCalendarItemInfo>
get() = visibleItemsInfo.map { info ->
WeekCalendarItemInfo(info, getIndexData(info.index))
}
Expand All @@ -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
Loading

0 comments on commit 2881ba6

Please sign in to comment.