Pinned events : add the glue for the ViewAll click.
This commit is contained in:
parent
9a8c58313d
commit
c820003414
6 changed files with 60 additions and 39 deletions
|
|
@ -17,6 +17,7 @@
|
||||||
package io.element.android.features.messages.impl
|
package io.element.android.features.messages.impl
|
||||||
|
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
|
@ -81,6 +82,7 @@ import kotlinx.collections.immutable.ImmutableList
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
@ContributesNode(RoomScope::class)
|
@ContributesNode(RoomScope::class)
|
||||||
class MessagesFlowNode @AssistedInject constructor(
|
class MessagesFlowNode @AssistedInject constructor(
|
||||||
|
|
@ -217,6 +219,10 @@ class MessagesFlowNode @AssistedInject constructor(
|
||||||
analyticsService.captureInteraction(Interaction.Name.MobileRoomCallButton)
|
analyticsService.captureInteraction(Interaction.Name.MobileRoomCallButton)
|
||||||
elementCallEntryPoint.startCall(callType)
|
elementCallEntryPoint.startCall(callType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onViewAllPinnedEvents() {
|
||||||
|
Timber.d("On View All Pinned Events not implemented yet.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val inputs = MessagesNode.Inputs(
|
val inputs = MessagesNode.Inputs(
|
||||||
focusedEventId = inputs.focusedEventId,
|
focusedEventId = inputs.focusedEventId,
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ class MessagesNode @AssistedInject constructor(
|
||||||
fun onCreatePollClick()
|
fun onCreatePollClick()
|
||||||
fun onEditPollClick(eventId: EventId)
|
fun onEditPollClick(eventId: EventId)
|
||||||
fun onJoinCallClick(roomId: RoomId)
|
fun onJoinCallClick(roomId: RoomId)
|
||||||
|
fun onViewAllPinnedEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBuilt() {
|
override fun onBuilt() {
|
||||||
|
|
@ -185,6 +186,10 @@ class MessagesNode @AssistedInject constructor(
|
||||||
callbacks.forEach { it.onEditPollClick(eventId) }
|
callbacks.forEach { it.onEditPollClick(eventId) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun onViewAllPinnedMessagesClick() {
|
||||||
|
callbacks.forEach { it.onViewAllPinnedEvents() }
|
||||||
|
}
|
||||||
|
|
||||||
private fun onSendLocationClick() {
|
private fun onSendLocationClick() {
|
||||||
callbacks.forEach { it.onSendLocationClick() }
|
callbacks.forEach { it.onSendLocationClick() }
|
||||||
}
|
}
|
||||||
|
|
@ -221,6 +226,7 @@ class MessagesNode @AssistedInject constructor(
|
||||||
onSendLocationClick = this::onSendLocationClick,
|
onSendLocationClick = this::onSendLocationClick,
|
||||||
onCreatePollClick = this::onCreatePollClick,
|
onCreatePollClick = this::onCreatePollClick,
|
||||||
onJoinCallClick = this::onJoinCallClick,
|
onJoinCallClick = this::onJoinCallClick,
|
||||||
|
onViewAllPinnedMessagesClick = this::onViewAllPinnedMessagesClick,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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.MessageComposerEvents
|
||||||
import io.element.android.features.messages.impl.messagecomposer.MessageComposerView
|
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.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.TimelineView
|
||||||
import io.element.android.features.messages.impl.timeline.components.JoinCallMenuItem
|
import io.element.android.features.messages.impl.timeline.components.JoinCallMenuItem
|
||||||
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionBottomSheet
|
import io.element.android.features.messages.impl.timeline.components.customreaction.CustomReactionBottomSheet
|
||||||
|
|
@ -127,8 +126,9 @@ fun MessagesView(
|
||||||
onSendLocationClick: () -> Unit,
|
onSendLocationClick: () -> Unit,
|
||||||
onCreatePollClick: () -> Unit,
|
onCreatePollClick: () -> Unit,
|
||||||
onJoinCallClick: () -> Unit,
|
onJoinCallClick: () -> Unit,
|
||||||
|
onViewAllPinnedMessagesClick: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
forceJumpToBottomVisibility: Boolean = false
|
forceJumpToBottomVisibility: Boolean = false,
|
||||||
) {
|
) {
|
||||||
OnLifecycleEvent { _, event ->
|
OnLifecycleEvent { _, event ->
|
||||||
state.voiceMessageComposerState.eventSink(VoiceMessageComposerEvents.LifecycleEvent(event))
|
state.voiceMessageComposerState.eventSink(VoiceMessageComposerEvents.LifecycleEvent(event))
|
||||||
|
|
@ -229,6 +229,7 @@ fun MessagesView(
|
||||||
},
|
},
|
||||||
forceJumpToBottomVisibility = forceJumpToBottomVisibility,
|
forceJumpToBottomVisibility = forceJumpToBottomVisibility,
|
||||||
onJoinCallClick = onJoinCallClick,
|
onJoinCallClick = onJoinCallClick,
|
||||||
|
onViewAllPinnedMessagesClick = onViewAllPinnedMessagesClick,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
snackbarHost = {
|
snackbarHost = {
|
||||||
|
|
@ -320,6 +321,7 @@ private fun MessagesViewContent(
|
||||||
onSendLocationClick: () -> Unit,
|
onSendLocationClick: () -> Unit,
|
||||||
onCreatePollClick: () -> Unit,
|
onCreatePollClick: () -> Unit,
|
||||||
onJoinCallClick: () -> Unit,
|
onJoinCallClick: () -> Unit,
|
||||||
|
onViewAllPinnedMessagesClick: () -> Unit,
|
||||||
forceJumpToBottomVisibility: Boolean,
|
forceJumpToBottomVisibility: Boolean,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onSwipeToReply: (TimelineItem.Event) -> Unit,
|
onSwipeToReply: (TimelineItem.Event) -> Unit,
|
||||||
|
|
@ -405,6 +407,7 @@ private fun MessagesViewContent(
|
||||||
onClick = { pinnedEventId ->
|
onClick = { pinnedEventId ->
|
||||||
//state.timelineState.eventSink(TimelineEvents.FocusOnEvent(pinnedEventId))
|
//state.timelineState.eventSink(TimelineEvents.FocusOnEvent(pinnedEventId))
|
||||||
},
|
},
|
||||||
|
onViewAllClick = onViewAllPinnedMessagesClick,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -576,12 +579,13 @@ internal fun MessagesViewPreview(@PreviewParameter(MessagesStateProvider::class)
|
||||||
onBackClick = {},
|
onBackClick = {},
|
||||||
onRoomDetailsClick = {},
|
onRoomDetailsClick = {},
|
||||||
onEventClick = { false },
|
onEventClick = { false },
|
||||||
onPreviewAttachments = {},
|
|
||||||
onUserDataClick = {},
|
onUserDataClick = {},
|
||||||
onLinkClick = {},
|
onLinkClick = {},
|
||||||
|
onPreviewAttachments = {},
|
||||||
onSendLocationClick = {},
|
onSendLocationClick = {},
|
||||||
onCreatePollClick = {},
|
onCreatePollClick = {},
|
||||||
onJoinCallClick = {},
|
onJoinCallClick = {},
|
||||||
|
onViewAllPinnedMessagesClick = { },
|
||||||
forceJumpToBottomVisibility = true,
|
forceJumpToBottomVisibility = true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ import io.element.android.libraries.ui.strings.CommonStrings
|
||||||
fun PinnedMessagesBannerView(
|
fun PinnedMessagesBannerView(
|
||||||
state: PinnedMessagesBannerState,
|
state: PinnedMessagesBannerState,
|
||||||
onClick: (EventId) -> Unit,
|
onClick: (EventId) -> Unit,
|
||||||
|
onViewAllClick: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
if (state.currentPinnedMessage == null) return
|
if (state.currentPinnedMessage == null) return
|
||||||
|
|
@ -69,30 +70,30 @@ fun PinnedMessagesBannerView(
|
||||||
val borderColor = ElementTheme.colors.pinnedMessageBannerBorder
|
val borderColor = ElementTheme.colors.pinnedMessageBannerBorder
|
||||||
Row(
|
Row(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.background(color = ElementTheme.colors.bgCanvasDefault)
|
.background(color = ElementTheme.colors.bgCanvasDefault)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.drawBehind {
|
.drawBehind {
|
||||||
val strokeWidth = 0.5.dp.toPx()
|
val strokeWidth = 0.5.dp.toPx()
|
||||||
val y = size.height - strokeWidth / 2
|
val y = size.height - strokeWidth / 2
|
||||||
drawLine(
|
drawLine(
|
||||||
borderColor,
|
borderColor,
|
||||||
Offset(0f, y),
|
Offset(0f, y),
|
||||||
Offset(size.width, y),
|
Offset(size.width, y),
|
||||||
strokeWidth
|
strokeWidth
|
||||||
)
|
)
|
||||||
drawLine(
|
drawLine(
|
||||||
borderColor,
|
borderColor,
|
||||||
Offset(0f, 0f),
|
Offset(0f, 0f),
|
||||||
Offset(size.width, 0f),
|
Offset(size.width, 0f),
|
||||||
strokeWidth
|
strokeWidth
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.shadow(elevation = 5.dp, spotColor = Color.Transparent)
|
.shadow(elevation = 5.dp, spotColor = Color.Transparent)
|
||||||
.heightIn(min = 64.dp)
|
.heightIn(min = 64.dp)
|
||||||
.clickable {
|
.clickable {
|
||||||
onClick(state.currentPinnedMessage.eventId)
|
onClick(state.currentPinnedMessage.eventId)
|
||||||
state.eventSink(PinnedMessagesBannerEvents.MoveToNextPinned)
|
state.eventSink(PinnedMessagesBannerEvents.MoveToNextPinned)
|
||||||
},
|
},
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = spacedBy(10.dp)
|
horizontalArrangement = spacedBy(10.dp)
|
||||||
) {
|
) {
|
||||||
|
|
@ -114,7 +115,7 @@ fun PinnedMessagesBannerView(
|
||||||
message = state.currentPinnedMessage.formatted,
|
message = state.currentPinnedMessage.formatted,
|
||||||
modifier = Modifier.weight(1f)
|
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(
|
||||||
items(pinsCount) { index ->
|
items(pinsCount) { index ->
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.width(2.dp)
|
.width(2.dp)
|
||||||
.height(indicatorHeight.dp)
|
.height(indicatorHeight.dp)
|
||||||
.background(
|
.background(
|
||||||
color = if (index == pinIndex) {
|
color = if (index == pinIndex) {
|
||||||
ElementTheme.colors.iconAccentPrimary
|
ElementTheme.colors.iconAccentPrimary
|
||||||
} else {
|
} else {
|
||||||
ElementTheme.colors.pinnedMessageBannerIndicator
|
ElementTheme.colors.pinnedMessageBannerIndicator
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -174,7 +175,7 @@ private fun PinnedMessageItem(
|
||||||
val countMessage = stringResource(id = CommonStrings.screen_room_pinned_banner_indicator, index + 1, totalCount)
|
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)
|
val fullCountMessage = stringResource(id = CommonStrings.screen_room_pinned_banner_indicator_description, countMessage)
|
||||||
Column(modifier = modifier) {
|
Column(modifier = modifier) {
|
||||||
AnimatedVisibility (totalCount > 1) {
|
AnimatedVisibility(totalCount > 1) {
|
||||||
Text(
|
Text(
|
||||||
text = annotatedTextWithBold(
|
text = annotatedTextWithBold(
|
||||||
text = fullCountMessage,
|
text = fullCountMessage,
|
||||||
|
|
@ -202,5 +203,6 @@ internal fun PinnedMessagesBannerViewPreview(@PreviewParameter(PinnedMessagesBan
|
||||||
PinnedMessagesBannerView(
|
PinnedMessagesBannerView(
|
||||||
state = state,
|
state = state,
|
||||||
onClick = {},
|
onClick = {},
|
||||||
|
onViewAllClick = {},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,12 @@ internal fun MessagesViewWithTypingPreview(
|
||||||
onBackClick = {},
|
onBackClick = {},
|
||||||
onRoomDetailsClick = {},
|
onRoomDetailsClick = {},
|
||||||
onEventClick = { false },
|
onEventClick = { false },
|
||||||
onPreviewAttachments = {},
|
|
||||||
onUserDataClick = {},
|
onUserDataClick = {},
|
||||||
onLinkClick = {},
|
onLinkClick = {},
|
||||||
|
onPreviewAttachments = {},
|
||||||
onSendLocationClick = {},
|
onSendLocationClick = {},
|
||||||
onCreatePollClick = {},
|
onCreatePollClick = {},
|
||||||
onJoinCallClick = {},
|
onJoinCallClick = {},
|
||||||
|
onViewAllPinnedMessagesClick = {},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -471,6 +471,7 @@ private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setMessa
|
||||||
onSendLocationClick: () -> Unit = EnsureNeverCalled(),
|
onSendLocationClick: () -> Unit = EnsureNeverCalled(),
|
||||||
onCreatePollClick: () -> Unit = EnsureNeverCalled(),
|
onCreatePollClick: () -> Unit = EnsureNeverCalled(),
|
||||||
onJoinCallClick: () -> Unit = EnsureNeverCalled(),
|
onJoinCallClick: () -> Unit = EnsureNeverCalled(),
|
||||||
|
onViewAllPinnedMessagesClick: () -> Unit = EnsureNeverCalled(),
|
||||||
) {
|
) {
|
||||||
setContent {
|
setContent {
|
||||||
// Cannot use the RichTextEditor, so simulate a LocalInspectionMode
|
// Cannot use the RichTextEditor, so simulate a LocalInspectionMode
|
||||||
|
|
@ -488,6 +489,7 @@ private fun <R : TestRule> AndroidComposeTestRule<R, ComponentActivity>.setMessa
|
||||||
onSendLocationClick = onSendLocationClick,
|
onSendLocationClick = onSendLocationClick,
|
||||||
onCreatePollClick = onCreatePollClick,
|
onCreatePollClick = onCreatePollClick,
|
||||||
onJoinCallClick = onJoinCallClick,
|
onJoinCallClick = onJoinCallClick,
|
||||||
|
onViewAllPinnedMessagesClick = onViewAllPinnedMessagesClick,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue