@@ -3,9 +3,12 @@ package app.passwordstore.ui.crypto
3
3
import androidx.compose.foundation.layout.Box
4
4
import androidx.compose.foundation.layout.Column
5
5
import androidx.compose.foundation.layout.fillMaxSize
6
+ import androidx.compose.foundation.layout.padding
6
7
import androidx.compose.material3.ExperimentalMaterial3Api
7
8
import androidx.compose.material3.Icon
8
9
import androidx.compose.material3.IconButton
10
+ import androidx.compose.material3.MaterialTheme
11
+ import androidx.compose.material3.Scaffold
9
12
import androidx.compose.material3.Text
10
13
import androidx.compose.material3.TextField
11
14
import androidx.compose.runtime.Composable
@@ -17,8 +20,11 @@ import androidx.compose.ui.res.painterResource
17
20
import androidx.compose.ui.res.stringResource
18
21
import androidx.compose.ui.text.AnnotatedString
19
22
import androidx.compose.ui.tooling.preview.Preview
23
+ import androidx.compose.ui.unit.dp
20
24
import app.passwordstore.R
21
25
import app.passwordstore.data.passfile.PasswordEntry
26
+ import app.passwordstore.ui.APSAppBar
27
+ import app.passwordstore.ui.compose.theme.APSThemePreview
22
28
import app.passwordstore.util.time.UserClock
23
29
import app.passwordstore.util.totp.UriTotpFinder
24
30
import kotlin.time.ExperimentalTime
@@ -32,28 +38,42 @@ fun PasswordEntryScreen(
32
38
entry : PasswordEntry ,
33
39
modifier : Modifier = Modifier ,
34
40
) {
35
- val clipboard = LocalClipboardManager .current
36
- Box (modifier = modifier.fillMaxSize()) {
37
- Column {
38
- Text (entryName)
39
- if (entry.password != null ) {
40
- TextField (
41
- value = entry.password!! ,
42
- onValueChange = {},
43
- readOnly = true ,
44
- label = { Text (" Password" ) },
45
- trailingIcon = { CopyButton { clipboard.setText(AnnotatedString (entry.password!! )) } },
46
- )
47
- }
48
- if (entry.hasTotp()) {
49
- val totp by entry.totp.collectAsState(runBlocking { entry.totp.first() })
50
- TextField (
51
- value = totp.value,
52
- onValueChange = {},
53
- readOnly = true ,
54
- label = { Text (" OTP (expires in ${totp.remainingTime.inWholeSeconds} s)" ) },
55
- trailingIcon = { CopyButton { clipboard.setText(AnnotatedString (totp.value)) } }
41
+ Scaffold (
42
+ topBar = {
43
+ APSAppBar (
44
+ title = " " ,
45
+ navigationIcon = painterResource(R .drawable.ic_arrow_back_black_24dp),
46
+ onNavigationIconClick = {},
47
+ backgroundColor = MaterialTheme .colorScheme.surface,
48
+ )
49
+ },
50
+ ) { paddingValues ->
51
+ val clipboard = LocalClipboardManager .current
52
+ Box (modifier = modifier.fillMaxSize().padding(paddingValues)) {
53
+ Column (modifier = Modifier .padding(8 .dp)) {
54
+ Text (
55
+ text = entryName,
56
+ style = MaterialTheme .typography.headlineSmall,
56
57
)
58
+ if (entry.password != null ) {
59
+ TextField (
60
+ value = entry.password!! ,
61
+ onValueChange = {},
62
+ readOnly = true ,
63
+ label = { Text (" Password" ) },
64
+ trailingIcon = { CopyButton { clipboard.setText(AnnotatedString (entry.password!! )) } },
65
+ )
66
+ }
67
+ if (entry.hasTotp()) {
68
+ val totp by entry.totp.collectAsState(runBlocking { entry.totp.first() })
69
+ TextField (
70
+ value = totp.value,
71
+ onValueChange = {},
72
+ readOnly = true ,
73
+ label = { Text (" OTP (expires in ${totp.remainingTime.inWholeSeconds} s)" ) },
74
+ trailingIcon = { CopyButton { clipboard.setText(AnnotatedString (totp.value)) } }
75
+ )
76
+ }
57
77
}
58
78
}
59
79
}
@@ -74,7 +94,7 @@ private fun CopyButton(onClick: () -> Unit) {
74
94
@Preview
75
95
@Composable
76
96
private fun PasswordEntryPreview () {
77
- PasswordEntryScreen (" Test Entry" , createTestEntry())
97
+ APSThemePreview { PasswordEntryScreen (" Test Entry" , createTestEntry()) }
78
98
}
79
99
80
100
fun createTestEntry () =
0 commit comments