Skip to content

Commit cbcfae6

Browse files
committed
Show the name of the custom list in remove location bottom sheet
1 parent fce09af commit cbcfae6

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SelectLocationScreen.kt

+10-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ import net.mullvad.mullvadvpn.compose.transitions.SelectLocationTransition
9292
import net.mullvad.mullvadvpn.compose.util.CollectSideEffectWithLifecycle
9393
import net.mullvad.mullvadvpn.compose.util.RunOnKeyChange
9494
import net.mullvad.mullvadvpn.compose.util.showSnackbarImmediately
95+
import net.mullvad.mullvadvpn.lib.model.CustomList
9596
import net.mullvad.mullvadvpn.lib.model.CustomListId
97+
import net.mullvad.mullvadvpn.lib.model.CustomListName
9698
import net.mullvad.mullvadvpn.lib.model.RelayItem
9799
import net.mullvad.mullvadvpn.lib.model.RelayItemId
98100
import net.mullvad.mullvadvpn.lib.theme.AppTheme
@@ -365,6 +367,7 @@ fun SelectLocationScreen(
365367
bottomSheetState =
366368
ShowCustomListsEntryBottomSheet(
367369
listItem.parentId,
370+
listItem.parentName,
368371
listItem.item
369372
)
370373
}
@@ -589,7 +592,8 @@ private fun BottomSheets(
589592
CustomListEntryBottomSheet(
590593
sheetState = sheetState,
591594
onBackgroundColor = onBackgroundColor,
592-
customListId = bottomSheetState.parentId,
595+
customListId = bottomSheetState.customListId,
596+
customListName = bottomSheetState.customListName,
593597
item = bottomSheetState.item,
594598
onRemoveLocationFromList = onRemoveLocationFromList,
595599
closeBottomSheet = onCloseBottomSheet
@@ -784,6 +788,7 @@ private fun CustomListEntryBottomSheet(
784788
onBackgroundColor: Color,
785789
sheetState: SheetState,
786790
customListId: CustomListId,
791+
customListName: CustomListName,
787792
item: RelayItem.Location,
788793
onRemoveLocationFromList: (location: RelayItem.Location, customListId: CustomListId) -> Unit,
789794
closeBottomSheet: (animate: Boolean) -> Unit
@@ -794,7 +799,8 @@ private fun CustomListEntryBottomSheet(
794799
modifier = Modifier.testTag(SELECT_LOCATION_LOCATION_BOTTOM_SHEET_TEST_TAG)
795800
) {
796801
HeaderCell(
797-
text = stringResource(id = R.string.remove_location_from_list, item.name),
802+
text =
803+
stringResource(id = R.string.remove_location_from_list, item.name, customListName),
798804
background = Color.Unspecified
799805
)
800806
HorizontalDivider(color = onBackgroundColor)
@@ -902,7 +908,8 @@ sealed interface BottomSheetState {
902908
data class ShowCustomListsBottomSheet(val editListEnabled: Boolean) : BottomSheetState
903909

904910
data class ShowCustomListsEntryBottomSheet(
905-
val parentId: CustomListId,
911+
val customListId: CustomListId,
912+
val customListName: CustomListName,
906913
val item: RelayItem.Location
907914
) : BottomSheetState
908915

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/SelectLocationUiState.kt

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.mullvad.mullvadvpn.compose.state
22

33
import net.mullvad.mullvadvpn.lib.model.CustomListId
4+
import net.mullvad.mullvadvpn.lib.model.CustomListName
45
import net.mullvad.mullvadvpn.lib.model.RelayItem
56

67
typealias ModelOwnership = net.mullvad.mullvadvpn.lib.model.Ownership
@@ -60,6 +61,7 @@ sealed interface RelayListItem {
6061

6162
data class CustomListEntryItem(
6263
val parentId: CustomListId,
64+
val parentName: CustomListName,
6365
val item: RelayItem.Location,
6466
override val expanded: Boolean,
6567
override val depth: Int = 0

android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SelectLocationViewModel.kt

+5-4
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class SelectLocationViewModel(
214214
if (expanded) {
215215
addAll(
216216
customList.locations.flatMap {
217-
createCustomListEntry(parent = customList.id, item = it, 1, isExpanded)
217+
createCustomListEntry(parent = customList, item = it, 1, isExpanded)
218218
}
219219
)
220220
}
@@ -240,15 +240,16 @@ class SelectLocationViewModel(
240240
}
241241

242242
private fun createCustomListEntry(
243-
parent: CustomListId,
243+
parent: RelayItem.CustomList,
244244
item: RelayItem.Location,
245245
depth: Int = 1,
246246
isExpanded: (String) -> Boolean,
247247
): List<RelayListItem.CustomListEntryItem> = buildList {
248-
val expanded = isExpanded(item.id.expandKey(parent))
248+
val expanded = isExpanded(item.id.expandKey(parent.id))
249249
add(
250250
RelayListItem.CustomListEntryItem(
251-
parentId = parent,
251+
parentId = parent.id,
252+
parentName = parent.customList.name,
252253
item = item,
253254
expanded = expanded,
254255
depth

android/lib/resource/src/main/res/values/strings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310
<string name="discard_changes">Discard changes?</string>
311311
<string name="discard">Discard</string>
312312
<string name="add_location_to_list">Add %s to list</string>
313-
<string name="remove_location_from_list">Remove %s from list</string>
313+
<string name="remove_location_from_list">Remove %s from %s</string>
314314
<string name="location_was_added_to_list">%s was added to \"%s\"</string>
315315
<string name="location_added">%s (added)</string>
316316
<string name="edit_name">Edit name</string>

0 commit comments

Comments
 (0)