Update the VaultAddItemScreen spacing between items (#222)

This commit is contained in:
David Perez 2023-11-07 15:28:24 -06:00 committed by Álison Fernandes
parent 749f726f8a
commit 790e755aac

View file

@ -1,10 +1,15 @@
package com.x8bit.bitwarden.ui.vault.feature.vault package com.x8bit.bitwarden.ui.vault.feature.vault
import android.widget.Toast import android.widget.Toast
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.exclude
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
@ -13,12 +18,12 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.ScaffoldDefaults
import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.rememberTopAppBarState import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
@ -78,6 +83,9 @@ fun VaultAddItemScreen(
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.nestedScroll(scrollBehavior.nestedScrollConnection), .nestedScroll(scrollBehavior.nestedScrollConnection),
contentWindowInsets = ScaffoldDefaults
.contentWindowInsets
.exclude(WindowInsets.navigationBars),
topBar = { topBar = {
BitwardenTopAppBar( BitwardenTopAppBar(
title = stringResource(id = R.string.add_item), title = stringResource(id = R.string.add_item),
@ -103,15 +111,14 @@ fun VaultAddItemScreen(
.padding(innerPadding) .padding(innerPadding)
.fillMaxSize() .fillMaxSize()
.verticalScroll(scrollState), .verticalScroll(scrollState),
verticalArrangement = Arrangement.spacedBy(16.dp),
) { ) {
BitwardenListHeaderText( BitwardenListHeaderText(
label = stringResource(id = R.string.item_information), label = stringResource(id = R.string.item_information),
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )
Spacer(modifier = Modifier.height(8.dp))
TypeOptionsItem( TypeOptionsItem(
selectedType = state.selectedType, selectedType = state.selectedType,
onTypeOptionClicked = remember(viewModel) { onTypeOptionClicked = remember(viewModel) {
@ -176,6 +183,7 @@ private fun AddLoginTypeItemContent(
state: VaultAddItemState.ItemType.Login, state: VaultAddItemState.ItemType.Login,
loginItemTypeHandlers: VaultAddLoginItemTypeHandlers, loginItemTypeHandlers: VaultAddLoginItemTypeHandlers,
) { ) {
Spacer(modifier = Modifier.height(8.dp))
BitwardenTextField( BitwardenTextField(
label = stringResource(id = R.string.name), label = stringResource(id = R.string.name),
value = state.name, value = state.name,
@ -185,6 +193,7 @@ private fun AddLoginTypeItemContent(
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )
Spacer(modifier = Modifier.height(8.dp))
BitwardenTextFieldWithActions( BitwardenTextFieldWithActions(
label = stringResource(id = R.string.username), label = stringResource(id = R.string.username),
value = state.username, value = state.username,
@ -201,6 +210,7 @@ private fun AddLoginTypeItemContent(
modifier = Modifier.padding(horizontal = 16.dp), modifier = Modifier.padding(horizontal = 16.dp),
) )
Spacer(modifier = Modifier.height(8.dp))
BitwardenPasswordFieldWithActions( BitwardenPasswordFieldWithActions(
label = stringResource(id = R.string.password), label = stringResource(id = R.string.password),
value = state.password, value = state.password,
@ -224,14 +234,15 @@ private fun AddLoginTypeItemContent(
) )
} }
Spacer(modifier = Modifier.height(24.dp))
BitwardenListHeaderText( BitwardenListHeaderText(
label = stringResource(id = R.string.authenticator_key), label = stringResource(id = R.string.authenticator_key),
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(top = 8.dp)
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )
Spacer(modifier = Modifier.height(16.dp))
BitwardenFilledButtonWithIcon( BitwardenFilledButtonWithIcon(
label = stringResource(id = R.string.setup_totp), label = stringResource(id = R.string.setup_totp),
icon = painterResource(id = R.drawable.ic_light_bulb), icon = painterResource(id = R.drawable.ic_light_bulb),
@ -241,14 +252,15 @@ private fun AddLoginTypeItemContent(
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )
Spacer(modifier = Modifier.height(24.dp))
BitwardenListHeaderText( BitwardenListHeaderText(
label = stringResource(id = R.string.ur_is), label = stringResource(id = R.string.ur_is),
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(top = 8.dp)
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )
Spacer(modifier = Modifier.height(8.dp))
BitwardenTextFieldWithActions( BitwardenTextFieldWithActions(
label = stringResource(id = R.string.uri), label = stringResource(id = R.string.uri),
value = state.uri, value = state.uri,
@ -265,6 +277,7 @@ private fun AddLoginTypeItemContent(
modifier = Modifier.padding(horizontal = 16.dp), modifier = Modifier.padding(horizontal = 16.dp),
) )
Spacer(modifier = Modifier.height(16.dp))
BitwardenFilledTonalButton( BitwardenFilledTonalButton(
label = stringResource(id = R.string.new_uri), label = stringResource(id = R.string.new_uri),
onClick = loginItemTypeHandlers.onAddNewUriClick, onClick = loginItemTypeHandlers.onAddNewUriClick,
@ -273,14 +286,15 @@ private fun AddLoginTypeItemContent(
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )
Spacer(modifier = Modifier.height(24.dp))
BitwardenListHeaderText( BitwardenListHeaderText(
label = stringResource(id = R.string.miscellaneous), label = stringResource(id = R.string.miscellaneous),
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(top = 8.dp)
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )
Spacer(modifier = Modifier.height(8.dp))
BitwardenMultiSelectButton( BitwardenMultiSelectButton(
label = stringResource(id = R.string.folder), label = stringResource(id = R.string.folder),
options = state.availableFolders, options = state.availableFolders,
@ -289,6 +303,7 @@ private fun AddLoginTypeItemContent(
modifier = Modifier.padding(horizontal = 16.dp), modifier = Modifier.padding(horizontal = 16.dp),
) )
Spacer(modifier = Modifier.height(16.dp))
BitwardenSwitch( BitwardenSwitch(
label = stringResource( label = stringResource(
id = R.string.favorite, id = R.string.favorite,
@ -300,6 +315,7 @@ private fun AddLoginTypeItemContent(
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )
Spacer(modifier = Modifier.height(16.dp))
BitwardenSwitchWithActions( BitwardenSwitchWithActions(
label = stringResource(id = R.string.password_prompt), label = stringResource(id = R.string.password_prompt),
isChecked = state.masterPasswordReprompt, isChecked = state.masterPasswordReprompt,
@ -320,35 +336,33 @@ private fun AddLoginTypeItemContent(
}, },
) )
Spacer(modifier = Modifier.height(24.dp))
BitwardenListHeaderText( BitwardenListHeaderText(
label = stringResource(id = R.string.notes), label = stringResource(id = R.string.notes),
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(top = 8.dp)
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )
Column( Spacer(modifier = Modifier.height(8.dp))
horizontalAlignment = Alignment.CenterHorizontally, BitwardenTextField(
) { label = stringResource(id = R.string.notes),
BitwardenTextField( value = state.notes,
label = stringResource(id = R.string.notes), onValueChange = loginItemTypeHandlers.onNotesTextChange,
value = state.notes, modifier = Modifier
onValueChange = loginItemTypeHandlers.onNotesTextChange, .fillMaxWidth()
modifier = Modifier .padding(horizontal = 16.dp),
.fillMaxWidth() )
.padding(horizontal = 16.dp),
)
}
Spacer(modifier = Modifier.height(24.dp))
BitwardenListHeaderText( BitwardenListHeaderText(
label = stringResource(id = R.string.custom_fields), label = stringResource(id = R.string.custom_fields),
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(top = 8.dp)
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )
Spacer(modifier = Modifier.height(16.dp))
BitwardenFilledTonalButton( BitwardenFilledTonalButton(
label = stringResource(id = R.string.new_custom_field), label = stringResource(id = R.string.new_custom_field),
onClick = loginItemTypeHandlers.onAddNewCustomFieldClick, onClick = loginItemTypeHandlers.onAddNewCustomFieldClick,
@ -357,23 +371,22 @@ private fun AddLoginTypeItemContent(
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )
Spacer(modifier = Modifier.height(24.dp))
BitwardenListHeaderText( BitwardenListHeaderText(
label = stringResource(id = R.string.ownership), label = stringResource(id = R.string.ownership),
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(top = 8.dp)
.padding(horizontal = 16.dp), .padding(horizontal = 16.dp),
) )
Spacer(modifier = Modifier.height(8.dp))
BitwardenMultiSelectButton( BitwardenMultiSelectButton(
label = stringResource(id = R.string.who_owns_this_item), label = stringResource(id = R.string.who_owns_this_item),
options = state.availableOwners, options = state.availableOwners,
selectedOption = state.ownership, selectedOption = state.ownership,
onOptionSelected = loginItemTypeHandlers.onOwnershipTextChange, onOptionSelected = loginItemTypeHandlers.onOwnershipTextChange,
modifier = Modifier.padding( modifier = Modifier.padding(horizontal = 16.dp),
bottom = 30.dp,
start = 16.dp,
end = 16.dp,
),
) )
Spacer(modifier = Modifier.height(24.dp))
Spacer(modifier = Modifier.navigationBarsPadding())
} }