diff --git a/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/FooterSection.kt b/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/FooterSection.kt index 3096c0f..1e47d95 100644 --- a/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/FooterSection.kt +++ b/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/FooterSection.kt @@ -10,6 +10,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -38,3 +39,13 @@ fun FooterSection(nextMonthName: String, onConfirm: () -> Unit, onCancel: () -> } } } + +@Preview(showBackground = true) +@Composable +fun PreviewFooterSection() { + FooterSection( + nextMonthName = "Safar", + onConfirm = { /* Handle confirm action in preview */ }, + onCancel = { /* Handle cancel action in preview */ } + ) +} \ No newline at end of file diff --git a/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/HeaderSection.kt b/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/HeaderSection.kt index 1d87707..12984dc 100644 --- a/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/HeaderSection.kt +++ b/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/HeaderSection.kt @@ -15,6 +15,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -44,3 +45,19 @@ fun HeaderSection(calendar: Calendar, onYearClick: () -> Unit) { ) } } + +@Preview(showBackground = true) +@Composable +fun PreviewHeaderSection() { + // Creating an instance of IslamicCalendar for preview purposes + val calendar = IslamicCalendar().apply { + set(Calendar.YEAR, 1445) + set(Calendar.MONTH, 1) // Safar + set(Calendar.DAY_OF_MONTH, 5) + } + + // Preview the HeaderSection with a mock IslamicCalendar and a simple onYearClick action + HeaderSection(calendar = calendar, onYearClick = { + // Handle year click in preview + }) +} \ No newline at end of file diff --git a/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/HijriDatePickerButton.kt b/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/HijriDatePickerButton.kt index b49bcb2..5ef1d09 100644 --- a/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/HijriDatePickerButton.kt +++ b/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/HijriDatePickerButton.kt @@ -15,6 +15,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -85,4 +86,11 @@ fun HijriDatePickerButton( "umalqura" // "umalqura", "civil", or "islamic" ) } +} + +@Preview(showBackground = true) +@Composable +fun PreviewHijriDatePickerButton() { + // Preview the HijriDatePickerButton with "umalqura" as calendar type + HijriDatePickerButton(calendarType = "umalqura") } \ No newline at end of file diff --git a/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/HijriDatePickerDialogWithThreeSections.kt b/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/HijriDatePickerDialogWithThreeSections.kt index 4b5278b..14de701 100644 --- a/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/HijriDatePickerDialogWithThreeSections.kt +++ b/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/HijriDatePickerDialogWithThreeSections.kt @@ -18,6 +18,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog @@ -107,3 +108,22 @@ fun HijriDatePickerDialogWithThreeSections( } } +@Preview(showBackground = true) +@Composable +fun PreviewHijriDatePickerDialogWithThreeSections() { + HijriDatePickerDialogWithThreeSections( + initialYear = 1445, // Initial Hijri year + initialMonth = 1, // Safar (month index starts at 0) + initialDay = 5, // 5th day of Safar + onDateSelected = { year, month, day -> + // Handle date selection (preview action) + }, + onConfirm = { + // Handle confirm action (preview action) + }, + onDismissRequest = { + // Handle dismiss action (preview action) + }, + calendarType = "umalqura" // Simulate the "umalqura" calendar type for preview + ) +} \ No newline at end of file diff --git a/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/MonthGridWithDays.kt b/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/MonthGridWithDays.kt index 1e6ccc1..ba6f449 100644 --- a/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/MonthGridWithDays.kt +++ b/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/MonthGridWithDays.kt @@ -20,6 +20,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -79,4 +80,18 @@ fun MonthGridWithDays( } } } +} + +@Preview(showBackground = true) +@Composable +fun PreviewMonthGridWithDays() { + MonthGridWithDays( + selectedYear = 1445, // Example year + onDaySelected = { year, month, day -> + // Handle day selection (preview action) + }, + preselectedMonth = 1, // Safar (0-indexed month) + preselectedDay = 5, // Preselected day + calendarType = "umalqura" // Calendar type for preview + ) } \ No newline at end of file diff --git a/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/YearSelectionScreen.kt b/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/YearSelectionScreen.kt index 8ee5a0b..c47c12a 100644 --- a/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/YearSelectionScreen.kt +++ b/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/YearSelectionScreen.kt @@ -14,6 +14,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -57,4 +58,16 @@ fun YearSelectionScreen( ) } } +} + +@Preview(showBackground = true) +@Composable +fun PreviewYearSelectionScreen() { + YearSelectionScreen( + selectedYear = 1445, // Preselected year + onYearSelected = { year -> + // Handle year selection (preview action) + }, + currentYear = 1445 // Scroll to this year by default + ) } \ No newline at end of file diff --git a/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/showHijriDatePicker.kt b/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/showHijriDatePicker.kt index b0b01f9..87af81a 100644 --- a/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/showHijriDatePicker.kt +++ b/HijriDatePickerLib/src/main/java/com/sdody/hijridatepickerlib/showHijriDatePicker.kt @@ -5,6 +5,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue +import androidx.compose.ui.tooling.preview.Preview // Example of how you can trigger the date picker from anywhere /* showHijriDatePicker( @@ -70,3 +71,24 @@ fun showHijriDatePicker( ) } } + +@Preview(showBackground = true) +@Composable +fun PreviewHijriDatePicker() { + // Preview the Hijri Date Picker with some predefined values + showHijriDatePicker( + initialYear = 1445, // Initial year in Hijri calendar + initialMonth = 1, // Safar (0-indexed month) + initialDay = 1, // 1st day of Safar + onDateSelected = { year, month, day -> + // Handle date selection (preview action) + }, + onConfirm = { year, month, day -> + // Handle confirmation (preview action) + }, + onDismissRequest = { + // Handle dismissal (preview action) + }, + calendarType = "umalqura" // Calendar type for preview + ) +} \ No newline at end of file diff --git a/README.md b/README.md index cf898a0..42018b9 100644 --- a/README.md +++ b/README.md @@ -225,3 +225,6 @@ For any questions or support regarding this project, you can contact the project [![](https://jitpack.io/v/mohamedma872/HijriDatePickerPlus.svg)](https://jitpack.io/#mohamedma872/HijriDatePickerPlus) +--- + +This updated README includes the mention of the `getIslamicCalendar` function and an example of how to use it to get the current Hijri date. Let me know if you need any further adjustments!