GithubHelp home page GithubHelp logo

hamooo90 / jalali-datepicker-compose Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 1.0 2.22 MB

Jalali Datepicker is an Android library written in Jetpack Compose that offers Persian calendar.

Kotlin 100.00%
android calendar compose date datepicker dialog jalali jetpack kotlin library

jalali-datepicker-compose's Introduction

jalali-datepicker-compose

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.

Download

Library Image

Setup

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.0.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.

How To Use

Minimum Configuration

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}")
    }
)

With Customization

val openDialog = remember { mutableStateOf(false) }
Button(onClick = { openDialog.value = true }) {
    Text(text = "Open JalaliDatePicker")
}
JalaliDatePickerDialog(
    openDialog = openDialog,
    initialDate = JalaliCalendar(1402, 1, 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 colors

Demo

Credit

Special Thanks to JalaliCalendar

Licence

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.