Skip to content

Commit 3f736fa

Browse files
committed
Refactor dialog display functionality
The Dialog component has been refactored to DialogWindow. This change comes in order to foster better overall layout organization, increase code clarity, and reinforce the dialog's cohesiveness with the application's broader layout and functionality. This refactor also comprises an update of the import statement to reflect the use of DialogWindow, as well as adjustments in the alignment of elements within the dialog.
1 parent c6b79ac commit 3f736fa

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

src/main/kotlin/dev/coderpwh/sparkapidesk/components/About.kt

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import androidx.compose.ui.res.painterResource
1414
import androidx.compose.ui.unit.DpSize
1515
import androidx.compose.ui.unit.dp
1616
import androidx.compose.ui.window.Dialog
17+
import androidx.compose.ui.window.DialogWindow
18+
import androidx.compose.ui.window.DialogWindowScope
1719
import androidx.compose.ui.window.rememberDialogState
1820

1921
/**
@@ -24,37 +26,45 @@ import androidx.compose.ui.window.rememberDialogState
2426

2527
@Composable
2628
fun About(isShow:Boolean,onCloseRequest:()->Unit) {
27-
Dialog(
29+
//显示简介
30+
DialogWindow(onCloseRequest = onCloseRequest,
31+
state = rememberDialogState(size = DpSize(400.dp, 300.dp)),
2832
visible = isShow,
29-
onCloseRequest = onCloseRequest,
3033
title = "About",
31-
state = rememberDialogState(size = DpSize(400.dp, 300.dp)),
32-
) {
34+
) {
3335
Column {
3436
Row(
3537
modifier = Modifier.align(Alignment.CenterHorizontally),
3638
) {
37-
Image(painter = painterResource("img.png"), contentDescription = "img", modifier = Modifier.size(40.dp))
39+
Image(
40+
painter = painterResource("img.png"),
41+
contentDescription = "img",
42+
modifier = Modifier.size(40.dp)
43+
)
3844
Spacer(modifier = Modifier.width(20.dp))
3945
Text(text = "spark apidesk", modifier = Modifier.align(alignment = Alignment.CenterVertically))
4046
}
4147
//显示简介
42-
TextField(value = "使用sparkapi进行接口对接的桌面端应用", onValueChange = {}, readOnly = true,
43-
colors = TextFieldDefaults.textFieldColors(backgroundColor = Color.Transparent, focusedIndicatorColor = Color.Transparent, unfocusedIndicatorColor = Color.Transparent),
44-
)
48+
TextField(
49+
value = "使用sparkapi进行接口对接的桌面端应用", onValueChange = {}, readOnly = true,
50+
colors = TextFieldDefaults.textFieldColors(
51+
backgroundColor = Color.Transparent,
52+
focusedIndicatorColor = Color.Transparent,
53+
unfocusedIndicatorColor = Color.Transparent
54+
),
55+
)
4556
Spacer(modifier = Modifier.height(20.dp))
4657
Row(modifier = Modifier.align(Alignment.CenterHorizontally)) {
4758
Text(text = "Author: coderpwh", modifier = Modifier.align(alignment = Alignment.CenterVertically))
4859
Spacer(modifier = Modifier.width(20.dp))
49-
LinkButton("https://github.com/pwh-pwh","github")
60+
LinkButton("https://github.com/pwh-pwh", "github")
5061
}
5162
Spacer(modifier = Modifier.height(2.dp))
5263
Row(modifier = Modifier.align(Alignment.CenterHorizontally)) {
5364
Text(text = "Code: sparkapidesk", modifier = Modifier.align(alignment = Alignment.CenterVertically))
5465
Spacer(modifier = Modifier.width(20.dp))
55-
LinkButton("https://github.com/pwh-pwh/sparkapidesk","sparkapidesk")
66+
LinkButton("https://github.com/pwh-pwh/sparkapidesk", "sparkapidesk")
5667
}
5768
}
58-
5969
}
6070
}

src/main/kotlin/dev/coderpwh/sparkapidesk/components/KeyConfigDialog.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import androidx.compose.material.Text
44
import androidx.compose.runtime.Composable
55
import androidx.compose.ui.unit.DpSize
66
import androidx.compose.ui.unit.dp
7-
import androidx.compose.ui.window.Dialog
8-
import androidx.compose.ui.window.TrayState
9-
import androidx.compose.ui.window.rememberDialogState
7+
import androidx.compose.ui.window.*
108

119
/**
1210
* @Auther: pangwenhao
@@ -16,12 +14,11 @@ import androidx.compose.ui.window.rememberDialogState
1614

1715
@Composable
1816
fun KeyConfigDialog(alertDialog:Boolean,onCloseRequest:()->Unit,trayState: TrayState) {
19-
Dialog(
20-
onCloseRequest = onCloseRequest,
21-
visible = alertDialog,
17+
DialogWindow(onCloseRequest = onCloseRequest,
2218
state = rememberDialogState(size = DpSize(400.dp, 300.dp)),
23-
title = "set key"
24-
) {
19+
visible = alertDialog,
20+
title = "set key",
21+
) {
2522
KeyForm(trayState)
2623
}
2724
}

0 commit comments

Comments
 (0)