@@ -37,18 +37,13 @@ import androidx.compose.foundation.layout.widthIn
3737import androidx.compose.material.icons.Icons
3838import androidx.compose.material.icons.filled.CloudDownload
3939import androidx.compose.material.icons.filled.FolderOpen
40+ import androidx.compose.material.icons.filled.Delete
4041import androidx.compose.material.icons.filled.Public
4142import androidx.compose.material.icons.filled.Star
4243import androidx.compose.material.icons.filled.Sync
4344import androidx.compose.foundation.layout.PaddingValues
4445import androidx.compose.material3.*
45- import androidx.compose.runtime.Composable
46- import androidx.compose.runtime.LaunchedEffect
47- import androidx.compose.runtime.getValue
48- import androidx.compose.runtime.key
49- import androidx.compose.runtime.mutableIntStateOf
50- import androidx.compose.runtime.mutableStateOf
51- import androidx.compose.runtime.remember
46+ import androidx.compose.runtime.*
5247import androidx.compose.ui.Alignment
5348import androidx.compose.ui.Modifier
5449import androidx.compose.ui.geometry.Offset
@@ -85,6 +80,29 @@ internal fun GlyphsScreen(
8580 presets.firstOrNull { it.key == selectedPreset } ? : presets.firstOrNull()
8681 }
8782
83+ var showDeleteConfirm by remember { mutableStateOf<String ?>(null ) }
84+
85+ if (showDeleteConfirm != null ) {
86+ AlertDialog (
87+ onDismissRequest = { showDeleteConfirm = null },
88+ title = { Text (" Delete Preset?" ) },
89+ text = { Text (" Are you sure you want to delete the local preset '${showDeleteConfirm} '?" ) },
90+ confirmButton = {
91+ TextButton (onClick = {
92+ showDeleteConfirm?.let { viewModel.deleteCustomPreset(it) }
93+ showDeleteConfirm = null
94+ }) {
95+ Text (" Delete" , color = Color .Red )
96+ }
97+ },
98+ dismissButton = {
99+ TextButton (onClick = { showDeleteConfirm = null }) {
100+ Text (" Cancel" )
101+ }
102+ }
103+ )
104+ }
105+
88106 Column (
89107 modifier = Modifier
90108 .fillMaxSize()
@@ -245,17 +263,36 @@ internal fun GlyphsScreen(
245263 )
246264 ),
247265 ) {
248- Crossfade (
249- targetState = selectedInfo?.description,
250- label = " desc_fade" ,
251- animationSpec = spring(stiffness = Spring .StiffnessMedium )
252- ) { description ->
253- Text (
254- text = description ? : stringResource(R .string.glyph_no_config),
255- style = MaterialTheme .typography.bodyLarge.copy(lineHeight = 22 .sp),
256- color = MaterialTheme .colorScheme.onSurface.copy(alpha = 0.9f ),
257- modifier = Modifier .fillMaxWidth(),
258- )
266+ Row (
267+ modifier = Modifier .fillMaxWidth(),
268+ verticalAlignment = Alignment .CenterVertically
269+ ) {
270+ Crossfade (
271+ targetState = selectedInfo?.description,
272+ label = " desc_fade" ,
273+ animationSpec = spring(stiffness = Spring .StiffnessMedium ),
274+ modifier = Modifier .weight(1f )
275+ ) { description ->
276+ Text (
277+ text = description ? : stringResource(R .string.glyph_no_config),
278+ style = MaterialTheme .typography.bodyLarge.copy(lineHeight = 22 .sp),
279+ color = MaterialTheme .colorScheme.onSurface.copy(alpha = 0.9f ),
280+ modifier = Modifier .fillMaxWidth(),
281+ )
282+ }
283+
284+ if (selectedInfo?.description?.startsWith(" Custom:" ) == true ) {
285+ IconButton (
286+ onClick = { showDeleteConfirm = selectedInfo.key },
287+ modifier = Modifier .padding(start = 8 .dp)
288+ ) {
289+ Icon (
290+ Icons .Default .Delete ,
291+ contentDescription = " Delete Local Preset" ,
292+ tint = MaterialTheme .colorScheme.error.copy(alpha = 0.7f )
293+ )
294+ }
295+ }
259296 }
260297 }
261298
0 commit comments