mirror of
https://github.com/bitwarden/android.git
synced 2025-02-17 12:30:00 +03:00
BIT-1178: Adding element ids for the generator (#655)
This commit is contained in:
parent
0b0fa55653
commit
c7dad53fe4
3 changed files with 22 additions and 4 deletions
|
@ -19,15 +19,17 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
|||
* @param iconRes Icon to display on the button.
|
||||
* @param onClick Callback for when the icon button is clicked.
|
||||
* @param isEnabled Whether or not the button should be enabled.
|
||||
* @param modifier A [Modifier] for the composable.
|
||||
*/
|
||||
@Composable
|
||||
fun BitwardenIconButtonWithResource(
|
||||
iconRes: IconResource,
|
||||
onClick: () -> Unit,
|
||||
isEnabled: Boolean = true,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
FilledIconButton(
|
||||
modifier = Modifier.semantics(mergeDescendants = true) {},
|
||||
modifier = modifier.semantics(mergeDescendants = true) {},
|
||||
onClick = onClick,
|
||||
colors = IconButtonColors(
|
||||
containerColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||
|
|
|
@ -9,6 +9,7 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.semantics.testTag
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.input.VisualTransformation
|
||||
|
@ -32,6 +33,7 @@ import com.x8bit.bitwarden.ui.platform.theme.BitwardenTheme
|
|||
* @param actions A lambda containing the set of actions (usually icons or similar) to display
|
||||
* next to the text field. This lambda extends [RowScope],
|
||||
* providing flexibility in the layout definition.
|
||||
* @param textFieldTestTag The test tag to be used on the text field.
|
||||
*/
|
||||
@Composable
|
||||
fun BitwardenTextFieldWithActions(
|
||||
|
@ -47,6 +49,7 @@ fun BitwardenTextFieldWithActions(
|
|||
keyboardType: KeyboardType = KeyboardType.Text,
|
||||
trailingIconContent: (@Composable () -> Unit)? = null,
|
||||
actions: @Composable RowScope.() -> Unit = {},
|
||||
textFieldTestTag: String? = null,
|
||||
) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
|
@ -56,6 +59,7 @@ fun BitwardenTextFieldWithActions(
|
|||
) {
|
||||
BitwardenTextField(
|
||||
modifier = Modifier
|
||||
.semantics { textFieldTestTag?.let { testTag = it } }
|
||||
.weight(1f),
|
||||
label = label,
|
||||
value = value,
|
||||
|
|
|
@ -31,6 +31,7 @@ import androidx.compose.runtime.mutableStateOf
|
|||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.ExperimentalComposeUiApi
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.layout.onGloballyPositioned
|
||||
|
@ -39,6 +40,8 @@ import androidx.compose.ui.platform.LocalDensity
|
|||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.semantics.testTag
|
||||
import androidx.compose.ui.semantics.testTagsAsResourceId
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.Dp
|
||||
|
@ -272,6 +275,7 @@ private fun ModalAppBar(
|
|||
|
||||
//region ScrollContent and Static Items
|
||||
|
||||
@OptIn(ExperimentalComposeUiApi::class)
|
||||
@Suppress("LongMethod")
|
||||
@Composable
|
||||
private fun ScrollContent(
|
||||
|
@ -291,6 +295,7 @@ private fun ScrollContent(
|
|||
) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.semantics { testTagsAsResourceId = true }
|
||||
.fillMaxHeight()
|
||||
.verticalScroll(rememberScrollState()),
|
||||
) {
|
||||
|
@ -353,6 +358,7 @@ private fun GeneratedStringItem(
|
|||
) {
|
||||
BitwardenTextFieldWithActions(
|
||||
label = "",
|
||||
textFieldTestTag = "GeneratedPasswordLabel",
|
||||
value = generatedText,
|
||||
singleLine = false,
|
||||
actions = {
|
||||
|
@ -362,6 +368,7 @@ private fun GeneratedStringItem(
|
|||
contentDescription = stringResource(id = R.string.copy),
|
||||
),
|
||||
onClick = onCopyClick,
|
||||
modifier = Modifier.semantics { testTag = "CopyValueButton" },
|
||||
)
|
||||
BitwardenIconButtonWithResource(
|
||||
iconRes = IconResource(
|
||||
|
@ -369,6 +376,7 @@ private fun GeneratedStringItem(
|
|||
contentDescription = stringResource(id = R.string.generate_password),
|
||||
),
|
||||
onClick = onRegenerateClick,
|
||||
modifier = Modifier.semantics { testTag = "RegenerateValueButton" },
|
||||
)
|
||||
},
|
||||
onValueChange = {},
|
||||
|
@ -399,7 +407,8 @@ private fun MainStateOptionsItem(
|
|||
},
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 16.dp)
|
||||
.fillMaxWidth(),
|
||||
.fillMaxWidth()
|
||||
.semantics { testTag = "GeneratorTypePicker" },
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -452,7 +461,8 @@ private fun PasscodeOptionsItem(
|
|||
},
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 16.dp)
|
||||
.fillMaxWidth(),
|
||||
.fillMaxWidth()
|
||||
.semantics { testTag = "PasswordTypePicker" },
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -460,6 +470,7 @@ private fun PasscodeOptionsItem(
|
|||
|
||||
//region PasswordType Composables
|
||||
|
||||
@Suppress("LongMethod")
|
||||
@Composable
|
||||
private fun ColumnScope.PasswordTypeContent(
|
||||
passwordTypeState: GeneratorState.MainType.Passcode.PasscodeType.Password,
|
||||
|
@ -855,7 +866,8 @@ private fun UsernameOptionsItem(
|
|||
},
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 16.dp)
|
||||
.fillMaxWidth(),
|
||||
.fillMaxWidth()
|
||||
.semantics { testTag = "PasswordTypePicker" },
|
||||
supportingText = currentSubState.selectedType.supportingStringResId?.let {
|
||||
stringResource(id = it)
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue