diff --git a/app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/JourneyMap.kt b/app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/JourneyMap.kt index 3d119d1e..ec7a724b 100644 --- a/app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/JourneyMap.kt +++ b/app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/JourneyMap.kt @@ -91,13 +91,18 @@ fun JourneyMap( val boundsBuilder = LatLngBounds.builder() .apply { include(fromLatLang) - include(toLatLang) + if (location?.to_latitude != null && location.to_longitude != null) { + include(toLatLang) + } routePoints.forEach { latLng -> this.include(latLng) } }.build() val update = CameraUpdateFactory.newLatLngBounds(boundsBuilder, 50) cameraPositionState.move(update) + if (location?.to_latitude == null && location?.to_longitude == null) { + cameraPositionState.move(CameraUpdateFactory.newLatLngZoom(fromLatLang, 18f)) + } } catch (e: Exception) { e.printStackTrace() } @@ -135,8 +140,9 @@ fun JourneyMap( ) { location?.let { LocationMarker(fromLatLang, anchor, fromMarkerContent) - - LocationMarker(toLatLang, anchor, toMarkerContent) + if (location.to_latitude != null && location.to_longitude != null) { + LocationMarker(toLatLang, anchor, toMarkerContent) + } Polyline( points = if (shouldAnimate) animatedPoints else routePoints, diff --git a/app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/LocationHistory.kt b/app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/LocationHistory.kt index cc9e15ee..d937e620 100644 --- a/app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/LocationHistory.kt +++ b/app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/LocationHistory.kt @@ -5,6 +5,7 @@ import android.location.Address import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -72,7 +73,7 @@ fun LocationHistoryItem( selectedMapStyle: String ) { if (location.isSteady()) { - SteadyLocationItem(location, isFirstItem, isLastItem, journeyList) { + SteadyLocationItem(location, isFirstItem, isLastItem, journeyList, showJourneyDetails) { addPlaceTap(location.from_latitude, location.from_longitude) } } else { @@ -155,6 +156,7 @@ fun SteadyLocationItem( isFirstItem: Boolean, isLastItem: Boolean, journeyList: List, + onTap: () -> Unit, addPlace: () -> Unit ) { val context = LocalContext.current @@ -209,6 +211,7 @@ fun SteadyLocationItem( Column( modifier = Modifier + .clickable { onTap() } .padding(start = 16.dp) .weight(1f) ) { diff --git a/app/src/main/java/com/canopas/yourspace/ui/flow/journey/detail/UserJourneyDetailScreen.kt b/app/src/main/java/com/canopas/yourspace/ui/flow/journey/detail/UserJourneyDetailScreen.kt index d0ec3a82..83d5c102 100644 --- a/app/src/main/java/com/canopas/yourspace/ui/flow/journey/detail/UserJourneyDetailScreen.kt +++ b/app/src/main/java/com/canopas/yourspace/ui/flow/journey/detail/UserJourneyDetailScreen.kt @@ -8,12 +8,14 @@ import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack @@ -38,6 +40,8 @@ import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import com.canopas.yourspace.R @@ -139,43 +143,84 @@ private fun JourneyInfo(journey: LocationJourney) { val distance = getDistanceString(journey.route_distance ?: 0.0) val duration = getRouteDurationString(journey.route_duration ?: 0) - Text( - text = "$distance - $duration", - color = AppTheme.colorScheme.textPrimary, - style = AppTheme.appTypography.header2, - modifier = Modifier - .padding(top = 8.dp, bottom = 24.dp) - .padding(horizontal = 16.dp) - ) + if (toAddress != null) { + Text( + text = "$distance - $duration", + color = AppTheme.colorScheme.textPrimary, + style = AppTheme.appTypography.header2, + modifier = Modifier + .padding(top = 8.dp, bottom = 24.dp) + .padding(horizontal = 16.dp) + ) - Row( - verticalAlignment = Alignment.Top, - modifier = Modifier - .height(90.dp) - ) { - DottedTimeline(isSteadyLocation = false, isLastItem = false, isJourneyDetail = true) - Column( + Row( + verticalAlignment = Alignment.Top, modifier = Modifier - .padding(start = 16.dp) - .weight(1f) + .height(90.dp) ) { - PlaceInfo(fromAddressStr, getFormattedLocationTime(journey.created_at!!)) + DottedTimeline(isSteadyLocation = false, isLastItem = false, isJourneyDetail = true) + Column( + modifier = Modifier + .padding(start = 16.dp) + .weight(1f) + ) { + PlaceInfo(fromAddressStr, getFormattedLocationTime(journey.created_at)) + } } - } - Row( - verticalAlignment = Alignment.Top, - modifier = Modifier - .height(90.dp) - ) { - DottedTimeline(isSteadyLocation = true, isLastItem = true, isJourneyDetail = true) - Column( + Row( + verticalAlignment = Alignment.Top, modifier = Modifier - .padding(start = 16.dp) - .weight(1f) + .height(90.dp) ) { - journey.updated_at?.let { getFormattedLocationTime(it) } - ?.let { PlaceInfo(toAddressStr, it) } + DottedTimeline(isSteadyLocation = true, isLastItem = true, isJourneyDetail = true) + Column( + modifier = Modifier + .padding(start = 16.dp) + .weight(1f) + ) { + PlaceInfo(toAddressStr, getFormattedLocationTime(journey.updated_at)) + } + } + } else { + Row( + verticalAlignment = Alignment.Top, + modifier = Modifier + .wrapContentHeight() + .padding(4.dp) + ) { + Icon( + painter = painterResource(R.drawable.ic_journey_destination), + contentDescription = "", + tint = AppTheme.colorScheme.primary, + modifier = Modifier + .padding(start = 8.dp) + .background(AppTheme.colorScheme.secondaryInverseVariant, CircleShape) + .size(30.dp) + .padding(4.dp) + ) + Column( + modifier = Modifier + .padding(start = 16.dp) + .weight(1f) + ) { + Text( + text = fromAddressStr, + style = AppTheme.appTypography.body2.copy( + color = AppTheme.colorScheme.textPrimary, + fontWeight = FontWeight.Medium + ), + overflow = TextOverflow.Ellipsis, + modifier = Modifier.padding(end = 16.dp) + ) + + Spacer(modifier = Modifier.size(8.dp)) + + Text( + text = getFormattedLocationTime(journey.created_at), + style = AppTheme.appTypography.caption.copy(color = AppTheme.colorScheme.textDisabled) + ) + } } } }