Skip to content
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

Added landscape support for Data Collection Dialog #2800

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@
*/
package com.google.android.ground.ui.datacollection

import android.content.res.Configuration
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
Expand All @@ -31,11 +36,14 @@
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.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
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 androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import com.google.android.ground.R
Expand All @@ -52,41 +60,78 @@
shape = RoundedCornerShape(16.dp),
tonalElevation = 8.dp,
) {
Column(
modifier = Modifier.padding(16.dp),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Image(
painter = painterResource(id = R.drawable.data_submitted),
contentDescription = stringResource(R.string.data_submitted_image),
contentScale = ContentScale.Fit,
)

Spacer(modifier = Modifier.height(12.dp))

Text(
text = stringResource(R.string.data_collection_complete),
style = MaterialTheme.typography.titleLarge,
textAlign = TextAlign.Center,
)

Spacer(modifier = Modifier.height(8.dp))
val configuration = LocalConfiguration.current
if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Column {
Row(verticalAlignment = Alignment.CenterVertically) {
DataCollectionThumbnail(modifier = Modifier.weight(1f))
Column(
modifier = Modifier.padding(start = 16.dp, end = 24.dp, top = 16.dp).weight(2f),
verticalArrangement = Arrangement.Center,

Check warning on line 70 in ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt

View check run for this annotation

Codecov / codecov/patch

ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt#L65-L70

Added lines #L65 - L70 were not covered by tests
) {
DetailColumn()
}
}
CloseButton(modifier = Modifier.padding(bottom = 24.dp, end = 24.dp), onDismiss)
}

Check warning on line 76 in ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt

View check run for this annotation

Codecov / codecov/patch

ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt#L72-L76

Added lines #L72 - L76 were not covered by tests
} else {
Column(modifier = Modifier.padding(horizontal = 24.dp, vertical = 16.dp)) {
DataCollectionThumbnail()
DetailColumn()
Spacer(modifier = Modifier.height(12.dp))
CloseButton(onDismiss = onDismiss)
}
}

Check warning on line 84 in ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt

View check run for this annotation

Codecov / codecov/patch

ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt#L84

Added line #L84 was not covered by tests
}
}
}

Text(
text = stringResource(R.string.data_collection_complete_details),
style = MaterialTheme.typography.bodyMedium,
textAlign = TextAlign.Center,
)
@Composable
private fun DataCollectionThumbnail(modifier: Modifier = Modifier) {
Image(
modifier = modifier,
painter = painterResource(id = R.drawable.data_submitted),
contentDescription = stringResource(R.string.data_submitted_image),
contentScale = ContentScale.Fit,
)
}

Spacer(modifier = Modifier.height(12.dp))
@Composable
private fun ColumnScope.DetailColumn() {
Text(
text = stringResource(R.string.data_collection_complete),
style = MaterialTheme.typography.titleLarge,
color = MaterialTheme.colorScheme.onBackground,
lineHeight = 28.sp,
)
Spacer(modifier = Modifier.height(8.dp))
Text(
text = stringResource(R.string.data_collection_complete_details),
fontSize = 16.sp,
lineHeight = 24.sp,
color = MaterialTheme.colorScheme.onSurfaceVariant,
fontFamily = FontFamily(Font(R.font.text_500)),
)
}

OutlinedButton(onClick = { onDismiss() }) { Text(stringResource(id = R.string.close)) }
}
}
@Composable
private fun ColumnScope.CloseButton(modifier: Modifier = Modifier, onDismiss: () -> Unit) {
OutlinedButton(
modifier = modifier.align(Alignment.End),
border = BorderStroke(width = 1.dp, color = MaterialTheme.colorScheme.outline),
onClick = { onDismiss() },
) {
Text(
stringResource(id = R.string.close),
fontSize = 14.sp,
lineHeight = 20.sp,
fontFamily = FontFamily(Font(R.font.text_500)),
)

Check warning on line 129 in ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt

View check run for this annotation

Codecov / codecov/patch

ground/src/main/java/com/google/android/ground/ui/datacollection/DataSubmissionConfirmationDialog.kt#L129

Added line #L129 was not covered by tests
}
}

@Composable
@Preview(showBackground = false, heightDp = 360, widthDp = 800)
@Preview
fun DataSubmissionConfirmationDialogPreview() {
AppTheme { DataSubmissionConfirmationDialog {} }
Expand Down