diff --git a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationScreen.kt b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationScreen.kt index 89abe704c9066450494cfac6b810d00a0485403a..0826283aa4b79519d97e93bf63d1f80c1d697cbe 100644 --- a/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationScreen.kt +++ b/briar-desktop/src/main/kotlin/org/briarproject/briar/desktop/conversation/ConversationScreen.kt @@ -18,20 +18,9 @@ package org.briarproject.briar.desktop.conversation -import androidx.compose.animation.core.animateDpAsState -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.interaction.MutableInteractionSource -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxWithConstraints -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.offset -import androidx.compose.foundation.layout.requiredSize -import androidx.compose.foundation.layout.width import androidx.compose.material.ExperimentalMaterialApi -import androidx.compose.material.MaterialTheme import androidx.compose.material.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect @@ -39,15 +28,11 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp import org.briarproject.bramble.api.contact.ContactId import org.briarproject.briar.desktop.contact.ContactInfoDrawer import org.briarproject.briar.desktop.contact.ContactInfoDrawerState -import org.briarproject.briar.desktop.navigation.SIDEBAR_WIDTH -import org.briarproject.briar.desktop.theme.surfaceVariant -import org.briarproject.briar.desktop.ui.Constants.COLUMN_WIDTH import org.briarproject.briar.desktop.ui.Loader +import org.briarproject.briar.desktop.ui.getInfoDrawerHandler import org.briarproject.briar.desktop.viewmodel.viewModel @OptIn(ExperimentalMaterialApi::class) @@ -67,20 +52,32 @@ fun ConversationScreen( return } - val (infoDrawer, setInfoDrawer) = remember { mutableStateOf(false) } - val (contactDrawerState, setDrawerState) = remember { mutableStateOf(ContactInfoDrawerState.MakeIntro) } + val infoDrawerHandler = getInfoDrawerHandler() + val (deleteAllMessagesDialogVisible, setDeleteAllMessagesDialog) = remember { mutableStateOf(false) } val (changeAliasDialogVisible, setChangeAliasDialog) = remember { mutableStateOf(false) } val (deleteContactDialogVisible, setDeleteContactDialog) = remember { mutableStateOf(false) } BoxWithConstraints(Modifier.fillMaxSize()) { - val animatedInfoDrawerOffsetX by animateDpAsState(if (infoDrawer) (-275).dp else 0.dp) Scaffold( topBar = { ConversationHeader( contactItem, onMakeIntroduction = { - setInfoDrawer(true) + infoDrawerHandler.open { + ContactInfoDrawer( + contactItem, + closeInfoDrawer = { reload -> + infoDrawerHandler.close() + if (reload) { + // reload all messages to also show introduction message + // todo: might be better to have an event to react to, also for (all) outgoing messages + viewModel.reloadMessages() + } + }, + ContactInfoDrawerState.MakeIntro + ) + } }, onDeleteAllMessages = { setDeleteAllMessagesDialog(true) @@ -120,38 +117,6 @@ fun ConversationScreen( }, ) - if (infoDrawer) { - // TODO Find non-hacky way of setting scrim on entire app - Box( - Modifier.offset(-(COLUMN_WIDTH + SIDEBAR_WIDTH)) - .requiredSize(maxWidth + COLUMN_WIDTH + SIDEBAR_WIDTH, maxHeight) - .background(Color(0, 0, 0, 100)) - .clickable( - // prevent visual indication - interactionSource = remember { MutableInteractionSource() }, - indication = null - ) { setInfoDrawer(false) } - ) - Column( - modifier = Modifier.fillMaxHeight().width(COLUMN_WIDTH) - .offset(maxWidth + animatedInfoDrawerOffsetX) - .background(MaterialTheme.colors.surfaceVariant) - ) { - ContactInfoDrawer( - contactItem, - closeInfoDrawer = { reload -> - setInfoDrawer(false) - if (reload) { - // reload all messages to also show introduction message - // todo: might be better to have an event to react to, also for (all) outgoing messages - viewModel.reloadMessages() - } - }, - contactDrawerState - ) - } - } - DeleteAllMessagesConfirmationDialog( isVisible = deleteAllMessagesDialogVisible, close = { setDeleteAllMessagesDialog(false) },