Skip to content

Commit 334fc12

Browse files
committed
Fixed some more things
1 parent c74dcaf commit 334fc12

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/component/MullvadModalBottomSheet.kt

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package net.mullvad.mullvadvpn.compose.component
22

33
import androidx.compose.foundation.layout.ColumnScope
4+
import androidx.compose.foundation.layout.Spacer
5+
import androidx.compose.foundation.layout.WindowInsets
6+
import androidx.compose.foundation.layout.height
47
import androidx.compose.material3.BottomSheetDefaults
58
import androidx.compose.material3.ExperimentalMaterial3Api
69
import androidx.compose.material3.HorizontalDivider
@@ -16,6 +19,7 @@ import kotlinx.coroutines.launch
1619
import net.mullvad.mullvadvpn.compose.cell.HeaderCell
1720
import net.mullvad.mullvadvpn.compose.cell.IconCell
1821
import net.mullvad.mullvadvpn.lib.theme.AppTheme
22+
import net.mullvad.mullvadvpn.lib.theme.Dimens
1923

2024
@Preview
2125
@Composable
@@ -54,6 +58,7 @@ fun MullvadModalBottomSheet(
5458
sheetState = sheetState,
5559
containerColor = backgroundColor,
5660
modifier = modifier,
61+
windowInsets = WindowInsets(0, 0, 0, 0), // No insets
5762
dragHandle = { BottomSheetDefaults.DragHandle(color = onBackgroundColor) }
5863
) {
5964
sheetContent(onBackgroundColor) {
@@ -65,5 +70,6 @@ fun MullvadModalBottomSheet(
6570
}
6671
}
6772
}
73+
Spacer(modifier = Modifier.height(Dimens.cellHeight))
6874
}
6975
}

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

+23-20
Original file line numberDiff line numberDiff line change
@@ -563,22 +563,27 @@ private fun BottomSheets(
563563
}
564564

565565
private fun SelectLocationUiState.Content.indexOfSelectedRelayItem(): Int {
566-
val rawIndex =
567-
countries.indexOfFirst { relayCountry ->
568-
relayCountry.location.location.country ==
569-
when (selectedItem) {
570-
is RelayItem.Country -> selectedItem.code
571-
is RelayItem.City -> selectedItem.location.countryCode
572-
is RelayItem.Relay -> selectedItem.location.countryCode
573-
is RelayItem.CustomList,
574-
null -> null
575-
}
576-
}
577-
return if (rawIndex >= 0) {
578-
// Extra items are: Custom list header, custom list description and locations header
579-
return rawIndex + customLists.size + EXTRA_ITEMS
566+
if (selectedItem is RelayItem.CustomList) {
567+
// Add the header for custom list
568+
return filteredCustomLists.indexOfFirst { it.id == selectedItem.id } +
569+
EXTRA_ITEM_CUSTOM_LIST
580570
} else {
581-
rawIndex
571+
val rawIndex =
572+
countries.indexOfFirst { relayCountry ->
573+
relayCountry.location.location.country ==
574+
when (selectedItem) {
575+
is RelayItem.Country -> selectedItem.code
576+
is RelayItem.City -> selectedItem.location.countryCode
577+
is RelayItem.Relay -> selectedItem.location.countryCode
578+
else -> null
579+
}
580+
}
581+
return if (rawIndex >= 0) {
582+
// Extra items are: Custom list header, custom list description and locations header
583+
return rawIndex + customLists.size + EXTRA_ITEMS_LOCATION
584+
} else {
585+
rawIndex
586+
}
582587
}
583588
}
584589

@@ -687,10 +692,7 @@ private fun EditCustomListBottomSheet(
687692
closeBottomSheet: () -> Unit
688693
) {
689694
MullvadModalBottomSheet(closeBottomSheet = closeBottomSheet) { onBackgroundColor, onClose ->
690-
HeaderCell(
691-
text = stringResource(id = R.string.edit_custom_lists),
692-
background = Color.Unspecified
693-
)
695+
HeaderCell(text = customList.name, background = Color.Unspecified)
694696
IconCell(
695697
iconId = R.drawable.icon_edit,
696698
title = stringResource(id = R.string.edit_name),
@@ -761,7 +763,8 @@ private fun CustomListResult.message(context: Context): String =
761763
context.getString(R.string.locations_were_changed_for, name)
762764
}
763765

764-
private const val EXTRA_ITEMS = 3
766+
private const val EXTRA_ITEMS_LOCATION = 3
767+
private const val EXTRA_ITEM_CUSTOM_LIST = 1
765768

766769
sealed interface BottomSheetState {
767770
data object Hidden : BottomSheetState

0 commit comments

Comments
 (0)