fix(ui): update reset stats dialog to match M3 spec

This commit is contained in:
Nishant Mishra
2025-12-21 09:57:03 +05:30
parent 8c63dfe71c
commit f3824416f4
2 changed files with 48 additions and 18 deletions

View File

@@ -1,6 +1,22 @@
/*
* Copyright (c) 2025 Nishant Mishra
*
* This file is part of Tomato - a minimalist pomodoro timer for Android.
*
* Tomato is free software: you can redistribute it and/or modify it under the terms of the GNU
* General Public License as published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Tomato is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Tomato.
* If not, see <https://www.gnu.org/licenses/>.
*/
package org.nsh07.pomodoro.ui.settingsScreen
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@@ -10,13 +26,16 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material3.AlertDialogDefaults
import androidx.compose.material3.BasicAlertDialog
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.MaterialTheme.shapes
import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
@@ -29,7 +48,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import org.nsh07.pomodoro.R
import org.nsh07.pomodoro.ui.theme.TomatoTheme
@@ -40,47 +58,57 @@ fun ResetDataDialog(
onDismiss: () -> Unit,
resetData: () -> Unit
) {
Dialog(
BasicAlertDialog(
onDismissRequest = onDismiss,
modifier = modifier
) {
Card(
modifier = modifier
.clickable(onClick = onDismiss),
shape = RoundedCornerShape(16.dp),
Surface(
modifier = Modifier
.wrapContentWidth()
.wrapContentHeight(),
shape = shapes.extraLarge,
color = colorScheme.surfaceContainerHigh,
tonalElevation = AlertDialogDefaults.TonalElevation
) {
Column(modifier = Modifier.padding(24.dp)) {
Icon(
painter = painterResource(R.drawable.clear),
painter = painterResource(R.drawable.restart),
contentDescription = null,
tint = colorScheme.secondary,
modifier = Modifier
.align(Alignment.CenterHorizontally)
.size(40.dp)
.size(24.dp)
)
Spacer(Modifier.height(16.dp))
Text(
text = stringResource(R.string.reset_data),
text = stringResource(R.string.reset_data_dialog_title),
textAlign = TextAlign.Center,
style = typography.headlineSmall,
color = colorScheme.onSurface,
modifier = Modifier.align(Alignment.CenterHorizontally)
)
Spacer(Modifier.height(16.dp))
Text(
text = stringResource(R.string.reset_data_dialog_text),
textAlign = TextAlign.Center
style = typography.bodyMedium
)
Spacer(modifier = Modifier.height(24.dp))
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.End
) {
TextButton(onClick = onDismiss) {
TextButton(
onClick = onDismiss,
shapes = ButtonDefaults.shapes(),
) {
Text(stringResource(android.R.string.cancel))
}
Spacer(modifier = Modifier.width(8.dp))
Button(
TextButton(
onClick = resetData,
shapes = ButtonDefaults.shapes(),
) {
@@ -100,7 +128,8 @@ fun PreviewResetDataDialog() {
Surface {
ResetDataDialog(
onDismiss = { },
resetData = { }
resetData = { },
modifier = Modifier.padding(16.dp)
)
}
}

View File

@@ -121,6 +121,7 @@
<string name="focus_history_calendar">Focus history calendar</string>
<string name="focus_history_calendar_desc">Focus history of the past month. Days of the previous month are marked with a different color. Tap on a date for more info.</string>
<string name="reset_data">Reset stats</string>
<string name="reset_data_dialog_text">Are you sure you want to reset all your stats?</string>
<string name="reset_data_dialog_title">Reset all stats?</string>
<string name="reset_data_dialog_text">All saved stats will be deleted permanently. This cannot be undone.</string>
<string name="back">Back</string>
</resources>