Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BCV and enable Explicit API mode #560

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,20 @@ jobs:
- name: Run Ktlint
run: ./gradlew lintKotlin

api-check:
name: API Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
- uses: gradle/actions/setup-gradle@v3
with:
gradle-home-cache-cleanup: true
- run: ./gradlew apiCheck

unit-tests:
name: Unit tests
runs-on: ubuntu-latest
Expand Down
18 changes: 18 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 @@ -9,10 +12,25 @@ plugins {
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.jetbrainsCompose) apply false
alias(libs.plugins.versionCheck)
alias(libs.plugins.bcv)
}

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

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

apiValidation {
ignoredProjects += listOf(
"sample",
)
}

// tasks.register<Delete>("clean").configure {
Expand Down
337 changes: 337 additions & 0 deletions compose-multiplatform/library/api/android/library.api

Large diffs are not rendered by default.

337 changes: 337 additions & 0 deletions compose-multiplatform/library/api/desktop/library.api

Large diffs are not rendered by default.

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>)
Loading
Loading