Set AlertDialog width to M specs
Honor the material specs:
- Width must be at least 280dp and at most 560dp
- Default width should be 312dp for parity with Android
- Margins should be at least 24dp
Note that the margins are enforced by the dialog window on Android, so
they don't have to be added in the Compose part.
Fixes: 144798445
Test: ./gradlew ui:ui-material:cC
Change-Id: Ibd506bf9d72695454bb92b2ec831bceef1b3d1ed
diff --git a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt
index 3c37f3d..649e721 100644
--- a/ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt
+++ b/ui/ui-foundation/src/main/java/androidx/ui/foundation/Dialog.kt
@@ -72,6 +72,8 @@
onCommit {
dialog.setContent {
+ // TODO(b/159900354): draw a scrim and add margins around the Compose Dialog, and
+ // consume clicks so they can't pass through to the underlying UI
Box(Modifier.semantics { this.dialog = true }, children = children)
}
}
@@ -94,6 +96,8 @@
ViewTreeViewModelStoreOwner.set(frameLayout, ViewTreeViewModelStoreOwner.get(composeView))
}
+ // TODO(b/159900354): Make the Android Dialog full screen and the scrim fully transparent
+
fun setContent(children: @Composable () -> Unit) {
// TODO: This should probably create a child composition of the original
composition = frameLayout.setContent(recomposer, children)
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/AlertDialog.kt b/ui/ui-material/src/main/java/androidx/ui/material/AlertDialog.kt
index ef38f3b..add9ccd 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/AlertDialog.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/AlertDialog.kt
@@ -194,7 +194,7 @@
}
}
-private val AlertDialogWidth = Modifier.preferredWidth(280.dp)
+private val AlertDialogWidth = Modifier.preferredWidth(312.dp)
private val ButtonsBoxModifier = Modifier.fillMaxWidth().padding(all = 8.dp)
private val ButtonsWidthSpace = Modifier.preferredWidth(8.dp)
private val ButtonsHeightSpace = Modifier.preferredHeight(12.dp)
@@ -205,4 +205,4 @@
private val TitlePadding = Modifier.padding(start = 24.dp, top = 24.dp, end = 24.dp, bottom = 0.dp)
// The height difference of the padding between a Dialog with a title and one without a title
private val NoTitleExtraHeight = Modifier.preferredHeight(2.dp)
-private val TextToButtonsHeight = Modifier.preferredHeight(28.dp)
\ No newline at end of file
+private val TextToButtonsHeight = Modifier.preferredHeight(28.dp)