Skip to content

Commit f739cfc

Browse files
author
Andrey
committed
Refactor AddSMBDriveDialog to match JumpToPathDialog design
1 parent 8583863 commit f739cfc

File tree

1 file changed

+75
-17
lines changed

1 file changed

+75
-17
lines changed

app/src/main/java/com/raival/compose/file/explorer/screen/main/ui/AddSMBDriveDialog.kt

Lines changed: 75 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,18 @@ import androidx.compose.ui.text.font.FontWeight
2727
import androidx.compose.ui.unit.dp
2828
import androidx.compose.ui.window.Dialog
2929
import androidx.compose.foundation.layout.height
30+
import androidx.compose.material3.CardDefaults
31+
import androidx.compose.material3.HorizontalDivider
32+
import androidx.compose.material3.OutlinedButton
33+
import androidx.compose.material3.TextFieldDefaults
34+
import androidx.compose.ui.graphics.Color
3035
import androidx.compose.ui.platform.LocalContext
3136
import androidx.compose.ui.res.stringResource
3237
import androidx.compose.ui.text.input.PasswordVisualTransformation
38+
import androidx.compose.ui.text.style.TextAlign
3339
import com.raival.compose.file.explorer.App.Companion.globalClass
3440
import com.raival.compose.file.explorer.R
41+
import com.raival.compose.file.explorer.common.ui.Space
3542
import kotlinx.coroutines.CoroutineScope
3643
import kotlinx.coroutines.Dispatchers
3744
import kotlinx.coroutines.launch
@@ -55,24 +62,41 @@ fun AddSMBDriveDialog(
5562

5663
Dialog(onDismissRequest = onDismiss) {
5764
Card(
58-
shape = RoundedCornerShape(12.dp),
59-
modifier = Modifier
60-
.fillMaxWidth()
61-
.padding(16.dp)
62-
) {
65+
shape = RoundedCornerShape(6.dp),
66+
colors = CardDefaults.cardColors(
67+
containerColor = MaterialTheme.colorScheme.surfaceContainerHigh
68+
),
69+
elevation = CardDefaults.cardElevation(defaultElevation = 8.dp)
70+
) {
6371
Column(modifier = Modifier.padding(16.dp)) {
64-
Text(
65-
text = stringResource(R.string.smb_storage),
66-
style = MaterialTheme.typography.titleMedium,
67-
fontWeight = FontWeight.Bold
68-
)
69-
Spacer(modifier = Modifier.height(12.dp))
72+
Column {
73+
Text(
74+
modifier = Modifier.fillMaxWidth(),
75+
text = stringResource(R.string.smb_storage),
76+
style = MaterialTheme.typography.headlineSmall,
77+
fontWeight = FontWeight.SemiBold,
78+
textAlign = TextAlign.Center,
79+
color = MaterialTheme.colorScheme.onSurface
80+
)
81+
Space(8.dp)
82+
HorizontalDivider(
83+
thickness = 1.dp,
84+
color = MaterialTheme.colorScheme.outlineVariant
85+
)
86+
}
7087

7188
OutlinedTextField(
7289
value = host,
7390
onValueChange = { host = it },
7491
label = { Text(stringResource(R.string.host)) },
7592
singleLine = true,
93+
shape = RoundedCornerShape(6.dp),
94+
colors = TextFieldDefaults.colors(
95+
focusedIndicatorColor = Color.Transparent,
96+
unfocusedIndicatorColor = Color.Transparent,
97+
disabledIndicatorColor = Color.Transparent,
98+
errorIndicatorColor = Color.Transparent
99+
),
76100
modifier = Modifier.fillMaxWidth()
77101
)
78102

@@ -81,6 +105,13 @@ fun AddSMBDriveDialog(
81105
onValueChange = { username = it },
82106
label = { Text(stringResource(R.string.username)) },
83107
singleLine = true,
108+
shape = RoundedCornerShape(6.dp),
109+
colors = TextFieldDefaults.colors(
110+
focusedIndicatorColor = Color.Transparent,
111+
unfocusedIndicatorColor = Color.Transparent,
112+
disabledIndicatorColor = Color.Transparent,
113+
errorIndicatorColor = Color.Transparent
114+
),
84115
modifier = Modifier.fillMaxWidth(),
85116
enabled = !anonymous
86117
)
@@ -91,6 +122,13 @@ fun AddSMBDriveDialog(
91122
label = { Text(stringResource(R.string.password)) },
92123
singleLine = true,
93124
visualTransformation = PasswordVisualTransformation(),
125+
shape = RoundedCornerShape(6.dp),
126+
colors = TextFieldDefaults.colors(
127+
focusedIndicatorColor = Color.Transparent,
128+
unfocusedIndicatorColor = Color.Transparent,
129+
disabledIndicatorColor = Color.Transparent,
130+
errorIndicatorColor = Color.Transparent
131+
),
94132
modifier = Modifier.fillMaxWidth(),
95133
enabled = !anonymous
96134
)
@@ -120,19 +158,35 @@ fun AddSMBDriveDialog(
120158
label = { Text(stringResource(R.string.domain)) },
121159
placeholder = { Text(stringResource(R.string.optional)) },
122160
singleLine = true,
161+
shape = RoundedCornerShape(6.dp),
162+
colors = TextFieldDefaults.colors(
163+
focusedIndicatorColor = Color.Transparent,
164+
unfocusedIndicatorColor = Color.Transparent,
165+
disabledIndicatorColor = Color.Transparent,
166+
errorIndicatorColor = Color.Transparent
167+
),
123168
modifier = Modifier.fillMaxWidth()
124169
)
125170
}
126171

127172
Spacer(modifier = Modifier.height(12.dp))
128173

129174
Row(
130-
horizontalArrangement = Arrangement.End,
131-
modifier = Modifier.fillMaxWidth()
175+
modifier = Modifier.fillMaxWidth(),
176+
horizontalArrangement = Arrangement.spacedBy(12.dp)
132177
) {
133-
TextButton(onClick = onDismiss) { Text(stringResource(R.string.cancel)) }
134-
Spacer(modifier = Modifier.width(8.dp))
178+
OutlinedButton(
179+
modifier = Modifier.weight(1f),
180+
onClick = onDismiss,
181+
shape = RoundedCornerShape(6.dp)
182+
) {
183+
Text(
184+
text = stringResource(R.string.cancel),
185+
style = MaterialTheme.typography.labelLarge
186+
)
187+
}
135188
Button(
189+
modifier = Modifier.weight(1f),
136190
onClick = {
137191
CoroutineScope(Dispatchers.IO).launch {
138192
val success = mainActivityManager.addSmbDrive(
@@ -152,9 +206,13 @@ fun AddSMBDriveDialog(
152206
}
153207
}
154208
},
155-
enabled = host.isNotBlank() && (anonymous || (username.isNotBlank() && password.isNotBlank()))
209+
enabled = host.isNotBlank() && (anonymous || (username.isNotBlank() && password.isNotBlank())),
210+
shape = RoundedCornerShape(6.dp)
156211
) {
157-
Text(stringResource(R.string.connect))
212+
Text(
213+
text = stringResource(R.string.connect),
214+
style = MaterialTheme.typography.labelLarge
215+
)
158216
}
159217
}
160218
}

0 commit comments

Comments
 (0)