Skip to content

Commit 0477825

Browse files
committed
Add RenameDialog.kt
1 parent fb127f4 commit 0477825

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.quickfilemanager.ui.components
2+
3+
import androidx.compose.foundation.layout.*
4+
import androidx.compose.material3.*
5+
import androidx.compose.runtime.*
6+
import androidx.compose.ui.Modifier
7+
import androidx.compose.ui.unit.dp
8+
9+
@Composable
10+
fun RenameDialog(
11+
currentName: String,
12+
onDismiss: () -> Unit,
13+
onConfirm: (String) -> Unit
14+
) {
15+
var name by remember { mutableStateOf(currentName) }
16+
17+
AlertDialog(
18+
onDismissRequest = onDismiss,
19+
title = { Text("重命名") },
20+
text = {
21+
OutlinedTextField(
22+
value = name,
23+
onValueChange = { name = it },
24+
label = { Text("文件名") },
25+
singleLine = true,
26+
modifier = Modifier.fillMaxWidth()
27+
)
28+
},
29+
confirmButton = {
30+
TextButton(
31+
onClick = { onConfirm(name) },
32+
enabled = name.isNotBlank() && name != currentName
33+
) {
34+
Text("确定")
35+
}
36+
},
37+
dismissButton = {
38+
TextButton(onClick = onDismiss) {
39+
Text("取消")
40+
}
41+
}
42+
)
43+
}

0 commit comments

Comments
 (0)