Skip to content

Commit

Permalink
Merge pull request #3 from DogusTeknoloji/feature/months_as_number_wi…
Browse files Browse the repository at this point in the history
…th_header

Feature/months as number with header
  • Loading branch information
BerkkanB authored Jan 10, 2022
2 parents eec4045 + 7f37f21 commit e141398
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/dt/calendarwork/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fun MainScreen() {
maxDate = calendarMax.time,
locale = Locale("en"),
title = "Select Date",
monthViewType = null,
monthViewType = MonthViewType.ONLY_NUMBER_ONE_COLUMN,
listener = object : SelectDateListener {
override fun onDateSelected(date: Date) {
Log.i("DENEME", date.toString())
Expand Down
13 changes: 10 additions & 3 deletions library/src/main/java/com/dt/composedatepicker/CalendarHeader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ import androidx.compose.ui.unit.sp

@Composable
fun CalendarHeader(
selectedMonth: String,
selectedMonth: MonthData,
selectedYear: Int,
showMonths: Boolean,
setShowMonths: (Boolean) -> Unit,
title: String,
showOnlyMonth: Boolean,
showOnlyYear: Boolean,
themeColor:Color
themeColor:Color,
monthViewType: MonthViewType?
) {
val monthAsNumber = String.format("%02d",selectedMonth.index.plus(1))
val monthText = if (monthViewType==MonthViewType.ONLY_MONTH) selectedMonth.name.uppercase() else monthAsNumber
Column(modifier = Modifier
.fillMaxWidth()
.background(themeColor),
Expand All @@ -35,7 +38,8 @@ fun CalendarHeader(
color = Color.White)
Row() {
if (!showOnlyYear) {
Text(text = selectedMonth.uppercase(),
Text(
text = monthText,
fontSize = 35.sp,
modifier = Modifier
.padding(bottom = 20.dp,
Expand All @@ -44,6 +48,9 @@ fun CalendarHeader(
.clickable { setShowMonths(true) },
color = if (showMonths) Color.White else Color.LightGray)
}
if (!showOnlyMonth && !showOnlyYear){
Text(text = "/",fontSize = 35.sp,color = Color.White)
}
if (!showOnlyMonth) {
Text(text = selectedYear.toString(),
fontSize = 35.sp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,17 @@ fun ComposeCalendar(
Card(modifier = Modifier
.fillMaxWidth(0.9f)) {
Column(modifier = Modifier.fillMaxWidth()) {
CalendarHeader(selectedMonth = selectedMonth.name,
CalendarHeader(
selectedMonth = selectedMonth,
selectedYear = selectedYear,
showMonths = showMonths,
setShowMonths = setShowMonths,
title = title,
showOnlyMonth = showOnlyMonth,
showOnlyYear = showOnlyYear,
themeColor=themeColor)
themeColor=themeColor,
monthViewType = monthViewType
)
Crossfade(targetState = showMonths) {
when (it) {
true -> {
Expand Down

0 comments on commit e141398

Please sign in to comment.