Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to show steady location on map #160

Merged
merged 3 commits into from
Jan 10, 2025

Conversation

cp-sneh-s
Copy link
Collaborator

@cp-sneh-s cp-sneh-s commented Jan 9, 2025

Changelog

  • Added functionality to check the steay location on map.

New Features

  • On click of steady location from journey timeline screen user can see that location on map
Screen_recording_20250109_114238.mp4

Summary by CodeRabbit

  • New Features

    • Enhanced map rendering with improved coordinate handling.
    • Added tap interaction for steady location items.
    • Conditional display of journey details based on address availability.
  • Bug Fixes

    • Improved error handling for map coordinate rendering.
    • Prevented potential null value runtime errors in map display.
  • UI/UX Improvements

    • Updated journey detail screen layout for better spacing and consistency.
    • Added more flexible location item interactions.

Copy link

coderabbitai bot commented Jan 9, 2025

Walkthrough

The pull request introduces improvements to journey-related components in the Android application. The changes focus on enhancing error handling, coordinate processing, and UI interactions across three main files: JourneyMap.kt, LocationHistory.kt, and UserJourneyDetailScreen.kt. The modifications include more robust coordinate checking, adding tap interactions to location items, and conditional rendering of journey details based on available address information.

Changes

File Change Summary
app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/JourneyMap.kt - Added conditional checks for toLatLng coordinates before including in LatLngBounds
- Improved camera positioning when destination coordinates are null
- Modified onMapLoaded callback to set isMapLoaded more precisely
app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/LocationHistory.kt - Added onTap parameter to SteadyLocationItem composable
- Introduced clickable modifier to enable tap interactions on location items
app/src/main/java/com/canopas/yourspace/ui/flow/journey/detail/UserJourneyDetailScreen.kt - Added conditional rendering for distance and duration text
- Created new Row component for handling null toAddress scenarios
- Updated layout and styling of journey detail components

Sequence Diagram

sequenceDiagram
    participant User
    participant LocationHistoryItem
    participant SteadyLocationItem
    participant JourneyDetailScreen

    User->>LocationHistoryItem: Tap on location item
    LocationHistoryItem->>SteadyLocationItem: Trigger onTap
    SteadyLocationItem->>JourneyDetailScreen: Show journey details
Loading

Possibly related PRs

Suggested reviewers

  • cp-megh-l
  • kaushiksaliya

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0b5514 and 098b564.

📒 Files selected for processing (2)
  • app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/LocationHistory.kt (4 hunks)
  • app/src/main/java/com/canopas/yourspace/ui/flow/journey/detail/UserJourneyDetailScreen.kt (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/src/main/java/com/canopas/yourspace/ui/flow/journey/detail/UserJourneyDetailScreen.kt
  • app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/LocationHistory.kt
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or Summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/JourneyMap.kt (1)

103-105: Consider adjusting the zoom level for better UX.

The current implementation uses a fixed zoom level of 18f when showing only the starting location. This might be too zoomed in for some scenarios.

-                    cameraPositionState.move(CameraUpdateFactory.newLatLngZoom(fromLatLng, 18f))
+                    cameraPositionState.move(CameraUpdateFactory.newLatLngZoom(fromLatLng, 16f))
app/src/main/java/com/canopas/yourspace/ui/flow/journey/detail/UserJourneyDetailScreen.kt (1)

186-222: Consider extracting the steady location UI into a separate composable.

The UI for steady locations could be moved to a reusable composable to improve code organization and maintainability.

+@Composable
+private fun SteadyLocationInfo(
+    fromAddressStr: String,
+    createdAt: Long,
+) {
+    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(createdAt),
+                style = AppTheme.appTypography.caption.copy(color = AppTheme.colorScheme.textDisabled)
+            )
+        }
+    }
+}

// Usage:
-            Row(
-                verticalAlignment = Alignment.Top,
-                modifier = Modifier.wrapContentHeight().padding(4.dp)
-            ) {
-                Icon(...)
-                Column(...) {
-                    Text(...)
-                    Spacer(...)
-                    Text(...)
-                }
-            }
+            SteadyLocationInfo(fromAddressStr, journey.created_at!!)
app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/LocationHistory.kt (1)

214-217: Consider adding visual feedback for clickable items.

The clickable area should provide visual feedback when pressed.

                 .clickable { onTap() }
+                .composed {
+                    Modifier.conditional(true) {
+                        this.then(
+                            Modifier.background(
+                                color = AppTheme.colorScheme.surface,
+                                shape = RoundedCornerShape(8.dp)
+                            )
+                        )
+                    }
+                }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd11194 and f0b5514.

📒 Files selected for processing (3)
  • app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/JourneyMap.kt (2 hunks)
  • app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/LocationHistory.kt (4 hunks)
  • app/src/main/java/com/canopas/yourspace/ui/flow/journey/detail/UserJourneyDetailScreen.kt (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (4)
app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/JourneyMap.kt (2)

94-96: LGTM! Robust null-safety handling for map bounds.

The null check for destination coordinates before including them in the bounds calculation prevents potential crashes.


143-145: LGTM! Consistent null-safety handling for destination marker.

The null check aligns with the bounds calculation logic, ensuring UI consistency.

app/src/main/java/com/canopas/yourspace/ui/flow/journey/detail/UserJourneyDetailScreen.kt (1)

146-185: LGTM! Well-structured journey details with destination.

The implementation provides a clear visual hierarchy with proper spacing and alignment.

app/src/main/java/com/canopas/yourspace/ui/flow/journey/components/LocationHistory.kt (1)

76-78: LGTM! Clean parameter passing.

The showJourneyDetails callback is properly passed as the onTap parameter.

@cp-sneh-s cp-sneh-s changed the title Add functionality to show steady location on map. Add functionality to show steady location on map Jan 9, 2025
@cp-sneh-s cp-sneh-s requested a review from cp-megh-l January 9, 2025 10:46
cp-megh-l
cp-megh-l previously approved these changes Jan 9, 2025
…y-on-map

# Conflicts:
#	app/src/main/java/com/canopas/yourspace/ui/flow/journey/detail/UserJourneyDetailScreen.kt
@cp-megh-l cp-megh-l merged commit bd65542 into main Jan 10, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants