diff --git a/app/src/main/java/com/geeksville/mesh/ui/map/DownloadButton.kt b/app/src/main/java/com/geeksville/mesh/ui/map/DownloadButton.kt index c6bf124a..21b7e6ea 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/map/DownloadButton.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/map/DownloadButton.kt @@ -8,10 +8,11 @@ import androidx.compose.animation.slideOutHorizontally import androidx.compose.material.FloatingActionButton import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Download import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.scale -import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import com.geeksville.mesh.R @@ -36,8 +37,8 @@ internal fun DownloadButton( backgroundColor = MaterialTheme.colors.primary, ) { Icon( - painterResource(R.drawable.ic_twotone_download_24), - stringResource(R.string.map_download_region), + imageVector = Icons.Default.Download, + contentDescription = stringResource(R.string.map_download_region), modifier = Modifier.scale(1.25f), ) } diff --git a/app/src/main/java/com/geeksville/mesh/ui/map/MapButton.kt b/app/src/main/java/com/geeksville/mesh/ui/map/MapButton.kt index 1e980361..8eacd324 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/map/MapButton.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/map/MapButton.kt @@ -1,63 +1,74 @@ package com.geeksville.mesh.ui.map -import androidx.annotation.DrawableRes import androidx.annotation.StringRes import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.CircleShape import androidx.compose.material.Button +import androidx.compose.material.ButtonDefaults import androidx.compose.material.Icon +import androidx.compose.material.MaterialTheme +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.Layers import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.draw.scale -import com.geeksville.mesh.R -import androidx.compose.ui.res.painterResource +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.tooling.preview.PreviewLightDark import androidx.compose.ui.unit.dp +import com.geeksville.mesh.R +import com.geeksville.mesh.ui.theme.AppTheme @Composable fun MapButton( - onClick: () -> Unit, - @DrawableRes drawableRes: Int, + icon: ImageVector, @StringRes contentDescription: Int, modifier: Modifier = Modifier, enabled: Boolean = true, + onClick: () -> Unit = {} ) { MapButton( - onClick = onClick, - drawableRes = drawableRes, + icon = icon, contentDescription = stringResource(contentDescription), modifier = modifier, enabled = enabled, + onClick = onClick, ) } @Composable fun MapButton( - onClick: () -> Unit, - @DrawableRes drawableRes: Int, + icon: ImageVector, contentDescription: String?, modifier: Modifier = Modifier, enabled: Boolean = true, + onClick: () -> Unit = {} ) { Button( onClick = onClick, enabled = enabled, modifier = modifier.size(48.dp), + shape = CircleShape, + colors = ButtonDefaults.buttonColors( + backgroundColor = MaterialTheme.colors.surface.copy(alpha = 1f), + contentColor = MaterialTheme.colors.onSurface, + ), ) { Icon( - painterResource(id = drawableRes), - contentDescription, + imageVector = icon, + contentDescription = contentDescription, modifier = Modifier.scale(scale = 1.5f), ) } } -@Preview(showBackground = true) +@PreviewLightDark @Composable private fun MapButtonPreview() { - MapButton( - onClick = {}, - drawableRes = R.drawable.ic_twotone_layers_24, - R.string.map_style_selection, - ) + AppTheme { + MapButton( + icon = Icons.Outlined.Layers, + contentDescription = R.string.map_style_selection, + ) + } } diff --git a/app/src/main/java/com/geeksville/mesh/ui/map/MapFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/map/MapFragment.kt index 17138122..c65d1e76 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/map/MapFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/map/MapFragment.kt @@ -16,6 +16,10 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material.Scaffold +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.LocationDisabled +import androidx.compose.material.icons.outlined.Layers +import androidx.compose.material.icons.outlined.MyLocation import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -691,26 +695,25 @@ fun MapView( verticalArrangement = Arrangement.spacedBy(8.dp), ) { MapButton( - onClick = { showMapStyleDialog() }, - drawableRes = R.drawable.ic_twotone_layers_24, + onClick = ::showMapStyleDialog, + icon = Icons.Outlined.Layers, contentDescription = R.string.map_style_selection, ) MapButton( - onClick = { - if (context.hasLocationPermission()) { - map.toggleMyLocation() - } else { - requestPermissionAndToggleLauncher.launch(context.getLocationPermissions()) - } - }, enabled = hasGps, - drawableRes = if (myLocationOverlay == null) { - R.drawable.ic_twotone_my_location_24 + icon = if (myLocationOverlay == null) { + Icons.Outlined.MyLocation } else { - R.drawable.ic_twotone_location_disabled_24 + Icons.Default.LocationDisabled }, contentDescription = null, - ) + ) { + if (context.hasLocationPermission()) { + map.toggleMyLocation() + } else { + requestPermissionAndToggleLauncher.launch(context.getLocationPermissions()) + } + } } } } diff --git a/app/src/main/res/drawable/ic_twotone_download_24.xml b/app/src/main/res/drawable/ic_twotone_download_24.xml deleted file mode 100644 index 16e437be..00000000 --- a/app/src/main/res/drawable/ic_twotone_download_24.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/ic_twotone_layers_24.xml b/app/src/main/res/drawable/ic_twotone_layers_24.xml deleted file mode 100644 index 4b26e9d3..00000000 --- a/app/src/main/res/drawable/ic_twotone_layers_24.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/app/src/main/res/drawable/ic_twotone_location_disabled_24.xml b/app/src/main/res/drawable/ic_twotone_location_disabled_24.xml deleted file mode 100644 index fe3907ca..00000000 --- a/app/src/main/res/drawable/ic_twotone_location_disabled_24.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_twotone_my_location_24.xml b/app/src/main/res/drawable/ic_twotone_my_location_24.xml deleted file mode 100644 index 7d15d13f..00000000 --- a/app/src/main/res/drawable/ic_twotone_my_location_24.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - -