Closed russellbanks closed 1 year ago
Which event would trigger the selection then if the button view is not wanted for the views, via a separate invocation to trigger it via the use-case state?
Which event would trigger the selection then if the button view is not wanted for the views, via a separate invocation to trigger it via the use-case state?
Yes, a separate invocation via the use-case state would work.
Great issue and a change I welcome much as well. I will work on this sometime within the next two weeks when I can find time.
Here's an example:
val selectedTimeInSeconds = remember { mutableStateOf<Long>(240) }
val state = rememberUseCaseState(visible = true, onCloseRequest = { closeSelection() })
DurationDialog(
state = state,
selection = DurationSelection(
withButtonView = false,
) { newTimeInSeconds ->
selectedTimeInSeconds.value = newTimeInSeconds
},
config = DurationConfig(
timeFormat = DurationFormat.HH_MM_SS,
currentTime = selectedTimeInSeconds.value,
),
)
val coroutineScope = rememberCoroutineScope()
coroutineScope.launch {
delay(5000)
state.invokePositiveAction()
Log.d("DurationSample1", "DurationSample1: ${selectedTimeInSeconds.value}")
}
@maxkeppeler onPositiveClick is still a required option even though there can be no buttons now.
InfoView(
useCaseState = rememberUseCaseState(),
selection = InfoSelection(withButtonView = false)
)
No value passed for parameter 'onPositiveClick'
It's often the case that buttons are not needed at all. For example, bottom sheets already have a convenient way to dismiss them, so a positive button is not needed. Using the view (InfoView, etc) counterparts have more use cases of not needing a button such as providing buttons elsewhere or using animations.
Providing
withButtonView
across all dialogs would be good, or allowing the positive button to be null.Use case 1:
I want my own button so that I can animate it
Use case 2:
This is a bottom sheet only for information so I don't need any buttons. The user can just swipe it away