Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Garzas committed Mar 27, 2024
1 parent 1dd135d commit bdac706
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ private fun ConversationScreenContent(
}

@Composable
fun SnackBarMessage(
private fun SnackBarMessage(
composerMessages: SharedFlow<SnackBarMessage>,
conversationMessages: SharedFlow<SnackBarMessage>
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.hilt.navigation.compose.hiltViewModel
import com.ramcosta.composedestinations.annotation.Destination
Expand All @@ -55,23 +56,22 @@ import com.wire.android.ui.common.calculateCurrentTab
import com.wire.android.ui.common.colorsScheme
import com.wire.android.ui.common.dialogs.PermissionPermanentlyDeniedDialog
import com.wire.android.ui.common.scaffold.WireScaffold
import com.wire.android.ui.common.snackbar.LocalSnackbarHostState
import com.wire.android.ui.common.topBarElevation
import com.wire.android.ui.common.topappbar.NavigationIconType
import com.wire.android.ui.common.topappbar.WireCenterAlignedTopAppBar
import com.wire.android.ui.common.visbility.rememberVisibilityState
import com.wire.android.ui.destinations.MediaGalleryScreenDestination
import com.wire.android.ui.home.conversations.DownloadedAssetDialog
import com.wire.android.ui.home.conversations.PermissionPermanentlyDeniedDialogState
import com.wire.android.ui.home.conversations.SnackBarMessage
import com.wire.android.ui.home.conversations.messages.ConversationMessagesViewModel
import com.wire.android.ui.theme.WireTheme
import com.wire.android.ui.theme.wireDimensions
import com.wire.android.util.ui.PreviewMultipleThemes
import com.wire.kalium.logic.data.id.ConversationId
import kotlinx.collections.immutable.PersistentMap
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.launch

@RootNavGraph
Expand Down Expand Up @@ -130,10 +130,7 @@ fun ConversationMediaScreen(
hideDialog = permissionPermanentlyDeniedDialogState::dismiss
)

SnackBarMessage(
composerMessages = MutableSharedFlow<SnackBarMessage>().asSharedFlow(),
conversationMessages = conversationMessagesViewModel.infoMessage
)
SnackBarMessage(conversationMessagesViewModel.infoMessage)
}

@OptIn(ExperimentalFoundationApi::class)
Expand Down Expand Up @@ -208,6 +205,20 @@ private fun Content(
}
}

@Composable
private fun SnackBarMessage(infoMessages: SharedFlow<SnackBarMessage>) {
val context = LocalContext.current
val snackbarHostState = LocalSnackbarHostState.current

LaunchedEffect(Unit) {
infoMessages.collect {
snackbarHostState.showSnackbar(
message = it.uiText.asString(context.resources)
)
}
}
}

enum class ConversationMediaScreenTabItem(@StringRes override val titleResId: Int) : TabItem {
PICTURES(R.string.label_conversation_pictures),
FILES(R.string.label_conversation_files);
Expand Down

0 comments on commit bdac706

Please sign in to comment.