Skip to content

AmirMousavi-Dev/Persian_Date_Picker

Repository files navigation

Persian Date Picker for Jetpack Compose

A simple, robust, and highly customizable Persian (Jalali) date picker for Jetpack Compose.

Features

  • Two UI Styles: Choose between a classic Dialog or a modern Bottom Sheet with wheel selection.
  • Native RTL Support: Built-in support for Right-to-Left layout direction.
  • Highly Customizable: Full control over colors, fonts, and dimensions.
  • Leap Year Support: Accurate Jalali calendar calculations.
  • State Management: Includes PersianDatePickerState for easy control and state hoisting.

Screenshots

Persian Date Picker Dialog Year Selection View Month Selection View

Installation

1. Add the JitPack repository to your settings.gradle.kts:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
    }
}

2. Add the dependency to your build.gradle.kts:

dependencies {
    implementation("com.github.AmirMousavi-Dev:Persian_Date_Picker:v1.3.0")
}

Usage

1. Date Picker Dialog

A classic calendar grid view in a dialog.

import com.amirmousavi_dev.date_picker.ui.dialog.PersianDatePickerDialog
import com.amirmousavi_dev.date_picker.ui.rememberPersianDatePickerState

val datePickerState = rememberPersianDatePickerState()

Button(onClick = { datePickerState.show() }) {
    Text("نمایش انتخاب‌گر تاریخ (دیالوگ)")
}

PersianDatePickerDialog(state = datePickerState)

2. Date Picker Bottom Sheet

A modern wheel-based selection system in a bottom sheet.

import com.amirmousavi_dev.date_picker.ui.bottomsheet.PersianDatePickerBottomSheet
import com.amirmousavi_dev.date_picker.ui.rememberPersianDatePickerState

val datePickerState = rememberPersianDatePickerState()

Button(onClick = { datePickerState.show() }) {
    Text("نمایش انتخاب‌گر تاریخ (باتم شیت)")
}

PersianDatePickerBottomSheet(state = datePickerState)

PersianDate Properties

The PersianDate object provides several useful properties:

  • year, month, day: Basic date components.
  • dayName: Persian name of the day (e.g., "سه‌شنبه").
  • monthName: Persian name of the month (e.g., "مهر").
  • formattedDate: Standard string representation (e.g., "1403/07/10").
  • fullDateName: User-friendly Persian string (e.g., "سه‌شنبه ۱۰ مهر").

Customization

You can customize the look and feel using DatePickerDefaults.colors():

PersianDatePickerDialog(
    state = datePickerState,
    colors = DatePickerDefaults.colors(
        headerBackgroundColor = MaterialTheme.colorScheme.primary,
        headerTextColor = MaterialTheme.colorScheme.onPrimary,
        // ... more color options
    ),
    fontFamily = myCustomFontFamily
)

License

Copyright 2024 Amir Mousavi

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.

About

Lightweight and customizable Persian Date Picker for Android built with Jetpack Compose.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages