Repository navigation
feat(map): add the Map tab #392
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
Changes from all commits
5dc00a9
8c6325b
3f589f4
9a69325
36f7d00
0cefb3e
08f51b5
eebb1b6
e12100f
8362cba
1724c4c
4533d23
205a110
534ac3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- Co-authored-by: Claude Code (Claude Opus 5.5) --> | ||
| <!-- "map" (folded map) icon of the Map tab in the bottom bar (Figma "Map — …" frames). --> | ||
| <vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="21dp" | ||
| android:height="21dp" | ||
| android:viewportWidth="24" | ||
| android:viewportHeight="24"> | ||
| <path | ||
| android:strokeColor="#20231F" | ||
| android:strokeWidth="2" | ||
| android:strokeLineCap="round" | ||
| android:strokeLineJoin="round" | ||
| android:pathData="M14.106,5.553a2,2 0,0 0,1.788 0l3.659,-1.83A1,1 0,0 1,21 4.619v12.764a1,1 0,0 1,-0.553 0.894l-4.553,2.277a2,2 0,0 1,-1.788 0l-4.212,-2.106a2,2 0,0 0,-1.788 0l-3.659,1.83A1,1 0,0 1,3 19.381V6.618a1,1 0,0 1,0.553 -0.894l4.553,-2.277a2,2 0,0 1,1.788 0zM15,5.764v15M9,3.236v15" /> | ||
| </vector> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,12 @@ package com.android.polybazaar.ui.navigation | |
| import android.content.Context | ||
| import android.net.Uri | ||
| import androidx.activity.compose.LocalActivityResultRegistryOwner | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.runtime.CompositionLocalProvider | ||
| import androidx.compose.runtime.remember | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.platform.testTag | ||
| import androidx.compose.ui.semantics.Role | ||
| import androidx.compose.ui.semantics.SemanticsActions | ||
| import androidx.compose.ui.semantics.SemanticsProperties | ||
|
|
@@ -80,11 +84,14 @@ import com.android.polybazaar.listing.model.FakeListingRepository | |
| import com.android.polybazaar.listing.model.FilePhotoStorage | ||
| import com.android.polybazaar.listing.model.ItemListing | ||
| import com.android.polybazaar.listing.model.ListingCategory | ||
| import com.android.polybazaar.listing.model.ListingLocation | ||
| import com.android.polybazaar.listing.model.ServiceListing | ||
| import com.android.polybazaar.listing.ui.CreateListingScreenTags | ||
| import com.android.polybazaar.listing.ui.EditListingScreenTags | ||
| import com.android.polybazaar.listing.ui.ListingDetailScreenTags | ||
| import com.android.polybazaar.map.model.FakeLocationRepository | ||
| import com.android.polybazaar.map.ui.MapScreenTags | ||
| import com.android.polybazaar.map.viewmodel.MapUiState | ||
| import com.android.polybazaar.profile.model.ProfileRepository | ||
| import com.android.polybazaar.profile.ui.EditProfileScreenTags | ||
| import com.android.polybazaar.profile.ui.LenderProfileScreenTags | ||
|
|
@@ -134,6 +141,10 @@ class AppNavHostTest { | |
| private val listingRepository = FakeListingRepository(ownerUid = user.uid) | ||
| private val chatRepository = FakeChatRepository() | ||
| private val bookingRepository = FakeBookingRepository() | ||
| private val locationRepository = FakeLocationRepository() | ||
|
|
||
| /** What the Map tab last gave its map: the stand-in records it, since it draws no markers. */ | ||
| private var mapState: MapUiState? = null | ||
| private val photoStorage = | ||
| FilePhotoStorage( | ||
| ApplicationProvider.getApplicationContext(), | ||
|
|
@@ -166,7 +177,12 @@ class AppNavHostTest { | |
| editPhotoStorage = editPhotoStorage, | ||
| chatRepository = chatRepository, | ||
| bookingRepository = bookingRepository, | ||
| locationRepository = FakeLocationRepository(), | ||
| locationRepository = locationRepository, | ||
| // Google Maps can't run under Robolectric: a stand-in that shows the markers. | ||
| listingsMap = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: this stand-in is copied in both setContent helpers (here and l.231), and l.714/1548/1627 use another one,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good points, both are in #394 so they don't reset the approval here. |
||
| mapState = it | ||
| Box(Modifier.fillMaxSize().testTag(MAP_STAND_IN)) | ||
| }, | ||
| connectivityRepository = FakeConnectivityRepository(), | ||
| navController = navController, | ||
| ) | ||
|
|
@@ -210,7 +226,12 @@ class AppNavHostTest { | |
| editPhotoStorage = editPhotoStorage, | ||
| chatRepository = chatRepository, | ||
| bookingRepository = bookingRepository, | ||
| locationRepository = FakeLocationRepository(), | ||
| locationRepository = locationRepository, | ||
| // Google Maps can't run under Robolectric: a stand-in that shows the markers. | ||
| listingsMap = { | ||
| mapState = it | ||
| Box(Modifier.fillMaxSize().testTag(MAP_STAND_IN)) | ||
| }, | ||
| connectivityRepository = FakeConnectivityRepository(), | ||
| navController = navController, | ||
| ) | ||
|
|
@@ -260,6 +281,12 @@ class AppNavHostTest { | |
| assertEquals(Routes.INBOX, navController.currentBackStackEntry?.destination?.route) | ||
| } | ||
|
|
||
| private fun openMap() { | ||
| composeTestRule.onNodeWithTag(BottomBarTags.MAP_TAB).performClick() | ||
| composeTestRule.onNodeWithTag(MapScreenTags.SCREEN).assertIsDisplayed() | ||
| assertEquals(Routes.MAP, navController.currentBackStackEntry?.destination?.route) | ||
| } | ||
|
|
||
| private fun openBrowse() { | ||
| composeTestRule.onNodeWithTag(BottomBarTags.BROWSE_TAB).performClick() | ||
| composeTestRule.onNodeWithTag(BrowseScreenTags.SCREEN).assertIsDisplayed() | ||
|
|
@@ -681,9 +708,10 @@ class AppNavHostTest { | |
| editPhotoStorage = editPhotoStorage, | ||
| chatRepository = chatRepository, | ||
| bookingRepository = bookingRepository, | ||
| locationRepository = FakeLocationRepository(), | ||
| locationRepository = locationRepository, | ||
| connectivityRepository = FakeConnectivityRepository(), | ||
| navController = navController, | ||
| listingsMap = { mapState = it }, | ||
| ) | ||
| } | ||
|
|
||
|
|
@@ -1514,9 +1542,10 @@ class AppNavHostTest { | |
| editPhotoStorage = editPhotoStorage, | ||
| chatRepository = chatRepository, | ||
| bookingRepository = bookingRepository, | ||
| locationRepository = FakeLocationRepository(), | ||
| locationRepository = locationRepository, | ||
| connectivityRepository = FakeConnectivityRepository(), | ||
| navController = navController, | ||
| listingsMap = { mapState = it }, | ||
| ) | ||
| } | ||
| openProfile() | ||
|
|
@@ -1592,9 +1621,10 @@ class AppNavHostTest { | |
| editPhotoStorage = editPhotoStorage, | ||
| chatRepository = chatRepository, | ||
| bookingRepository = bookingRepository, | ||
| locationRepository = FakeLocationRepository(), | ||
| locationRepository = locationRepository, | ||
| connectivityRepository = FakeConnectivityRepository(), | ||
| navController = navController, | ||
| listingsMap = { mapState = it }, | ||
| ) | ||
| } | ||
| composeTestRule.onNodeWithTag(VerifyEmailScreenTags.SCREEN).assertIsDisplayed() | ||
|
|
@@ -1664,6 +1694,9 @@ class AppNavHostTest { | |
| composeTestRule.onNodeWithTag(BrowseScreenTags.SCREEN).assertIsDisplayed() | ||
| composeTestRule.onNodeWithTag(BottomBarTags.BAR).assertIsDisplayed() | ||
|
|
||
| openMap() | ||
| composeTestRule.onNodeWithTag(BottomBarTags.BAR).assertIsDisplayed() | ||
|
|
||
| openCreateListing() | ||
| composeTestRule.onNodeWithTag(BottomBarTags.BAR).assertIsDisplayed() | ||
|
|
||
|
|
@@ -1674,6 +1707,39 @@ class AppNavHostTest { | |
| composeTestRule.onNodeWithTag(BottomBarTags.BAR).assertIsDisplayed() | ||
| } | ||
|
|
||
| @Test | ||
| fun mapTab_isSecond_betweenBrowseAndCreateListing() { | ||
| setContent(FakeAuthRepository(currentUser = user)) | ||
|
|
||
| fun left(tag: String) = composeTestRule.onNodeWithTag(tag).getBoundsInRoot().left | ||
| assertTrue(left(BottomBarTags.BROWSE_TAB) < left(BottomBarTags.MAP_TAB)) | ||
| assertTrue(left(BottomBarTags.MAP_TAB) < left(BottomBarTags.CREATE_LISTING_TAB)) | ||
| } | ||
|
|
||
| @Test | ||
| fun mapTab_showsOtherUsersListingsWithALocation_andReloadsWhenComingBack() { | ||
| val rolex = ListingLocation(46.5185, 6.5683, "Rolex Learning Center") | ||
| listingRepository.allListings = | ||
| listOf( | ||
| gracesDrill.copy(location = rolex), | ||
| gracesDrill.copy(listingId = "nowhere", title = "No location"), | ||
| ) | ||
| setContent(FakeAuthRepository(currentUser = user)) | ||
|
|
||
| openMap() | ||
| composeTestRule.waitForIdle() | ||
| assertEquals(listOf("drill"), mapState?.markers?.map { it.id }) | ||
|
|
||
| // A listing placed meanwhile shows when the renter comes back to the tab. | ||
| listingRepository.allListings = | ||
| listingRepository.allListings + gracesDrill.copy(listingId = "tent", location = rolex) | ||
| openBrowse() | ||
| openMap() | ||
| composeTestRule.waitForIdle() | ||
|
|
||
| assertEquals(listOf("drill", "tent"), mapState?.markers?.map { it.id }) | ||
| } | ||
|
|
||
| @Test | ||
| fun bottomBar_isHiddenOnLoading() { | ||
| setContent(FakeAuthRepository(currentUserGate = CompletableDeferred())) | ||
|
|
@@ -2228,3 +2294,6 @@ class AppNavHostTest { | |
| } | ||
|
|
||
| private const val NETWORK_MESSAGE = "No connection. Check your internet and try again." | ||
|
|
||
| /** Tag of the stand-in drawn instead of the Google map, which can't run under Robolectric. */ | ||
| private const val MAP_STAND_IN = "map_stand_in" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: this default copies the
mapdefault ofMapScreen. If one of them changes (sayListingsMapgets a new param), the app could quietly stop matching what MapScreen does. CouldlistingsMapbe nullable here and only be passed on to MapScreen when it's set?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good points, both are in #394 so they don't reset the approval here.