Skip to content

Commit 67da63d

Browse files
authored
Merge pull request #154 from Esri/gunther/clean_up_feature_branch
Clean up feature branch
2 parents 88ca66d + 18a4db3 commit 67da63d

File tree

4 files changed

+10
-86
lines changed

4 files changed

+10
-86
lines changed

microapps/MapComposeApp/app/src/main/java/com/arcgismaps/toolkit/mapcomposeapp/screens/MainScreen.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@ package com.arcgismaps.toolkit.mapcomposeapp.screens
2020

2121
import androidx.compose.foundation.layout.fillMaxSize
2222
import androidx.compose.runtime.Composable
23+
import androidx.compose.runtime.getValue
24+
import androidx.compose.runtime.mutableStateOf
2325
import androidx.compose.runtime.remember
2426
import androidx.compose.ui.Modifier
2527
import com.arcgismaps.mapping.ArcGISMap
2628
import com.arcgismaps.mapping.BasemapStyle
2729
import com.arcgismaps.toolkit.geocompose.Map
28-
import com.arcgismaps.toolkit.geocompose.MapState
2930

3031
@Composable
3132
fun MainScreen() {
32-
33-
val mapState = remember { MapState(arcGISMap = ArcGISMap(BasemapStyle.ArcGISStreets)) }
33+
val arcGISMap by remember { mutableStateOf(ArcGISMap(BasemapStyle.ArcGISStreets)) }
3434
Map(
3535
modifier = Modifier.fillMaxSize(),
36-
mapState = mapState,
36+
arcGISMap = arcGISMap,
3737
)
3838
}

toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/GeoComposeState.kt

-27
This file was deleted.

toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/Map.kt

+6-14
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package com.arcgismaps.toolkit.geocompose
2020
import androidx.compose.foundation.layout.Box
2121
import androidx.compose.runtime.Composable
2222
import androidx.compose.runtime.DisposableEffect
23-
import androidx.compose.runtime.LaunchedEffect
2423
import androidx.compose.runtime.remember
2524
import androidx.compose.ui.Modifier
2625
import androidx.compose.ui.platform.LocalContext
@@ -29,27 +28,28 @@ import androidx.compose.ui.semantics.contentDescription
2928
import androidx.compose.ui.semantics.semantics
3029
import androidx.compose.ui.tooling.preview.Preview
3130
import androidx.compose.ui.viewinterop.AndroidView
31+
import com.arcgismaps.mapping.ArcGISMap
3232
import com.arcgismaps.mapping.view.MapView
33-
import kotlinx.coroutines.launch
3433

3534
/**
3635
* A compose equivalent of the [MapView].
3736
*
3837
* @param modifier Modifier to be applied to the Map
39-
* @param mapState the state of the Map
38+
* @param arcGISMap the [ArcGISMap] to be rendered by this composable
4039
* @param overlay the composable overlays to display on top of the Map. Example, a compass, floorfilter etc.
4140
* @since 200.3.0
4241
*/
4342
@Composable
4443
public fun Map(
4544
modifier: Modifier = Modifier,
46-
mapState: MapState = MapState(),
45+
arcGISMap: ArcGISMap? = null,
4746
overlay: @Composable () -> Unit = {}
4847
) {
49-
5048
val lifecycleOwner = LocalLifecycleOwner.current
5149
val context = LocalContext.current
52-
val mapView = remember { MapView(context) }
50+
val mapView = remember { MapView(context) }.apply {
51+
map = arcGISMap
52+
}
5353

5454
Box(modifier = Modifier.semantics {
5555
contentDescription = "MapContainer"
@@ -69,14 +69,6 @@ public fun Map(
6969
mapView.onDestroy(lifecycleOwner)
7070
}
7171
}
72-
73-
LaunchedEffect(mapState) {
74-
launch {
75-
mapState.arcGISMap.collect {
76-
mapView.map = it
77-
}
78-
}
79-
}
8072
}
8173

8274
@Preview

toolkit/geo-compose/src/main/java/com/arcgismaps/toolkit/geocompose/MapState.kt

-41
This file was deleted.

0 commit comments

Comments
 (0)