Skip to content

Commit

Permalink
feat: attachments popup [WPB-10499] (#3373)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garzas authored Aug 27, 2024
1 parent 1a8c31f commit 8fa1f4f
Show file tree
Hide file tree
Showing 27 changed files with 849 additions and 839 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.SplashScreen"
android:windowSoftInputMode="adjustResize|stateHidden">
android:windowSoftInputMode="adjustNothing|stateHidden">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ import com.wire.android.ui.theme.wireDimensions
import com.wire.android.ui.theme.wireTypography

@Composable
fun AttachmentButton(
text: String = "",
@DrawableRes icon: Int,
labelStyle: TextStyle,
modifier: Modifier = Modifier,
onClick: () -> Unit
) {
fun AttachmentButton(@DrawableRes icon: Int, labelStyle: TextStyle, modifier: Modifier = Modifier, text: String = "", onClick: () -> Unit) {
Column(
modifier = modifier
.padding(dimensions().spacing4x)
Expand Down Expand Up @@ -96,5 +90,10 @@ fun AttachmentButton(
@Preview(showBackground = true)
@Composable
fun PreviewAttachmentButton() {
AttachmentButton("Share Location", R.drawable.ic_location, MaterialTheme.wireTypography.button03) { }
AttachmentButton(
icon = R.drawable.ic_location,
labelStyle = MaterialTheme.wireTypography.button03,
modifier = Modifier,
text = "Share Location"
) { }
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.ui.text.AnnotatedString
import com.wire.android.R
import com.wire.android.ui.common.bottomsheet.WireModalSheetState
import com.wire.android.ui.common.bottomsheet.rememberWireModalSheetState
import com.wire.android.ui.common.bottomsheet.show
import com.wire.android.ui.common.snackbar.LocalSnackbarHostState
import com.wire.android.ui.home.conversations.model.UIMessage
import com.wire.kalium.logic.data.message.SelfDeletionTimer
Expand All @@ -40,19 +41,20 @@ import kotlinx.coroutines.launch
fun rememberConversationScreenState(
editSheetState: WireModalSheetState<UIMessage.Regular> = rememberWireModalSheetState<UIMessage.Regular>(),
selfDeletingSheetState: WireModalSheetState<SelfDeletionTimer> = rememberWireModalSheetState<SelfDeletionTimer>(),
locationSheetState: WireModalSheetState<Unit> = rememberWireModalSheetState(),
coroutineScope: CoroutineScope = rememberCoroutineScope()
): ConversationScreenState {
val context = LocalContext.current
val clipboardManager = LocalClipboardManager.current
val snackBarHostState = LocalSnackbarHostState.current

return remember {
ConversationScreenState(
context = context,
clipboardManager = clipboardManager,
snackBarHostState = snackBarHostState,
editSheetState = editSheetState,
selfDeletingSheetState = selfDeletingSheetState,
locationSheetState = locationSheetState,
coroutineScope = coroutineScope
)
}
Expand All @@ -65,10 +67,11 @@ class ConversationScreenState(
val snackBarHostState: SnackbarHostState,
val editSheetState: WireModalSheetState<UIMessage.Regular>,
val selfDeletingSheetState: WireModalSheetState<SelfDeletionTimer>,
val locationSheetState: WireModalSheetState<Unit>,
val coroutineScope: CoroutineScope
) {
fun showEditContextMenu(message: UIMessage.Regular) {
editSheetState.show(message)
editSheetState.show(message, hideKeyboard = true)
}

fun copyMessage(text: String) {
Expand All @@ -79,9 +82,13 @@ class ConversationScreenState(
}

fun showSelfDeletionContextMenu(currentlySelected: SelfDeletionTimer) {
selfDeletingSheetState.show(currentlySelected)
selfDeletingSheetState.show(currentlySelected, hideKeyboard = true)
}

fun showLocationSheet() {
locationSheetState.show(hideKeyboard = true)
}

val isAnySheetVisible: Boolean
get() = editSheetState.isVisible || selfDeletingSheetState.isVisible
get() = editSheetState.isVisible || selfDeletingSheetState.isVisible || locationSheetState.isVisible
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fun MessageOptionsModalSheetLayout(
onEditClick: (messageId: String, messageBody: String, mentions: List<MessageMention>) -> Unit,
onShareAssetClick: (messageId: String) -> Unit,
onDownloadAssetClick: (messageId: String) -> Unit,
onOpenAssetClick: (messageId: String) -> Unit
onOpenAssetClick: (messageId: String) -> Unit,
) {
val context = LocalContext.current
WireModalSheetLayout(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fun SearchConversationMessagesResultsScreen(
message = message,
conversationDetailsData = ConversationDetailsData.None(null),
searchQuery = searchQuery,
audioState = null,
onLongClicked = { },
onAssetMessageClicked = { },
onAudioClick = { },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.wire.android.ui.home.conversations.selfdeletion

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.wire.android.R
import com.wire.android.ui.common.bottomsheet.MenuModalSheetHeader
Expand All @@ -36,9 +37,11 @@ import com.wire.kalium.logic.data.message.SelfDeletionTimer
fun SelfDeletionOptionsModalSheetLayout(
sheetState: WireModalSheetState<SelfDeletionTimer>,
onNewSelfDeletingMessagesStatus: (SelfDeletionTimer) -> Unit,
modifier: Modifier = Modifier
) {
WireModalSheetLayout(
sheetState = sheetState,
modifier = modifier,
sheetContent = { currentlySelected ->
WireMenuModalSheetContent(
header = MenuModalSheetHeader.Visible(title = stringResource(R.string.automatically_delete_message_after)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import androidx.compose.ui.Modifier
import com.wire.android.ui.common.colorsScheme
import com.wire.android.ui.home.conversations.ConversationActionPermissionType
import com.wire.android.ui.home.conversations.model.UriAsset
import com.wire.android.ui.home.messagecomposer.location.GeoLocatedAddress
import com.wire.android.ui.home.messagecomposer.location.LocationPickerComponent
import com.wire.android.ui.home.messagecomposer.recordaudio.RecordAudioComponent
import com.wire.android.ui.home.messagecomposer.state.AdditionalOptionMenuState
import com.wire.android.ui.home.messagecomposer.state.AdditionalOptionSelectItem
Expand All @@ -46,6 +44,7 @@ fun AdditionalOptionsMenu(
conversationId: ConversationId,
additionalOptionsState: AdditionalOptionMenuState,
selectedOption: AdditionalOptionSelectItem,
attachmentsVisible: Boolean,
isEditing: Boolean,
isMentionActive: Boolean,
onAdditionalOptionsMenuClicked: () -> Unit,
Expand All @@ -65,6 +64,7 @@ fun AdditionalOptionsMenu(
AttachmentAndAdditionalOptionsMenuItems(
conversationId = conversationId,
selectedOption = selectedOption,
attachmentsVisible = attachmentsVisible,
isEditing = isEditing,
isMentionActive = isMentionActive,
onMentionButtonClicked = onMentionButtonClicked,
Expand All @@ -85,15 +85,14 @@ fun AdditionalOptionsMenu(
onCloseRichTextEditingButtonClicked = onCloseRichEditingButtonClicked
)
}

AdditionalOptionMenuState.Hidden -> {}
}
}
}

@Composable
fun AdditionalOptionSubMenu(
isFileSharingEnabled: Boolean,
optionsVisible: Boolean,
onPermissionPermanentlyDenied: (type: ConversationActionPermissionType) -> Unit,
onLocationPickerClicked: () -> Unit,
onCloseAdditionalAttachment: () -> Unit,
Expand All @@ -102,13 +101,13 @@ fun AdditionalOptionSubMenu(
onImagesPicked: (List<Uri>) -> Unit,
onAttachmentPicked: (UriAsset) -> Unit,
onAudioRecorded: (UriAsset) -> Unit,
onLocationPicked: (GeoLocatedAddress) -> Unit,
tempWritableImageUri: Uri?,
tempWritableVideoUri: Uri?,
modifier: Modifier = Modifier,
) {
Box(modifier = modifier) {
AttachmentOptionsComponent(
modifier = modifier,
optionsVisible = optionsVisible,
onImagesPicked = onImagesPicked,
onAttachmentPicked = onAttachmentPicked,
tempWritableImageUri = tempWritableImageUri,
Expand All @@ -119,36 +118,23 @@ fun AdditionalOptionSubMenu(
onPermissionPermanentlyDenied = onPermissionPermanentlyDenied,
)
when (additionalOptionsState) {
AdditionalOptionSubMenuState.AttachFile -> {
/* DO NOTHING, ALREADY DISPLAYED AS PARENT */
}
AdditionalOptionSubMenuState.Default -> {}

AdditionalOptionSubMenuState.RecordAudio -> {
RecordAudioComponent(
onAudioRecorded = onAudioRecorded,
onCloseRecordAudio = onCloseAdditionalAttachment
)
}

AdditionalOptionSubMenuState.Location -> {
LocationPickerComponent(
onLocationPicked = onLocationPicked,
onLocationClosed = onCloseAdditionalAttachment
)
}
// non functional for now
AdditionalOptionSubMenuState.AttachImage -> {}
AdditionalOptionSubMenuState.Emoji -> {}
AdditionalOptionSubMenuState.Gif -> {}
}
}
}

@Composable
fun AttachmentAndAdditionalOptionsMenuItems(
conversationId: ConversationId,
isEditing: Boolean,
selectedOption: AdditionalOptionSelectItem,
attachmentsVisible: Boolean,
isMentionActive: Boolean,
onMentionButtonClicked: () -> Unit,
onSelfDeletionOptionButtonClicked: (SelfDeletionTimer) -> Unit,
Expand All @@ -164,6 +150,7 @@ fun AttachmentAndAdditionalOptionsMenuItems(
MessageComposeActions(
conversationId = conversationId,
isEditing = isEditing,
attachmentsVisible = attachmentsVisible,
selectedOption = selectedOption,
isMentionActive = isMentionActive,
onMentionButtonClicked = onMentionButtonClicked,
Expand Down
Loading

0 comments on commit 8fa1f4f

Please sign in to comment.