Skip to content

Commit

Permalink
(Calendar) Support calendar week start & calendar weeks #79 #49
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkeppeler committed Feb 8, 2024
1 parent 9ea7c26 commit 679deb0
Show file tree
Hide file tree
Showing 215 changed files with 891 additions and 110 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,26 @@ Module <code>calendar</code> ‎‎ | ‎‎ <a href="https://maxkeppeler.github
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%"> <a style="text-align: center" href="https://github.com/maxkeppeler/sheets-compose-dialogs/blob/main/app/src/main/java/com/mk/sheets/compose/samples/CalendarSample4.kt" title="Code">CalendarSample4</a>
</br>
<img src="docs/res/sheets/calendar/light/calendar_sample_4.png" /></td>
<td width="25%"> <a href="https://github.com/maxkeppeler/sheets-compose-dialogs/blob/main/app/src/main/java/com/mk/sheets/compose/samples/CalendarSample4.kt" title="Code">CalendarSample4</a>
</br>
<img src="docs/res/sheets/calendar/dark/calendar_sample_4.png" /></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%"> <a style="text-align: center" href="https://github.com/maxkeppeler/sheets-compose-dialogs/blob/main/app/src/main/java/com/mk/sheets/compose/samples/CalendarSample5.kt" title="Code">CalendarSample5</a>
</br>
<img src="docs/res/sheets/calendar/light/calendar_sample_5.png" /></td>
<td width="25%"> <a href="https://github.com/maxkeppeler/sheets-compose-dialogs/blob/main/app/src/main/java/com/mk/sheets/compose/samples/CalendarSample5.kt" title="Code">CalendarSample5</a>
</br>
<img src="docs/res/sheets/calendar/dark/calendar_sample_5.png" /></td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
</table>
</br>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import com.mk.sheets.compose.models.UseCaseType
import com.mk.sheets.compose.samples.CalendarSample1
import com.mk.sheets.compose.samples.CalendarSample2
import com.mk.sheets.compose.samples.CalendarSample3
import com.mk.sheets.compose.samples.CalendarSample4
import com.mk.sheets.compose.samples.CalendarSample5
import com.mk.sheets.compose.samples.ClockSample1
import com.mk.sheets.compose.samples.ClockSample2
import com.mk.sheets.compose.samples.ColorSample1
Expand Down Expand Up @@ -129,6 +131,8 @@ fun ShowcaseDialogSamples(
Sample.CALENDAR_SAMPLE_1 -> CalendarSample1(onResetSheet)
Sample.CALENDAR_SAMPLE_2 -> CalendarSample2(onResetSheet)
Sample.CALENDAR_SAMPLE_3 -> CalendarSample3(onResetSheet)
Sample.CALENDAR_SAMPLE_4 -> CalendarSample4(onResetSheet)
Sample.CALENDAR_SAMPLE_5 -> CalendarSample5(onResetSheet)

Sample.CLOCK_SAMPLE_1 -> ClockSample1(onReset)
Sample.CLOCK_SAMPLE_2 -> ClockSample2(onReset)
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/mk/sheets/compose/models/Sample.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@ enum class Sample(
"Disabled future with boundary"
),

CALENDAR_SAMPLE_4(
UseCaseType.CALENDAR,
"Select date",
"Month-style",
"Display Calendar Weeks"
),

CALENDAR_SAMPLE_5(
UseCaseType.CALENDAR,
"Select date",
"Week-style",
"Display Calendar Weeks"
),


CLOCK_SAMPLE_1(
UseCaseType.CLOCK,
"Hours and minutes selection",
Expand Down
48 changes: 48 additions & 0 deletions app/src/main/java/com/mk/sheets/compose/samples/CalendarSample4.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2022-2023. Maximilian Keppeler (https://www.maxkeppeler.com)
*
* 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:https://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.
*/
@file:OptIn(ExperimentalMaterial3Api::class)

package com.mk.sheets.compose.samples

import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import com.maxkeppeker.sheets.core.models.base.UseCaseState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.calendar.CalendarDialog
import com.maxkeppeler.sheets.calendar.models.CalendarConfig
import com.maxkeppeler.sheets.calendar.models.CalendarSelection
import com.maxkeppeler.sheets.calendar.models.CalendarStyle
import java.time.LocalDate

@Composable
internal fun CalendarSample4(closeSelection: UseCaseState.() -> Unit) {

val selectedDates = remember { mutableStateOf<List<LocalDate>>(listOf()) }
CalendarDialog(
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
config = CalendarConfig(
yearSelection = true,
monthSelection = true,
displayCalendarWeeks = true,
style = CalendarStyle.MONTH,
),
selection = CalendarSelection.Dates { newDates ->
selectedDates.value = newDates
},
)
}
48 changes: 48 additions & 0 deletions app/src/main/java/com/mk/sheets/compose/samples/CalendarSample5.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2022-2023. Maximilian Keppeler (https://www.maxkeppeler.com)
*
* 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:https://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.
*/
@file:OptIn(ExperimentalMaterial3Api::class)

package com.mk.sheets.compose.samples

import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import com.maxkeppeker.sheets.core.models.base.UseCaseState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.calendar.CalendarDialog
import com.maxkeppeler.sheets.calendar.models.CalendarConfig
import com.maxkeppeler.sheets.calendar.models.CalendarSelection
import com.maxkeppeler.sheets.calendar.models.CalendarStyle
import java.time.LocalDate

@Composable
internal fun CalendarSample5(closeSelection: UseCaseState.() -> Unit) {

val selectedDates = remember { mutableStateOf<List<LocalDate>>(listOf()) }
CalendarDialog(
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
config = CalendarConfig(
yearSelection = true,
monthSelection = true,
displayCalendarWeeks = true,
style = CalendarStyle.WEEK,
),
selection = CalendarSelection.Dates { newDates ->
selectedDates.value = newDates
},
)
}
Loading

0 comments on commit 679deb0

Please sign in to comment.