Skip to content
Open

test #11

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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()),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Add validation for selectedDate against isSelectFromFutureEnable constraint.

If isSelectFromFutureEnable is false but selectedDate is in the future, this creates an inconsistent state. Consider adding validation at the start of the composable.

selectableYearRange: Iterable<Int>? = null,
isSelectFromFutureEnable: Boolean = false,
textStyle: TextStyle = LocalTextStyle.current,
Expand All @@ -51,18 +53,23 @@ fun HeroDatePicker(
)
}
}

val selectedDateShamsi = ShamsiDatePickerUtill()
selectedDateShamsi.gregorianToPersian(selectedDate)

LaunchedEffect(Unit) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: LaunchedEffect should depend on selectedDate to handle parameter updates properly.

Currently, changes to selectedDate won't trigger an update of the initial selection. Change Unit to selectedDate to ensure the effect runs when the parameter changes.

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



Expand Down Expand Up @@ -104,10 +111,6 @@ fun HeroDatePicker(
onSelectedDateChange(SelectedDate(selectedYear, selectedMonth, selectedDay))
}
)

}

}


}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

<img alt="Banner" src="./images/banner.jpg" width="500"/>

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

Expand Down Expand Up @@ -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.

<p align="center">
<img src="https://github.com/hamid97m/HeroDatePicker/blob/master/images/library.gif" alt="gif" width="250 ">
<img alt="Screenshot" src="./images/screenshot.gif" width="250"/>
</p>

## Contributing
Expand Down
File renamed without changes