mirror of
https://github.com/bitwarden/android.git
synced 2025-03-15 18:58:59 +03:00
BIT-1709 Add the button element Ids on the AddSend screen (#975)
This commit is contained in:
parent
1a9ed4d288
commit
d58e06e00f
4 changed files with 8 additions and 17 deletions
|
@ -7,6 +7,8 @@ import androidx.compose.material3.SegmentedButtonDefaults
|
|||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.semantics.testTag
|
||||
|
||||
/**
|
||||
* Displays a Bitwarden styled row of segmented buttons.
|
||||
|
@ -32,6 +34,9 @@ fun BitwardenSegmentedButton(
|
|||
count = options.size,
|
||||
),
|
||||
label = { Text(text = option.text) },
|
||||
modifier = Modifier.run {
|
||||
option.testTag?.let { semantics { testTag = it } } ?: this
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -44,4 +49,5 @@ data class SegmentedButtonState(
|
|||
val text: String,
|
||||
val onClick: () -> Unit,
|
||||
val isChecked: Boolean,
|
||||
val testTag: String? = null,
|
||||
)
|
||||
|
|
|
@ -125,11 +125,13 @@ fun AddSendContent(
|
|||
text = stringResource(id = R.string.file),
|
||||
onClick = addSendHandlers.onFileTypeSelect,
|
||||
isChecked = state.isFileType,
|
||||
testTag = "SendFileButton",
|
||||
),
|
||||
SegmentedButtonState(
|
||||
text = stringResource(id = R.string.text),
|
||||
onClick = addSendHandlers.onTextTypeSelect,
|
||||
isChecked = state.isTextType,
|
||||
testTag = "SendTextButton",
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
|
@ -19,8 +19,6 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
|
|||
import androidx.compose.ui.platform.LocalContext
|
||||
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.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.x8bit.bitwarden.R
|
||||
|
@ -46,7 +44,6 @@ import com.x8bit.bitwarden.ui.platform.theme.LocalIntentManager
|
|||
import com.x8bit.bitwarden.ui.platform.theme.LocalPermissionsManager
|
||||
import com.x8bit.bitwarden.ui.platform.util.persistentListOfNotNull
|
||||
import com.x8bit.bitwarden.ui.tools.feature.send.addsend.handlers.AddSendHandlers
|
||||
import com.x8bit.bitwarden.ui.tools.feature.send.addsend.util.testTag
|
||||
|
||||
/**
|
||||
* Displays new send UX.
|
||||
|
@ -147,8 +144,6 @@ fun AddSendScreen(
|
|||
onClick = remember(viewModel) {
|
||||
{ viewModel.trySendAction(AddSendAction.SaveClick) }
|
||||
},
|
||||
modifier = Modifier
|
||||
.semantics { testTag = state.viewState.testTag },
|
||||
)
|
||||
if (!state.isAddMode) {
|
||||
BitwardenOverflowActionItem(
|
||||
|
|
|
@ -57,15 +57,3 @@ private fun AddSendState.ViewState.Content.toSendTextView(): SendTextView? =
|
|||
hidden = it.isHideByDefaultChecked,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension function to get the semantic test tag based on the AddSendState.ViewState.
|
||||
*/
|
||||
val AddSendState.ViewState.testTag: String
|
||||
get() = when (this) {
|
||||
is AddSendState.ViewState.Content -> {
|
||||
if (isFileType) "SendFileButton" else "SendTextButton"
|
||||
}
|
||||
is AddSendState.ViewState.Error -> ""
|
||||
AddSendState.ViewState.Loading -> ""
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue