Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kizitonwose committed Jul 26, 2024
1 parent 2ff8895 commit d19831b
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public fun Year.isLeap(): Boolean = Year.isLeap(year)
*/
public fun Year.length(): Int = if (isLeap()) 366 else 365


/**
* Returns the [LocalDate] at the specified [dayOfYear] in this year.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import kotlinx.datetime.LocalDate
import kotlinx.datetime.format.char

private val ISO_YEAR_MONTH by lazy {
LocalDate.Format { year(); char('-'); monthNumber() }
LocalDate.Format {
year()
char('-')
monthNumber()
}
}

private val ISO_YEAR by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import kotlinx.serialization.encoding.encodeStructure
* @see YearMonth.toString
*/
public object YearMonthIso8601Serializer : KSerializer<YearMonth> {

override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor("com.kizitonwose.calendar.core.YearMonth", PrimitiveKind.STRING)

Expand All @@ -44,7 +43,6 @@ public object YearMonthIso8601Serializer : KSerializer<YearMonth> {
* JSON example: `{"year":2020,"month":12}`
*/
public object YearMonthComponentSerializer : KSerializer<YearMonth> {

override val descriptor: SerialDescriptor =
buildClassSerialDescriptor("com.kizitonwose.calendar.core.YearMonth") {
element<Int>("year")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import kotlinx.serialization.encoding.encodeStructure
* @see Year.toString
*/
public object YearIso8601Serializer : KSerializer<Year> {

override val descriptor: SerialDescriptor =
PrimitiveSerialDescriptor("com.kizitonwose.calendar.core.Year", PrimitiveKind.STRING)

Expand All @@ -44,7 +43,6 @@ public object YearIso8601Serializer : KSerializer<Year> {
* JSON example: `{"year":2020}`
*/
public object YearComponentSerializer : KSerializer<Year> {

override val descriptor: SerialDescriptor =
buildClassSerialDescriptor("com.kizitonwose.calendar.core.Year") {
element<Int>("year")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import kotlin.test.Test
import kotlin.test.assertEquals

class YearDataTest {

@Test
@JsName("test1")
fun `year data is accurate with non-leap year`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ fun Modifier.backgroundHighlight(

DayPosition.InDate -> {
textColor(Color.Transparent)
if (startDate != null && endDate != null &&
if (startDate != null &&
endDate != null &&
isInDateBetweenSelection(day.date, startDate, endDate)
) {
padding(vertical = padding)
Expand All @@ -123,7 +124,8 @@ fun Modifier.backgroundHighlight(

DayPosition.OutDate -> {
textColor(Color.Transparent)
if (startDate != null && endDate != null &&
if (startDate != null &&
endDate != null &&
isOutDateBetweenSelection(day.date, startDate, endDate)
) {
padding(vertical = padding)
Expand Down Expand Up @@ -208,7 +210,8 @@ fun Modifier.backgroundHighlightLegacy(

DayPosition.InDate -> {
textColor(Color.Transparent)
if (startDate != null && endDate != null &&
if (startDate != null &&
endDate != null &&
isInDateBetweenSelection(day.date, startDate, endDate)
) {
padding(vertical = padding)
Expand All @@ -220,7 +223,8 @@ fun Modifier.backgroundHighlightLegacy(

DayPosition.OutDate -> {
textColor(Color.Transparent)
if (startDate != null && endDate != null &&
if (startDate != null &&
endDate != null &&
isOutDateBetweenSelection(day.date, startDate, endDate)
) {
padding(vertical = padding)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,10 @@ private fun getMonthWithYear(
val firstItem = visibleItemsInfo.first()
val daySizePx = with(density) { daySize.toPx() }
if (
firstItem.size < daySizePx * 3 || // Ensure the Month + Year text can fit.
firstItem.offset < layoutInfo.viewportStartOffset && // Ensure the week row size - 1 is visible.
// Ensure the Month + Year text can fit.
firstItem.size < daySizePx * 3 ||
// Ensure the week row size - 1 is visible.
firstItem.offset < layoutInfo.viewportStartOffset &&
(layoutInfo.viewportStartOffset - firstItem.offset > daySizePx)
) {
visibleItemsInfo[1].month.yearMonth
Expand Down
2 changes: 0 additions & 2 deletions compose-multiplatform/sample/src/commonMain/kotlin/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ fun rememberFirstVisibleYearAfterScroll(state: YearCalendarState): CalendarYear
return visibleYear.value
}


private val CalendarLayoutInfo.completelyVisibleMonths: List<CalendarMonth>
get() {
val visibleItemsInfo = this.visibleMonthsInfo.toMutableList()
Expand Down Expand Up @@ -258,6 +257,5 @@ suspend fun LazyListState.animateScrollAndCenterItem(index: Int) {
}
}


val YearMonth.next: YearMonth get() = this.plus(1, DateTimeUnit.MONTH)
val YearMonth.previous: YearMonth get() = this.minus(1, DateTimeUnit.MONTH)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import java.time.Year
import java.time.YearMonth

class YearDataTest {

@Test
fun `year data is accurate with non-leap year`() {
val year = Year.of(2019)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ fun Modifier.backgroundHighlight(
}
DayPosition.InDate -> {
textColor(Color.Transparent)
if (startDate != null && endDate != null &&
if (startDate != null &&
endDate != null &&
isInDateBetweenSelection(day.date, startDate, endDate)
) {
padding(vertical = padding)
Expand All @@ -120,7 +121,8 @@ fun Modifier.backgroundHighlight(
}
DayPosition.OutDate -> {
textColor(Color.Transparent)
if (startDate != null && endDate != null &&
if (startDate != null &&
endDate != null &&
isOutDateBetweenSelection(day.date, startDate, endDate)
) {
padding(vertical = padding)
Expand Down Expand Up @@ -198,7 +200,8 @@ fun Modifier.backgroundHighlightLegacy(
}
DayPosition.InDate -> {
textColor(Color.Transparent)
if (startDate != null && endDate != null &&
if (startDate != null &&
endDate != null &&
isInDateBetweenSelection(day.date, startDate, endDate)
) {
padding(vertical = padding)
Expand All @@ -209,7 +212,8 @@ fun Modifier.backgroundHighlightLegacy(
}
DayPosition.OutDate -> {
textColor(Color.Transparent)
if (startDate != null && endDate != null &&
if (startDate != null &&
endDate != null &&
isOutDateBetweenSelection(day.date, startDate, endDate)
) {
padding(vertical = padding)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,10 @@ private fun getMonthWithYear(
val firstItem = visibleItemsInfo.first()
val daySizePx = with(density) { daySize.toPx() }
if (
firstItem.size < daySizePx * 3 || // Ensure the Month + Year text can fit.
firstItem.offset < layoutInfo.viewportStartOffset && // Ensure the week row size - 1 is visible.
// Ensure the Month + Year text can fit.
firstItem.size < daySizePx * 3 ||
// Ensure the week row size - 1 is visible.
firstItem.offset < layoutInfo.viewportStartOffset &&
(layoutInfo.viewportStartOffset - firstItem.offset > daySizePx)
) {
visibleItemsInfo[1].month.yearMonth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,15 @@ class Example4Fragment : BaseFragment(R.layout.example_4_fragment), HasToolbar,
// Make the coloured selection background continuous on the
// invisible in and out dates across various months.
DayPosition.InDate ->
if (startDate != null && endDate != null &&
if (startDate != null &&
endDate != null &&
isInDateBetweenSelection(data.date, startDate, endDate)
) {
continuousBgView.applyBackground(rangeMiddleBackground)
}
DayPosition.OutDate ->
if (startDate != null && endDate != null &&
if (startDate != null &&
endDate != null &&
isOutDateBetweenSelection(data.date, startDate, endDate)
) {
continuousBgView.applyBackground(rangeMiddleBackground)
Expand Down

0 comments on commit d19831b

Please sign in to comment.