Document [TimelineItemGroupPosition] and improve preview of [MessageEventBubble].
This commit is contained in:
parent
6000a7ca5b
commit
6621163d27
38 changed files with 122 additions and 52 deletions
|
|
@ -94,7 +94,7 @@ internal fun aTimelineItemEvent(
|
|||
eventId: EventId = EventId("\$" + Random.nextInt().toString()),
|
||||
isMine: Boolean = false,
|
||||
content: TimelineItemEventContent = aTimelineItemTextContent(),
|
||||
groupPosition: TimelineItemGroupPosition = TimelineItemGroupPosition.First,
|
||||
groupPosition: TimelineItemGroupPosition = TimelineItemGroupPosition.None,
|
||||
sendState: EventSendState = EventSendState.Sent(eventId),
|
||||
): TimelineItem.Event {
|
||||
return TimelineItem.Event(
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import androidx.compose.foundation.ExperimentalFoundationApi
|
|||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
|
|
@ -35,13 +34,16 @@ import androidx.compose.ui.graphics.Shape
|
|||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import io.element.android.features.messages.impl.timeline.model.TimelineItemGroupPosition
|
||||
import io.element.android.features.messages.impl.timeline.model.bubble.BubbleState
|
||||
import io.element.android.features.messages.impl.timeline.model.bubble.BubbleStateProvider
|
||||
import io.element.android.libraries.core.extensions.to01
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
||||
import io.element.android.libraries.designsystem.theme.ElementTheme
|
||||
import io.element.android.libraries.designsystem.theme.components.Surface
|
||||
import io.element.android.libraries.designsystem.theme.components.Text
|
||||
|
||||
private val BUBBLE_RADIUS = 16.dp
|
||||
|
||||
|
|
@ -141,7 +143,14 @@ private fun ContentToPreview(state: BubbleState) {
|
|||
state = state,
|
||||
interactionSource = MutableInteractionSource(),
|
||||
) {
|
||||
Spacer(modifier = Modifier.size(width = 120.dp, height = 32.dp))
|
||||
// Render the state as a text to better understand the previews
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.size(width = 120.dp, height = 32.dp)
|
||||
.padding(horizontal = 12.dp, vertical = 6.dp),
|
||||
fontSize = 10.sp,
|
||||
text = "${state.groupPosition.javaClass.simpleName} m:${state.isMine.to01()} h:${state.isHighlighted.to01()}"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class TimelineItemEventFactory @Inject constructor(
|
|||
return when {
|
||||
previousSender != currentSender && nextSender == currentSender -> TimelineItemGroupPosition.First
|
||||
previousSender == currentSender && nextSender == currentSender -> TimelineItemGroupPosition.Middle
|
||||
previousSender == currentSender && nextSender != currentSender -> TimelineItemGroupPosition.Last
|
||||
previousSender == currentSender /* && nextSender != currentSender (== true) */ -> TimelineItemGroupPosition.Last
|
||||
else -> TimelineItemGroupPosition.None
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,48 @@ package io.element.android.features.messages.impl.timeline.model
|
|||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
/**
|
||||
* Attribute for a TimelineItem, used to render successive events from the same sender differently.
|
||||
*
|
||||
* Possible sequences in the timeline will be:
|
||||
*
|
||||
* Only one Event:
|
||||
* - [None]
|
||||
*
|
||||
* Two Events
|
||||
* - [First]
|
||||
* - [Last]
|
||||
*
|
||||
* Many Events:
|
||||
* - [First]
|
||||
* - [Middle] (repeated if necessary)
|
||||
* - [Last]
|
||||
*/
|
||||
@Immutable
|
||||
sealed interface TimelineItemGroupPosition {
|
||||
/**
|
||||
* The event is part of a group of events from the same sender and is the first sent Event.
|
||||
*/
|
||||
object First : TimelineItemGroupPosition
|
||||
|
||||
/**
|
||||
* The event is part of a group of events from the same sender and is neither the first nor the last sent Event.
|
||||
*/
|
||||
object Middle : TimelineItemGroupPosition
|
||||
|
||||
/**
|
||||
* The event is part of a group of events from the same sender and is the last sent Event.
|
||||
*/
|
||||
object Last : TimelineItemGroupPosition
|
||||
|
||||
/**
|
||||
* The event is not part of a group of events. Sender of previous event is different, and sender of next event is different.
|
||||
*/
|
||||
object None : TimelineItemGroupPosition
|
||||
|
||||
/**
|
||||
* Return true if the previous sender of the event is a different sender.
|
||||
*/
|
||||
fun isNew(): Boolean = when (this) {
|
||||
First, None -> true
|
||||
else -> false
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ open class BubbleStateProvider : PreviewParameterProvider<BubbleState> {
|
|||
TimelineItemGroupPosition.First,
|
||||
TimelineItemGroupPosition.Middle,
|
||||
TimelineItemGroupPosition.Last,
|
||||
TimelineItemGroupPosition.None,
|
||||
).map { groupPosition ->
|
||||
sequenceOf(false, true).map { isMine ->
|
||||
sequenceOf(false, true).map { isHighlighted ->
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package io.element.android.libraries.core.extensions
|
||||
|
||||
fun Boolean.toOnOff() = if (this) "ON" else "OFF"
|
||||
fun Boolean.to01() = if (this) "1" else "0"
|
||||
|
||||
inline fun <T> T.ooi(block: (T) -> Unit): T = also(block)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bb1648a000da198a30d3214adecf0b1266a150a226548ce77ac6d0eb001c65e2
|
||||
size 5238
|
||||
oid sha256:16b26c7ab2061dcc99daafef6507524969b942a39fa4f183325aa562ec76909a
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:44487cb1f6115b388bb043081e15d904a090277fca6edea05ccb7b6c54d56de2
|
||||
size 5761
|
||||
oid sha256:4f82e5a6048cdcf803073af9a8c108f81ec4c6f70be2696182239fccd3cce2a3
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:75ba23e1b82c3a5e4c3f4330a004b00d4eb2a2d3a27ce687ad6876c6e6e129be
|
||||
size 5547
|
||||
oid sha256:0bdcdccd0ae75d5a36bcf41e6421d912086ef520fc5ad5ddee8343290be42aa5
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:46067cba703ae02846a141dd53b888d48b6e55890cefed4cef4795c0b5910346
|
||||
size 5871
|
||||
oid sha256:294dca25a706fd0dc56e4997196e77ec1ce65d88f41f2a1ee1a4d27e75105a48
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bccda39ab7124622f388f186f86ec203f91c721e397b0d23aa900c8272e574f4
|
||||
size 4550
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bc0f8753e58d9487a7c08bad4aa360f2aeae03b9309621b8f28a8eb8d8e03aba
|
||||
size 5272
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:95a92355a64b63d223a45a99283ff4d9939a90a3da96387c0f6605cc3b0593cd
|
||||
size 5011
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b4dc33b8578f34ad99e198897d80d2e9b6de7141bbc29bc2b39ee99376c2059f
|
||||
size 4940
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:dbd968203eb9092f6ceab631da735a72bd15a44c3c8faaba45246a58bf3d9837
|
||||
size 5566
|
||||
oid sha256:708dd91f3622dfee4f569010a58dda1aed1866b1b4e13dd47af0c8dbacd33698
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d7f03a7e0ac8e63116d1c4806f07266ace800f52c8f089846c515ff12488918f
|
||||
size 5875
|
||||
oid sha256:b126e4d6d9087ca246f9b3a70d93bdfb953052cbdf2089eca67513b6cb04d40a
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:492b8ec89b02bbba9abb849d6b28f61d77f448d66d1eef5eba5a6f66db725897
|
||||
size 5133
|
||||
oid sha256:cfec26d03db4df611e20908d3b5765497fcba74077070af80bbb16332f68c922
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ccf5cf29bdcb6016203c849ea1013de2ab42ec21c9b202c56dea2d7b2b75434b
|
||||
size 5516
|
||||
oid sha256:57af2ecc51482b53d331cf20b553dbaa580d9f472cf0db72c6e0f8ab3d51711f
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e666a4e785be44883e945e5ab22766c96358381467fc6860c3e8733a359d6801
|
||||
size 5462
|
||||
oid sha256:84efea63cf1faebc110c6b194411a9568c91c6e38eaf6c0b5df49bc2b105a0e1
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6fc64090e9c685246a0adc2a2250cb80fcc64cbe7d6578d63bc4827eaa50591e
|
||||
size 5682
|
||||
oid sha256:971214d459626ff3e6cad74be7506a16d9ef33e97fcb428fc76fab9dc28f38f9
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:b584ab84ca09c1fe9c2ce8433a92adb8f1f6c595ccc702f10b976b81951b9048
|
||||
size 5253
|
||||
oid sha256:0bf72e3bd9955500764925e339673ccf70889fb003550116e9a611b8ac4702f6
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ab7a53108da1eda0c1f24360d4c4073dca110dd3b368cc1f117cd3f351a385dc
|
||||
size 5789
|
||||
oid sha256:5d1d06501e11adca85e4755ebcb8823aafa09ecd1fdd29765ca1971a130c8e5b
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ace5a91e960c6570647e2b8ad2de428ba474e48531a2f74ab267d07668d7a9e8
|
||||
size 4928
|
||||
oid sha256:891218a3de22a8de7e8a28ea316190dfd9250e43ccd0a26f6f5ff0a92e8bba88
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:aec5d74e6f4d316c1ea124dc50e2abbfd22d6ee94b6d82519b3f9cab7a191dfa
|
||||
size 5348
|
||||
oid sha256:1bfc2475f2f6b142a8674d44bfb27bd62d5972f7a9ee443c0cc57be300790464
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:dfaa4d6032641b332b111b20c81ec4bca917391cf122a06718fca7da849a7c94
|
||||
size 5124
|
||||
oid sha256:9f215f708626e853d1baf778c0a952881bf06c7981123a7bd27ac56df437658e
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ac3eb3ebe9f2f30224389586f9b5901106b73cee9f5b4cdeb0f76b313ba0cd31
|
||||
size 5384
|
||||
oid sha256:ea44be04299641b1f525105b1fbafcb7ba46d97d2a9807efbb9bc63f0e29dc4d
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e816c683a931a21519eaa4e82b1ca3510b0e4d6f1dc6bd43487974bf0982a0b5
|
||||
size 4917
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7909e03ee9d6e2811863ed9b93df5cd00814765c8421443606df425b80be7670
|
||||
size 5428
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5351ec4553c3650c52553f753d966ea9c726bb2ce949225be363891ab7d667c2
|
||||
size 5188
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:74f0a3e254f9c34212ca93c17efca0b3a7edff6912c8f559f8ba276bd74946f0
|
||||
size 5065
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8e0eaf65f627b7be068311b0c8f52cfbe847571684a0c63dda3e7c0621eac42c
|
||||
size 5133
|
||||
oid sha256:a71faa0aee58b977af48b5f8d8df0edf9b0bc4d21c6d5f65bdb54de0065906a2
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8359444a65d74682106930a7bbc6fb171acb95446cc5ff67eefa0dadc51e5932
|
||||
size 5397
|
||||
oid sha256:11296725ee57a3ba87f5c89e76253d964808c9991faa50369f3483b0b846299b
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d774fca7f28623d7e464c233e5e2282b5c7d608d7aa6084b2350a4f71765bc5a
|
||||
size 4809
|
||||
oid sha256:d88fd626137d1793981906989a1922193941b2367c59ff0c6bdc5e2d15cda97b
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:32c81961535a22ce1fccc15865cd76bc9844168552a2205f7f7342398866b622
|
||||
size 5109
|
||||
oid sha256:5c7248dd717838956900527431f8dda4aff2717a2c9238a80a828aaea2a4f9cf
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bd53dc603b4689eabe41e5d90ea0d8a70b769d60082ee57eee556ef9a7ea24ec
|
||||
size 4984
|
||||
oid sha256:49e1f398b462cb05907142a14416e039faaf20bfc4c1733f36d63e69286525f3
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:43e08e7c243192571121595483ddc2dd44b56892afff5ae949ac224cad13e73f
|
||||
size 5165
|
||||
oid sha256:0a8caac9c140941bd71b8e9b36cd15df8ec37ef85755b3de8a3353cd602e0797
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7c61846e0037aa7a4d6f146fa4f2b441654570db082b3f506bb6f49aa01f3999
|
||||
size 4944
|
||||
oid sha256:7d2be4bed342f82cd180f7dd31d8be9719e59123b991e9a804f5586a3a943ce1
|
||||
size 329
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:137bfee9d776c8abff1a2428e3edc1c28cc7ca21d9849640e2aad2d945d7f7f2
|
||||
size 5361
|
||||
oid sha256:0bc50249a165de79de671860657998f771ec26ef8a4d07a78004423b2a44a82e
|
||||
size 329
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue