Adding ended live banner view in the map screen

This commit is contained in:
Maxime NATUREL 2022-07-25 12:01:10 +02:00
parent 5e59eb474a
commit e51488bc57
4 changed files with 56 additions and 18 deletions

View file

@ -111,13 +111,6 @@ class LocationLiveMapViewFragment @Inject constructor() : VectorBaseFragment<Fra
private fun setupMap() {
val mapFragment = getOrCreateSupportMapFragment()
mapFragment.getMapAsync { mapboxMap ->
val bottomSheetHeight = BottomSheetBehavior.from(views.bottomSheet).peekHeight
mapboxMap.uiSettings.apply {
// Place copyright above the user list bottom sheet
setLogoMargins(dimensionConverter.dpToPx(8), 0, 0, bottomSheetHeight + dimensionConverter.dpToPx(8))
setAttributionMargins(dimensionConverter.dpToPx(96), 0, 0, bottomSheetHeight + dimensionConverter.dpToPx(8))
}
lifecycleScope.launch {
mapboxMap.setStyle(urlMapProvider.getMapUrl()) { style ->
mapStyle = style
@ -175,11 +168,43 @@ class LocationLiveMapViewFragment @Inject constructor() : VectorBaseFragment<Fra
private fun updateUserListBottomSheet(userLocations: List<UserLiveLocationViewState>) {
if (userLocations.isEmpty()) {
views.bottomSheet.isGone = true
// TODO show Live location ended view
showEndedLiveBanner()
} else {
views.bottomSheet.isVisible = true
bottomSheetController.setData(userLocations)
showUserList(userLocations)
}
}
private fun showEndedLiveBanner() {
views.bottomSheet.isGone = true
views.liveLocationMapFragmentEndedBanner.isVisible = true
updateCopyrightMargin(bottomOffset = views.liveLocationMapFragmentEndedBanner.height)
}
private fun showUserList(userLocations: List<UserLiveLocationViewState>) {
val bottomSheetHeight = BottomSheetBehavior.from(views.bottomSheet).peekHeight
updateCopyrightMargin(bottomOffset = bottomSheetHeight)
views.bottomSheet.isVisible = true
views.liveLocationMapFragmentEndedBanner.isGone = true
bottomSheetController.setData(userLocations)
}
private fun updateCopyrightMargin(bottomOffset: Int) {
getOrCreateSupportMapFragment().getMapAsync { mapboxMap ->
mapboxMap.uiSettings.apply {
// Place copyright above the user list bottom sheet
setLogoMargins(
dimensionConverter.dpToPx(COPYRIGHT_MARGIN_DP),
0,
0,
bottomOffset + dimensionConverter.dpToPx(COPYRIGHT_MARGIN_DP)
)
setAttributionMargins(
dimensionConverter.dpToPx(COPYRIGHT_ATTRIBUTION_MARGIN_DP),
0,
0,
bottomOffset + dimensionConverter.dpToPx(COPYRIGHT_MARGIN_DP)
)
}
}
}
@ -285,5 +310,7 @@ class LocationLiveMapViewFragment @Inject constructor() : VectorBaseFragment<Fra
companion object {
private const val MAP_FRAGMENT_TAG = "im.vector.app.features.location.live.map"
private const val COPYRIGHT_MARGIN_DP = 8
private const val COPYRIGHT_ATTRIBUTION_MARGIN_DP = 96
}
}

View file

@ -10,7 +10,7 @@
android:id="@+id/liveLocationPopupAnchor"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="center"/>
android:layout_gravity="center" />
<FrameLayout
android:id="@+id/liveLocationMapFragmentContainer"
@ -49,4 +49,13 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<im.vector.app.features.location.live.LocationLiveEndedBannerView
android:id="@+id/liveLocationMapFragmentEndedBanner"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_gravity="bottom"
android:visibility="gone"
app:locLiveEndedBkgWithAlpha="false"
tools:visibility="visible" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -28,8 +28,8 @@
<ImageView
android:id="@+id/locationLiveStartIcon"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginVertical="8dp"
android:layout_marginStart="8dp"
android:background="@drawable/circle"

View file

@ -3,22 +3,24 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="48dp"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
<ImageView
android:id="@+id/locationLiveEndedBannerBackground"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_height="0dp"
android:src="?android:colorBackground"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
tools:ignore="ContentDescription" />
<ImageView
android:id="@+id/locationLiveEndedBannerIcon"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginVertical="8dp"
android:layout_marginStart="8dp"
android:background="@drawable/circle"