Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Provide withButtonView across all views/dialogs #50

Closed
russellbanks opened this issue May 3, 2023 · 5 comments
Closed

[Feature] Provide withButtonView across all views/dialogs #50

russellbanks opened this issue May 3, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@russellbanks
Copy link

russellbanks commented May 3, 2023

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

studio64_Q3LdExE2z2

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

studio64_TbJ9e0yYfk

@russellbanks russellbanks changed the title [Feature] Allow Positive Button to be nullable [Feature] Allow Positive Button to be null May 4, 2023
@russellbanks russellbanks changed the title [Feature] Allow Positive Button to be null [Feature] Provide withButtonView across all views/dialogs May 5, 2023
@maxkeppeler
Copy link
Owner

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?

@russellbanks
Copy link
Author

russellbanks commented May 8, 2023

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.

@maxkeppeler
Copy link
Owner

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.

@maxkeppeler maxkeppeler self-assigned this May 9, 2023
@maxkeppeler maxkeppeler added the enhancement New feature or request label May 9, 2023
@maxkeppeler
Copy link
Owner

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

@russellbanks
Copy link
Author

@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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants