Skip to content

Commit

Permalink
Merge pull request #16 from HawkiesZA/main
Browse files Browse the repository at this point in the history
Make Month view type configurable on OneScreenMonthYear
  • Loading branch information
BerkkanB authored Dec 22, 2022
2 parents 502c320 + b114365 commit f2d13e9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fun CalendarMonthViewOneColumn(
.fillMaxHeight(0.85f)
.fillMaxWidth()
.padding(10.dp),
monthViewType: MonthViewType?,
) {

LazyColumn(
Expand All @@ -55,7 +56,8 @@ fun CalendarMonthViewOneColumn(
setShowMonths = setShowMonths,
showOnlyMonth = showOnlyMonth,
themeColor = themeColor,
unselectedColor = unselectedColor
unselectedColor = unselectedColor,
monthViewType = monthViewType
)
}
}
Expand All @@ -76,6 +78,7 @@ fun MonthItemOneColumn(
showOnlyMonth: Boolean,
themeColor: Color,
unselectedColor: Color,
monthViewType: MonthViewType?,
) {
val enabled = checkDate(
minYear = minYear,
Expand All @@ -88,6 +91,15 @@ fun MonthItemOneColumn(

val monthAsNumber = String.format("%02d", index.plus(1))

val monthText: String = when (monthViewType) {
MonthViewType.ONLY_MONTH -> month.name.uppercase()
MonthViewType.ONLY_NUMBER -> monthAsNumber
MonthViewType.BOTH_NUMBER_AND_MONTH -> month.name.uppercase() + " " + "(${
monthAsNumber
})"
else -> month.name.uppercase()
}

Box(modifier = Modifier
.padding(vertical = 6.dp)
.clickable(
Expand All @@ -101,7 +113,7 @@ fun MonthItemOneColumn(
}
}) {
Text(
text = monthAsNumber,
text = monthText,
fontSize = if (month.name == selectedMonth) 35.sp else 30.sp,
color = if (enabled && month.name == selectedMonth) themeColor
else if (enabled) unselectedColor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ fun ComposeCalendar(
showOnlyMonth = calendarType == CalendarType.ONLY_MONTH,
themeColor = themeColor,
unselectedColor = unselectedColor,
setYear = setYear
setYear = setYear,
monthViewType = monthViewType
)
} else {
Crossfade(targetState = showMonths) {
Expand All @@ -162,7 +163,8 @@ fun ComposeCalendar(
monthList = monthList,
showOnlyMonth = calendarType == CalendarType.ONLY_MONTH,
themeColor = themeColor,
unselectedColor = unselectedColor
unselectedColor = unselectedColor,
monthViewType = monthViewType
)
} else {
CalendarMonthView(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fun OneScreenMonthYear(
themeColor: Color,
unselectedColor: Color,
setYear: (Int) -> Unit,
monthViewType: MonthViewType?,
) {
Row() {
CalendarMonthViewOneColumn(
Expand All @@ -43,6 +44,7 @@ fun OneScreenMonthYear(
.fillMaxHeight(0.85f)
.fillMaxWidth(0.5f)
.padding(vertical = 10.dp),
monthViewType = monthViewType,
)
CalendarYearView(
selectedYear = selectedYear,
Expand Down

0 comments on commit f2d13e9

Please sign in to comment.