From df2e04d48b5ca0197b4f774cf3a0b3442bfc7024 Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Tue, 17 Dec 2024 16:00:28 +0530 Subject: [PATCH 1/2] added values in dimen --- ground/src/main/res/values/dimens.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ground/src/main/res/values/dimens.xml b/ground/src/main/res/values/dimens.xml index 882defb9ab..3b87253b4b 100644 --- a/ground/src/main/res/values/dimens.xml +++ b/ground/src/main/res/values/dimens.xml @@ -39,4 +39,16 @@ 16dp 8dp 50dp + + + 4dp + 8dp + 16dp + 24dp + + + 12sp + 14sp + 16sp + 20sp From d680b00652cd26a6b53cc75fa85538d8514d4159 Mon Sep 17 00:00:00 2001 From: Akshay Nandwana Date: Mon, 23 Dec 2024 15:04:19 +0530 Subject: [PATCH 2/2] use dimen --- .../DataSubmissionConfirmationDialog.kt | 17 +++++--- .../ui/offlineareas/OfflineAreaListItem.kt | 40 +++++++++++++------ ground/src/main/res/values/dimens.xml | 8 +--- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt index 329556aa74..8ddaafe727 100644 --- a/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt +++ b/ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt @@ -36,6 +36,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.Font @@ -70,14 +71,16 @@ fun DataSubmissionConfirmationDialog(onDismiss: () -> Unit) { verticalArrangement = Arrangement.Center, ) { DetailColumn() - Spacer(modifier = Modifier.height(24.dp)) + Spacer(modifier = Modifier.height(dimensionResource(R.dimen.spacing_xlarge))) CloseButton(modifier = Modifier.align(Alignment.CenterHorizontally), onDismiss = onDismiss) } } } else { Column(modifier = Modifier.fillMaxSize().background(MaterialTheme.colorScheme.background)) { Spacer(modifier = Modifier.height(150.dp)) - DataCollectionThumbnail(modifier = Modifier.padding(horizontal = 8.dp)) + DataCollectionThumbnail( + modifier = Modifier.padding(horizontal = dimensionResource(R.dimen.spacing_medium)) + ) Spacer(modifier = Modifier.height(100.dp)) DetailColumn() Spacer(modifier = Modifier.height(32.dp)) @@ -107,9 +110,9 @@ private fun DetailColumn() { fontSize = 22.sp, fontWeight = FontWeight(400), ) - Spacer(modifier = Modifier.height(8.dp)) + Spacer(modifier = Modifier.height(dimensionResource(R.dimen.spacing_medium))) Text( - modifier = Modifier.padding(horizontal = 28.dp), + modifier = Modifier.padding(horizontal = dimensionResource(R.dimen.spacing_xxlarge)), text = stringResource(R.string.data_collection_complete_details), fontSize = 14.sp, lineHeight = 20.sp, @@ -129,7 +132,11 @@ private fun CloseButton(modifier: Modifier = Modifier, onDismiss: () -> Unit) { onClick = { onDismiss() }, ) { Text( - modifier = Modifier.padding(horizontal = 16.dp, vertical = 4.dp), + modifier = + Modifier.padding( + horizontal = dimensionResource(R.dimen.spacing_large), + vertical = dimensionResource(R.dimen.spacing_small), + ), text = stringResource(id = R.string.close), fontSize = 14.sp, lineHeight = 20.sp, diff --git a/ground/src/main/java/com/google/android/ground/ui/offlineareas/OfflineAreaListItem.kt b/ground/src/main/java/com/google/android/ground/ui/offlineareas/OfflineAreaListItem.kt index 5296ed2ba0..480045a6d1 100644 --- a/ground/src/main/java/com/google/android/ground/ui/offlineareas/OfflineAreaListItem.kt +++ b/ground/src/main/java/com/google/android/ground/ui/offlineareas/OfflineAreaListItem.kt @@ -29,13 +29,13 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.res.dimensionResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.vectorResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.Font import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.tooling.preview.Preview -import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.google.android.ground.ExcludeFromJacocoGeneratedReport import com.google.android.ground.R @@ -52,21 +52,28 @@ fun OfflineAreaListItem( modifier = modifier .fillMaxWidth() - .padding(start = 16.dp, top = 4.dp, end = 24.dp, bottom = 4.dp) + .padding( + start = dimensionResource(R.dimen.spacing_large), + top = dimensionResource(R.dimen.spacing_small), + end = dimensionResource(R.dimen.spacing_xlarge), + bottom = dimensionResource(R.dimen.spacing_small), + ) .clickable { itemClicked(offlineAreaDetails.id) }, - horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.CenterHorizontally), + horizontalArrangement = + Arrangement.spacedBy( + dimensionResource(R.dimen.spacing_large), + Alignment.CenterHorizontally, + ), verticalAlignment = Alignment.CenterVertically, ) { - Icon( - imageVector = ImageVector.vectorResource(id = R.drawable.ic_offline_pin), - contentDescription = stringResource(id = R.string.offline_area_list_item_icon), - tint = MaterialTheme.colorScheme.primary, - modifier = Modifier.size(24.dp), - ) - + OfflinePinImage() Column( modifier = Modifier.fillMaxWidth(), - verticalArrangement = Arrangement.spacedBy(0.dp, Alignment.CenterVertically), + verticalArrangement = + Arrangement.spacedBy( + dimensionResource(R.dimen.spacing_empty), + Alignment.CenterVertically, + ), horizontalAlignment = Alignment.Start, ) { Text( @@ -79,7 +86,6 @@ fun OfflineAreaListItem( color = MaterialTheme.colorScheme.onSurface, ), ) - Text( text = stringResource( @@ -99,6 +105,16 @@ fun OfflineAreaListItem( } } +@Composable +private fun OfflinePinImage() { + Icon( + imageVector = ImageVector.vectorResource(id = R.drawable.ic_offline_pin), + contentDescription = stringResource(id = R.string.offline_area_list_item_icon), + tint = MaterialTheme.colorScheme.primary, + modifier = Modifier.size(dimensionResource(R.dimen.spacing_xlarge)), + ) +} + @Composable @Preview(showBackground = true, showSystemUi = true) @ExcludeFromJacocoGeneratedReport diff --git a/ground/src/main/res/values/dimens.xml b/ground/src/main/res/values/dimens.xml index 3a0a04ad0e..9537071b59 100644 --- a/ground/src/main/res/values/dimens.xml +++ b/ground/src/main/res/values/dimens.xml @@ -40,14 +40,10 @@ 50dp + 0dp 4dp 8dp 16dp 24dp - - - 12sp - 14sp - 16sp - 20sp + 28dp