A Jetpack Compose Calendar library to easily add calendar functionality to your Android app.
In order to be able to use CalendarJetpackCompose
, it requires you to configure your environment to support Jetpack Compose
. To do so, you can follow these steps.
CalendarJetpackCompose
only works for projects with minumum Android SDKs >= 26.
In your project build.gradle
, add:
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
In your module build.gradle
, add:
dependencies {
implementation 'com.github.fvalela1:CalendarJetpackCompose:$version'
}
Single Month Calendar
Result | Source |
![]() |
// defaults to your current year + month
CalendarJetpackCompose() |
Sample: SingleMonthCalendar.kt
Default Calendar With Vertical Padding
Result | Source |
![]() |
CalendarJetpackCompose(
verticalPadding = 10.dp
) |
Sample: DefaultWithIncreasedVerticalPaddingCalendar.kt
Default Calendar With Month Navigation
Sample: DefaultWithMonthNavigationCalendar.kt
Custom Month Navigation Arrows
Sample: CustomMonthNavArrowsCalendar.kt
The library has a model - CalendarDate.kt - that you can use to customize the selected dates. The model takes in three parameters:
dateInMilli: Long
- the date in milliseconds from epoch.backgroundColour: Color
- the colour of the background when selected.textStyle: TextStyle?
- the style of the number (i.e. bold, font, etc...) when it is selected.
The below samples are a showcase of using either a single colour or multiple colours as backgrounds for the selected dates.
convertSelectedDatesToCalendarDates()
can be found in any of the samples.
updateSelectedDate(newDate: Long)
can be found in ViewModel.kt
Select Date with Background Colours
Samples:
-
Ensure your environment supports Jetpack Compose (see Prerequisites).
-
Clone the repo
HTTPS
git clone https://github.com/fvalela1/CalendarJetpackCompose.git
SSH
git clone [email protected]:fvalela1/CalendarJetpackCompose.git
-
Open Android Studio and import the
CalendarJetpackCompose
project -
Make necessary changes
-
Submit a PR
-
Eat a slice of cake because you're awesome!
Copyright 2020 Francesco Valela
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.