Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fun LazyListScope.collectionItemsSelector(
if (isCollectionsTitleVisible) {
item {
BitwardenListHeaderText(
label = stringResource(id = BitwardenString.collections),
label = stringResource(id = BitwardenString.shared_folders),
modifier = Modifier
.fillMaxWidth()
.standardHorizontalMargin()
Expand Down Expand Up @@ -76,7 +76,7 @@ fun LazyListScope.collectionItemsSelector(
.standardHorizontalMargin(),
) {
Text(
text = stringResource(id = BitwardenString.no_collections_to_list),
text = stringResource(id = BitwardenString.there_are_no_shared_folders_to_list),
style = BitwardenTheme.typography.bodyMedium,
color = BitwardenTheme.colorScheme.text.primary,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ fun CoachMarkScope<AddEditItemCoachMark>.VaultAddEditContent(
val collections = state.common.selectedOwner?.collections.orEmpty()
item {
BitwardenTextSelectionButton(
label = stringResource(id = BitwardenString.owner),
selectedOption = state.common.selectedOwner?.name,
label = stringResource(id = BitwardenString.vault),
selectedOption = state.common.selectedOwner?.name?.invoke(),
onClick = commonTypeHandlers.onPresentOwnerOptions,
cardStyle = if (collections.isNotEmpty()) {
CardStyle.Middle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ fun VaultAddEditScreen(
)
.takeUnless { !state.shouldShowMoveToOrganization },
OverflowMenuItemData(
text = stringResource(id = BitwardenString.collections),
text = stringResource(id = BitwardenString.shared_folders),
onClick = {
viewModel.trySendAction(
VaultAddEditAction.Common.CollectionsClick,
Expand Down Expand Up @@ -805,48 +805,41 @@ private fun OwnerSelectionBottomSheet(
modifier: Modifier = Modifier,
) {

var selectedOptionState by rememberSaveable {
mutableStateOf(state.selectedOwner?.name.orEmpty())
var selectedOwner by rememberSaveable {
mutableStateOf(state.selectedOwner)
}
Comment on lines +808 to 810
BitwardenModalBottomSheet(
sheetTitle = stringResource(BitwardenString.owner),
sheetTitle = stringResource(BitwardenString.select_vault),
onDismiss = handlers.onDismissBottomSheet,
topBarActions = { animatedOnDismiss ->
BitwardenTextButton(
label = stringResource(BitwardenString.save),
onClick = {
handlers.onDismissBottomSheet()
state
.availableOwners
.firstOrNull {
it.name == selectedOptionState
}
?.run {
handlers.onOwnerSelected(this.id)
}
selectedOwner?.let { handlers.onOwnerSelected(it.id) }
animatedOnDismiss()
},
isEnabled = selectedOptionState.isNotBlank(),
isEnabled = selectedOwner != null,
)
},
sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true),
modifier = modifier.statusBarsPadding(),
) {
OwnerSelectionBottomSheetContent(
options = state.availableOwners.map { it.name }.toImmutableList(),
selectedOption = selectedOptionState,
options = state.availableOwners,
selectedOwner = selectedOwner,
onOptionSelected = {
selectedOptionState = it
selectedOwner = it
},
)
}
}

@Composable
private fun OwnerSelectionBottomSheetContent(
options: ImmutableList<String>,
selectedOption: String,
onOptionSelected: (String) -> Unit,
options: ImmutableList<VaultAddEditState.Owner>,
selectedOwner: VaultAddEditState.Owner?,
onOptionSelected: (VaultAddEditState.Owner) -> Unit,
modifier: Modifier = Modifier,
) {
LazyColumn(
Expand All @@ -870,15 +863,15 @@ private fun OwnerSelectionBottomSheetContent(
verticalAlignment = Alignment.CenterVertically,
) {
Text(
text = option,
text = option.name(),
color = BitwardenTheme.colorScheme.text.primary,
style = BitwardenTheme.typography.bodyLarge,
modifier = Modifier
.weight(weight = 1f)
.padding(horizontal = 16.dp),
)
BitwardenRadioButton(
isSelected = selectedOption == option,
isSelected = selectedOwner == option,
onClick = {
onOptionSelected(option)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ import com.x8bit.bitwarden.ui.vault.util.detectCardBrand
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
Expand Down Expand Up @@ -514,7 +515,7 @@ class VaultAddEditViewModel @Inject constructor(
content.common.selectedOwner?.collections?.all { !it.isSelected } == true
) {
showGenericErrorDialog(
message = BitwardenString.select_one_collection.asText(),
message = BitwardenString.you_must_select_at_least_one_shared_folder.asText(),
)
true
} else if (
Expand Down Expand Up @@ -2666,7 +2667,7 @@ class VaultAddEditViewModel @Inject constructor(
private fun List<VaultAddEditState.Owner>.toUpdatedOwners(
selectedOwnerId: String?,
selectedCollectionId: String,
): List<VaultAddEditState.Owner> =
): ImmutableList<VaultAddEditState.Owner> =
map { owner ->
if (owner.id != selectedOwnerId) return@map owner
owner.copy(
Expand All @@ -2675,6 +2676,7 @@ class VaultAddEditViewModel @Inject constructor(
.toUpdatedCollections(selectedCollectionId = selectedCollectionId),
)
}
.toImmutableList()

private fun List<VaultCollection>.toUpdatedCollections(
selectedCollectionId: String,
Expand Down Expand Up @@ -2926,7 +2928,7 @@ data class VaultAddEditState(
val selectedFolderId: String? = null,
val availableFolders: List<Folder> = emptyList(),
val selectedOwnerId: String? = null,
val availableOwners: List<Owner> = emptyList(),
val availableOwners: ImmutableList<Owner> = persistentListOf(),
val hasOrganizations: Boolean = false,
val canDelete: Boolean = true,
val canAssignToCollections: Boolean = true,
Expand Down Expand Up @@ -3312,7 +3314,7 @@ data class VaultAddEditState(
@Parcelize
data class Owner(
val id: String?,
val name: String,
val name: Text,
val collections: List<VaultCollection>,
) : Parcelable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package com.x8bit.bitwarden.ui.vault.feature.addedit.util
import com.bitwarden.collections.CollectionType
import com.bitwarden.collections.CollectionView
import com.bitwarden.core.data.util.toFormattedDateTimeStyle
import com.bitwarden.core.util.persistentListOfNotNull
import com.bitwarden.ui.platform.model.TotpData
import com.bitwarden.ui.platform.resource.BitwardenString
import com.bitwarden.ui.util.asText
Expand All @@ -31,6 +32,8 @@ import com.x8bit.bitwarden.ui.vault.model.findVaultCardBrandWithNameOrNull
import java.time.Clock
import java.time.format.FormatStyle
import java.util.UUID
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf

/**
* Transforms [CipherView] into [VaultAddEditState.ViewState].
Expand Down Expand Up @@ -154,7 +157,7 @@ fun CipherView.toViewState(
favorite = this.favorite,
masterPasswordReprompt = this.reprompt == CipherRepromptType.PASSWORD,
notes = this.notes.orEmpty(),
availableOwners = emptyList(),
availableOwners = persistentListOf(),
hasOrganizations = false,
customFieldData = this.fields.orEmpty().map { it.toCustomField() },
canDelete = canDelete,
Expand Down Expand Up @@ -294,19 +297,19 @@ private fun UserState.Account.toAvailableOwners(
cipherView: CipherView?,
isIndividualVaultDisabled: Boolean,
selectedCollectionId: String? = null,
): List<VaultAddEditState.Owner> =
listOfNotNull(
): ImmutableList<VaultAddEditState.Owner> =
persistentListOfNotNull(
VaultAddEditState
.Owner(
name = email,
name = BitwardenString.my_vault.asText(),
id = null,
collections = emptyList(),
)
.takeUnless { isIndividualVaultDisabled },
*organizations
.map {
VaultAddEditState.Owner(
name = it.name,
name = it.name.asText(),
id = it.id,
collections = collectionViewList
.filter { collection ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ fun VaultItemScreen(
!state.hasOrganizations
},
OverflowMenuItemData(
text = stringResource(id = BitwardenString.collections),
text = stringResource(id = BitwardenString.shared_folders),
onClick = {
viewModel.trySendAction(VaultItemAction.Common.CollectionsClick)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ sealed class VaultItemLocation : Parcelable {
override val name: String,
) : VaultItemLocation() {
override val icon: Int
get() = BitwardenDrawable.ic_collections
get() = BitwardenDrawable.ic_shared_folder
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fun VaultItemListingContent(
item(key = "collections_header") {
Spacer(modifier = Modifier.height(height = 12.dp))
BitwardenListHeaderText(
label = stringResource(id = BitwardenString.collections),
label = stringResource(id = BitwardenString.shared_folders),
supportingLabel = state.displayCollectionList.count().toString(),
modifier = Modifier
.animateItem()
Expand All @@ -150,7 +150,7 @@ fun VaultItemListingContent(
key = { _, collection -> "collection_${collection.id}" },
) { index, collection ->
BitwardenGroupItem(
startIcon = IconData.Local(iconRes = BitwardenDrawable.ic_collections),
startIcon = IconData.Local(iconRes = BitwardenDrawable.ic_shared_folder),
label = collection.name,
supportingLabel = collection.count.toString(),
onClick = { vaultItemListingHandlers.collectionClick(collection.id) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fun VaultData.toViewState(
}

is VaultItemListingState.ItemListingType.Vault.Collection -> {
BitwardenString.no_items_collection
BitwardenString.there_are_no_items_in_this_shared_folder
}

VaultItemListingState.ItemListingType.Vault.Trash -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class VaultMoveToOrganizationViewModel @Inject constructor(
mutableStateFlow.update {
it.copy(
dialogState = VaultMoveToOrganizationState.DialogState.Error(
message = BitwardenString.select_one_collection.asText(),
message = BitwardenString.you_must_select_at_least_one_shared_folder.asText(),
),
)
}
Expand Down Expand Up @@ -349,7 +349,7 @@ data class VaultMoveToOrganizationState(

val appBarText: Text
get() = if (onlyShowCollections) {
BitwardenString.collections.asText()
BitwardenString.shared_folders.asText()
} else {
BitwardenString.move_to_vault.asText()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ fun VaultContent(
if (state.collectionItems.isNotEmpty()) {
item(key = "collection_header") {
BitwardenListHeaderText(
label = stringResource(id = BitwardenString.collections),
label = stringResource(id = BitwardenString.shared_folders),
supportingLabel = state.collectionItems.count().toString(),
modifier = Modifier
.animateItem()
Expand All @@ -487,7 +487,7 @@ fun VaultContent(
key = { _, collection -> "collection_${collection.id}" },
) { index, collection ->
BitwardenGroupItem(
startIcon = IconData.Local(iconRes = BitwardenDrawable.ic_collections),
startIcon = IconData.Local(iconRes = BitwardenDrawable.ic_shared_folder),
label = collection.name,
supportingLabel = collection.itemCount.toString(),
onClick = { vaultHandlers.collectionClick(collection) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ enum class VaultTrailingIcon(
val testTag: String,
) {
COLLECTION(
iconRes = BitwardenDrawable.ic_collections,
contentDescription = BitwardenString.collections.asText(),
iconRes = BitwardenDrawable.ic_shared_folder,
contentDescription = BitwardenString.shared_folders.asText(),
testTag = "CipherInCollectionIcon",
),
ATTACHMENT(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ fun createMockDisplayItemForCipher(
),
extraIconList = persistentListOf(
IconData.Local(
iconRes = BitwardenDrawable.ic_collections,
contentDescription = BitwardenString.collections.asText(),
iconRes = BitwardenDrawable.ic_shared_folder,
contentDescription = BitwardenString.shared_folders.asText(),
testTag = "CipherInCollectionIcon",
),
IconData.Local(
Expand Down Expand Up @@ -88,8 +88,8 @@ fun createMockDisplayItemForCipher(
iconData = IconData.Local(BitwardenDrawable.ic_note),
extraIconList = persistentListOf(
IconData.Local(
iconRes = BitwardenDrawable.ic_collections,
contentDescription = BitwardenString.collections.asText(),
iconRes = BitwardenDrawable.ic_shared_folder,
contentDescription = BitwardenString.shared_folders.asText(),
testTag = "CipherInCollectionIcon",
),
IconData.Local(
Expand Down Expand Up @@ -132,8 +132,8 @@ fun createMockDisplayItemForCipher(
iconData = IconData.Local(BitwardenDrawable.ic_payment_card),
extraIconList = persistentListOf(
IconData.Local(
iconRes = BitwardenDrawable.ic_collections,
contentDescription = BitwardenString.collections.asText(),
iconRes = BitwardenDrawable.ic_shared_folder,
contentDescription = BitwardenString.shared_folders.asText(),
testTag = "CipherInCollectionIcon",
),
IconData.Local(
Expand Down Expand Up @@ -181,8 +181,8 @@ fun createMockDisplayItemForCipher(
iconData = IconData.Local(BitwardenDrawable.ic_id_card),
extraIconList = persistentListOf(
IconData.Local(
iconRes = BitwardenDrawable.ic_collections,
contentDescription = BitwardenString.collections.asText(),
iconRes = BitwardenDrawable.ic_shared_folder,
contentDescription = BitwardenString.shared_folders.asText(),
testTag = "CipherInCollectionIcon",
),
IconData.Local(
Expand Down Expand Up @@ -221,8 +221,8 @@ fun createMockDisplayItemForCipher(
iconData = IconData.Local(BitwardenDrawable.ic_ssh_key),
extraIconList = persistentListOf(
IconData.Local(
iconRes = BitwardenDrawable.ic_collections,
contentDescription = BitwardenString.collections.asText(),
iconRes = BitwardenDrawable.ic_shared_folder,
contentDescription = BitwardenString.shared_folders.asText(),
testTag = "CipherInCollectionIcon",
),
),
Expand Down Expand Up @@ -256,8 +256,8 @@ fun createMockDisplayItemForCipher(
iconData = IconData.Local(BitwardenDrawable.ic_payment_card),
extraIconList = persistentListOf(
IconData.Local(
iconRes = BitwardenDrawable.ic_collections,
contentDescription = BitwardenString.collections.asText(),
iconRes = BitwardenDrawable.ic_shared_folder,
contentDescription = BitwardenString.shared_folders.asText(),
testTag = "CipherInCollectionIcon",
),
),
Expand Down Expand Up @@ -291,8 +291,8 @@ fun createMockDisplayItemForCipher(
iconData = IconData.Local(BitwardenDrawable.ic_note),
extraIconList = persistentListOf(
IconData.Local(
iconRes = BitwardenDrawable.ic_collections,
contentDescription = BitwardenString.collections.asText(),
iconRes = BitwardenDrawable.ic_shared_folder,
contentDescription = BitwardenString.shared_folders.asText(),
testTag = "CipherInCollectionIcon",
),
),
Expand Down Expand Up @@ -326,8 +326,8 @@ fun createMockDisplayItemForCipher(
iconData = IconData.Local(BitwardenDrawable.ic_note),
extraIconList = persistentListOf(
IconData.Local(
iconRes = BitwardenDrawable.ic_collections,
contentDescription = BitwardenString.collections.asText(),
iconRes = BitwardenDrawable.ic_shared_folder,
contentDescription = BitwardenString.shared_folders.asText(),
testTag = "CipherInCollectionIcon",
),
),
Expand Down
Loading
Loading