/android-persian-picker

Android persian picker

Primary LanguageKotlinMIT LicenseMIT

Persian Date Picker & Alphabet Picker

Android library providing a beautiful persian date picker and alphabet picker to use inside modal bottom sheet for Jetpack Compose.

License MIT Android minimuml version

Download

Add in project build.gradle:

repositories {
    maven { url 'https://jitpack.io' }
}

// App build.gradle
dependencies {
    implementation 'com.github.hasin-neobank:android-persian-picker:latestVersion'

}

Usage


Create an instance from PersianBirthDatePicker, PersianExpirationDatePicker or PersianAlphabetPicker outside of composable function (the best place is ViewModel):

//birth date picker
val picker = PersianBirthDatePicker()
//expiration date picker
val picker = PersianExpirationDatePicker()
//alphabet picker
val picker = PersianAlphabetPicker()

Set picker.BirthDatePickerUI, picker.ExpirationDatePickerUI or picker.AlphabetPickerUI as content to ModalBottomSheetLayout:

picker.BirthDatePickerUI(
    buttonTextStyle = MaterialTheme.typography.h3,
    selectedTextStyle = MaterialTheme.typography.h3.copy(
        color = TextBlack,
        fontWeight = FontWeight.Normal
    ),
    unSelectedTextStyle = MaterialTheme.typography.h3.copy(
        color = TextMediumGray,
        fontWeight = FontWeight.Normal
    ),
    buttonText = "تایید",
    onButtonPressed = { date ->
        result= "current persian date: ${date.persianYear}/${date.persianMonth}/${date.persianDay}"
    },
)
picker.ExpirationDatePickerUI(
    buttonTextStyle = MaterialTheme.typography.h3,
    selectedTextStyle = MaterialTheme.typography.h3.copy(
        color = TextBlack,
        fontWeight = FontWeight.Normal
    ),
    unSelectedTextStyle = MaterialTheme.typography.h3.copy(
        color = TextMediumGray,
        fontWeight = FontWeight.Normal
    ),
    buttonText = "تایید",
    onButtonPressed = { date ->
        result= "current persian date: ${date.persianYear}/${date.persianMonth}/${date.persianDay}"
    },
)
picker.AlphabetPickerUI(
    buttonTextStyle = MaterialTheme.typography.h3,
    selectedTextStyle = MaterialTheme.typography.h3.copy(
        color = TextBlack,
        fontWeight = FontWeight.Normal
    ),
    unSelectedTextStyle = MaterialTheme.typography.h3.copy(
        color = TextMediumGray,
        fontWeight = FontWeight.Normal
    ),
    buttonText = "تایید",
    onButtonPressed = { alphabet ->
        result= "current alphat: $alphabet"
    },
)

Note: see Example for more detail.

Credits

License

   
The MIT License (MIT)

Copyright (c) 2022 Hasin Neo Bank

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.