An Android library - built with jetpack compose - that offers Jalali/Persian calendar date picker dialog. It's easy to use, quick to implement and can be customized according to your application color and theme.
Add the JitPack repository to settings.gradle file
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependencies to app-level build.gradle file
dependencies {
...
implementation 'com.github.hamooo90:jalali-datepicker-compose:1.2.0'
implementation 'ir.huri:JalaliCalendar:1.3.3'
}
This library uses another library called JalaliCalendar to get, set and manipulate the dates. for more information on how to use it visit it's github page.
val openDialog = remember { mutableStateOf(false) }
Button(onClick = { openDialog.value = true }) {
Text(text = "Open JalaliDatePicker")
}
JalaliDatePickerDialog(
openDialog = openDialog,
onSelectDay = { //it:JalaliCalendar
Log.d("Date", "onSelect: ${it.day} ${it.monthString} ${it.year}")
},
onConfirm = {
Log.d("Date", "onConfirm: ${it.day} ${it.monthString} ${it.year}")
}
)
val openDialog = remember { mutableStateOf(false) }
Button(onClick = { openDialog.value = true }) {
Text(text = "Open JalaliDatePicker")
}
JalaliDatePickerDialog(
openDialog = openDialog,
fontFamily = FontFamily(
Font(R.font.bziba_0)
),
fontSize = 17.sp,
disableBeforeDate = JalaliCalendar(1403,10,15), //Days before this date are disabled and can't be selected.
disableAfterDate = JalaliCalendar(1404, 9, 30), //Days after this date are disabled and can't be selected.
initialDate = JalaliCalendar(1403, 11, 2),
onSelectDay = { //it:JalaliCalendar
Log.d("Date", "onSelect: ${it.day} ${it.monthString} ${it.year}")
},
onConfirm = {
Log.d("Date", "onConfirm: ${it.day} ${it.monthString} ${it.year}")
},
backgroundColor = Color.Yellow,
textColor = Color.Blue
)
jalali datepicker colors can be changed with the use of these parameters
Special Thanks to JalaliCalendar
Copyright 2023 Hamed Vakhideh
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.