archive-97f2350/app/src/main/java/uk/orllewin/sianel/ui/ConfigScreen.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package uk.orllewin.sianel.ui
import androidx.compose.foundation.Image
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import uk.orllewin.sianel.R
/**
* First-run setup shown full screen when no password is configured yet. Reuses
* [ConfigForm] for the actual password / server URL inputs. There is no way to
* dismiss it — the user must provide credentials before reaching the rest of the app.
*/
@Composable
fun ConfigScreen(
currentPassword: String,
currentBaseUrl: String,
verifyState: VerifyState,
onCheck: (password: String, baseUrl: String) -> Unit,
onSave: (password: String, baseUrl: String) -> Unit,
modifier: Modifier = Modifier,
) {
val done = verifyState as? VerifyState.Done
Column(
modifier = modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
.imePadding()
.padding(24.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
val logoRes = if (isSystemInDarkTheme()) {
R.drawable.screen_logo_dark
} else {
R.drawable.screen_logo
}
Image(
modifier = Modifier.height(48.dp),
painter = painterResource(id = logoRes),
contentDescription = stringResource(R.string.sianel),
)
Text(
text = stringResource(R.string.enter_sianel_service_url_and_password_to_get_started),
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.padding(top = 16.dp, bottom = 24.dp),
)
ConfigForm(
isDialog = false,
currentPassword = currentPassword,
currentBaseUrl = currentBaseUrl,
onCheck = onCheck,
checking = verifyState is VerifyState.Checking,
checkMessage = done?.message,
checkOk = done?.ok == true,
onSave = onSave,
modifier = Modifier.widthIn(max = 480.dp)
)
}
}