@@ -3,8 +3,10 @@ package com.x8bit.bitwarden.ui.vault.feature.addedit
3
3
import androidx.compose.foundation.layout.Spacer
4
4
import androidx.compose.foundation.layout.fillMaxWidth
5
5
import androidx.compose.foundation.layout.height
6
+ import androidx.compose.foundation.layout.padding
6
7
import androidx.compose.foundation.lazy.LazyColumn
7
8
import androidx.compose.foundation.lazy.LazyListScope
9
+ import androidx.compose.foundation.lazy.items
8
10
import androidx.compose.runtime.Composable
9
11
import androidx.compose.ui.Modifier
10
12
import androidx.compose.ui.platform.testTag
@@ -13,15 +15,23 @@ import androidx.compose.ui.tooling.preview.Preview
13
15
import androidx.compose.ui.unit.dp
14
16
import com.x8bit.bitwarden.R
15
17
import com.x8bit.bitwarden.ui.platform.base.util.standardHorizontalMargin
18
+ import com.x8bit.bitwarden.ui.platform.components.button.BitwardenStandardIconButton
19
+ import com.x8bit.bitwarden.ui.platform.components.dropdown.BitwardenMultiSelectButton
16
20
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenPasswordField
17
21
import com.x8bit.bitwarden.ui.platform.components.field.BitwardenTextField
22
+ import com.x8bit.bitwarden.ui.platform.components.header.BitwardenListHeaderText
23
+ import com.x8bit.bitwarden.ui.platform.components.toggle.BitwardenSwitch
18
24
import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
19
25
import com.x8bit.bitwarden.ui.vault.feature.addedit.handlers.VaultAddEditCommonHandlers
20
26
import com.x8bit.bitwarden.ui.vault.feature.addedit.handlers.VaultAddEditSshKeyTypeHandlers
27
+ import com.x8bit.bitwarden.ui.vault.model.VaultLinkedFieldType
28
+ import kotlinx.collections.immutable.persistentListOf
29
+ import kotlinx.collections.immutable.toImmutableList
21
30
22
31
/* *
23
32
* The UI for adding and editing a SSH key cipher.
24
33
*/
34
+ @Suppress(" LongMethod" )
25
35
fun LazyListScope.vaultAddEditSshKeyItems (
26
36
commonState : VaultAddEditState .ViewState .Content .Common ,
27
37
sshKeyState : VaultAddEditState .ViewState .Content .ItemType .SshKey ,
@@ -85,6 +95,138 @@ fun LazyListScope.vaultAddEditSshKeyItems(
85
95
.standardHorizontalMargin(),
86
96
)
87
97
}
98
+
99
+ item {
100
+ Spacer (modifier = Modifier .height(24 .dp))
101
+ BitwardenListHeaderText (
102
+ label = stringResource(id = R .string.miscellaneous),
103
+ modifier = Modifier
104
+ .fillMaxWidth()
105
+ .padding(horizontal = 16 .dp),
106
+ )
107
+ }
108
+
109
+ item {
110
+ Spacer (modifier = Modifier .height(8 .dp))
111
+ BitwardenMultiSelectButton (
112
+ label = stringResource(id = R .string.folder),
113
+ options = commonState
114
+ .availableFolders
115
+ .map { it.name }
116
+ .toImmutableList(),
117
+ selectedOption = commonState.selectedFolder?.name,
118
+ onOptionSelected = { selectedFolderName ->
119
+ commonTypeHandlers.onFolderSelected(
120
+ commonState
121
+ .availableFolders
122
+ .first { it.name == selectedFolderName },
123
+ )
124
+ },
125
+ modifier = Modifier
126
+ .testTag(" FolderPicker" )
127
+ .padding(horizontal = 16 .dp),
128
+ )
129
+ }
130
+
131
+ item {
132
+ Spacer (modifier = Modifier .height(16 .dp))
133
+ BitwardenSwitch (
134
+ label = stringResource(
135
+ id = R .string.favorite,
136
+ ),
137
+ isChecked = commonState.favorite,
138
+ onCheckedChange = commonTypeHandlers.onToggleFavorite,
139
+ modifier = Modifier
140
+ .testTag(" ItemFavoriteToggle" )
141
+ .fillMaxWidth()
142
+ .padding(horizontal = 16 .dp),
143
+ )
144
+ }
145
+ if (commonState.isUnlockWithPasswordEnabled) {
146
+ item {
147
+ Spacer (modifier = Modifier .height(16 .dp))
148
+ BitwardenSwitch (
149
+ label = stringResource(id = R .string.password_prompt),
150
+ isChecked = commonState.masterPasswordReprompt,
151
+ onCheckedChange = commonTypeHandlers.onToggleMasterPasswordReprompt,
152
+ modifier = Modifier
153
+ .testTag(" MasterPasswordRepromptToggle" )
154
+ .fillMaxWidth()
155
+ .padding(horizontal = 16 .dp),
156
+ actions = {
157
+ BitwardenStandardIconButton (
158
+ vectorIconRes = R .drawable.ic_question_circle_small,
159
+ contentDescription = stringResource(
160
+ id = R .string.master_password_re_prompt_help,
161
+ ),
162
+ onClick = commonTypeHandlers.onTooltipClick,
163
+ contentColor = BitwardenTheme .colorScheme.icon.secondary,
164
+ )
165
+ },
166
+ )
167
+ }
168
+ }
169
+
170
+ item {
171
+ Spacer (modifier = Modifier .height(24 .dp))
172
+ BitwardenListHeaderText (
173
+ label = stringResource(id = R .string.notes),
174
+ modifier = Modifier
175
+ .fillMaxWidth()
176
+ .padding(horizontal = 16 .dp),
177
+ )
178
+ }
179
+
180
+ item {
181
+ Spacer (modifier = Modifier .height(8 .dp))
182
+ BitwardenTextField (
183
+ singleLine = false ,
184
+ label = stringResource(id = R .string.notes),
185
+ value = commonState.notes,
186
+ onValueChange = commonTypeHandlers.onNotesTextChange,
187
+ modifier = Modifier
188
+ .testTag(" ItemNotesEntry" )
189
+ .fillMaxWidth()
190
+ .padding(horizontal = 16 .dp),
191
+ )
192
+ }
193
+
194
+ item {
195
+ Spacer (modifier = Modifier .height(24 .dp))
196
+ BitwardenListHeaderText (
197
+ label = stringResource(id = R .string.custom_fields),
198
+ modifier = Modifier
199
+ .fillMaxWidth()
200
+ .padding(horizontal = 16 .dp),
201
+ )
202
+ }
203
+
204
+ items(commonState.customFieldData) { customItem ->
205
+ Spacer (modifier = Modifier .height(8 .dp))
206
+ VaultAddEditCustomField (
207
+ customField = customItem,
208
+ onCustomFieldValueChange = commonTypeHandlers.onCustomFieldValueChange,
209
+ onCustomFieldAction = commonTypeHandlers.onCustomFieldActionSelect,
210
+ modifier = Modifier
211
+ .fillMaxWidth()
212
+ .padding(horizontal = 16 .dp),
213
+ supportedLinkedTypes = persistentListOf(
214
+ VaultLinkedFieldType .PASSWORD ,
215
+ VaultLinkedFieldType .USERNAME ,
216
+ ),
217
+ onHiddenVisibilityChanged = commonTypeHandlers.onHiddenFieldVisibilityChange,
218
+ )
219
+ }
220
+
221
+ item {
222
+ Spacer (modifier = Modifier .height(16 .dp))
223
+ VaultAddEditCustomFieldsButton (
224
+ onFinishNamingClick = commonTypeHandlers.onAddNewCustomFieldClick,
225
+ modifier = Modifier
226
+ .fillMaxWidth()
227
+ .padding(horizontal = 16 .dp),
228
+ )
229
+ }
88
230
}
89
231
90
232
@Preview(showBackground = true )
0 commit comments