Skip to content

Commit

Permalink
Header color fix and rounded corner for calendar card added
Browse files Browse the repository at this point in the history
  • Loading branch information
BerkkanB committed Sep 22, 2022
1 parent 460ea2f commit 55361aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
17 changes: 13 additions & 4 deletions library/src/main/java/com/dt/composedatepicker/CalendarHeader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ fun CalendarHeader(
title: String,
calendarType: CalendarType,
themeColor:Color,
monthViewType: MonthViewType?
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 @@ -45,7 +46,11 @@ fun CalendarHeader(
start = if (calendarType == CalendarType.ONLY_MONTH) 0.dp else 30.dp,
end = if (calendarType == CalendarType.ONLY_MONTH) 0.dp else 10.dp)
.clickable { setShowMonths(true) },
color = if (showMonths) Color.White else Color.LightGray)
color = if (calendarType == CalendarType.ONE_SCREEN_MONTH_AND_YEAR){
Color.White
} else {
if (showMonths) Color.White else Color.LightGray
})
}
if (calendarType != CalendarType.ONLY_MONTH && calendarType != CalendarType.ONLY_YEAR){
Text(text = "/",fontSize = 35.sp,color = Color.White)
Expand All @@ -58,8 +63,12 @@ fun CalendarHeader(
start = if (calendarType == CalendarType.ONLY_YEAR) 0.dp else 10.dp,
end = if (calendarType == CalendarType.ONLY_YEAR) 0.dp else 30.dp)
.clickable { setShowMonths(false) },
color = if (showMonths) Color.LightGray else Color.White)
color = if (calendarType == CalendarType.ONE_SCREEN_MONTH_AND_YEAR){
Color.White
} else {
if (showMonths) Color.LightGray else Color.White
})
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ package com.dt.composedatepicker
import androidx.compose.animation.Crossfade
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import java.text.DateFormatSymbols
import java.util.*

Expand Down Expand Up @@ -118,7 +115,8 @@ fun ComposeCalendar(

Card(
modifier = Modifier
.fillMaxSize()
.fillMaxSize(),
shape = RoundedCornerShape(16.dp)
) {
Column(modifier = Modifier.fillMaxSize()) {
CalendarHeader(
Expand All @@ -131,7 +129,7 @@ fun ComposeCalendar(
themeColor = themeColor,
monthViewType = monthViewType
)
if (calendarType == CalendarType.ONE_SCREEN_MONTH_AND_YEAR){
if (calendarType == CalendarType.ONE_SCREEN_MONTH_AND_YEAR) {
OneScreenMonthYear(
selectedMonth = selectedMonth,
setMonth = setMonth,
Expand All @@ -146,7 +144,7 @@ fun ComposeCalendar(
themeColor = themeColor,
unselectedColor = unselectedColor,
setYear = setYear
)
)
} else {
Crossfade(targetState = showMonths) {
when (it) {
Expand Down

0 comments on commit 55361aa

Please sign in to comment.