Browse Source

Pinned events : add the glue for the ViewAll click.

pull/3275/head
ganfra 2 months ago
parent
commit
9d2e35db0d
  1. 6
      features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesFlowNode.kt
  2. 6
      features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesNode.kt
  3. 10
      features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt
  4. 72
      features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/pinned/banner/PinnedMessagesBannerView.kt
  5. 3
      features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/typing/MessagesViewWithTypingPreview.kt
  6. 2
      features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/MessagesViewTest.kt

6
features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesFlowNode.kt

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
package io.element.android.features.messages.impl
import android.os.Parcelable
import android.widget.Toast
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
@ -81,6 +82,7 @@ import kotlinx.collections.immutable.ImmutableList @@ -81,6 +82,7 @@ import kotlinx.collections.immutable.ImmutableList
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.parcelize.Parcelize
import timber.log.Timber
@ContributesNode(RoomScope::class)
class MessagesFlowNode @AssistedInject constructor(
@ -217,6 +219,10 @@ class MessagesFlowNode @AssistedInject constructor( @@ -217,6 +219,10 @@ class MessagesFlowNode @AssistedInject constructor(
analyticsService.captureInteraction(Interaction.Name.MobileRoomCallButton)
elementCallEntryPoint.startCall(callType)
}
override fun onViewAllPinnedEvents() {
Timber.d("On View All Pinned Events not implemented yet.")
}
}
val inputs = MessagesNode.Inputs(
focusedEventId = inputs.focusedEventId,

6
features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesNode.kt

@ -97,6 +97,7 @@ class MessagesNode @AssistedInject constructor( @@ -97,6 +97,7 @@ class MessagesNode @AssistedInject constructor(
fun onCreatePollClick()
fun onEditPollClick(eventId: EventId)
fun onJoinCallClick(roomId: RoomId)
fun onViewAllPinnedEvents()
}
override fun onBuilt() {
@ -185,6 +186,10 @@ class MessagesNode @AssistedInject constructor( @@ -185,6 +186,10 @@ class MessagesNode @AssistedInject constructor(
callbacks.forEach { it.onEditPollClick(eventId) }
}
private fun onViewAllPinnedMessagesClick() {
callbacks.forEach { it.onViewAllPinnedEvents() }
}
private fun onSendLocationClick() {
callbacks.forEach { it.onSendLocationClick() }
}
@ -221,6 +226,7 @@ class MessagesNode @AssistedInject constructor( @@ -221,6 +226,7 @@ class MessagesNode @AssistedInject constructor(
onSendLocationClick = this::onSendLocationClick,
onCreatePollClick = this::onCreatePollClick,
onJoinCallClick = this::onJoinCallClick,
onViewAllPinnedMessagesClick = this::onViewAllPinnedMessagesClick,
modifier = modifier,
)

10
features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/MessagesView.kt

@ -73,7 +73,6 @@ import io.element.android.features.messages.impl.messagecomposer.AttachmentsStat @@ -73,7 +73,6 @@ import io.element.android.features.messages.impl.messagecomposer.AttachmentsStat
import io.element.android.features.messages.impl.messagecomposer.MessageComposerEvents
import io.element.android.features.messages.impl.messagecomposer.MessageComposerView
import io.element.android.features.messages.impl.pinned.banner.PinnedMessagesBannerView
import io.element.android.features.messages.impl.timeline.TimelineEvents
import io.element.android.features.messages.impl.timeline.TimelineView
import io.element.android.features.messages.impl.timeline.components.JoinCallMenuItem
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionBottomSheet
@ -127,8 +126,9 @@ fun MessagesView( @@ -127,8 +126,9 @@ fun MessagesView(
onSendLocationClick: () -> Unit,
onCreatePollClick: () -> Unit,
onJoinCallClick: () -> Unit,
onViewAllPinnedMessagesClick: () -> Unit,
modifier: Modifier = Modifier,
forceJumpToBottomVisibility: Boolean = false
forceJumpToBottomVisibility: Boolean = false,
) {
OnLifecycleEvent { _, event ->
state.voiceMessageComposerState.eventSink(VoiceMessageComposerEvents.LifecycleEvent(event))
@ -229,6 +229,7 @@ fun MessagesView( @@ -229,6 +229,7 @@ fun MessagesView(
},
forceJumpToBottomVisibility = forceJumpToBottomVisibility,
onJoinCallClick = onJoinCallClick,
onViewAllPinnedMessagesClick = onViewAllPinnedMessagesClick,
)
},
snackbarHost = {
@ -320,6 +321,7 @@ private fun MessagesViewContent( @@ -320,6 +321,7 @@ private fun MessagesViewContent(
onSendLocationClick: () -> Unit,
onCreatePollClick: () -> Unit,
onJoinCallClick: () -> Unit,
onViewAllPinnedMessagesClick: () -> Unit,
forceJumpToBottomVisibility: Boolean,
modifier: Modifier = Modifier,
onSwipeToReply: (TimelineItem.Event) -> Unit,
@ -405,6 +407,7 @@ private fun MessagesViewContent( @@ -405,6 +407,7 @@ private fun MessagesViewContent(
onClick = { pinnedEventId ->
//state.timelineState.eventSink(TimelineEvents.FocusOnEvent(pinnedEventId))
},
onViewAllClick = onViewAllPinnedMessagesClick,
)
}
}
@ -576,12 +579,13 @@ internal fun MessagesViewPreview(@PreviewParameter(MessagesStateProvider::class) @@ -576,12 +579,13 @@ internal fun MessagesViewPreview(@PreviewParameter(MessagesStateProvider::class)
onBackClick = {},
onRoomDetailsClick = {},
onEventClick = { false },
onPreviewAttachments = {},
onUserDataClick = {},
onLinkClick = {},
onPreviewAttachments = {},
onSendLocationClick = {},
onCreatePollClick = {},
onJoinCallClick = {},
onViewAllPinnedMessagesClick = { },
forceJumpToBottomVisibility = true,
)
}

72
features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/pinned/banner/PinnedMessagesBannerView.kt

@ -62,6 +62,7 @@ import io.element.android.libraries.ui.strings.CommonStrings @@ -62,6 +62,7 @@ import io.element.android.libraries.ui.strings.CommonStrings
fun PinnedMessagesBannerView(
state: PinnedMessagesBannerState,
onClick: (EventId) -> Unit,
onViewAllClick: () -> Unit,
modifier: Modifier = Modifier,
) {
if (state.currentPinnedMessage == null) return
@ -69,30 +70,30 @@ fun PinnedMessagesBannerView( @@ -69,30 +70,30 @@ fun PinnedMessagesBannerView(
val borderColor = ElementTheme.colors.pinnedMessageBannerBorder
Row(
modifier = modifier
.background(color = ElementTheme.colors.bgCanvasDefault)
.fillMaxWidth()
.drawBehind {
val strokeWidth = 0.5.dp.toPx()
val y = size.height - strokeWidth / 2
drawLine(
borderColor,
Offset(0f, y),
Offset(size.width, y),
strokeWidth
)
drawLine(
borderColor,
Offset(0f, 0f),
Offset(size.width, 0f),
strokeWidth
)
}
.shadow(elevation = 5.dp, spotColor = Color.Transparent)
.heightIn(min = 64.dp)
.clickable {
onClick(state.currentPinnedMessage.eventId)
state.eventSink(PinnedMessagesBannerEvents.MoveToNextPinned)
},
.background(color = ElementTheme.colors.bgCanvasDefault)
.fillMaxWidth()
.drawBehind {
val strokeWidth = 0.5.dp.toPx()
val y = size.height - strokeWidth / 2
drawLine(
borderColor,
Offset(0f, y),
Offset(size.width, y),
strokeWidth
)
drawLine(
borderColor,
Offset(0f, 0f),
Offset(size.width, 0f),
strokeWidth
)
}
.shadow(elevation = 5.dp, spotColor = Color.Transparent)
.heightIn(min = 64.dp)
.clickable {
onClick(state.currentPinnedMessage.eventId)
state.eventSink(PinnedMessagesBannerEvents.MoveToNextPinned)
},
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = spacedBy(10.dp)
) {
@ -114,7 +115,7 @@ fun PinnedMessagesBannerView( @@ -114,7 +115,7 @@ fun PinnedMessagesBannerView(
message = state.currentPinnedMessage.formatted,
modifier = Modifier.weight(1f)
)
TextButton(text = stringResource(id = CommonStrings.screen_room_pinned_banner_view_all_button_title), onClick = { /*TODO*/ })
TextButton(text = stringResource(id = CommonStrings.screen_room_pinned_banner_view_all_button_title), onClick = onViewAllClick)
}
}
@ -150,15 +151,15 @@ private fun PinIndicators( @@ -150,15 +151,15 @@ private fun PinIndicators(
items(pinsCount) { index ->
Box(
modifier = Modifier
.width(2.dp)
.height(indicatorHeight.dp)
.background(
color = if (index == pinIndex) {
ElementTheme.colors.iconAccentPrimary
} else {
ElementTheme.colors.pinnedMessageBannerIndicator
}
)
.width(2.dp)
.height(indicatorHeight.dp)
.background(
color = if (index == pinIndex) {
ElementTheme.colors.iconAccentPrimary
} else {
ElementTheme.colors.pinnedMessageBannerIndicator
}
)
)
}
}
@ -174,7 +175,7 @@ private fun PinnedMessageItem( @@ -174,7 +175,7 @@ private fun PinnedMessageItem(
val countMessage = stringResource(id = CommonStrings.screen_room_pinned_banner_indicator, index + 1, totalCount)
val fullCountMessage = stringResource(id = CommonStrings.screen_room_pinned_banner_indicator_description, countMessage)
Column(modifier = modifier) {
AnimatedVisibility (totalCount > 1) {
AnimatedVisibility(totalCount > 1) {
Text(
text = annotatedTextWithBold(
text = fullCountMessage,
@ -202,5 +203,6 @@ internal fun PinnedMessagesBannerViewPreview(@PreviewParameter(PinnedMessagesBan @@ -202,5 +203,6 @@ internal fun PinnedMessagesBannerViewPreview(@PreviewParameter(PinnedMessagesBan
PinnedMessagesBannerView(
state = state,
onClick = {},
onViewAllClick = {},
)
}

3
features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/typing/MessagesViewWithTypingPreview.kt

@ -33,11 +33,12 @@ internal fun MessagesViewWithTypingPreview( @@ -33,11 +33,12 @@ internal fun MessagesViewWithTypingPreview(
onBackClick = {},
onRoomDetailsClick = {},
onEventClick = { false },
onPreviewAttachments = {},
onUserDataClick = {},
onLinkClick = {},
onPreviewAttachments = {},
onSendLocationClick = {},
onCreatePollClick = {},
onJoinCallClick = {},
onViewAllPinnedMessagesClick = {},
)
}

2
features/messages/impl/src/test/kotlin/io/element/android/features/messages/impl/MessagesViewTest.kt

@ -471,6 +471,7 @@ private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setMessa @@ -471,6 +471,7 @@ private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setMessa
onSendLocationClick: () -> Unit = EnsureNeverCalled(),
onCreatePollClick: () -> Unit = EnsureNeverCalled(),
onJoinCallClick: () -> Unit = EnsureNeverCalled(),
onViewAllPinnedMessagesClick: () -> Unit = EnsureNeverCalled(),
) {
setContent {
// Cannot use the RichTextEditor, so simulate a LocalInspectionMode
@ -488,6 +489,7 @@ private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setMessa @@ -488,6 +489,7 @@ private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setMessa
onSendLocationClick = onSendLocationClick,
onCreatePollClick = onCreatePollClick,
onJoinCallClick = onJoinCallClick,
onViewAllPinnedMessagesClick = onViewAllPinnedMessagesClick,
)
}
}

Loading…
Cancel
Save