Skip to content

Commit

Permalink
fix: conv admin for unconnected user [WPB-3043] (#1955)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garzas authored and github-actions[bot] committed Jul 18, 2023
1 parent a44c67b commit 848290b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ package com.wire.android.ui.userprofile.other

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.material3.MaterialTheme
Expand All @@ -35,7 +33,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.wire.android.R
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.home.conversationslist.model.Membership
Expand All @@ -52,27 +49,31 @@ fun OtherUserConnectionStatusInfo(connectionStatus: ConnectionState, membership:
.padding(start = dimensions().spacing32x, end = dimensions().spacing32x)
) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
if (connectionStatus == ConnectionState.PENDING)
if (connectionStatus == ConnectionState.PENDING) {
Text(
text = stringResource(R.string.connection_label_user_wants_to_conect),
textAlign = TextAlign.Center,
color = MaterialTheme.wireColorScheme.onSurface,
style = MaterialTheme.wireTypography.title02
)
Spacer(modifier = Modifier.height(24.dp))
}
val descriptionResource = when (connectionStatus) {
ConnectionState.PENDING, ConnectionState.IGNORED -> R.string.connection_label_accepting_request_description
ConnectionState.ACCEPTED -> throw IllegalStateException("Unhandled Connected ConnectionStatus")
else -> if (membership == Membership.None)
ConnectionState.ACCEPTED, ConnectionState.BLOCKED -> null
else -> if (membership == Membership.None) {
R.string.connection_label_member_not_conneted
else R.string.connection_label_member_not_belongs_to_team
} else {
R.string.connection_label_member_not_belongs_to_team
}
}
descriptionResource?.let {
Text(
text = stringResource(it),
textAlign = TextAlign.Center,
color = MaterialTheme.wireColorScheme.labelText,
style = MaterialTheme.wireTypography.body01
)
}
Text(
text = stringResource(descriptionResource),
textAlign = TextAlign.Center,
color = MaterialTheme.wireColorScheme.labelText,
style = MaterialTheme.wireTypography.body01
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import androidx.compose.animation.fadeOut
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.LocalOverscrollConfiguration
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
Expand Down Expand Up @@ -76,6 +77,7 @@ import com.wire.android.ui.common.dialogs.UnblockUserDialogContent
import com.wire.android.ui.common.dialogs.UnblockUserDialogState
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.common.snackbar.SwipeDismissSnackbarHost
import com.wire.android.ui.common.spacers.VerticalSpace.x24
import com.wire.android.ui.common.topBarElevation
import com.wire.android.ui.common.topappbar.WireCenterAlignedTopAppBar
import com.wire.android.ui.common.visbility.rememberVisibilityState
Expand Down Expand Up @@ -374,43 +376,55 @@ private fun Content(
getOtherUserClients: () -> Unit,
onDeviceClick: (Device) -> Unit
) {

Crossfade(targetState = tabItems to state) { (tabItems, state) ->
when {
state.isDataLoading || state.botService != null -> Box {} // no content visible while loading
state.connectionState == ConnectionState.ACCEPTED ->
CompositionLocalProvider(LocalOverscrollConfiguration provides null) {
HorizontalPager(
modifier = Modifier.fillMaxSize(),
state = pagerState,
count = tabItems.size
) { pageIndex ->
when (val tabItem = tabItems[pageIndex]) {
OtherUserProfileTabItem.DETAILS ->
OtherUserProfileDetails(state, otherUserProfileScreenState, lazyListStates[tabItem]!!)
Column {
OtherUserConnectionStatusInfo(state.connectionState, state.membership)
x24()
when {
state.isDataLoading || state.botService != null -> Box {} // no content visible while loading
state.connectionState == ConnectionState.ACCEPTED -> {
CompositionLocalProvider(LocalOverscrollConfiguration provides null) {
HorizontalPager(
modifier = Modifier.fillMaxSize(),
state = pagerState,
count = tabItems.size
) { pageIndex ->
when (val tabItem = tabItems[pageIndex]) {
OtherUserProfileTabItem.DETAILS ->
OtherUserProfileDetails(state, otherUserProfileScreenState, lazyListStates[tabItem]!!)

OtherUserProfileTabItem.GROUP ->
OtherUserProfileGroup(
state,
lazyListStates[tabItem]!!,
openRemoveConversationMemberDialog,
openChangeRoleBottomSheet
)
OtherUserProfileTabItem.GROUP ->
OtherUserProfileGroup(
state,
lazyListStates[tabItem]!!,
openRemoveConversationMemberDialog,
openChangeRoleBottomSheet
)

OtherUserProfileTabItem.DEVICES -> {
getOtherUserClients()
OtherUserDevicesScreen(
lazyListState = lazyListStates[tabItem]!!,
state = state,
onDeviceClick = onDeviceClick
)
OtherUserProfileTabItem.DEVICES -> {
getOtherUserClients()
OtherUserDevicesScreen(
lazyListState = lazyListStates[tabItem]!!,
state = state,
onDeviceClick = onDeviceClick
)
}
}
}
}
}

state.connectionState == ConnectionState.BLOCKED -> Box {} // no content visible for blocked users
else -> {
OtherUserConnectionStatusInfo(state.connectionState, state.membership)
state.groupState != null -> {
OtherUserProfileGroup(
state,
lazyListStates[OtherUserProfileTabItem.DETAILS]!!,
openRemoveConversationMemberDialog,
openChangeRoleBottomSheet
)
}

else -> Box {}
}
}
}
Expand Down

0 comments on commit 848290b

Please sign in to comment.