Browse Source

Merge pull request #3714 from element-hq/feature/bma/pinSmallIteration

Small UI iteration on pin feature.
pull/3283/merge
Benoit Marty 1 week ago committed by GitHub
parent
commit
dc8bd64a36
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/actionlist/model/TimelineItemAction.kt
  2. 9
      features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/pinned/banner/PinnedMessagesBannerStateProvider.kt
  3. 8
      features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/pinned/banner/PinnedMessagesBannerView.kt
  4. 4
      tests/uitests/src/test/snapshots/images/features.messages.impl.pinned.banner_PinnedMessagesBannerView_Day_4_en.png
  5. 4
      tests/uitests/src/test/snapshots/images/features.messages.impl.pinned.banner_PinnedMessagesBannerView_Night_4_en.png

4
features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/actionlist/model/TimelineItemAction.kt

@ -32,7 +32,5 @@ sealed class TimelineItemAction(
data object ReportContent : TimelineItemAction(CommonStrings.action_report_content, CompoundDrawables.ic_compound_chat_problem, destructive = true) data object ReportContent : TimelineItemAction(CommonStrings.action_report_content, CompoundDrawables.ic_compound_chat_problem, destructive = true)
data object EndPoll : TimelineItemAction(CommonStrings.action_end_poll, CompoundDrawables.ic_compound_polls_end) data object EndPoll : TimelineItemAction(CommonStrings.action_end_poll, CompoundDrawables.ic_compound_polls_end)
data object Pin : TimelineItemAction(CommonStrings.action_pin, CompoundDrawables.ic_compound_pin) data object Pin : TimelineItemAction(CommonStrings.action_pin, CompoundDrawables.ic_compound_pin)
data object Unpin : TimelineItemAction(CommonStrings.action_unpin, CompoundDrawables.ic_compound_unpin)
// TODO use the Unpin compound icon when available.
data object Unpin : TimelineItemAction(CommonStrings.action_unpin, CompoundDrawables.ic_compound_pin)
} }

9
features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/pinned/banner/PinnedMessagesBannerStateProvider.kt

@ -19,7 +19,11 @@ internal class PinnedMessagesBannerStateProvider : PreviewParameterProvider<Pinn
aLoadingPinnedMessagesBannerState(knownPinnedMessagesCount = 1), aLoadingPinnedMessagesBannerState(knownPinnedMessagesCount = 1),
aLoadingPinnedMessagesBannerState(knownPinnedMessagesCount = 5), aLoadingPinnedMessagesBannerState(knownPinnedMessagesCount = 5),
aLoadedPinnedMessagesBannerState(knownPinnedMessagesCount = 1, currentPinnedMessageIndex = 0), aLoadedPinnedMessagesBannerState(knownPinnedMessagesCount = 1, currentPinnedMessageIndex = 0),
aLoadedPinnedMessagesBannerState(knownPinnedMessagesCount = 2, currentPinnedMessageIndex = 0), aLoadedPinnedMessagesBannerState(
knownPinnedMessagesCount = 2,
currentPinnedMessageIndex = 0,
message = "This is a pinned long message to check the wrapping behavior",
),
aLoadedPinnedMessagesBannerState(knownPinnedMessagesCount = 3, currentPinnedMessageIndex = 0), aLoadedPinnedMessagesBannerState(knownPinnedMessagesCount = 3, currentPinnedMessageIndex = 0),
aLoadedPinnedMessagesBannerState(knownPinnedMessagesCount = 5, currentPinnedMessageIndex = 0), aLoadedPinnedMessagesBannerState(knownPinnedMessagesCount = 5, currentPinnedMessageIndex = 0),
aLoadedPinnedMessagesBannerState(knownPinnedMessagesCount = 5, currentPinnedMessageIndex = 1), aLoadedPinnedMessagesBannerState(knownPinnedMessagesCount = 5, currentPinnedMessageIndex = 1),
@ -40,9 +44,10 @@ internal fun aLoadingPinnedMessagesBannerState(
internal fun aLoadedPinnedMessagesBannerState( internal fun aLoadedPinnedMessagesBannerState(
currentPinnedMessageIndex: Int = 0, currentPinnedMessageIndex: Int = 0,
knownPinnedMessagesCount: Int = 1, knownPinnedMessagesCount: Int = 1,
message: String = "This is a pinned message",
currentPinnedMessage: PinnedMessagesBannerItem = PinnedMessagesBannerItem( currentPinnedMessage: PinnedMessagesBannerItem = PinnedMessagesBannerItem(
eventId = EventId("\$" + Random.nextInt().toString()), eventId = EventId("\$" + Random.nextInt().toString()),
formatted = AnnotatedString("This is a pinned message") formatted = AnnotatedString(message)
), ),
eventSink: (PinnedMessagesBannerEvents) -> Unit = {} eventSink: (PinnedMessagesBannerEvents) -> Unit = {}
) = PinnedMessagesBannerState.Loaded( ) = PinnedMessagesBannerState.Loaded(

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

@ -18,6 +18,7 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -98,9 +99,8 @@ private fun PinnedMessagesBannerRow(
} }
}, },
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = spacedBy(10.dp)
) { ) {
Spacer(modifier = Modifier.width(16.dp)) Spacer(modifier = Modifier.width(26.dp))
PinIndicators( PinIndicators(
pinIndex = state.currentPinnedMessageIndex(), pinIndex = state.currentPinnedMessageIndex(),
pinsCount = state.pinnedMessagesCount(), pinsCount = state.pinnedMessagesCount(),
@ -109,7 +109,9 @@ private fun PinnedMessagesBannerRow(
imageVector = CompoundIcons.PinSolid(), imageVector = CompoundIcons.PinSolid(),
contentDescription = null, contentDescription = null,
tint = ElementTheme.materialColors.secondary, tint = ElementTheme.materialColors.secondary,
modifier = Modifier.size(20.dp) modifier = Modifier
.padding(horizontal = 10.dp)
.size(20.dp)
) )
PinnedMessageItem( PinnedMessageItem(
index = state.currentPinnedMessageIndex(), index = state.currentPinnedMessageIndex(),

4
tests/uitests/src/test/snapshots/images/features.messages.impl.pinned.banner_PinnedMessagesBannerView_Day_4_en.png

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:35f12c5ebb668fd4fa340d6657cc7c758eaac73c7ba758acb5d066009edea422 oid sha256:168b7b210c781588a53bfacdbeb64f694d227de488578a4a3c3545d111725acc
size 12943 size 13515

4
tests/uitests/src/test/snapshots/images/features.messages.impl.pinned.banner_PinnedMessagesBannerView_Night_4_en.png

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:ea13db4a7e464584ff8e7581b794f3bd5dbbc6fb30341fc65d1cdfbf90aab813 oid sha256:5aa6e199123276936b44e009f05696d00d4b3000b82e67c6280b5f15a92d2a8a
size 12353 size 12891

Loading…
Cancel
Save