-
Notifications
You must be signed in to change notification settings - Fork 7
Add action rows #76
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
Add action rows #76
Conversation
|
This PR is not ready yet. As of right now I have added |
|
I've added Adw.ActionRow but I couldn't find a nice way to set activatable widget. Maybe a |
|
I was thinking maybe we could add a |
lib/src/main/kotlin/io/github/compose4gtk/adw/components/ActionRow.kt
Outdated
Show resolved
Hide resolved
|
|
||
| children.forEach { child -> | ||
| widget.addPrefix(child) | ||
| widget.activatableWidget = child |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand. Is activatableWidget always the last children?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made it so the last inserted widget is the activatable one because I couldn't think of a better way to handle activatable widget right now.
|
About the issue with the active state, I am not familiar with the problem enough. Can you give me an example of an use case for |
|
Basically, an ActionRow is activated when you click on it and when there is something to activate. For example, when you click on a SwitchRow it activates the switch. If I click directly on the switch it does not count as an activation for the SwitchRow. Screencast.From.2025-07-19.16-05-20.mp4The problem I have with ActionRow is that there can be multiple widgets that are activatable like buttons. When this is the case we need to select which of these widgets will activate once you click on the ActionRow itself. (clicking on an individual widget will activate it like any other button) This is why the Adw widget provides the ActionRow(
title = "Toast",
subtitle = "Launches a toast",
prefix = {
Activatable {
IconButton(
ImageSource.Icon("bread-symbolic"),
modifier = Modifier.alignment(Align.CENTER),
onClick = {
logger.info { "Launch a toast" }
val toast = Toast().apply {
title = "A toast"
}
dismissAllToasts()
addToast(toast)
},
)
}
}
suffix = {
IconButton(
ImageSource.Icon("bread-symbolic"),
modifier = Modifier.alignment(Align.CENTER),
onClick = {
logger.info { "Launch a toast" }
val toast = Toast().apply {
title = "A toast"
}
dismissAllToasts()
addToast(toast)
},
)
},
)Where suffix and prefix expose and Activatable function that takes a composable function as parameter and makes that widget the activatable one. Let me know what you think. I have made all the other requested changes. And thank you for taking the time to help me with this! |
|
Got it. What about, instead of adding the That way, the widget can be set using the Modifier? |
|
Tell me what you think of this new commit. I added a modifier only accessible by the children of prefix and suffix. |
lib/src/main/kotlin/io/github/compose4gtk/adw/components/ActionRow.kt
Outdated
Show resolved
Hide resolved
lib/src/main/kotlin/io/github/compose4gtk/adw/components/ActionRow.kt
Outdated
Show resolved
Hide resolved
| ) | ||
| } | ||
|
|
||
| private class AdwActionRowSlotContainer(actionRow: AdwActionRow, private val slot: ActionRowSlot) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an alternative to slot, you could pass a lambda that does addPrefix / addSuffix.
But this works too
lib/src/main/kotlin/io/github/compose4gtk/adw/components/ActionRow.kt
Outdated
Show resolved
Hide resolved
lib/src/main/kotlin/io/github/compose4gtk/adw/components/ActionRow.kt
Outdated
Show resolved
Hide resolved
lib/src/main/kotlin/io/github/compose4gtk/adw/components/ActionRow.kt
Outdated
Show resolved
Hide resolved
|
Changes LGTM, thanks! The PR is still marked as draft. LMK if you want to make further changes, otherwise I can merge it |
|
Can this be merged now? |
|
Yes its all good on my side |
|
I added the last child of ActionRow (SpinRow). |
|
I think |
|
Yes, but EntryRow is not a child of ActionRow. I will create another PR for it. |
|
Thanks! Merged |
Adds
PreferencesGroupand every child ofAdw.ActionRow.