Skip to content

Commit 85576d5

Browse files
committed
Bug 1989307 - Migrate FocusDialog to Material3 r=android-reviewers,giorga
This commit migrates the `FocusDialog` composable and its related components (`FocusDialogButton`, `FocusDialogTextInput`) from Material Design 2 to Material Design 3. Not that the height of the dialog is increased due to new defaults that cannot be changed. Differential Revision: https://phabricator.services.mozilla.com/D265587
1 parent 8e94513 commit 85576d5

File tree

2 files changed

+18
-59
lines changed

2 files changed

+18
-59
lines changed

mobile/android/focus-android/app/lint-baseline.xml

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -177,50 +177,6 @@
177177
column="8"/>
178178
</issue>
179179

180-
<issue
181-
id="UsingMaterialAndMaterial3Libraries"
182-
message="Using a material import while also using the material3 library"
183-
errorLine1="import androidx.compose.material.AlertDialog"
184-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
185-
<location
186-
file="src/main/java/org/mozilla/focus/ui/dialog/FocusDialog.kt"
187-
line="9"
188-
column="8"/>
189-
</issue>
190-
191-
<issue
192-
id="UsingMaterialAndMaterial3Libraries"
193-
message="Using a material import while also using the material3 library"
194-
errorLine1="import androidx.compose.material.MaterialTheme"
195-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
196-
<location
197-
file="src/main/java/org/mozilla/focus/ui/dialog/FocusDialog.kt"
198-
line="10"
199-
column="8"/>
200-
</issue>
201-
202-
<issue
203-
id="UsingMaterialAndMaterial3Libraries"
204-
message="Using a material import while also using the material3 library"
205-
errorLine1="import androidx.compose.material.TextField"
206-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
207-
<location
208-
file="src/main/java/org/mozilla/focus/ui/dialog/FocusDialog.kt"
209-
line="11"
210-
column="8"/>
211-
</issue>
212-
213-
<issue
214-
id="UsingMaterialAndMaterial3Libraries"
215-
message="Using a material import while also using the material3 library"
216-
errorLine1="import androidx.compose.material.TextFieldDefaults"
217-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
218-
<location
219-
file="src/main/java/org/mozilla/focus/ui/dialog/FocusDialog.kt"
220-
line="12"
221-
column="8"/>
222-
</issue>
223-
224180
<issue
225181
id="UsingMaterialAndMaterial3Libraries"
226182
message="Using a material import while also using the material3 library"

mobile/android/focus-android/app/src/main/java/org/mozilla/focus/ui/dialog/FocusDialog.kt

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ package org.mozilla.focus.ui.dialog
66

77
import android.content.res.Configuration
88
import androidx.compose.foundation.layout.wrapContentHeight
9-
import androidx.compose.material.AlertDialog
10-
import androidx.compose.material.MaterialTheme
11-
import androidx.compose.material.TextField
12-
import androidx.compose.material.TextFieldDefaults
9+
import androidx.compose.material3.AlertDialog
10+
import androidx.compose.material3.MaterialTheme
1311
import androidx.compose.material3.Text
1412
import androidx.compose.material3.TextButton
13+
import androidx.compose.material3.TextField
14+
import androidx.compose.material3.TextFieldDefaults
1515
import androidx.compose.runtime.Composable
1616
import androidx.compose.ui.Modifier
1717
import androidx.compose.ui.graphics.Color
@@ -31,8 +31,8 @@ import org.mozilla.focus.ui.theme.focusTypography
3131
* (e.g., by tapping outside or pressing the back button).
3232
* @param confirmButtonConfig Optional configuration for the confirm button. If null, the button is not shown.
3333
* @param dismissButtonConfig Optional configuration for the dismiss button. If null, the button is not shown.
34-
* @param dialogBackgroundColor Background color for the dialog. Defaults to `focusColors.secondary`.
35-
* @param dialogShape Shape for the dialog. Defaults to `MaterialTheme.shapes.medium`.
34+
* @param dialogContainerColor Background color for the dialog. Defaults to `focusColors.secondary`.
35+
* @param dialogShape Shape for the dialog. Defaults to `MaterialTheme.shapes.extraSmall`.
3636
*/
3737
@Composable
3838
fun FocusDialog(
@@ -42,8 +42,8 @@ fun FocusDialog(
4242
onDismissRequest: () -> Unit,
4343
confirmButtonConfig: DialogButtonConfig? = null,
4444
dismissButtonConfig: DialogButtonConfig? = null,
45-
dialogBackgroundColor: Color = focusColors.secondary,
46-
dialogShape: Shape = MaterialTheme.shapes.medium,
45+
dialogContainerColor: Color = focusColors.secondary,
46+
dialogShape: Shape = MaterialTheme.shapes.extraSmall,
4747
) {
4848
AlertDialog(
4949
onDismissRequest = onDismissRequest,
@@ -75,7 +75,7 @@ fun FocusDialog(
7575
}
7676
}
7777
},
78-
backgroundColor = dialogBackgroundColor,
78+
containerColor = dialogContainerColor,
7979
shape = dialogShape,
8080
)
8181
}
@@ -141,7 +141,7 @@ fun DialogTextButton(
141141
onClick = onClick,
142142
modifier = modifier,
143143
enabled = enabled,
144-
shape = MaterialTheme.shapes.large,
144+
shape = MaterialTheme.shapes.extraSmall,
145145
) {
146146
Text(
147147
modifier = modifier,
@@ -151,7 +151,7 @@ fun DialogTextButton(
151151
focusColors.dialogActiveControls.copy(alpha = 0.5f)
152152
},
153153
text = text,
154-
style = MaterialTheme.typography.button,
154+
style = MaterialTheme.typography.labelLarge,
155155
)
156156
}
157157
}
@@ -173,15 +173,18 @@ fun DialogInputField(
173173
placeholder = placeholder,
174174
onValueChange = onValueChange,
175175
textStyle = focusTypography.dialogInput,
176-
colors = TextFieldDefaults.textFieldColors(
177-
backgroundColor = focusColors.secondary,
178-
textColor = focusColors.onSecondary,
176+
colors = TextFieldDefaults.colors(
177+
focusedContainerColor = focusColors.secondary,
178+
unfocusedContainerColor = focusColors.secondary,
179+
disabledContainerColor = focusColors.secondary,
180+
focusedTextColor = focusColors.onSecondary,
181+
unfocusedTextColor = focusColors.onSecondary,
179182
cursorColor = focusColors.onPrimary,
180183
focusedIndicatorColor = focusColors.dialogActiveControls,
181184
unfocusedIndicatorColor = focusColors.dialogActiveControls,
182185
),
183186
singleLine = true,
184-
shape = MaterialTheme.shapes.large,
187+
shape = MaterialTheme.shapes.extraSmall,
185188
)
186189
}
187190

0 commit comments

Comments
 (0)