diff --git a/library/src/main/java/io/github/boguszpawlowski/composecalendar/selection/SelectionState.kt b/library/src/main/java/io/github/boguszpawlowski/composecalendar/selection/SelectionState.kt index 029dfeb..d667d4a 100644 --- a/library/src/main/java/io/github/boguszpawlowski/composecalendar/selection/SelectionState.kt +++ b/library/src/main/java/io/github/boguszpawlowski/composecalendar/selection/SelectionState.kt @@ -11,8 +11,8 @@ import java.time.LocalDate @Stable public interface SelectionState { - public fun isDateSelected(date: LocalDate): Boolean - public fun onDateSelected(date: LocalDate) + public fun isDateSelected(date: LocalDate): Boolean = false + public fun onDateSelected(date: LocalDate) { } } /** diff --git a/library/src/test/java/io/github/boguszpawlowski/composecalendar/selection/SelectionStateTest.kt b/library/src/test/java/io/github/boguszpawlowski/composecalendar/selection/SelectionStateTest.kt index 267fe77..fbe25d4 100644 --- a/library/src/test/java/io/github/boguszpawlowski/composecalendar/selection/SelectionStateTest.kt +++ b/library/src/test/java/io/github/boguszpawlowski/composecalendar/selection/SelectionStateTest.kt @@ -2,6 +2,7 @@ package io.github.boguszpawlowski.composecalendar.selection +import io.kotest.assertions.throwables.shouldNotThrowAny import io.kotest.core.spec.style.ShouldSpec import io.kotest.matchers.collections.shouldContainExactly import io.kotest.matchers.shouldBe @@ -135,4 +136,18 @@ internal class SelectionStateTest : ShouldSpec({ state.selection.endOrNull() shouldBe null } } + + context("Selection State interface default values") { + val myInterfaceWithNoMethods = object : SelectionState {} + + should("Default isDateSelected to false") { + myInterfaceWithNoMethods.isDateSelected(today) shouldBe false + } + + should("Have a default implementation that doesn't throw an exception for onDateSelected") { + shouldNotThrowAny { + myInterfaceWithNoMethods.onDateSelected(today) + } + } + } })