diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..6b4fbc3 --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,14 @@ +version = 1 + +[[analyzers]] +name = "java" + + [analyzers.meta] + runtime_version = "11" + +[[analyzers]] +name = "kotlin" + + [analyzers.meta] + runtime_version = "1.8" + language_version = "1.7" \ No newline at end of file diff --git a/HeroDatePicker/src/main/java/com/hamid97m/herodatepicker/view/HeroDatePicker.kt b/HeroDatePicker/src/main/java/com/hamid97m/herodatepicker/view/HeroDatePicker.kt index c689210..7f4dd1a 100644 --- a/HeroDatePicker/src/main/java/com/hamid97m/herodatepicker/view/HeroDatePicker.kt +++ b/HeroDatePicker/src/main/java/com/hamid97m/herodatepicker/view/HeroDatePicker.kt @@ -20,12 +20,14 @@ import com.hamid97m.herodatepicker.utils.ShamsiHeroDatePicker import java.util.Date /** + * @param selectedDate sets the initial selected gregorian date. * @param selectableYearRange determines the range of years that is selectable. * @param isSelectFromFutureEnable if false, the max date that would be selected is now. */ @Composable fun HeroDatePicker( modifier: Modifier = Modifier, + selectedDate: Date = Date(System.currentTimeMillis()), selectableYearRange: Iterable? = null, isSelectFromFutureEnable: Boolean = false, textStyle: TextStyle = LocalTextStyle.current, @@ -51,18 +53,23 @@ fun HeroDatePicker( ) } } + + val selectedDateShamsi = ShamsiDatePickerUtill() + selectedDateShamsi.gregorianToPersian(selectedDate) + LaunchedEffect(Unit) { onSelectedDateChange( SelectedDate( - currentDateShamsi.year, - currentDateShamsi.month, - currentDateShamsi.day + selectedDateShamsi.year, + selectedDateShamsi.month, + selectedDateShamsi.day ) ) } - var selectedYear by remember { mutableStateOf(currentDateShamsi.year) } - var selectedMonth by remember { mutableStateOf(currentDateShamsi.month) } - var selectedDay by remember { mutableStateOf(currentDateShamsi.day) } + + var selectedYear by remember { mutableStateOf(selectedDateShamsi.year) } + var selectedMonth by remember { mutableStateOf(selectedDateShamsi.month) } + var selectedDay by remember { mutableStateOf(selectedDateShamsi.day) } @@ -104,10 +111,6 @@ fun HeroDatePicker( onSelectedDateChange(SelectedDate(selectedYear, selectedMonth, selectedDay)) } ) - } - } - - } \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..781ccbc --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Hamid Mahmoodi + +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. diff --git a/README.md b/README.md index 3cebb92..2503293 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,22 @@ # HeroDatePicker + +HeroDatePicker is a customizable date picker component for Android Jetpack Compose that allows users +to easily select Persian (Jalali) dates in a visually appealing way. It features a sleek and modern +design, with smooth animations and intuitive controls. + Banner -HeroDatePicker is a customizable date picker component for Android Jetpack Compose that allows users to easily select Persian (Jalali) dates in a visually appealing way. It features a sleek and modern design, with smooth animations and intuitive controls. +[![Download](https://img.shields.io/jitpack/version/com.github.hamid97m/herodatepicker)](https://jitpack.io/#hamid97m/herodatepicker) + ## Features: + - Support for Persian (Jalali) calendar system - Customizable date format and locale - Ability to disable specific dates or date ranges - Integration with ViewModel for state management - Easy-to-use API with clear documentation -[![Download](https://img.shields.io/jitpack/version/com.github.hamid97m/herodatepicker)](https://jitpack.io/#hamid97m/herodatepicker) ## Setup @@ -77,8 +83,12 @@ HeroDatePicker(Modifier.fillMaxWidth()) { selectedDate -> } ``` +In addition, there is a sample app available in the +project's [sample directory](https://github.com/hamid97m/HeroDatePicker/tree/master/sample) that +demonstrates how to use the library. +

-gif +Screenshot

## Contributing diff --git a/images/library.gif b/images/screenshot.gif similarity index 100% rename from images/library.gif rename to images/screenshot.gif