Photo Calendar - A customizable Jetpack Compose calendar that allows you to add background image to specific days.
A fully customizable calendar component for Jetpack Compose.
It supports both horizontal scrolling calendars and grid-based calendars.
This library lets you add rich visual elements, like background images for specific days.
It also provides extensive configuration options for styling and localization.
특정 날짜에 배경 이미지를 추가, Styling과 Localization 등 다양한 설정 옵션을 제공하는 Jetpack Compose를 이용한 캘린더 컴포넌트입니다.
Grid-based Calendar | Horizontal Calendar |
---|---|
- Header Configuration: Customize the text style, color, and layout of the month and year display.
- Week Header Configuration: Adjust weekday labels (e.g., Sun, Mon, etc.) with different styles and colors.
- Day Configuration: Set the text style, color, and background for both regular and selected days.
- Day Indicator: Add customizable shapes (e.g., CircleShape, RoundedCornerShape) and colors to selected day.
- Supports both English (EN) and Korean (KO) locales.
- Dynamically formats headers and weekday labels:
- EN: “February 2024” KO: “2024년 2월”
- Customize the background of specific days using events.
- Horizontal Scrolling Calendar: Week-based, scrollable layout.
- Grid-based Calendar: Month view with weeks in rows.
Add the following to your build.gradle file:
// Project level build.gradle
allprojects {
repositories {
google()
mavenCentral()
}
}
// App level build.gradle
dependencies {
implementation("io.github.dongchyeon:photo-calendar:1.0.0")
}
var selectedDate by remember { mutableStateOf(LocalDate.now()) }
val events = listOf(
CalendarEvent(
date = LocalDate.now().plusDays(1),
imgUrl = "https://picsum.photos/200/300",
imgShape = CircleShape
),
CalendarEvent(
date = LocalDate.now().plusDays(2),
imgUrl = "https://picsum.photos/200/300",
imgShape = RoundedCornerShape(8.dp)
),
)
Calendar(
selectedDate = selectedDate,
events = events,
) {
selectedDate = it
}
var selectedDate by remember { mutableStateOf(LocalDate.now()) }
val events = listOf(
CalendarEvent(
date = LocalDate.now().plusDays(1),
imgUrl = "https://picsum.photos/200/300",
imgShape = CircleShape
),
CalendarEvent(
date = LocalDate.now().plusDays(2),
imgUrl = "https://picsum.photos/200/300",
imgShape = RoundedCornerShape(8.dp)
),
)
HorizontalCalendar(
selectedDate = selectedDate,
events = events,
) {
selectedDate = it
}
You can add events to specific dates using the CalendarEvent class. Each event can include a background image and a shape.
val events = listOf(
CalendarEvent(
date = LocalDate.now().plusDays(1),
imgUrl = "https://example.com/image1.jpg",
imgShape = CircleShape
),
CalendarEvent(
date = LocalDate.now().plusDays(3),
imgUrl = "https://example.com/image2.jpg",
imgShape = RoundedCornerShape(8.dp)
)
)
HorizontalCalendar(
selectedDate = LocalDate.now(),
events = events,
onDayClicked = { selectedDate ->
println("Selected Date: $selectedDate")
}
)
Calendar(
// ...
headerConfig = CalendarHeaderConfig.default().copy(
textStyle = Typography.titleLarge,
textColor = Color.Red
)
// ...
)
Calendar(
// ...
weekHeaderConfig = CalendarWeekHeaderConfig.default().copy(
textStyle = Typography.bodyLarge,
textColor = Color.Gray
)
// ...
)
Calendar(
// ...
dayConfig = CalendarDayConfig.default().copy(
dayTextColor = Color.Blue,
selectedDayTextColor = Color.White
)
// ...
)
Calendar(
// ...
indicatorConfig = CalendarIndicatorConfig(
indicatorColor = Color.Yellow.copy(alpha = 0.4f),
shape = RoundedCornerShape(12.dp)
)
// ...
)
This project is licensed under the MIT License. See the LICENSE file for details.