Skip to content

Commit 8961d42

Browse files
committed
feature: konfeature edit config value dialog redesign
1 parent 7d34d96 commit 8961d42

4 files changed

Lines changed: 299 additions & 131 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.redmadrobot.debug.uikit.components
2+
3+
import androidx.compose.foundation.layout.Column
4+
import androidx.compose.foundation.layout.ColumnScope
5+
import androidx.compose.foundation.layout.fillMaxWidth
6+
import androidx.compose.foundation.layout.padding
7+
import androidx.compose.material3.Surface
8+
import androidx.compose.material3.Text
9+
import androidx.compose.runtime.Composable
10+
import androidx.compose.ui.Modifier
11+
import androidx.compose.ui.unit.dp
12+
import androidx.compose.ui.window.Dialog
13+
import androidx.compose.ui.window.DialogProperties
14+
import com.redmadrobot.debug.uikit.theme.DebugPanelShapes
15+
import com.redmadrobot.debug.uikit.theme.DebugPanelTheme
16+
17+
@Composable
18+
public fun PanelDialog(
19+
title: String,
20+
onDismiss: () -> Unit,
21+
modifier: Modifier = Modifier,
22+
content: @Composable ColumnScope.() -> Unit,
23+
) {
24+
Dialog(
25+
onDismissRequest = onDismiss,
26+
properties = DialogProperties(usePlatformDefaultWidth = false),
27+
) {
28+
Surface(
29+
shape = DebugPanelShapes.dialog,
30+
color = DebugPanelTheme.colors.surface.dialog,
31+
modifier = modifier
32+
.fillMaxWidth()
33+
.padding(horizontal = 24.dp),
34+
) {
35+
Column(modifier = Modifier.padding(all = 24.dp)) {
36+
Text(
37+
text = title,
38+
style = DebugPanelTheme.typography.titleLarge,
39+
color = DebugPanelTheme.colors.content.primary,
40+
modifier = Modifier.padding(bottom = 16.dp),
41+
)
42+
content()
43+
}
44+
}
45+
}
46+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.redmadrobot.debug.uikit.components
2+
3+
import androidx.compose.foundation.layout.Column
4+
import androidx.compose.foundation.layout.fillMaxWidth
5+
import androidx.compose.foundation.layout.padding
6+
import androidx.compose.foundation.text.KeyboardOptions
7+
import androidx.compose.material3.OutlinedTextField
8+
import androidx.compose.material3.OutlinedTextFieldDefaults
9+
import androidx.compose.material3.Text
10+
import androidx.compose.material3.TextFieldColors
11+
import androidx.compose.runtime.Composable
12+
import androidx.compose.ui.Modifier
13+
import androidx.compose.ui.text.TextStyle
14+
import androidx.compose.ui.unit.dp
15+
import com.redmadrobot.debug.uikit.theme.DebugPanelTheme
16+
17+
private val defaultTextStyle: TextStyle
18+
@Composable get() = DebugPanelTheme.typography.bodyMedium.copy(
19+
color = DebugPanelTheme.colors.content.primary,
20+
)
21+
22+
private val defaultColors: TextFieldColors
23+
@Composable get() = OutlinedTextFieldDefaults.colors(
24+
focusedBorderColor = DebugPanelTheme.colors.content.accent,
25+
unfocusedBorderColor = DebugPanelTheme.colors.stroke.secondary,
26+
focusedLabelColor = DebugPanelTheme.colors.content.accent,
27+
unfocusedLabelColor = DebugPanelTheme.colors.content.tertiary,
28+
errorBorderColor = DebugPanelTheme.colors.content.error,
29+
cursorColor = DebugPanelTheme.colors.content.accent,
30+
)
31+
32+
@Composable
33+
public fun PanelTextField(
34+
value: String,
35+
label: String,
36+
onValueChange: (String) -> Unit,
37+
modifier: Modifier = Modifier,
38+
isError: Boolean = false,
39+
errorMessage: String? = null,
40+
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
41+
textStyle: TextStyle = defaultTextStyle,
42+
colors: TextFieldColors = defaultColors
43+
) {
44+
Column(modifier = modifier.fillMaxWidth()) {
45+
OutlinedTextField(
46+
value = value,
47+
onValueChange = onValueChange,
48+
modifier = Modifier.fillMaxWidth(),
49+
label = { Text(text = label, style = DebugPanelTheme.typography.bodyMedium) },
50+
isError = isError,
51+
singleLine = true,
52+
keyboardOptions = keyboardOptions,
53+
textStyle = textStyle,
54+
colors = colors,
55+
)
56+
if (isError && errorMessage != null) {
57+
Text(
58+
text = errorMessage,
59+
style = DebugPanelTheme.typography.bodySmall,
60+
color = DebugPanelTheme.colors.content.error,
61+
modifier = Modifier.padding(top = 4.dp),
62+
)
63+
}
64+
}
65+
}

0 commit comments

Comments
 (0)