Merge pull request #783 from vector-im/feature/cjs/location-descriptions
This commit is contained in:
commit
5cfaae24b8
22 changed files with 62 additions and 34 deletions
|
|
@ -17,7 +17,6 @@
|
|||
package io.element.android.features.location.impl.show
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
|
|
|
|||
|
|
@ -16,8 +16,10 @@
|
|||
|
||||
package io.element.android.features.messages.impl.timeline.components.event
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
|
|
@ -28,21 +30,31 @@ import io.element.android.features.messages.impl.timeline.model.event.TimelineIt
|
|||
import io.element.android.features.messages.impl.timeline.model.event.TimelineItemLocationContentProvider
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewDark
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
||||
import io.element.android.libraries.designsystem.theme.components.Text
|
||||
|
||||
@Composable
|
||||
fun TimelineItemLocationView(
|
||||
content: TimelineItemLocationContent,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
StaticMapView(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.heightIn(max = 188.dp),
|
||||
lat = content.location.lat,
|
||||
lon = content.location.lon,
|
||||
zoom = 15.0,
|
||||
contentDescription = content.body
|
||||
)
|
||||
Column(modifier = modifier.fillMaxWidth()) {
|
||||
content.description?.let {
|
||||
Text(
|
||||
text = it,
|
||||
modifier = Modifier.padding(start = 12.dp, end = 12.dp, top = 8.dp, bottom = 8.dp),
|
||||
)
|
||||
}
|
||||
|
||||
StaticMapView(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.heightIn(max = 188.dp),
|
||||
lat = content.location.lat,
|
||||
lon = content.location.lon,
|
||||
zoom = 15.0,
|
||||
contentDescription = content.body
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ class TimelineItemContentMessageFactory @Inject constructor(
|
|||
TimelineItemLocationContent(
|
||||
body = messageType.body,
|
||||
location = location,
|
||||
description = messageType.description
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class TimelineItemEventContentProvider : PreviewParameterProvider<TimelineItemEv
|
|||
aTimelineItemFileContent("A file.pdf"),
|
||||
aTimelineItemFileContent("A bigger file name which doesn't fit.pdf"),
|
||||
aTimelineItemLocationContent(),
|
||||
aTimelineItemLocationContent("Location description"),
|
||||
aTimelineItemNoticeContent(),
|
||||
aTimelineItemRedactedContent(),
|
||||
aTimelineItemTextContent(),
|
||||
|
|
|
|||
|
|
@ -23,14 +23,16 @@ open class TimelineItemLocationContentProvider : PreviewParameterProvider<Timeli
|
|||
override val values: Sequence<TimelineItemLocationContent>
|
||||
get() = sequenceOf(
|
||||
aTimelineItemLocationContent(),
|
||||
aTimelineItemLocationContent("This is a description!"),
|
||||
)
|
||||
}
|
||||
|
||||
fun aTimelineItemLocationContent() = TimelineItemLocationContent(
|
||||
fun aTimelineItemLocationContent(description: String? = null) = TimelineItemLocationContent(
|
||||
body = "User location geo:52.2445,0.7186;u=5000",
|
||||
location = Location(
|
||||
lat = 52.2445,
|
||||
lon = 0.7186,
|
||||
accuracy = 5000f,
|
||||
)
|
||||
),
|
||||
description = description,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ class DefaultRoomLastMessageFormatterTests {
|
|||
AudioMessageType(body, MediaSource("url"), null),
|
||||
ImageMessageType(body, MediaSource("url"), null),
|
||||
FileMessageType(body, MediaSource("url"), null),
|
||||
LocationMessageType(body, "geo:1,2"),
|
||||
LocationMessageType(body, "geo:1,2", null),
|
||||
NoticeMessageType(body, null),
|
||||
EmoteMessageType(body, null),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ data class ImageMessageType(
|
|||
data class LocationMessageType(
|
||||
val body: String,
|
||||
val geoUri: String,
|
||||
val description: String?,
|
||||
) : MessageType
|
||||
|
||||
data class AudioMessageType(
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class EventMessageMapper {
|
|||
ImageMessageType(type.content.body, type.content.source.map(), type.content.info?.map())
|
||||
}
|
||||
is MessageType.Location -> {
|
||||
LocationMessageType(type.content.body, type.content.geoUri)
|
||||
LocationMessageType(type.content.body, type.content.geoUri, type.content.description)
|
||||
}
|
||||
is MessageType.Notice -> {
|
||||
NoticeMessageType(type.content.body, type.content.formatted?.map())
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8b14570268c5885105bb68d55e54afe83d1916e32a5a9cd8fa4084cba020b272
|
||||
size 80504
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2ae5e86ad1728027f7189041745592d4ed24df07e008b5798b29eadba5449569
|
||||
size 159493
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4d4d701ed86f9bc3e23dbcb0d1f4a61f66153e3f2d2e71c12cefb1ef72634f9f
|
||||
size 65937
|
||||
oid sha256:fb8609b0babc1a2e50f990b400090f57d3f0bddffbdfc02f76fb57d4c085bccd
|
||||
size 50178
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bcecf59a9361f9de63971d88a1e3d4daa1041d48cabdbe0bd6485052668d3906
|
||||
size 56636
|
||||
oid sha256:4d4d701ed86f9bc3e23dbcb0d1f4a61f66153e3f2d2e71c12cefb1ef72634f9f
|
||||
size 65937
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bcecf59a9361f9de63971d88a1e3d4daa1041d48cabdbe0bd6485052668d3906
|
||||
size 56636
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9d544ff72f07770d725a02ffe23fdf77278c15520273fd83a89509ef6a4632f0
|
||||
size 53520
|
||||
oid sha256:a89052fe6e40609a3a01fbe9e804a77bec37c428234fb4a68ca2044889c01913
|
||||
size 165199
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7ae78c21fa4c5bc13ef4d9b540a6db805af73a4b2ab686d35b5d37edca33ee1c
|
||||
size 65012
|
||||
oid sha256:9d544ff72f07770d725a02ffe23fdf77278c15520273fd83a89509ef6a4632f0
|
||||
size 53520
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:fb8609b0babc1a2e50f990b400090f57d3f0bddffbdfc02f76fb57d4c085bccd
|
||||
size 50178
|
||||
oid sha256:7ae78c21fa4c5bc13ef4d9b540a6db805af73a4b2ab686d35b5d37edca33ee1c
|
||||
size 65012
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2c9a43dedfef18acc8713b033ffe8ac59545eb96a77e3640ba69b9048a19bc59
|
||||
size 68644
|
||||
oid sha256:73dd69d4168847ee6339f9d02ae80157f810cab559f9f6c4659ba93c10d14a9e
|
||||
size 51702
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9a5713bf7670620247cd96760627c5b97dc393b3576b32712ae9073c7d5948de
|
||||
size 58797
|
||||
oid sha256:2c9a43dedfef18acc8713b033ffe8ac59545eb96a77e3640ba69b9048a19bc59
|
||||
size 68644
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9a5713bf7670620247cd96760627c5b97dc393b3576b32712ae9073c7d5948de
|
||||
size 58797
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1f031f626ce7b2aaa4d9fd551b5ddbf81dc9dd53bc7013bec179bc42a814bd9b
|
||||
size 55325
|
||||
oid sha256:589e8f7ca791fc13ee4171e05789e52269dfca142f633af9d0ff4a88e694e78b
|
||||
size 323977
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:351257a00f2b73baea6d6646123f48fa822d7af8dfdc21bc18647aa75ec848cd
|
||||
size 67457
|
||||
oid sha256:1f031f626ce7b2aaa4d9fd551b5ddbf81dc9dd53bc7013bec179bc42a814bd9b
|
||||
size 55325
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:73dd69d4168847ee6339f9d02ae80157f810cab559f9f6c4659ba93c10d14a9e
|
||||
size 51702
|
||||
oid sha256:351257a00f2b73baea6d6646123f48fa822d7af8dfdc21bc18647aa75ec848cd
|
||||
size 67457
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue