Skip to content

Commit

Permalink
(All) Rename SheetState to UseCaseState #35
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkeppeler committed Mar 13, 2023
1 parent 4c2f505 commit 0db781d
Show file tree
Hide file tree
Showing 85 changed files with 358 additions and 358 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.unit.dp
import com.maxkeppeker.sheets.core.models.base.SheetState
import com.maxkeppeker.sheets.core.models.base.UseCaseState
import com.mk.sheets.compose.models.Sample
import com.mk.sheets.compose.models.UseCaseType
import com.mk.sheets.compose.samples.*
Expand All @@ -43,7 +43,7 @@ fun ShowcaseDialogSamplesScreen() {

val currentSample = rememberSaveable { mutableStateOf<Sample?>(null) }
val onReset = { currentSample.value = null }
val onResetSheet: SheetState.() -> Unit = { currentSample.value = null }
val onResetSheet: UseCaseState.() -> Unit = { currentSample.value = null }

ShowcaseSamples(
modifier = Modifier.alpha(if (currentSample.value != null) 0f else 1f),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.rememberCoroutineScope
import com.maxkeppeker.sheets.core.models.base.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.calendar.CalendarView
import com.maxkeppeler.sheets.calendar.models.CalendarConfig
import com.maxkeppeler.sheets.calendar.models.CalendarSelection
Expand All @@ -41,14 +41,14 @@ fun BottomSheetSample(
) {
val coroutine = rememberCoroutineScope()
val hideBottomSheet = { coroutine.launch { state.animateTo(ModalBottomSheetValue.Hidden) } }
val dialogSheetState =
rememberSheetState(visible = true, onCloseRequest = { hideBottomSheet(); })
val useCaseState =
rememberUseCaseState(visible = true, onCloseRequest = { hideBottomSheet(); })

LaunchedEffect(state.currentValue) {
when (state.currentValue) {
ModalBottomSheetValue.Hidden,
ModalBottomSheetValue.Expanded -> {
dialogSheetState.invokeReset() // Manually reset internal state if required
useCaseState.invokeReset() // Manually reset internal state if required
}
ModalBottomSheetValue.HalfExpanded -> Unit

Expand All @@ -63,7 +63,7 @@ fun BottomSheetSample(
color = MaterialTheme.colorScheme.surface,
) {
CalendarView(
sheetState = dialogSheetState,
useCaseState = useCaseState,
config = CalendarConfig(
style = CalendarStyle.WEEK
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ 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.SheetState
import com.maxkeppeker.sheets.core.models.base.rememberSheetState
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 CalendarSample1(closeSelection: SheetState.() -> Unit) {
internal fun CalendarSample1(closeSelection: UseCaseState.() -> Unit) {

val selectedDates = remember { mutableStateOf<List<LocalDate>>(listOf()) }
val disabledDates = listOf(
Expand All @@ -39,7 +39,7 @@ internal fun CalendarSample1(closeSelection: SheetState.() -> Unit) {
LocalDate.now().plusDays(3),
)
CalendarDialog(
state = rememberSheetState(visible = true, onCloseRequest = { closeSelection() }),
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
config = CalendarConfig(
yearSelection = true,
monthSelection = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ 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.SheetState
import com.maxkeppeker.sheets.core.models.base.rememberSheetState
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 CalendarSample2(closeSelection: SheetState.() -> Unit) {
internal fun CalendarSample2(closeSelection: UseCaseState.() -> Unit) {

val selectedDate = remember { mutableStateOf<LocalDate?>(LocalDate.now().minusDays(3)) }

CalendarDialog(
state = rememberSheetState(visible = true, true, onCloseRequest = closeSelection),
state = rememberUseCaseState(visible = true, true, onCloseRequest = closeSelection),
config = CalendarConfig(
yearSelection = true,
style = CalendarStyle.WEEK,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ 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.SheetState
import com.maxkeppeker.sheets.core.models.base.rememberSheetState
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
Expand All @@ -32,15 +32,15 @@ import com.maxkeppeler.sheets.calendar.models.CalendarTimeline
import java.time.LocalDate

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

val selectedDateRange = remember {
val value = Range(LocalDate.now().minusDays(20), LocalDate.now().minusDays(10))
mutableStateOf(value)
}

CalendarDialog(
state = rememberSheetState(visible = true, true, onCloseRequest = closeSelection),
state = rememberUseCaseState(visible = true, true, onCloseRequest = closeSelection),
config = CalendarConfig(
disabledTimeline = CalendarTimeline.FUTURE,
style = CalendarStyle.MONTH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.clock.ClockDialog
import com.maxkeppeler.sheets.clock.models.ClockConfig
import com.maxkeppeler.sheets.clock.models.ClockSelection
Expand All @@ -32,7 +32,7 @@ internal fun ClockSample1(closeSelection: () -> Unit) {

val selectedTime = remember { mutableStateOf(LocalTime.of(23, 20, 0)) }
ClockDialog(
state = rememberSheetState(visible = true, onCloseRequest = { closeSelection() }),
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
selection = ClockSelection.HoursMinutes { hours, minutes ->
selectedTime.value = LocalTime.of(hours, minutes, 0)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.clock.ClockDialog
import com.maxkeppeler.sheets.clock.models.ClockConfig
import com.maxkeppeler.sheets.clock.models.ClockSelection
Expand All @@ -32,7 +32,7 @@ internal fun ClockSample2(closeSelection: () -> Unit) {

val selectedTime = remember { mutableStateOf<LocalTime?>(null) }
ClockDialog(
state = rememberSheetState(visible = true, onCloseRequest = { closeSelection() }),
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
selection = ClockSelection.HoursMinutesSeconds { hours, minutes, seconds ->
selectedTime.value = LocalTime.of(hours, minutes, seconds)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import com.maxkeppeker.sheets.core.models.base.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.color.ColorDialog
import com.maxkeppeler.sheets.color.models.ColorConfig
import com.maxkeppeler.sheets.color.models.ColorSelection
Expand All @@ -44,7 +44,7 @@ internal fun ColorSample1(closeSelection: () -> Unit) {
)

ColorDialog(
state = rememberSheetState(visible = true, onCloseRequest = { closeSelection() }),
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
selection = ColorSelection(
onSelectNone = { color.value = null },
onSelectColor = { color.value = it },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import com.maxkeppeker.sheets.core.models.base.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.color.ColorDialog
import com.maxkeppeler.sheets.color.models.*

Expand All @@ -42,7 +42,7 @@ internal fun ColorSample2(closeSelection: () -> Unit) {
)

ColorDialog(
state = rememberSheetState(visible = true, onCloseRequest = { closeSelection() }),
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
selection = ColorSelection(
selectedColor = SingleColor(color.value),
onSelectColor = { color.value = it },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import com.maxkeppeker.sheets.core.models.base.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.color.ColorDialog
import com.maxkeppeler.sheets.color.models.ColorConfig
import com.maxkeppeler.sheets.color.models.ColorSelection
Expand All @@ -36,7 +36,7 @@ internal fun ColorSample3(closeSelection: () -> Unit) {
val color = remember { mutableStateOf(Color.Red.toArgb()) }

ColorDialog(
state = rememberSheetState(visible = true, onCloseRequest = { closeSelection() }),
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
selection = ColorSelection(
selectedColor = SingleColor(color.value),
onSelectColor = { color.value = it },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import com.maxkeppeker.sheets.core.models.CoreSelection
import com.maxkeppeker.sheets.core.models.base.ButtonStyle
import com.maxkeppeker.sheets.core.models.base.IconSource
import com.maxkeppeker.sheets.core.models.base.SelectionButton
import com.maxkeppeker.sheets.core.models.base.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState

@Composable
internal fun CoreSample1(closeSelection: () -> Unit) {

CoreDialog(
state = rememberSheetState(visible = true, onCloseRequest = { closeSelection() }),
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
selection = CoreSelection(
withButtonView = true,
negativeButton = SelectionButton(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.date_time.DateTimeDialog
import com.maxkeppeler.sheets.date_time.models.DateTimeSelection
import java.time.LocalDateTime
Expand All @@ -31,7 +31,7 @@ internal fun DateTimeSample1(closeSelection: () -> Unit) {

val selectedDateTime = remember { mutableStateOf<LocalDateTime?>(null) }
DateTimeDialog(
state = rememberSheetState(visible = true, onCloseRequest = { closeSelection() }),
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
selection = DateTimeSelection.DateTime { newDateTime ->
selectedDateTime.value = newDateTime
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.date_time.DateTimeDialog
import com.maxkeppeler.sheets.date_time.models.DateTimeSelection
import java.time.LocalDate
Expand All @@ -31,7 +31,7 @@ internal fun DateTimeSample2(closeSelection: () -> Unit) {

val selectedDate = remember { mutableStateOf<LocalDate?>(null) }
DateTimeDialog(
state = rememberSheetState(visible = true, onCloseRequest = { closeSelection() }),
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
selection = DateTimeSelection.Date { newDate ->
selectedDate.value = newDate
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.date_time.DateTimeDialog
import com.maxkeppeler.sheets.date_time.models.DateTimeSelection
import java.time.LocalTime
Expand All @@ -31,7 +31,7 @@ internal fun DateTimeSample3(closeSelection: () -> Unit) {

val selectedTime = remember { mutableStateOf<LocalTime?>(null) }
DateTimeDialog(
state = rememberSheetState(visible = true, onCloseRequest = { closeSelection() }),
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
selection = DateTimeSelection.Time { newTime ->
selectedTime.value = newTime
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.duration.DurationDialog
import com.maxkeppeler.sheets.duration.models.DurationConfig
import com.maxkeppeler.sheets.duration.models.DurationFormat
Expand All @@ -32,7 +32,7 @@ internal fun DurationSample1(closeSelection: () -> Unit) {

val selectedTimeInSeconds = remember { mutableStateOf<Long>(240) }
DurationDialog(
state = rememberSheetState(visible = true, onCloseRequest = { closeSelection() }),
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
selection = DurationSelection { newTimeInSeconds ->
selectedTimeInSeconds.value = newTimeInSeconds
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.duration.DurationDialog
import com.maxkeppeler.sheets.duration.models.DurationConfig
import com.maxkeppeler.sheets.duration.models.DurationFormat
Expand All @@ -32,7 +32,7 @@ internal fun DurationSample2(closeSelection: () -> Unit) {

val selectedTimeInSeconds = remember { mutableStateOf<Long>(240) }
DurationDialog(
state = rememberSheetState(visible = true, onCloseRequest = { closeSelection() }),
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
selection = DurationSelection { newTimeInSeconds ->
selectedTimeInSeconds.value = newTimeInSeconds
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package com.mk.sheets.compose.samples
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import com.maxkeppeker.sheets.core.icons.LibIcons
import com.maxkeppeker.sheets.core.models.base.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.emoji.EmojiDialog
import com.maxkeppeler.sheets.emoji.models.EmojiConfig
import com.maxkeppeler.sheets.emoji.models.EmojiSelection
Expand All @@ -29,7 +29,7 @@ import com.maxkeppeler.sheets.emoji.models.EmojiSelection
internal fun EmojiSample1(closeSelection: () -> Unit) {

EmojiDialog(
state = rememberSheetState(visible = true, onCloseRequest = { closeSelection() }),
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
selection = EmojiSelection.Unicode(
onPositiveClick = { emojiUnicode ->
// Handle selection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.mk.sheets.compose.samples

import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import com.maxkeppeker.sheets.core.models.base.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.emoji.EmojiDialog
import com.maxkeppeler.sheets.emoji.models.EmojiCategoryAppearance
import com.maxkeppeler.sheets.emoji.models.EmojiConfig
Expand All @@ -30,7 +30,7 @@ import com.maxkeppeler.sheets.emoji.models.EmojiSelection
internal fun EmojiSample2(closeSelection: () -> Unit) {

EmojiDialog(
state = rememberSheetState(visible = true, onCloseRequest = { closeSelection() }),
state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() }),
selection = EmojiSelection.Unicode(
onPositiveClick = { emojiUnicode ->
// Handle selection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import com.maxkeppeker.sheets.core.models.base.rememberSheetState
import com.maxkeppeker.sheets.core.models.base.rememberUseCaseState
import com.maxkeppeler.sheets.info.InfoDialog
import com.maxkeppeler.sheets.info.models.InfoBody
import com.maxkeppeler.sheets.info.models.InfoSelection
Expand All @@ -30,7 +30,7 @@ import com.maxkeppeler.sheets.info.models.InfoSelection
internal fun InfoSample1(closeSelection: () -> Unit) {

InfoDialog(
state = rememberSheetState(
state = rememberUseCaseState(
visible = true,
onCloseRequest = { closeSelection() }),
body = InfoBody.Default(
Expand Down
Loading

0 comments on commit 0db781d

Please sign in to comment.