From 0a5a1105421808f657a47eaa10dd45f48c3dcde5 Mon Sep 17 00:00:00 2001 From: somethingGit <113336038+somethingGit@users.noreply.github.com> Date: Sun, 29 Nov 2026 16:22:32 -0600 Subject: [PATCH 1/2] New Filter and Fixes Maps Issues --- .../data/RemoteChangesTest.kt | 2 +- .../ui/campsites/FilterPageUITest.kt | 88 ++++++++- .../ui/create/LocationSearchUITest.kt | 14 ++ .../ui/navigation/HomeSearchUITest.kt | 121 ++++++++++++ .../example/lambda_bbb_events/MainActivity.kt | 3 +- .../controller/CampsiteController.kt | 17 +- .../model/campsite/CampsiteFilters.kt | 4 +- .../campsite}/CampsiteStore.kt | 9 +- .../model/campsite/SearchArea.kt | 131 +++++++++++++ .../lambda_bbb_events/store/UserStore.kt | 5 - .../components/filter/HomeCampsiteFilter.kt | 71 ++++++- .../view/ui/components/map/AreaMap.kt | 179 ++++++++++++++++++ .../view/ui/components/map/GoogleAreaMap.kt | 140 ++++++++++++++ .../view/ui/components/map/GoogleMapViews.kt | 2 +- .../ui/components/map/LocationSearchBar.kt | 179 ++++++++++++------ .../ui/components/map/OpenStreetAreaMap.kt | 170 +++++++++++++++++ .../ui/components/map/OpenStreetMapViews.kt | 6 +- .../CampsiteControllerAreaUnitTest.kt | 94 +++++++++ .../CampsiteControllerSearchUnitTest.kt | 2 +- .../controller/CampsiteControllerUnitTest.kt | 2 +- .../model/campsite/SearchAreaUnitTest.kt | 127 +++++++++++++ .../store/CampsiteStoreUnitTest.kt | 1 + 22 files changed, 1275 insertions(+), 92 deletions(-) create mode 100644 code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/navigation/HomeSearchUITest.kt rename code/app/src/main/java/com/example/lambda_bbb_events/{store => model/campsite}/CampsiteStore.kt (93%) create mode 100644 code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/SearchArea.kt delete mode 100644 code/app/src/main/java/com/example/lambda_bbb_events/store/UserStore.kt create mode 100644 code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/AreaMap.kt create mode 100644 code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/GoogleAreaMap.kt create mode 100644 code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/OpenStreetAreaMap.kt create mode 100644 code/app/src/test/java/com/example/lambda_bbb_events/controller/CampsiteControllerAreaUnitTest.kt create mode 100644 code/app/src/test/java/com/example/lambda_bbb_events/model/campsite/SearchAreaUnitTest.kt diff --git a/code/app/src/androidTest/java/com/example/lambda_bbb_events/data/RemoteChangesTest.kt b/code/app/src/androidTest/java/com/example/lambda_bbb_events/data/RemoteChangesTest.kt index a45233db..8067e0df 100644 --- a/code/app/src/androidTest/java/com/example/lambda_bbb_events/data/RemoteChangesTest.kt +++ b/code/app/src/androidTest/java/com/example/lambda_bbb_events/data/RemoteChangesTest.kt @@ -13,7 +13,7 @@ import com.example.lambda_bbb_events.model.repository.CampsiteRepository import com.example.lambda_bbb_events.model.repository.UserRepository import com.example.lambda_bbb_events.model.user.Entrant import com.example.lambda_bbb_events.model.user.UserRole -import com.example.lambda_bbb_events.store.CampsiteStore +import com.example.lambda_bbb_events.model.campsite.CampsiteStore import com.google.firebase.FirebaseApp import com.google.firebase.firestore.FirebaseFirestore import io.mockk.clearAllMocks diff --git a/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/campsites/FilterPageUITest.kt b/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/campsites/FilterPageUITest.kt index 0998355a..6280da21 100644 --- a/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/campsites/FilterPageUITest.kt +++ b/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/campsites/FilterPageUITest.kt @@ -3,6 +3,9 @@ package com.example.lambda_bbb_events.ui.campsites import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.semantics.SemanticsProperties +import androidx.compose.ui.test.click import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsNotSelected import androidx.compose.ui.test.assertIsSelected @@ -54,8 +57,8 @@ class FilterPageUITest { showResultsCalled = false // Remembers the filters like the real controller every { campsiteController.filters } answers { filters } - every { campsiteController.applyFilters(any(), any(), any(), any(), any()) } answers { - filters = CampsiteFilters(arg(0), arg(1), arg(2), arg(3), arg(4)) + every { campsiteController.applyFilters(any(), any(), any(), any(), any(), any()) } answers { + filters = CampsiteFilters(arg(0), arg(1), arg(2), arg(3), arg(4), arg(5)) emptyMap() } every { campsiteController.guestOptions } answers { guestOptions } @@ -314,6 +317,7 @@ class FilterPageUITest { fun ratingInputWorks() { composeTestRule .onNodeWithTag("ratingStar3") + .performScrollTo() .performClick() composeTestRule.onNodeWithTag("ratingStar1").assertIsSelected() @@ -336,4 +340,84 @@ class FilterPageUITest { assertTrue(showResultsCalled) } } + + /** The text under the area map. */ + private fun areaSummary(): String = + composeTestRule.onNodeWithTag("areaSummary") + .fetchSemanticsNode() + .config[SemanticsProperties.Text] + .joinToString("") { it.text } + + /** + * Taps the middle of the area map until an area is placed, since the map takes a moment to + * load before it reports taps. + */ + private fun placeArea() { + composeTestRule.onNodeWithTag("areaMap").performScrollTo() + repeat(MAP_TAP_ATTEMPTS) { + composeTestRule.onNodeWithTag("areaMap").performTouchInput { click(center) } + composeTestRule.waitForIdle() + if (areaSummary().startsWith("Within")) return + Thread.sleep(MAP_TAP_WAIT_MS) + } + throw AssertionError("Tapping the map never placed an area") + } + + @Test + fun areaStartsUnchosen() { + composeTestRule.onNodeWithTag("areaSummary").performScrollTo() + + assertTrue(areaSummary().startsWith("Tap the map")) + } + + @Test + fun tappingTheMapPlacesAnArea() { + placeArea() + + composeTestRule.onNodeWithTag("areaRadiusHandle").assertIsDisplayed() + } + + @Test + fun draggingTheHandleResizesTheArea() { + placeArea() + val before = areaSummary() + + composeTestRule.onNodeWithTag("areaRadiusHandle").performTouchInput { + swipe(start = center, end = center + Offset(HANDLE_DRAG_PX, 0f), durationMillis = 500) + } + composeTestRule.waitForIdle() + + assertTrue("Expected the radius to change from \"$before\"", areaSummary() != before) + } + + @Test + fun resettingTheAreaClearsIt() { + placeArea() + + composeTestRule.onNodeWithTag("areaResetButton").performScrollTo().performClick() + + assertTrue(areaSummary().startsWith("Tap the map")) + } + + @Test + fun showResultsAppliesTheArea() { + placeArea() + + composeTestRule.onNodeWithTag("showResultsButton").performScrollTo().performClick() + + composeTestRule.runOnIdle { + assertTrue(filters.area != null) + } + } + + private companion object { + /** How many times [placeArea] taps before giving up. */ + const val MAP_TAP_ATTEMPTS = 15 + + /** How long [placeArea] waits between taps for the map to load. */ + const val MAP_TAP_WAIT_MS = 1000L + + /** How far the handle is dragged outwards in the resize test. */ + const val HANDLE_DRAG_PX = 150f + } } diff --git a/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/create/LocationSearchUITest.kt b/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/create/LocationSearchUITest.kt index a1ddea54..a5ba9faf 100644 --- a/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/create/LocationSearchUITest.kt +++ b/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/create/LocationSearchUITest.kt @@ -90,6 +90,20 @@ class LocationSearchUITest { composeTestRule.onNodeWithText("Jasper").assertIsDisplayed() } + /** Where the top of the address field is, in pixels from the top of the screen's content. */ + private fun addressFieldTop(): Float = + composeTestRule.onNodeWithTag("create_address").fetchSemanticsNode().boundsInRoot.top + + @Test + fun suggestionsCoverWhatIsBelowInsteadOfPushingItDown() { + val before = addressFieldTop() + + type("Lake") + waitForSuggestions() + + assertEquals(before, addressFieldTop(), 0.5f) + } + @Test fun choosingAPlaceFillsInTheLocation() { form.postalCode = "X0X 0X0" diff --git a/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/navigation/HomeSearchUITest.kt b/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/navigation/HomeSearchUITest.kt new file mode 100644 index 00000000..e4f0cd22 --- /dev/null +++ b/code/app/src/androidTest/java/com/example/lambda_bbb_events/ui/navigation/HomeSearchUITest.kt @@ -0,0 +1,121 @@ +package com.example.lambda_bbb_events.ui.navigation + +import androidx.compose.ui.test.junit4.v2.createComposeRule +import androidx.compose.ui.test.onAllNodesWithText +import androidx.compose.ui.test.onNodeWithTag +import androidx.compose.ui.test.performImeAction +import androidx.compose.ui.test.performTextClearance +import androidx.compose.ui.test.performTextInput +import androidx.navigation.NavHostController +import androidx.navigation.compose.NavHost +import androidx.navigation.compose.composable +import androidx.navigation.compose.rememberNavController +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.example.lambda_bbb_events.controller.AppControllers +import com.example.lambda_bbb_events.controller.CampsiteController +import com.example.lambda_bbb_events.model.campsite.Campsite +import com.example.lambda_bbb_events.model.campsite.CampsiteStore +import com.example.lambda_bbb_events.view.ui.user_screens.explore.ExploreDefaultScreen +import com.example.lambda_bbb_events.view.ui.user_screens.home.HomeScreen +import io.mockk.clearAllMocks +import io.mockk.every +import io.mockk.mockk +import io.mockk.unmockkAll +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import org.junit.After +import org.junit.Assert.assertEquals +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +/** + * Tests searching from the home screen, which opens the explore screen with the results, using + * a real [CampsiteController] over three campsites. + */ +@RunWith(AndroidJUnit4::class) +class HomeSearchUITest { + @get:Rule + val composeTestRule = createComposeRule() + + private lateinit var navController: NavHostController + + private val campsites = listOf( + Campsite(campsiteId = "lake", campsiteName = "Lakeside Retreat", address = "Banff"), + Campsite(campsiteId = "forest", campsiteName = "Forest Hideout", address = "Jasper"), + Campsite(campsiteId = "meadow", campsiteName = "Meadow Field", address = "Canmore") + ).associateBy { it.campsiteId }.toMutableMap() + + @Before + fun setup() { + val store = mockk(relaxed = true) + every { store.campsites } returns campsites + val campsiteController = CampsiteController(store, scope = CoroutineScope(Dispatchers.Unconfined)) + val controllers = mockk(relaxed = true) + every { controllers.campsites } returns campsiteController + + composeTestRule.setContent { + navController = rememberNavController() + NavHost(navController, startDestination = "home") { + composable("home") { HomeScreen(navController, controllers) } + composable("explore_default") { ExploreDefaultScreen(navController, controllers) } + } + } + } + + @After + fun cleanUp() { + unmockkAll() + clearAllMocks() + } + + /** Types [text] into the home search bar, replacing what was there, and presses search. */ + private fun searchFromHome(text: String) { + val input = composeTestRule.onNodeWithTag("searchInput") + input.performTextClearance() + if (text.isNotEmpty()) { + input.performTextInput(text) + } + input.performImeAction() + composeTestRule.waitForIdle() + } + + /** How many times [name] is shown on the current screen. */ + private fun shown(name: String): Int = + composeTestRule.onAllNodesWithText(name).fetchSemanticsNodes().size + + @Test + fun searchingFromHomeShowsMatchingCampsites() { + searchFromHome("Lake") + + assertEquals("explore_default", navController.currentDestination?.route) + assertEquals(1, shown("Lakeside Retreat")) + assertEquals(0, shown("Forest Hideout")) + } + + @Test + fun searchingNothingFromHomeAfterASearchShowsEveryCampsite() { + searchFromHome("Lake") + composeTestRule.runOnIdle { navController.popBackStack() } + composeTestRule.waitForIdle() + + searchFromHome("") + + assertEquals("explore_default", navController.currentDestination?.route) + assertEquals(1, shown("Forest Hideout")) + assertEquals(1, shown("Meadow Field")) + } + + @Test + fun clearingTheHomeSearchBarThenSearchingShowsEveryCampsite() { + val input = composeTestRule.onNodeWithTag("searchInput") + input.performTextInput("Lake") + input.performTextClearance() + input.performImeAction() + composeTestRule.waitForIdle() + + assertEquals("explore_default", navController.currentDestination?.route) + assertEquals(1, shown("Forest Hideout")) + } +} diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/MainActivity.kt b/code/app/src/main/java/com/example/lambda_bbb_events/MainActivity.kt index 946a1b44..575888ee 100644 --- a/code/app/src/main/java/com/example/lambda_bbb_events/MainActivity.kt +++ b/code/app/src/main/java/com/example/lambda_bbb_events/MainActivity.kt @@ -45,7 +45,7 @@ import com.example.lambda_bbb_events.model.services.GooglePlaceSearch import com.example.lambda_bbb_events.model.services.ImageProcessor import com.example.lambda_bbb_events.model.services.IncomingMessageListener import com.example.lambda_bbb_events.model.user.UserRole -import com.example.lambda_bbb_events.store.CampsiteStore +import com.example.lambda_bbb_events.model.campsite.CampsiteStore import com.example.lambda_bbb_events.view.ui.theme.Lambda_BBBeventsTheme import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope @@ -55,7 +55,6 @@ import kotlinx.coroutines.launch import androidx.lifecycle.Lifecycle import androidx.lifecycle.repeatOnLifecycle import com.example.lambda_bbb_events.model.services.FirebaseNotificationService -import kotlinx.coroutines.flow.collect import kotlinx.coroutines.delay /* diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/controller/CampsiteController.kt b/code/app/src/main/java/com/example/lambda_bbb_events/controller/CampsiteController.kt index 437ccea7..4d757588 100644 --- a/code/app/src/main/java/com/example/lambda_bbb_events/controller/CampsiteController.kt +++ b/code/app/src/main/java/com/example/lambda_bbb_events/controller/CampsiteController.kt @@ -8,10 +8,11 @@ import androidx.compose.runtime.mutableStateOf import com.example.lambda_bbb_events.model.campsite.AvailabilitySchedule import com.example.lambda_bbb_events.model.campsite.Campsite import com.example.lambda_bbb_events.model.campsite.CampsiteFilters +import com.example.lambda_bbb_events.model.campsite.SearchArea import com.example.lambda_bbb_events.model.image.ImageMetaData import com.example.lambda_bbb_events.model.local.InMemoryRecentlyViewedStore import com.example.lambda_bbb_events.model.local.RecentlyViewedStore -import com.example.lambda_bbb_events.store.CampsiteStore +import com.example.lambda_bbb_events.model.campsite.CampsiteStore import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob @@ -336,7 +337,8 @@ class CampsiteController( endDate: LocalDate? = null, location: String = "", starRating: Double? = null, - guestRange: IntRange? = null + guestRange: IntRange? = null, + area: SearchArea? = null ): Map { filters = CampsiteFilters( @@ -344,7 +346,8 @@ class CampsiteController( endDate = endDate, location = location.trim(), starRating = starRating, - guestRange = guestRange + guestRange = guestRange, + area = area ) return filteredCampsites } @@ -379,9 +382,15 @@ class CampsiteController( return isAvailable(campsite) && meetsStarRating(campsite) && meetsGuestRange(campsite) && - meetsLocation(campsite) + meetsLocation(campsite) && + meetsArea(campsite) } + /** Checks the campsite is inside the chosen area, or that no area is chosen. */ + private fun meetsArea( + campsite: Campsite + ): Boolean = filters.area?.contains(campsite) ?: true + private fun isAvailable( campsite: Campsite ): Boolean { diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/CampsiteFilters.kt b/code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/CampsiteFilters.kt index 961f63e2..43112172 100644 --- a/code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/CampsiteFilters.kt +++ b/code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/CampsiteFilters.kt @@ -14,13 +14,15 @@ import java.util.Date * @property location Text the campsite's address or name must contain. Empty for anywhere. * @property starRating The lowest average rating, or `null` for any rating. * @property guestRange The numbers of guests the campsite can allow, or `null` for any number. + * @property area The circle on the map the campsite must be inside, or `null` for anywhere. */ data class CampsiteFilters( val startDate: LocalDate? = null, val endDate: LocalDate? = null, val location: String = "", val starRating: Double? = null, - val guestRange: IntRange? = null + val guestRange: IntRange? = null, + val area: SearchArea? = null ) /** diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/store/CampsiteStore.kt b/code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/CampsiteStore.kt similarity index 93% rename from code/app/src/main/java/com/example/lambda_bbb_events/store/CampsiteStore.kt rename to code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/CampsiteStore.kt index 7f457f19..85439ea3 100644 --- a/code/app/src/main/java/com/example/lambda_bbb_events/store/CampsiteStore.kt +++ b/code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/CampsiteStore.kt @@ -1,9 +1,7 @@ -package com.example.lambda_bbb_events.store +package com.example.lambda_bbb_events.model.campsite import androidx.compose.runtime.MutableState import androidx.compose.runtime.mutableStateMapOf -import com.example.lambda_bbb_events.model.campsite.AvailabilitySchedule -import com.example.lambda_bbb_events.model.campsite.Campsite import com.example.lambda_bbb_events.model.image.ImageMetaData import com.example.lambda_bbb_events.model.repository.CampsiteRepository import com.example.lambda_bbb_events.model.repository.LotteryRepository @@ -163,9 +161,4 @@ class CampsiteStore( val campsite = campsites.remove(campsiteId) ?: return campsites[campsiteId] = campsite.copy(imageIds = photos) } - - /** Looks up a campsite using [ownerId] as the cache key and throws if the key is absent. */ - fun getByOwner(ownerId: String): Campsite { - return campsites[ownerId] ?: throw IllegalArgumentException("Campsite not found") - } } \ No newline at end of file diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/SearchArea.kt b/code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/SearchArea.kt new file mode 100644 index 00000000..4704a230 --- /dev/null +++ b/code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/SearchArea.kt @@ -0,0 +1,131 @@ +package com.example.lambda_bbb_events.model.campsite + +import kotlin.math.asin +import kotlin.math.atan2 +import kotlin.math.cos +import kotlin.math.pow +import kotlin.math.sin +import kotlin.math.sqrt + +/* + * Describes a circle on the map that campsites can be filtered by. + */ + +/** + * A point on Earth. + * + * @property latitude Degrees north of the equator. + * @property longitude Degrees east of Greenwich. + */ +data class GeoPoint(val latitude: Double, val longitude: Double) { + + /** + * Finds the distance to [other] along Earth's surface, using the haversine formula. + * + * @return The distance in kilometres. + */ + fun distanceKmTo(other: GeoPoint): Double { + val dLat = Math.toRadians(other.latitude - latitude) + val dLon = Math.toRadians(other.longitude - longitude) + val a = sin(dLat / 2).pow(2) + + cos(Math.toRadians(latitude)) * cos(Math.toRadians(other.latitude)) * sin(dLon / 2).pow(2) + return 2 * EARTH_RADIUS_KM * asin(sqrt(a.coerceIn(0.0, 1.0))) + } + + /** + * Finds the point reached by travelling [distanceKm] from here along Earth's surface. + * + * @param distanceKm How far to travel, in kilometres. + * @param bearingDegrees The direction to travel, in degrees clockwise from north. + * @return The point reached, with its longitude between -180 and 180. + */ + fun destination(distanceKm: Double, bearingDegrees: Double): GeoPoint { + val angle = distanceKm / EARTH_RADIUS_KM + val bearing = Math.toRadians(bearingDegrees) + val lat1 = Math.toRadians(latitude) + val lat2 = asin(sin(lat1) * cos(angle) + cos(lat1) * sin(angle) * cos(bearing)) + val lon2 = Math.toRadians(longitude) + + atan2(sin(bearing) * sin(angle) * cos(lat1), cos(angle) - sin(lat1) * sin(lat2)) + return GeoPoint(Math.toDegrees(lat2), normalizeLongitude(Math.toDegrees(lon2))) + } + + companion object { + /** Earth's mean radius in kilometres. */ + const val EARTH_RADIUS_KM = 6371.0 + + /** Wraps [degrees] into the range -180 to 180. */ + private fun normalizeLongitude(degrees: Double): Double = ((degrees + 540.0) % 360.0) - 180.0 + } +} + +/** + * A circle on the map that campsites must be inside to match the filter. + * + * Create one with [of], which keeps the radius between [MIN_RADIUS_KM] and [MAX_RADIUS_KM]. + * + * @property center The middle of the circle. + * @property radiusKm How far the circle reaches from [center], in kilometres. + */ +data class SearchArea(val center: GeoPoint, val radiusKm: Double) { + + /** The point on the circle's edge due east of [center], where its resize handle sits. */ + val edge: GeoPoint + get() = center.destination(radiusKm, EAST) + + /** + * Checks whether [campsite] is inside the circle, counting its edge. Campsites without a + * location never are. Distances within [EDGE_TOLERANCE_KM] of the edge count as on it, so + * rounding cannot leave out a campsite exactly on the edge. + */ + fun contains(campsite: Campsite): Boolean = + campsite.hasLocation() && + center.distanceKmTo(GeoPoint(campsite.latitude, campsite.longitude)) <= radiusKm + EDGE_TOLERANCE_KM + + /** The same circle moved so its middle is at [newCenter]. */ + fun movedTo(newCenter: GeoPoint): SearchArea = copy(center = newCenter) + + /** The same circle resized so its edge passes through [edgePoint], within the allowed radii. */ + fun resizedTo(edgePoint: GeoPoint): SearchArea = of(center, center.distanceKmTo(edgePoint)) + + /** + * Points evenly spaced around the circle's edge, for drawing it. The first point is repeated + * at the end so the outline is closed. + * + * @param points How many different points to use. + */ + fun outline(points: Int = OUTLINE_POINTS): List = + (0..points).map { center.destination(radiusKm, FULL_TURN * it / points) } + + /** The circle's northernmost, easternmost, southernmost and westernmost points, for framing it. */ + fun extremes(): List = + listOf(NORTH, EAST, SOUTH, WEST).map { center.destination(radiusKm, it) } + + companion object { + /** The smallest radius in kilometres. */ + const val MIN_RADIUS_KM = 1.0 + + /** The largest radius in kilometres. */ + const val MAX_RADIUS_KM = 500.0 + + /** The radius used when the map cannot measure a better one. */ + const val DEFAULT_RADIUS_KM = 25.0 + + /** How far past the edge, in kilometres, still counts as on it: one millimetre. */ + const val EDGE_TOLERANCE_KM = 1e-6 + + /** How many points [outline] uses by default, enough to look round on a phone. */ + const val OUTLINE_POINTS = 64 + + private const val NORTH = 0.0 + private const val EAST = 90.0 + private const val SOUTH = 180.0 + private const val WEST = 270.0 + private const val FULL_TURN = 360.0 + + /** + * Creates a circle, keeping [radiusKm] between [MIN_RADIUS_KM] and [MAX_RADIUS_KM]. + */ + fun of(center: GeoPoint, radiusKm: Double): SearchArea = + SearchArea(center, radiusKm.coerceIn(MIN_RADIUS_KM, MAX_RADIUS_KM)) + } +} diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/store/UserStore.kt b/code/app/src/main/java/com/example/lambda_bbb_events/store/UserStore.kt deleted file mode 100644 index f49c923c..00000000 --- a/code/app/src/main/java/com/example/lambda_bbb_events/store/UserStore.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.example.lambda_bbb_events.store - -/** Defines the placeholder type for a user store. */ -class UserStore { -} \ No newline at end of file diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/filter/HomeCampsiteFilter.kt b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/filter/HomeCampsiteFilter.kt index 9bcbf4db..d8e6fbdf 100644 --- a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/filter/HomeCampsiteFilter.kt +++ b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/filter/HomeCampsiteFilter.kt @@ -13,6 +13,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.unit.dp import com.example.lambda_bbb_events.controller.CampsiteController +import com.example.lambda_bbb_events.model.campsite.SearchArea +import com.example.lambda_bbb_events.view.ui.components.map.AreaMap +import java.util.Locale import com.example.lambda_bbb_events.model.formatting.parseDateOrNull import com.example.lambda_bbb_events.view.ui.components.rating.PickRatingStars import com.example.lambda_bbb_events.view.ui.components.calendar.DatePickerField @@ -48,6 +51,7 @@ fun HomeCampsiteFilter( var fromDate by remember { mutableStateOf(applied.startDate?.toString() ?: "") } var toDate by remember { mutableStateOf(applied.endDate?.toString() ?: "") } var location by remember { mutableStateOf(applied.location) } + var area by remember { mutableStateOf(applied.area) } var chosenGuests by remember { mutableStateOf(applied.guestRange) } var rating by remember { mutableIntStateOf(applied.starRating?.roundToInt() ?: 0) } @@ -206,6 +210,17 @@ fun HomeCampsiteFilter( color = MaterialTheme.colorScheme.outlineVariant ) + AreaFilterSection( + area = area, + onAreaChange = { area = it } + ) + + Spacer(modifier = Modifier.height(12.dp)) + + HorizontalDivider( + color = MaterialTheme.colorScheme.outlineVariant + ) + // Number of guests FilterHeader( title = "Number of Guests", @@ -282,7 +297,8 @@ fun HomeCampsiteFilter( endDate = endDate, location = location.trim(), guestRange = guestRange, - starRating = rating.takeIf { it > 0 }?.toDouble() + starRating = rating.takeIf { it > 0 }?.toDouble(), + area = area ) onShowResults() @@ -315,6 +331,59 @@ fun HomeCampsiteFilter( } } +/** + * Displays the area filter: a map where tapping places a circle and dragging its edge resizes + * it, with a line saying how far the circle reaches. + * + * @param area The chosen area, or `null` for anywhere. + * @param onAreaChange Called with the new area, or `null` when it is reset. + */ +@Composable +private fun AreaFilterSection( + area: SearchArea?, + onAreaChange: (SearchArea?) -> Unit +) { + FilterHeader( + title = "Area", + onReset = { onAreaChange(null) }, + titleTag = "areaLabel", + resetTag = "areaResetButton" + ) + + AreaMap( + area = area, + onAreaChange = onAreaChange + ) + + Text( + text = areaSummary(area), + style = MaterialTheme.typography.bodyMedium, + color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier + .padding(top = 8.dp) + .testTag("areaSummary") + ) +} + +/** + * Describes [area] for the line under the map, with the radius to one decimal place when it is + * under [PRECISE_RADIUS_BELOW_KM] kilometres. + */ +private fun areaSummary(area: SearchArea?): String { + if (area == null) { + return "Tap the map to choose an area, then drag the handle to resize it." + } + val radius = if (area.radiusKm < PRECISE_RADIUS_BELOW_KM) { + String.format(Locale.getDefault(), "%.1f", area.radiusKm) + } else { + area.radiusKm.roundToInt().toString() + } + return "Within $radius km of the marker" +} + +/** Radii in kilometres below this are shown to one decimal place, since rounding hides them. */ +private const val PRECISE_RADIUS_BELOW_KM = 10.0 + /** * Displays a filter section heading with a reset button. * diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/AreaMap.kt b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/AreaMap.kt new file mode 100644 index 00000000..3aae449c --- /dev/null +++ b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/AreaMap.kt @@ -0,0 +1,179 @@ +package com.example.lambda_bbb_events.view.ui.components.map + +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.gestures.detectDragGestures +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.offset +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.Card +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.rememberUpdatedState +import androidx.compose.ui.Modifier +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.platform.testTag +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.IntOffset +import androidx.compose.ui.unit.dp +import com.example.lambda_bbb_events.model.campsite.GeoPoint +import com.example.lambda_bbb_events.model.campsite.SearchArea +import com.example.lambda_bbb_events.model.services.MapFallback +import com.example.lambda_bbb_events.model.services.MapProvider +import kotlin.math.roundToInt + +/* + * Provides a map for choosing an area to filter campsites by. Tapping the map places the + * area's centre, and dragging the handle on its edge resizes it. The Google and OpenStreetMap + * versions are in GoogleAreaMap.kt and OpenStreetAreaMap.kt. + */ + +/** Where the map looks before an area is chosen, the same place as the location picker. */ +internal val AREA_MAP_START = GeoPoint(51.1869, -115.5323) + +/** Zoom used before an area is chosen, far enough out to show a region. */ +internal const val AREA_MAP_START_ZOOM = 6 + +/** Opacity of the area's fill, so the map under it stays readable. */ +internal const val AREA_FILL_ALPHA = 0.15f + +/** Width of the area's outline in pixels. */ +internal const val AREA_STROKE_WIDTH = 4f + +/** How much of the map's width a new area's radius takes, so its handle starts on screen. */ +private const val NEW_AREA_WIDTH_FRACTION = 0.25f + +/** Size of the resize handle, big enough to grab with a finger. */ +private val HANDLE_SIZE = 28.dp + +/** Width of the coloured ring around the resize handle. */ +private val HANDLE_BORDER = 3.dp + +/** + * Converts between places and pixels on a map, so things drawn over the map can follow it. + */ +internal interface MapProjector { + + /** Where [point] is on the map, in pixels from its top left, or `null` before the map is ready. */ + fun toScreen(point: GeoPoint): Offset? + + /** The place at [screen] pixels from the map's top left, or `null` before the map is ready. */ + fun toPoint(screen: Offset): GeoPoint? +} + +/** + * Displays a map for choosing a circular area. + * + * Tapping the map places a marker with a circle around it, or moves the circle there if one is + * already placed. Dragging the handle on the circle's edge resizes it. The map is Google's, or + * OpenStreetMap's when there is no Google API key. + * + * @param area The chosen area, or `null` if none is chosen yet. + * @param onAreaChange Called with the new area each time it is placed, moved or resized. + * @param modifier Modifier for styling and layout. + * @param height Height of the map. + */ +@Composable +fun AreaMap( + area: SearchArea?, + onAreaChange: (SearchArea) -> Unit, + modifier: Modifier = Modifier, + height: Dp = 260.dp +) { + Card( + modifier = modifier + .fillMaxWidth() + .height(height) + .testTag("areaMap"), + shape = RoundedCornerShape(12.dp) + ) { + when (MapFallback.shared.mapProvider) { + MapProvider.GOOGLE -> GoogleAreaMap(area, onAreaChange, Modifier.fillMaxSize()) + MapProvider.OPEN_STREET_MAP -> OpenStreetAreaMap(area, onAreaChange, Modifier.fillMaxSize()) + } + } +} + +/** + * Finds the area after the map is tapped at [tap]: the current area moved there, or a new one + * there whose radius is a quarter of the map's width. + * + * @param current The area before the tap, or `null` if none was chosen. + * @param projector Measures the map, to size a new area. + * @param mapWidthPx The map's width in pixels. + */ +internal fun areaAfterTap( + tap: GeoPoint, + current: SearchArea?, + projector: MapProjector, + mapWidthPx: Int +): SearchArea = current?.movedTo(tap) ?: SearchArea.of(tap, newAreaRadiusKm(tap, projector, mapWidthPx)) + +/** + * The radius for a new area at [center]: the distance covered by a quarter of the map's width, + * or [SearchArea.DEFAULT_RADIUS_KM] if the map cannot be measured yet. + */ +private fun newAreaRadiusKm(center: GeoPoint, projector: MapProjector, mapWidthPx: Int): Double { + val centerOnScreen = projector.toScreen(center) ?: return SearchArea.DEFAULT_RADIUS_KM + val edgeOnScreen = centerOnScreen + Offset(mapWidthPx * NEW_AREA_WIDTH_FRACTION, 0f) + val edge = projector.toPoint(edgeOnScreen) ?: return SearchArea.DEFAULT_RADIUS_KM + return center.distanceKmTo(edge) +} + +/** + * Draws the resize handle on [area]'s edge, over the map. Callers must recompose it whenever + * the map moves, so the handle stays on the edge. + * + * @param area The area to resize, or `null` to draw nothing. + * @param projector Places the handle and converts drags back to places. + * @param onAreaChange Called with the resized area while the handle is dragged. + */ +@Composable +internal fun AreaResizeHandle( + area: SearchArea?, + projector: MapProjector, + onAreaChange: (SearchArea) -> Unit +) { + if (area == null) return + val position = projector.toScreen(area.edge) ?: return + RadiusHandle(position) { screen -> + projector.toPoint(screen)?.let { onAreaChange(area.resizedTo(it)) } + } +} + +/** + * A round handle centred on [position] that reports where it is dragged to. + * + * @param position Where the handle is, in pixels from the map's top left. + * @param onDragTo Called with the handle's new position, in the same pixels, while it is dragged. + */ +@Composable +private fun RadiusHandle(position: Offset, onDragTo: (Offset) -> Unit) { + val currentPosition by rememberUpdatedState(position) + val currentOnDragTo by rememberUpdatedState(onDragTo) + val halfSizePx = with(LocalDensity.current) { HANDLE_SIZE.toPx() / 2 } + + Box( + modifier = Modifier + .offset { IntOffset((position.x - halfSizePx).roundToInt(), (position.y - halfSizePx).roundToInt()) } + .size(HANDLE_SIZE) + .background(Color.White, CircleShape) + .border(HANDLE_BORDER, MaterialTheme.colorScheme.primary, CircleShape) + .pointerInput(Unit) { + detectDragGestures { change, drag -> + change.consume() + currentOnDragTo(currentPosition + drag) + } + } + .testTag("areaRadiusHandle") + ) +} diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/GoogleAreaMap.kt b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/GoogleAreaMap.kt new file mode 100644 index 00000000..8faea581 --- /dev/null +++ b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/GoogleAreaMap.kt @@ -0,0 +1,140 @@ +package com.example.lambda_bbb_events.view.ui.components.map + +import android.graphics.Point +import androidx.compose.foundation.layout.Box +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.key +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.unit.dp +import com.example.lambda_bbb_events.model.campsite.GeoPoint +import com.example.lambda_bbb_events.model.campsite.SearchArea +import com.google.android.gms.maps.CameraUpdateFactory +import com.google.android.gms.maps.GoogleMap +import com.google.android.gms.maps.model.CameraPosition +import com.google.android.gms.maps.model.LatLng +import com.google.android.gms.maps.model.LatLngBounds +import com.google.maps.android.compose.CameraPositionState +import com.google.maps.android.compose.Circle +import com.google.maps.android.compose.GoogleMapComposable +import com.google.maps.android.compose.MapEffect +import com.google.maps.android.compose.MapsComposeExperimentalApi +import com.google.maps.android.compose.Marker +import com.google.maps.android.compose.rememberCameraPositionState +import com.google.maps.android.compose.rememberUpdatedMarkerState +import kotlin.math.roundToInt + +/* + * The Google version of AreaMap, using the native Maps SDK for Android. + */ + +/** Metres in a kilometre, for Google's circle radius. */ +private const val METRES_PER_KM = 1000.0 + +/** The same place as a Google map location. */ +private fun GeoPoint.toLatLng(): LatLng = LatLng(latitude, longitude) + +/** The same place as a [GeoPoint]. */ +private fun LatLng.toGeoPoint(): GeoPoint = GeoPoint(latitude, longitude) + +/** + * Converts between places and pixels on a Google map. + * + * @param state The map's camera, which gives its projection once the map is ready. + */ +private class GoogleProjector(private val state: CameraPositionState) : MapProjector { + + override fun toScreen(point: GeoPoint): Offset? = + state.projection?.toScreenLocation(point.toLatLng())?.let { Offset(it.x.toFloat(), it.y.toFloat()) } + + override fun toPoint(screen: Offset): GeoPoint? = + state.projection?.fromScreenLocation(Point(screen.x.roundToInt(), screen.y.roundToInt()))?.toGeoPoint() +} + +/** + * Moves [map] so the whole of [area] is in view. + * + * @param paddingPx Space kept between the circle and the edge of the map. + */ +private fun frameArea(map: GoogleMap, area: SearchArea, paddingPx: Int) { + val bounds = LatLngBounds.builder() + area.extremes().forEach { bounds.include(it.toLatLng()) } + map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds.build(), paddingPx)) +} + +/** + * The circle and centre marker of [area] on a Google map. + * + * @param color Colour of the circle's outline and, faded, its fill. + */ +@Composable +@GoogleMapComposable +private fun GoogleAreaShape(area: SearchArea, color: Color) { + Circle( + center = area.center.toLatLng(), + radius = area.radiusKm * METRES_PER_KM, + fillColor = color.copy(alpha = AREA_FILL_ALPHA), + strokeColor = color, + strokeWidth = AREA_STROKE_WIDTH + ) + Marker( + state = rememberUpdatedMarkerState(area.center.toLatLng()), + title = "Area centre", + onClick = { true } + ) +} + +/** + * The Google version of [AreaMap]. The map frames the area once it loads, if one was already + * chosen, and the resize handle is drawn over it once it is ready. + * + * @param area The chosen area, or `null` if none is chosen yet. + * @param onAreaChange Called with the new area each time it is placed, moved or resized. + * @param modifier Sets the size and shape of the map. + */ +@OptIn(MapsComposeExperimentalApi::class) +@Composable +internal fun GoogleAreaMap( + area: SearchArea?, + onAreaChange: (SearchArea) -> Unit, + modifier: Modifier +) { + val cameraPositionState = rememberCameraPositionState { + position = CameraPosition.fromLatLngZoom((area?.center ?: AREA_MAP_START).toLatLng(), AREA_MAP_START_ZOOM.toFloat()) + } + val projector = remember(cameraPositionState) { GoogleProjector(cameraPositionState) } + val paddingPx = with(LocalDensity.current) { BOUNDS_PADDING.dp.roundToPx() } + val color = MaterialTheme.colorScheme.primary + var isLoaded by remember { mutableStateOf(false) } + var widthPx by remember { mutableIntStateOf(0) } + + Box(modifier = modifier.onSizeChanged { widthPx = it.width }) { + AppGoogleMap( + cameraPositionState = cameraPositionState, + modifier = Modifier.matchParentSize(), + onMapClick = { onAreaChange(areaAfterTap(it.toGeoPoint(), area, projector, widthPx)) }, + onMapLoaded = { isLoaded = true } + ) { + MapEffect(isLoaded) { map -> + if (isLoaded) { + area?.let { frameArea(map, it, paddingPx) } + } + } + area?.let { GoogleAreaShape(it, color) } + } + if (isLoaded) { + key(cameraPositionState.position) { + AreaResizeHandle(area, projector, onAreaChange) + } + } + } +} diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/GoogleMapViews.kt b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/GoogleMapViews.kt index a1a4507e..da400ea8 100644 --- a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/GoogleMapViews.kt +++ b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/GoogleMapViews.kt @@ -96,7 +96,7 @@ private class ScrollGuardMapView(context: Context, options: GoogleMapOptions) : * @param content The markers on the map. */ @Composable -private fun AppGoogleMap( +internal fun AppGoogleMap( cameraPositionState: CameraPositionState, modifier: Modifier, onMapClick: ((LatLng) -> Unit)? = null, diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/LocationSearchBar.kt b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/LocationSearchBar.kt index 9c6682bc..735b6801 100644 --- a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/LocationSearchBar.kt +++ b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/LocationSearchBar.kt @@ -2,6 +2,15 @@ package com.example.lambda_bbb_events.view.ui.components.map import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.width +import androidx.compose.ui.focus.onFocusChanged +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.unit.IntOffset +import androidx.compose.ui.unit.IntSize +import androidx.compose.ui.window.Popup +import androidx.compose.ui.window.PopupProperties import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth @@ -94,6 +103,8 @@ fun LocationSearchBar( // The text being searched for again, because its place could not be looked up var searchedAgain by remember { mutableStateOf(null) } var choosing by remember { mutableStateOf(null) } + var fieldSize by remember { mutableStateOf(IntSize.Zero) } + var isFocused by remember { mutableStateOf(false) } val isLoading = isSuggesting || choosing?.isActive == true val scope = rememberCoroutineScope() val focusManager = LocalFocusManager.current @@ -156,75 +167,68 @@ fun LocationSearchBar( modifier = modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(4.dp) ) { - OutlinedTextField( - value = query, - onValueChange = { - message = null - searchedAgain = null - typedQuery = it - onQueryChange(it) - }, - placeholder = { Text("Search location...") }, - leadingIcon = { - Icon( - Icons.Default.Search, - contentDescription = "Search" - ) - }, - trailingIcon = { - if (isLoading) { - CircularProgressIndicator( - modifier = Modifier.size(20.dp), - strokeWidth = 2.dp + Box { + OutlinedTextField( + value = query, + onValueChange = { + message = null + searchedAgain = null + typedQuery = it + onQueryChange(it) + }, + placeholder = { Text("Search location...") }, + leadingIcon = { + Icon( + Icons.Default.Search, + contentDescription = "Search" ) - } else if (query.isNotEmpty()) { - IconButton( - onClick = { - message = null - typedQuery = "" - onQueryChange("") - }, - modifier = Modifier.testTag("locationSearchClear") - ) { - Icon( - Icons.Default.Clear, - contentDescription = "Clear search" + }, + trailingIcon = { + if (isLoading) { + CircularProgressIndicator( + modifier = Modifier.size(20.dp), + strokeWidth = 2.dp ) + } else if (query.isNotEmpty()) { + IconButton( + onClick = { + message = null + typedQuery = "" + onQueryChange("") + }, + modifier = Modifier.testTag("locationSearchClear") + ) { + Icon( + Icons.Default.Clear, + contentDescription = "Clear search" + ) + } } - } - }, - singleLine = true, - keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search), - keyboardActions = KeyboardActions( - onSearch = { - val first = suggestions.firstOrNull() - if (isSearching && first != null && suggestedFor == typedQuery.trim()) { - choose(first) + }, + singleLine = true, + keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search), + keyboardActions = KeyboardActions( + onSearch = { + val first = suggestions.firstOrNull() + if (isSearching && first != null && suggestedFor == typedQuery.trim()) { + choose(first) + } } - } - ), - modifier = Modifier - .fillMaxWidth() - .testTag("locationSearchInput"), - shape = RoundedCornerShape(16.dp) - ) - - if (isSearching && suggestions.isNotEmpty()) { - Card( + ), modifier = Modifier .fillMaxWidth() - .testTag("locationSuggestions"), - shape = RoundedCornerShape(12.dp), - colors = CardDefaults.cardColors( - containerColor = MaterialTheme.colorScheme.surfaceVariant + .onSizeChanged { fieldSize = it } + .onFocusChanged { isFocused = it.isFocused } + .testTag("locationSearchInput"), + shape = RoundedCornerShape(16.dp) + ) + + if (isSearching && suggestions.isNotEmpty() && (isFocused || searchedAgain != null)) { + SuggestionsPopup( + suggestions = suggestions, + fieldSize = fieldSize, + onChoose = { choose(it) } ) - ) { - for (suggestion in suggestions) { - SuggestionRow( - suggestion = suggestion, - onClick = { choose(suggestion) } - ) - } } } @@ -239,6 +243,57 @@ fun LocationSearchBar( } } +/** + * Displays the recommended places in a popup just under the search field, drawn over whatever + * is below it, such as the map, instead of pushing it down. The popup does not take focus, so + * the keyboard stays open for typing. It is shown while the field is focused, or while a place + * must be chosen again after the search switched services. + * + * @param suggestions The places to recommend. + * @param fieldSize The search field's size, so the popup sits under it at the same width. + * @param onChoose Called with the place that is tapped. + */ +@Composable +private fun SuggestionsPopup( + suggestions: List, + fieldSize: IntSize, + onChoose: (PlaceSuggestion) -> Unit +) { + val density = LocalDensity.current + val gapPx = with(density) { SUGGESTIONS_GAP.roundToPx() } + val width = with(density) { fieldSize.width.toDp() } + + Popup( + alignment = Alignment.TopStart, + offset = IntOffset(0, fieldSize.height + gapPx), + properties = PopupProperties(focusable = false) + ) { + Card( + modifier = Modifier + .width(width) + .testTag("locationSuggestions"), + shape = RoundedCornerShape(12.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant + ), + elevation = CardDefaults.cardElevation(defaultElevation = SUGGESTIONS_ELEVATION) + ) { + for (suggestion in suggestions) { + SuggestionRow( + suggestion = suggestion, + onClick = { onChoose(suggestion) } + ) + } + } + } +} + +/** Space between the search field and the suggestions under it. */ +private val SUGGESTIONS_GAP = 4.dp + +/** Shadow under the suggestions, so they stand out from the map they cover. */ +private val SUGGESTIONS_ELEVATION = 6.dp + /** Displays one recommended place. */ @Composable private fun SuggestionRow( diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/OpenStreetAreaMap.kt b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/OpenStreetAreaMap.kt new file mode 100644 index 00000000..ab2baea8 --- /dev/null +++ b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/OpenStreetAreaMap.kt @@ -0,0 +1,170 @@ +package com.example.lambda_bbb_events.view.ui.components.map + +import android.graphics.PointF +import androidx.compose.material3.MaterialTheme +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.key +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberUpdatedState +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.unit.dp +import com.example.lambda_bbb_events.model.campsite.GeoPoint +import com.example.lambda_bbb_events.model.campsite.SearchArea +import org.maplibre.android.camera.CameraPosition +import org.maplibre.android.camera.CameraUpdateFactory +import org.maplibre.android.geometry.LatLng +import org.maplibre.android.geometry.LatLngBounds +import org.maplibre.android.maps.MapLibreMap +import org.maplibre.android.style.layers.FillLayer +import org.maplibre.android.style.layers.LineLayer +import org.maplibre.android.style.layers.PropertyFactory.fillColor +import org.maplibre.android.style.layers.PropertyFactory.fillOpacity +import org.maplibre.android.style.layers.PropertyFactory.lineColor +import org.maplibre.android.style.layers.PropertyFactory.lineWidth +import org.maplibre.android.style.sources.GeoJsonSource +import org.maplibre.geojson.FeatureCollection +import org.maplibre.geojson.Point +import org.maplibre.geojson.Polygon + +/* + * The OpenStreetMap version of AreaMap, drawn natively with MapLibre. The circle is a polygon + * layer under the marker layer. + */ + +/** The ID of the source that holds the area's circle. */ +private const val AREA = "area" + +/** The ID of the layer that fills the area's circle. */ +private const val AREA_FILL = "area-fill" + +/** The ID of the layer that outlines the area's circle. */ +private const val AREA_OUTLINE = "area-outline" + +/** Nothing, for clearing a source when no area is chosen. */ +private val NOTHING: FeatureCollection = FeatureCollection.fromFeatures(emptyList()) + +/** The same place as a MapLibre location. */ +private fun GeoPoint.toOsmLatLng(): LatLng = LatLng(latitude, longitude) + +/** + * Converts between places and pixels on an OpenStreetMap map. + */ +private class OsmProjector(private val map: MapLibreMap) : MapProjector { + + override fun toScreen(point: GeoPoint): Offset = + map.projection.toScreenLocation(point.toOsmLatLng()).let { Offset(it.x, it.y) } + + override fun toPoint(screen: Offset): GeoPoint = + map.projection.fromScreenLocation(PointF(screen.x, screen.y)).let { GeoPoint(it.latitude, it.longitude) } +} + +/** + * The sources an OpenStreetMap map draws an area with: the circle, and the marker at its centre. + */ +private class OsmAreaSources(private val circle: GeoJsonSource, private val marker: GeoJsonSource) { + + /** Draws [area] on the map, or clears it if [area] is `null`. */ + fun show(area: SearchArea?) { + if (area == null) { + circle.setGeoJson(NOTHING) + marker.setGeoJson(NOTHING) + return + } + circle.setGeoJson(Polygon.fromLngLats(listOf(area.outline().map { Point.fromLngLat(it.longitude, it.latitude) }))) + marker.setGeoJson(markerPoint(area.center.latitude, area.center.longitude)) + } + + companion object { + /** + * Adds the circle's source and layers to [map], under the marker layer so the centre + * marker is drawn on top. + * + * @param marker The map's marker source, which shows the centre. + * @param color Colour of the circle's outline and, faded, its fill. + */ + fun addTo(map: MapLibreMap, marker: GeoJsonSource, color: Int): OsmAreaSources { + val circle = GeoJsonSource(AREA) + map.style?.apply { + addSource(circle) + addLayerBelow(FillLayer(AREA_FILL, AREA).withProperties(fillColor(color), fillOpacity(AREA_FILL_ALPHA)), MARKERS) + addLayerBelow(LineLayer(AREA_OUTLINE, AREA).withProperties(lineColor(color), lineWidth(AREA_STROKE_WIDTH / 2)), MARKERS) + } + return OsmAreaSources(circle, marker) + } + } +} + +/** + * Moves [map] so the whole of [area] is in view. + * + * @param paddingPx Space kept between the circle and the edge of the map. + */ +private fun frameOsmArea(map: MapLibreMap, area: SearchArea, paddingPx: Int) { + val bounds = LatLngBounds.Builder() + area.extremes().forEach { bounds.include(it.toOsmLatLng()) } + map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds.build(), paddingPx)) +} + +/** + * The OpenStreetMap version of [AreaMap]. The map frames the area when it opens, if one was + * already chosen, and the resize handle is drawn over it once it is ready. + * + * @param area The chosen area, or `null` if none is chosen yet. + * @param onAreaChange Called with the new area each time it is placed, moved or resized. + * @param modifier Sets the size and shape of the map. + */ +@Composable +internal fun OpenStreetAreaMap( + area: SearchArea?, + onAreaChange: (SearchArea) -> Unit, + modifier: Modifier +) { + val currentArea by rememberUpdatedState(area) + val currentOnAreaChange by rememberUpdatedState(onAreaChange) + val paddingPx = with(LocalDensity.current) { BOUNDS_PADDING.dp.roundToPx() } + val color = MaterialTheme.colorScheme.primary.toArgb() + var sources by remember { mutableStateOf(null) } + var projector by remember { mutableStateOf(null) } + var cameraMoves by remember { mutableIntStateOf(0) } + var widthPx by remember { mutableIntStateOf(0) } + + LaunchedEffect(sources, area) { + sources?.show(area) + } + + val start = CameraPosition.Builder() + .target((area?.center ?: AREA_MAP_START).toOsmLatLng()) + .zoom(AREA_MAP_START_ZOOM.toDouble()) + .build() + OsmMap( + start = start, + modifier = modifier.onSizeChanged { widthPx = it.width }, + overlay = { + projector?.let { + key(cameraMoves) { + AreaResizeHandle(area, it, onAreaChange) + } + } + } + ) { map, marker -> + val mapProjector = OsmProjector(map) + sources = OsmAreaSources.addTo(map, marker, color) + map.addOnCameraMoveListener { cameraMoves++ } + map.addOnMapClickListener { location -> + val tap = GeoPoint(location.latitude, location.longitude) + currentOnAreaChange(areaAfterTap(tap, currentArea, mapProjector, widthPx)) + true + } + currentArea?.let { frameOsmArea(map, it, paddingPx) } + projector = mapProjector + } +} diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/OpenStreetMapViews.kt b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/OpenStreetMapViews.kt index b455e411..03563e75 100644 --- a/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/OpenStreetMapViews.kt +++ b/code/app/src/main/java/com/example/lambda_bbb_events/view/ui/components/map/OpenStreetMapViews.kt @@ -74,7 +74,7 @@ import com.google.android.gms.maps.model.LatLng as GoogleLatLng private const val OSM_PICKER_ZOOM = 13.0 /** The ID of the source and layer that hold the markers. */ -private const val MARKERS = "markers" +internal const val MARKERS = "markers" /** How far in pixels from a marker a tap still selects it. */ private const val TAP_SLOP_PX = 32f @@ -92,7 +92,7 @@ private val osmHttpClient: OkHttpClient by lazy { } /** A point on the map, as the marker source needs it. */ -private fun markerPoint(latitude: Double, longitude: Double): Point = Point.fromLngLat(longitude, latitude) +internal fun markerPoint(latitude: Double, longitude: Double): Point = Point.fromLngLat(longitude, latitude) /** Where the campsite is on the map. */ private fun Campsite.osmPosition(): LatLng = LatLng(latitude, longitude) @@ -147,7 +147,7 @@ private class OsmMapView(context: Context, start: CameraPosition) : MapView( * @param onReady Sets up the map's markers and listeners. */ @Composable -private fun OsmMap( +internal fun OsmMap( start: CameraPosition, modifier: Modifier, overlay: @Composable BoxScope.() -> Unit = {}, diff --git a/code/app/src/test/java/com/example/lambda_bbb_events/controller/CampsiteControllerAreaUnitTest.kt b/code/app/src/test/java/com/example/lambda_bbb_events/controller/CampsiteControllerAreaUnitTest.kt new file mode 100644 index 00000000..e41b16d4 --- /dev/null +++ b/code/app/src/test/java/com/example/lambda_bbb_events/controller/CampsiteControllerAreaUnitTest.kt @@ -0,0 +1,94 @@ +package com.example.lambda_bbb_events.controller + +import com.example.lambda_bbb_events.model.campsite.Campsite +import com.example.lambda_bbb_events.model.campsite.CampsiteStore +import com.example.lambda_bbb_events.model.campsite.GeoPoint +import com.example.lambda_bbb_events.model.campsite.SearchArea +import io.mockk.every +import io.mockk.mockk +import kotlinx.coroutines.test.TestScope +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Before +import org.junit.Test + +/** + * Tests [CampsiteController] filtering campsites by an area on the map. + */ +class CampsiteControllerAreaUnitTest { + private val store = mockk() + private lateinit var controller: CampsiteController + + private val calgary = GeoPoint(51.0447, -114.0719) + + private val banffSite = Campsite( + campsiteId = "banff", + campsiteName = "Tunnel Mountain", + address = "Banff", + latitude = 51.1784, + longitude = -115.5708 + ) + private val jasperSite = Campsite( + campsiteId = "jasper", + campsiteName = "Whistlers", + address = "Jasper", + latitude = 52.8737, + longitude = -118.0814 + ) + private val unlocatedSite = Campsite( + campsiteId = "unlocated", + campsiteName = "Somewhere", + address = "Banff" + ) + + @Before + fun setup() { + val campsites = listOf(banffSite, jasperSite, unlocatedSite).associateBy { it.campsiteId } + every { store.campsites } returns campsites.toMutableMap() + controller = CampsiteController(store, scope = TestScope()) + } + + private fun Map.ids() = keys.sorted() + + @Test + fun areaKeepsOnlyCampsitesInsideIt() { + val results = controller.applyFilters(area = SearchArea.of(calgary, 150.0)) + + assertEquals(listOf("banff"), results.ids()) + } + + @Test + fun largerAreaKeepsMoreCampsites() { + val results = controller.applyFilters(area = SearchArea.of(calgary, 450.0)) + + assertEquals(listOf("banff", "jasper"), results.ids()) + } + + @Test + fun campsitesWithoutLocationAreLeftOutOfAnArea() { + val results = controller.applyFilters(area = SearchArea.of(calgary, SearchArea.MAX_RADIUS_KM)) + + assertEquals(listOf("banff", "jasper"), results.ids()) + } + + @Test + fun noAreaKeepsEveryCampsite() { + assertEquals(listOf("banff", "jasper", "unlocated"), controller.applyFilters().ids()) + } + + @Test + fun areaCombinesWithTheTextLocationFilter() { + val results = controller.applyFilters(location = "Jasper", area = SearchArea.of(calgary, 150.0)) + + assertEquals(emptyList(), results.ids()) + } + + @Test + fun clearingFiltersRemovesTheArea() { + controller.applyFilters(area = SearchArea.of(calgary, 150.0)) + controller.clearFilters() + + assertNull(controller.filters.area) + assertEquals(listOf("banff", "jasper", "unlocated"), controller.filteredCampsites.ids()) + } +} diff --git a/code/app/src/test/java/com/example/lambda_bbb_events/controller/CampsiteControllerSearchUnitTest.kt b/code/app/src/test/java/com/example/lambda_bbb_events/controller/CampsiteControllerSearchUnitTest.kt index 4b72d749..10132ac1 100644 --- a/code/app/src/test/java/com/example/lambda_bbb_events/controller/CampsiteControllerSearchUnitTest.kt +++ b/code/app/src/test/java/com/example/lambda_bbb_events/controller/CampsiteControllerSearchUnitTest.kt @@ -7,7 +7,7 @@ import com.example.lambda_bbb_events.model.campsite.CampsiteFilters import com.example.lambda_bbb_events.model.image.ImageMetaData import com.example.lambda_bbb_events.model.lottery.Lottery import com.example.lambda_bbb_events.model.lottery.LotteryStatus -import com.example.lambda_bbb_events.store.CampsiteStore +import com.example.lambda_bbb_events.model.campsite.CampsiteStore import io.mockk.coEvery import io.mockk.coVerify import io.mockk.every diff --git a/code/app/src/test/java/com/example/lambda_bbb_events/controller/CampsiteControllerUnitTest.kt b/code/app/src/test/java/com/example/lambda_bbb_events/controller/CampsiteControllerUnitTest.kt index 6342c477..8504bfbf 100644 --- a/code/app/src/test/java/com/example/lambda_bbb_events/controller/CampsiteControllerUnitTest.kt +++ b/code/app/src/test/java/com/example/lambda_bbb_events/controller/CampsiteControllerUnitTest.kt @@ -2,7 +2,7 @@ package com.example.lambda_bbb_events.controller import com.example.lambda_bbb_events.model.campsite.Campsite import com.example.lambda_bbb_events.model.local.InMemoryRecentlyViewedStore -import com.example.lambda_bbb_events.store.CampsiteStore +import com.example.lambda_bbb_events.model.campsite.CampsiteStore import io.mockk.every import kotlinx.coroutines.test.runTest import org.junit.Assert.assertFalse diff --git a/code/app/src/test/java/com/example/lambda_bbb_events/model/campsite/SearchAreaUnitTest.kt b/code/app/src/test/java/com/example/lambda_bbb_events/model/campsite/SearchAreaUnitTest.kt new file mode 100644 index 00000000..f6dac283 --- /dev/null +++ b/code/app/src/test/java/com/example/lambda_bbb_events/model/campsite/SearchAreaUnitTest.kt @@ -0,0 +1,127 @@ +package com.example.lambda_bbb_events.model.campsite + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test + +/** + * Tests [GeoPoint] distances and [SearchArea] checks, resizing, and outlines. + */ +class SearchAreaUnitTest { + private val edmonton = GeoPoint(53.5461, -113.4938) + private val calgary = GeoPoint(51.0447, -114.0719) + private val banff = GeoPoint(51.1784, -115.5708) + + private fun campsiteAt(point: GeoPoint) = Campsite( + campsiteId = "site", + latitude = point.latitude, + longitude = point.longitude + ) + + @Test + fun distanceBetweenCitiesMatchesTheMap() { + assertEquals(280.0, edmonton.distanceKmTo(calgary), 5.0) + assertEquals(105.0, calgary.distanceKmTo(banff), 5.0) + } + + @Test + fun distanceToItselfIsZero() { + assertEquals(0.0, banff.distanceKmTo(banff), 1e-9) + } + + @Test + fun destinationIsTheGivenDistanceAway() { + for (bearing in listOf(0.0, 45.0, 90.0, 180.0, 270.0)) { + assertEquals(50.0, banff.distanceKmTo(banff.destination(50.0, bearing)), 1e-6) + } + } + + @Test + fun destinationWrapsAcrossTheDateLine() { + val point = GeoPoint(0.0, 179.9).destination(50.0, 90.0) + assertTrue(point.longitude in -180.0..-179.0) + } + + @Test + fun containsCampsitesInsideTheCircleOnly() { + val area = SearchArea.of(calgary, 150.0) + + assertTrue(area.contains(campsiteAt(banff))) + assertFalse(area.contains(campsiteAt(edmonton))) + } + + @Test + fun campsiteOnTheEdgeIsInside() { + val area = SearchArea.of(calgary, 100.0) + + assertTrue(area.contains(campsiteAt(area.edge))) + } + + @Test + fun campsiteWithoutLocationIsNeverInside() { + val area = SearchArea.of(GeoPoint(0.0, 0.0), SearchArea.MAX_RADIUS_KM) + + assertFalse(area.contains(campsiteAt(GeoPoint(0.0, 0.0)))) + } + + @Test + fun radiusIsKeptWithinLimits() { + assertEquals(SearchArea.MIN_RADIUS_KM, SearchArea.of(banff, 0.01).radiusKm, 0.0) + assertEquals(SearchArea.MAX_RADIUS_KM, SearchArea.of(banff, 10_000.0).radiusKm, 0.0) + } + + @Test + fun resizingMakesTheEdgePassThroughThePoint() { + val area = SearchArea.of(calgary, 10.0).resizedTo(banff) + + assertEquals(calgary.distanceKmTo(banff), area.radiusKm, 1e-9) + assertEquals(calgary, area.center) + } + + @Test + fun resizingIsKeptWithinLimits() { + val area = SearchArea.of(calgary, 10.0) + + assertEquals(SearchArea.MIN_RADIUS_KM, area.resizedTo(calgary).radiusKm, 0.0) + assertEquals(SearchArea.MAX_RADIUS_KM, area.resizedTo(GeoPoint(-calgary.latitude, 60.0)).radiusKm, 0.0) + } + + @Test + fun movingKeepsTheRadius() { + val area = SearchArea.of(calgary, 42.0).movedTo(banff) + + assertEquals(banff, area.center) + assertEquals(42.0, area.radiusKm, 0.0) + } + + @Test + fun edgeIsDueEastAtTheRadius() { + val area = SearchArea.of(calgary, 30.0) + + assertEquals(30.0, calgary.distanceKmTo(area.edge), 1e-6) + assertEquals(calgary.latitude, area.edge.latitude, 0.01) + assertTrue(area.edge.longitude > calgary.longitude) + } + + @Test + fun outlineIsClosedAndOnTheEdge() { + val outline = SearchArea.of(banff, 20.0).outline(points = 16) + + assertEquals(17, outline.size) + assertEquals(outline.first().latitude, outline.last().latitude, 1e-9) + assertEquals(outline.first().longitude, outline.last().longitude, 1e-9) + outline.forEach { assertEquals(20.0, banff.distanceKmTo(it), 1e-6) } + } + + @Test + fun extremesAreTheFourCompassPoints() { + val extremes = SearchArea.of(banff, 20.0).extremes() + + assertEquals(4, extremes.size) + assertTrue(extremes[0].latitude > banff.latitude) + assertTrue(extremes[1].longitude > banff.longitude) + assertTrue(extremes[2].latitude < banff.latitude) + assertTrue(extremes[3].longitude < banff.longitude) + } +} diff --git a/code/app/src/test/java/com/example/lambda_bbb_events/store/CampsiteStoreUnitTest.kt b/code/app/src/test/java/com/example/lambda_bbb_events/store/CampsiteStoreUnitTest.kt index 39fe9ffd..9ebac1cb 100644 --- a/code/app/src/test/java/com/example/lambda_bbb_events/store/CampsiteStoreUnitTest.kt +++ b/code/app/src/test/java/com/example/lambda_bbb_events/store/CampsiteStoreUnitTest.kt @@ -2,6 +2,7 @@ package com.example.lambda_bbb_events.store import androidx.compose.runtime.mutableStateOf import com.example.lambda_bbb_events.model.campsite.Campsite +import com.example.lambda_bbb_events.model.campsite.CampsiteStore import com.example.lambda_bbb_events.model.image.ImageMetaData import com.example.lambda_bbb_events.model.repository.CampsiteRepository import com.example.lambda_bbb_events.model.repository.LotteryRepository From ae28bf00f7bbfeb03e8ffcf896b2c0229bf95f57 Mon Sep 17 00:00:00 2001 From: somethingGit <113336038+somethingGit@users.noreply.github.com> Date: Sun, 29 Nov 2026 16:26:25 -0600 Subject: [PATCH 2/2] Fixes comment issues with merge conflict --- .../example/lambda_bbb_events/model/campsite/CampsiteStore.kt | 4 ---- .../lambda_bbb_events/model/local/NotificationHistoryStore.kt | 4 ---- .../lambda_bbb_events/model/services/ImageProcessor.kt | 4 ---- 3 files changed, 12 deletions(-) diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/CampsiteStore.kt b/code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/CampsiteStore.kt index 46a9a4a3..50027029 100644 --- a/code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/CampsiteStore.kt +++ b/code/app/src/main/java/com/example/lambda_bbb_events/model/campsite/CampsiteStore.kt @@ -11,10 +11,6 @@ import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.launch import kotlin.coroutines.cancellation.CancellationException -/* - * Maintains the observable campsite cache and coordinates persistence with the repositories. - */ - /** * Maintains the observable campsite cache and coordinates persistence with the repositories. * diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/model/local/NotificationHistoryStore.kt b/code/app/src/main/java/com/example/lambda_bbb_events/model/local/NotificationHistoryStore.kt index b618a0f9..f5afb5e3 100644 --- a/code/app/src/main/java/com/example/lambda_bbb_events/model/local/NotificationHistoryStore.kt +++ b/code/app/src/main/java/com/example/lambda_bbb_events/model/local/NotificationHistoryStore.kt @@ -8,10 +8,6 @@ import android.content.SharedPreferences import org.json.JSONArray import org.json.JSONObject -/* - * Stores notification history locally for each user. - */ - /** * Stores notification history locally for each user. * diff --git a/code/app/src/main/java/com/example/lambda_bbb_events/model/services/ImageProcessor.kt b/code/app/src/main/java/com/example/lambda_bbb_events/model/services/ImageProcessor.kt index 207cb4c9..fa2996a1 100644 --- a/code/app/src/main/java/com/example/lambda_bbb_events/model/services/ImageProcessor.kt +++ b/code/app/src/main/java/com/example/lambda_bbb_events/model/services/ImageProcessor.kt @@ -14,10 +14,6 @@ import com.example.lambda_bbb_events.model.repository.ImageRepository import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext -/* - * Prepares images for storage and loads them back for display. - */ - /** * Prepares images for storage and loads them back for display. *