feature(space) : prepare LeaveSpace for navigation to Roles&Permissions
This commit is contained in:
parent
389c2f3452
commit
fd980cf5bd
4 changed files with 38 additions and 8 deletions
|
|
@ -82,7 +82,16 @@ class SpaceFlowNode(
|
|||
override fun resolve(navTarget: NavTarget, buildContext: BuildContext): Node {
|
||||
return when (navTarget) {
|
||||
NavTarget.Leave -> {
|
||||
createNode<LeaveSpaceNode>(buildContext)
|
||||
val callback = object : LeaveSpaceNode.Callback {
|
||||
override fun closeLeaveSpaceFlow() {
|
||||
backstack.pop()
|
||||
}
|
||||
|
||||
override fun navigateToRolesAndPermissions() {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
createNode<LeaveSpaceNode>(buildContext, listOf(callback))
|
||||
}
|
||||
NavTarget.Root -> {
|
||||
val callback = object : SpaceNode.Callback {
|
||||
|
|
@ -111,7 +120,7 @@ class SpaceFlowNode(
|
|||
}
|
||||
|
||||
override fun navigateToSpaceInfo() {
|
||||
//TODO
|
||||
// TODO
|
||||
}
|
||||
|
||||
override fun navigateToSpaceMembers() {
|
||||
|
|
@ -119,11 +128,11 @@ class SpaceFlowNode(
|
|||
}
|
||||
|
||||
override fun navigateToRolesAndPermissions() {
|
||||
//TODO
|
||||
// TODO
|
||||
}
|
||||
|
||||
override fun navigateToSecurityAndPrivacy() {
|
||||
//TODO
|
||||
// TODO
|
||||
}
|
||||
|
||||
override fun startLeaveSpaceFlow() {
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.bumble.appyx.core.lifecycle.subscribe
|
|||
import com.bumble.appyx.core.modality.BuildContext
|
||||
import com.bumble.appyx.core.node.Node
|
||||
import com.bumble.appyx.core.plugin.Plugin
|
||||
import com.bumble.appyx.core.plugin.plugins
|
||||
import dev.zacsweers.metro.Assisted
|
||||
import dev.zacsweers.metro.AssistedInject
|
||||
import io.element.android.annotations.ContributesNode
|
||||
|
|
@ -29,9 +30,16 @@ class LeaveSpaceNode(
|
|||
room: JoinedRoom,
|
||||
presenterFactory: LeaveSpacePresenter.Factory,
|
||||
) : Node(buildContext, plugins = plugins) {
|
||||
interface Callback : Plugin {
|
||||
fun closeLeaveSpaceFlow()
|
||||
fun navigateToRolesAndPermissions()
|
||||
}
|
||||
|
||||
private val leaveSpaceHandle = matrixClient.spaceService.getLeaveSpaceHandle(room.roomId)
|
||||
private val presenter: LeaveSpacePresenter = presenterFactory.create(leaveSpaceHandle)
|
||||
|
||||
private val callback = plugins<Callback>().single()
|
||||
|
||||
override fun onBuilt() {
|
||||
super.onBuilt()
|
||||
lifecycle.subscribe(
|
||||
|
|
@ -46,7 +54,8 @@ class LeaveSpaceNode(
|
|||
val state = presenter.present()
|
||||
LeaveSpaceView(
|
||||
state = state,
|
||||
onCancel = ::navigateUp,
|
||||
onCancel = callback::closeLeaveSpaceFlow,
|
||||
onRolesAndPermissionsClick = callback::navigateToRolesAndPermissions,
|
||||
modifier = modifier
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ import io.element.android.libraries.ui.strings.CommonStrings
|
|||
fun LeaveSpaceView(
|
||||
state: LeaveSpaceState,
|
||||
onCancel: () -> Unit,
|
||||
onRolesAndPermissionsClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Scaffold(
|
||||
|
|
@ -130,6 +131,9 @@ fun LeaveSpaceView(
|
|||
state.eventSink(LeaveSpaceEvents.LeaveSpace)
|
||||
},
|
||||
onCancel = onCancel,
|
||||
// TODO enable when navigation is ready
|
||||
showRolesAndPermissionsButton = false, // state.isLastAdmin,
|
||||
onRolesAndPermissionsClick = onRolesAndPermissionsClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -210,6 +214,8 @@ private fun LeaveSpaceButtons(
|
|||
showLeaveButton: Boolean,
|
||||
selectedRoomsCount: Int,
|
||||
onLeaveSpace: () -> Unit,
|
||||
showRolesAndPermissionsButton: Boolean,
|
||||
onRolesAndPermissionsClick: () -> Unit,
|
||||
onCancel: () -> Unit,
|
||||
) {
|
||||
ButtonColumnMolecule(
|
||||
|
|
@ -229,8 +235,14 @@ private fun LeaveSpaceButtons(
|
|||
destructive = true,
|
||||
)
|
||||
}
|
||||
// TODO For least admin space, add a button to open the settings.
|
||||
// See https://www.figma.com/design/kcnHxunG1LDWXsJhaNuiHz/ER-145--Spaces-on-Element-X?node-id=4622-59600
|
||||
if (showRolesAndPermissionsButton) {
|
||||
Button(
|
||||
text = stringResource(CommonStrings.action_go_to_roles_and_permissions),
|
||||
onClick = onRolesAndPermissionsClick,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
leadingIcon = IconSource.Vector(CompoundIcons.Settings()),
|
||||
)
|
||||
}
|
||||
TextButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
text = stringResource(CommonStrings.action_cancel),
|
||||
|
|
@ -345,5 +357,6 @@ internal fun LeaveSpaceViewPreview(
|
|||
LeaveSpaceView(
|
||||
state = state,
|
||||
onCancel = {},
|
||||
onRolesAndPermissionsClick = {},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ fun SpaceSettingsView(
|
|||
onClick = onLeaveSpaceClick
|
||||
)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue