diff options
| author | David Göransson <david.goransson@mullvad.net> | 2024-07-25 14:33:50 +0200 |
|---|---|---|
| committer | David Göransson <david.goransson@mullvad.net> | 2024-07-25 14:40:25 +0200 |
| commit | 2e2ab93340ae05fda8446a3e74f41dd1276789be (patch) | |
| tree | d5d5003f6050b80ed2b9bf6cb28a05ae2ce850d9 /android/lib | |
| parent | 5c24fc35aa8369d2d49767dca73ce8ae391a11e0 (diff) | |
| download | mullvadvpn-2e2ab93340ae05fda8446a3e74f41dd1276789be.tar.xz mullvadvpn-2e2ab93340ae05fda8446a3e74f41dd1276789be.zip | |
Convert select location into flat LazyColumn
Diffstat (limited to 'android/lib')
5 files changed, 25 insertions, 42 deletions
diff --git a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/FromDomain.kt b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/FromDomain.kt index 014bafb85b..4359ddff93 100644 --- a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/FromDomain.kt +++ b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/FromDomain.kt @@ -106,12 +106,10 @@ internal fun GeoLocationId.fromDomain(): ManagementInterface.GeographicLocationC ManagementInterface.GeographicLocationConstraint.newBuilder() .apply { when (val id = this@fromDomain) { - is GeoLocationId.Country -> setCountry(id.countryCode) - is GeoLocationId.City -> setCountry(id.countryCode.countryCode).setCity(id.cityCode) + is GeoLocationId.Country -> setCountry(id.code) + is GeoLocationId.City -> setCountry(id.country.code).setCity(id.code) is GeoLocationId.Hostname -> - setCountry(id.country.countryCode) - .setCity(id.city.cityCode) - .setHostname(id.hostname) + setCountry(id.country.code).setCity(id.city.code).setHostname(id.code) } } .build() diff --git a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt index 13ebe74350..50599ad7f4 100644 --- a/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt +++ b/android/lib/daemon-grpc/src/main/kotlin/net/mullvad/mullvadvpn/lib/daemon/grpc/mapper/ToDomain.kt @@ -455,7 +455,6 @@ internal fun ManagementInterface.RelayListCountry.toDomain(): RelayItem.Location return RelayItem.Location.Country( countryCode, name, - false, citiesList .map { city -> city.toDomain(countryCode) } .filter { it.relays.isNotEmpty() } @@ -470,7 +469,6 @@ internal fun ManagementInterface.RelayListCity.toDomain( return RelayItem.Location.City( name = name, id = cityCode, - expanded = false, relays = relaysList .filter { it.endpointType == ManagementInterface.Relay.RelayType.WIREGUARD } diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/RelayItem.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/RelayItem.kt index a31a6f67df..17bc563a8d 100644 --- a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/RelayItem.kt +++ b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/RelayItem.kt @@ -2,28 +2,26 @@ package net.mullvad.mullvadvpn.lib.model import arrow.optics.optics +typealias DomainCustomList = CustomList + @optics sealed interface RelayItem { val id: RelayItemId val name: String + val active: Boolean val hasChildren: Boolean - val expanded: Boolean @optics data class CustomList( - override val id: CustomListId, - val customListName: CustomListName, + val customList: DomainCustomList, val locations: List<Location>, - override val expanded: Boolean, ) : RelayItem { - override val name: String = customListName.value + override val name: String = customList.name.value + override val id = customList.id - override val active - get() = locations.any { location -> location.active } - - override val hasChildren - get() = locations.isNotEmpty() + override val active = locations.any { it.active } + override val hasChildren: Boolean = locations.isNotEmpty() companion object } @@ -36,16 +34,11 @@ sealed interface RelayItem { data class Country( override val id: GeoLocationId.Country, override val name: String, - override val expanded: Boolean, val cities: List<City> ) : Location { val relays = cities.flatMap { city -> city.relays } - - override val active - get() = cities.any { city -> city.active } - - override val hasChildren - get() = cities.isNotEmpty() + override val active = cities.any { it.active } + override val hasChildren: Boolean = cities.isNotEmpty() companion object } @@ -54,15 +47,10 @@ sealed interface RelayItem { data class City( override val id: GeoLocationId.City, override val name: String, - override val expanded: Boolean, val relays: List<Relay> ) : Location { - - override val active - get() = relays.any { relay -> relay.active } - - override val hasChildren - get() = relays.isNotEmpty() + override val active = relays.any { it.active } + override val hasChildren: Boolean = relays.isNotEmpty() companion object } @@ -73,10 +61,8 @@ sealed interface RelayItem { val provider: Provider, override val active: Boolean, ) : Location { - override val name: String = id.hostname - - override val hasChildren = false - override val expanded = false + override val name: String = id.code + override val hasChildren: Boolean = false companion object } diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/RelayItemId.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/RelayItemId.kt index c560fab49c..85326d8d2a 100644 --- a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/RelayItemId.kt +++ b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/RelayItemId.kt @@ -21,28 +21,29 @@ value class CustomListId(val value: String) : RelayItemId, Parcelable { sealed interface GeoLocationId : RelayItemId, Parcelable { @optics @Parcelize - data class Country(val countryCode: String) : GeoLocationId { + data class Country(override val code: String) : GeoLocationId { companion object } @optics @Parcelize - data class City(val countryCode: Country, val cityCode: String) : GeoLocationId { + data class City(override val country: Country, override val code: String) : GeoLocationId { companion object } @optics @Parcelize - data class Hostname(val city: City, val hostname: String) : GeoLocationId { + data class Hostname(val city: City, override val code: String) : GeoLocationId { companion object } + val code: String val country: Country get() = when (this) { is Country -> this - is City -> this.countryCode - is Hostname -> this.city.countryCode + is City -> this.country + is Hostname -> this.city.country } companion object diff --git a/android/lib/theme/src/main/kotlin/net/mullvad/mullvadvpn/lib/theme/dimensions/Dimensions.kt b/android/lib/theme/src/main/kotlin/net/mullvad/mullvadvpn/lib/theme/dimensions/Dimensions.kt index d4e5e4803d..922e97073b 100644 --- a/android/lib/theme/src/main/kotlin/net/mullvad/mullvadvpn/lib/theme/dimensions/Dimensions.kt +++ b/android/lib/theme/src/main/kotlin/net/mullvad/mullvadvpn/lib/theme/dimensions/Dimensions.kt @@ -18,7 +18,7 @@ data class Dimensions( val cellHeight: Dp = 56.dp, val cellHeightTwoRows: Dp = 72.dp, val cellLabelVerticalPadding: Dp = 14.dp, - val cellStartPadding: Dp = 22.dp, + val cellStartPadding: Dp = 14.dp, val cellStartPaddingInteractive: Dp = 14.dp, val cellTopPadding: Dp = 6.dp, val cellVerticalSpacing: Dp = 14.dp, @@ -41,7 +41,7 @@ data class Dimensions( val dropdownMenuVerticalPadding: Dp = 8.dp, // Used to remove padding from dropdown menu val dropdownMenuBorder: Dp = 1.dp, val expandableCellChevronSize: Dp = 30.dp, - val filterTittlePadding: Dp = 4.dp, + val filterTitlePadding: Dp = 4.dp, val formTextFieldMinHeight: Dp = 72.dp, val iconFailSuccessTopMargin: Dp = 30.dp, val iconHeight: Dp = 44.dp, |
