mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3278 Navigation | Fix | Share/members button must look like a 'share' button and be inaccessible in Entry space (#2080)
This commit is contained in:
parent
258b705c79
commit
b97e9d9b85
3 changed files with 37 additions and 14 deletions
|
@ -174,18 +174,25 @@ fun BottomNavigationMenu(
|
|||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
if (state is NavPanelState.Default) {
|
||||
when (state.leftButtonState) {
|
||||
when (val left = state.leftButtonState) {
|
||||
is NavPanelState.LeftButtonState.AddMembers -> {
|
||||
MenuItem(
|
||||
modifier = Modifier
|
||||
.width(72.dp)
|
||||
.height(52.dp),
|
||||
.height(52.dp)
|
||||
.alpha(
|
||||
if (left.isActive)
|
||||
FULL_ALPHA
|
||||
else
|
||||
DEFAULT_DISABLED_ALPHA
|
||||
)
|
||||
,
|
||||
contentDescription = stringResource(id = R.string.main_navigation_content_desc_members_button),
|
||||
res = BottomNavigationItem.ADD_MEMBERS.res,
|
||||
onClick = onShareButtonClicked
|
||||
onClick = onShareButtonClicked,
|
||||
enabled = left.isActive
|
||||
)
|
||||
}
|
||||
|
||||
is NavPanelState.LeftButtonState.Comment -> {
|
||||
// TODO
|
||||
}
|
||||
|
|
|
@ -368,15 +368,29 @@ class HomeScreenViewModel(
|
|||
|
||||
private fun proceedWithNavPanelState() {
|
||||
viewModelScope.launch {
|
||||
userPermissions
|
||||
.map { permission ->
|
||||
NavPanelState.fromPermission(
|
||||
permission = permission,
|
||||
forceHome = false
|
||||
)
|
||||
}.collect {
|
||||
navPanelState.value = it
|
||||
val spaceAccessType = views
|
||||
.map {
|
||||
val space = it.firstOrNull { it is WidgetView.SpaceWidget.View }
|
||||
if (space is WidgetView.SpaceWidget.View) {
|
||||
space.space
|
||||
.spaceAccessType
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
.distinctUntilChanged()
|
||||
combine(
|
||||
spaceAccessType,
|
||||
userPermissions
|
||||
) { type, permission ->
|
||||
NavPanelState.fromPermission(
|
||||
permission = permission,
|
||||
forceHome = false,
|
||||
spaceAccessType = type
|
||||
)
|
||||
}.collect {
|
||||
navPanelState.value = it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.anytypeio.anytype.analytics.base.EventsDictionary
|
|||
import com.anytypeio.anytype.analytics.base.EventsPropertiesKey
|
||||
import com.anytypeio.anytype.analytics.base.sendEvent
|
||||
import com.anytypeio.anytype.analytics.props.Props
|
||||
import com.anytypeio.anytype.core_models.multiplayer.SpaceAccessType
|
||||
import com.anytypeio.anytype.core_models.multiplayer.SpaceMemberPermissions
|
||||
|
||||
sealed class NavPanelState {
|
||||
|
@ -26,7 +27,8 @@ sealed class NavPanelState {
|
|||
companion object {
|
||||
fun fromPermission(
|
||||
permission: SpaceMemberPermissions?,
|
||||
forceHome: Boolean = true
|
||||
forceHome: Boolean = true,
|
||||
spaceAccessType: SpaceAccessType? = null
|
||||
) : NavPanelState {
|
||||
return when(permission) {
|
||||
SpaceMemberPermissions.READER -> {
|
||||
|
@ -54,7 +56,7 @@ sealed class NavPanelState {
|
|||
LeftButtonState.Home
|
||||
else
|
||||
LeftButtonState.AddMembers(
|
||||
isActive = true
|
||||
isActive = spaceAccessType != SpaceAccessType.DEFAULT
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue