mirror of
https://github.com/bitwarden/android.git
synced 2025-02-16 11:59:57 +03:00
BIT-479: Fix minor New Send bugs (#236)
This commit is contained in:
parent
8e92e2c529
commit
382c4a0172
4 changed files with 83 additions and 10 deletions
|
@ -14,6 +14,7 @@ import androidx.compose.foundation.layout.fillMaxSize
|
|||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.imePadding
|
||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
|
@ -103,10 +104,10 @@ fun NewSendScreen(
|
|||
) { innerPadding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.imePadding()
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState())
|
||||
.padding(paddingValues = innerPadding)
|
||||
.imePadding(),
|
||||
.padding(paddingValues = innerPadding),
|
||||
) {
|
||||
BitwardenTextField(
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
|
@ -224,6 +225,8 @@ fun NewSendScreen(
|
|||
{ viewModel.trySendAction(NewSendAction.DeactivateThisSendToggle(it)) }
|
||||
},
|
||||
)
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
Spacer(modifier = Modifier.navigationBarsPadding())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -288,10 +291,14 @@ private fun NewSendOptions(
|
|||
modifier = Modifier.clipToBounds(),
|
||||
) {
|
||||
Column {
|
||||
SendDeletionDateChooser(
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
SendExpirationDateChooser(
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
BitwardenStepper(
|
||||
label = stringResource(id = R.string.maximum_access_count),
|
||||
value = state.maxAccessCount,
|
||||
|
@ -309,7 +316,7 @@ private fun NewSendOptions(
|
|||
.fillMaxWidth()
|
||||
.padding(horizontal = 32.dp),
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
BitwardenPasswordField(
|
||||
label = stringResource(id = R.string.new_password),
|
||||
hint = stringResource(id = R.string.password_info),
|
||||
|
@ -317,7 +324,7 @@ private fun NewSendOptions(
|
|||
onValueChange = onPasswordChange,
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
BitwardenTextField(
|
||||
label = stringResource(id = R.string.notes),
|
||||
hint = stringResource(id = R.string.notes_info),
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package com.x8bit.bitwarden.ui.tools.feature.send
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenMultiSelectButton
|
||||
|
||||
/**
|
||||
* Displays UX for choosing deletion date of a send.
|
||||
*
|
||||
* TODO: Implement custom date choosing and send choices to the VM: BIT-1090.
|
||||
*/
|
||||
@Composable
|
||||
fun SendDeletionDateChooser(
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val options = listOf(
|
||||
stringResource(id = R.string.one_day),
|
||||
stringResource(id = R.string.two_days),
|
||||
stringResource(id = R.string.three_days),
|
||||
stringResource(id = R.string.seven_days),
|
||||
stringResource(id = R.string.thirty_days),
|
||||
stringResource(id = R.string.custom),
|
||||
)
|
||||
val defaultOption = stringResource(id = R.string.seven_days)
|
||||
var selectedOption: String by rememberSaveable { mutableStateOf(defaultOption) }
|
||||
Column(
|
||||
modifier = modifier,
|
||||
) {
|
||||
BitwardenMultiSelectButton(
|
||||
label = stringResource(id = R.string.deletion_date),
|
||||
options = options,
|
||||
selectedOption = selectedOption,
|
||||
onOptionSelected = { selectedOption = it },
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = stringResource(id = R.string.deletion_date_info),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp),
|
||||
)
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ fun SendExpirationDateChooser(
|
|||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val options = listOf(
|
||||
stringResource(id = R.string.never),
|
||||
stringResource(id = R.string.one_day),
|
||||
stringResource(id = R.string.two_days),
|
||||
stringResource(id = R.string.three_days),
|
||||
|
@ -35,20 +36,20 @@ fun SendExpirationDateChooser(
|
|||
stringResource(id = R.string.thirty_days),
|
||||
stringResource(id = R.string.custom),
|
||||
)
|
||||
val defaultOption = stringResource(id = R.string.seven_days)
|
||||
val defaultOption = stringResource(id = R.string.never)
|
||||
var selectedOption: String by rememberSaveable { mutableStateOf(defaultOption) }
|
||||
Column(
|
||||
modifier = modifier,
|
||||
) {
|
||||
BitwardenMultiSelectButton(
|
||||
label = stringResource(id = R.string.deletion_date),
|
||||
label = stringResource(id = R.string.expiration_date),
|
||||
options = options,
|
||||
selectedOption = selectedOption,
|
||||
onOptionSelected = { selectedOption = it },
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = stringResource(id = R.string.deletion_date_info),
|
||||
text = stringResource(id = R.string.expiration_date_info),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier
|
||||
|
|
|
@ -175,7 +175,10 @@ class NewSendScreenTest : BaseComposeTest() {
|
|||
@Test
|
||||
fun `options sections should start hidden and show after options clicked`() {
|
||||
composeTestRule
|
||||
.onNodeWithText("Deletion date")
|
||||
.onNodeWithContentDescription("Deletion date", substring = true)
|
||||
.assertDoesNotExist()
|
||||
composeTestRule
|
||||
.onNodeWithContentDescription("Expiration date", substring = true)
|
||||
.assertDoesNotExist()
|
||||
composeTestRule
|
||||
.onNodeWithText("Maximum access count")
|
||||
|
@ -197,7 +200,10 @@ class NewSendScreenTest : BaseComposeTest() {
|
|||
.performScrollTo()
|
||||
.performClick()
|
||||
composeTestRule
|
||||
.onNodeWithText("Deletion date", useUnmergedTree = true)
|
||||
.onNodeWithContentDescription("Deletion date", substring = true)
|
||||
.assertExists()
|
||||
composeTestRule
|
||||
.onNodeWithContentDescription("Expiration date", substring = true)
|
||||
.assertExists()
|
||||
composeTestRule
|
||||
.onNodeWithText("Maximum access count")
|
||||
|
|
Loading…
Add table
Reference in a new issue