Skip to content

Refactor screens to use preview parameter provider #6810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

kl
Copy link
Contributor

@kl kl commented Sep 18, 2024


This change is Reviewable

@kl kl added the Android Issues related to Android label Sep 18, 2024
Copy link

linear bot commented Sep 18, 2024

Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 45 of 45 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @kl)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/FilterUiStatePreviewParameterProvider.kt line 9 at r1 (raw file):

import net.mullvad.mullvadvpn.lib.model.ProviderId

val PROVIDER = Provider(providerId = ProviderId("provider1"), ownership = Ownership.MullvadOwned)

Private?


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/SelectLocationsUiStatePreviewParameterProvider.kt line 17 at r1 (raw file):

import net.mullvad.mullvadvpn.lib.model.RelayItem

val RELAY =

Could this also be private?


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/VpnSettingsUiStatePreviewParameterProvider.kt line 39 at r1 (raw file):

                selectedWireguardPort = Constraint.Any,
                customWireguardPort = Port(PORT),
                availablePortRanges = listOf(PortRange(IntRange(PORT, PORT + PORT))),

PORT + PORT looks a bit weird to me. This also looks like a perfect reason to introduce the following function to our domain:

    operator fun rangeTo(other: Port): PortRange

Then we can create a PortRange from two ports, e.g:

val lowerPort = Port(10)
val upperPort = Port(20)
val portRange: PortRange = lowerPort..upperPort

android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ApiAccessListScreen.kt line 47 at r1 (raw file):

import org.koin.androidx.compose.koinViewModel

@Preview("Default|WithoutCustomApi|WithCustomApi")

Just wondering, these are the names for the previews with the order they were passed into the preview, correct? | is a magical divider for preview names?


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/EditCustomListUiState.kt line 7 at r1 (raw file):

import net.mullvad.mullvadvpn.lib.model.GeoLocationId

sealed interface EditCustomListUiState {

Nice fixing these! ⭐

Pururun
Pururun previously approved these changes Sep 18, 2024
Copy link
Contributor

@Pururun Pururun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @kl)

Copy link
Contributor Author

@kl kl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @Rawa)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/FilterUiStatePreviewParameterProvider.kt line 9 at r1 (raw file):

Previously, Rawa (David Göransson) wrote…

Private?

Done.


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/SelectLocationsUiStatePreviewParameterProvider.kt line 17 at r1 (raw file):

Previously, Rawa (David Göransson) wrote…

Could this also be private?

Done.


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/VpnSettingsUiStatePreviewParameterProvider.kt line 39 at r1 (raw file):

Previously, Rawa (David Göransson) wrote…

PORT + PORT looks a bit weird to me. This also looks like a perfect reason to introduce the following function to our domain:

    operator fun rangeTo(other: Port): PortRange

Then we can create a PortRange from two ports, e.g:

val lowerPort = Port(10)
val upperPort = Port(20)
val portRange: PortRange = lowerPort..upperPort

Done.


android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/ApiAccessListScreen.kt line 47 at r1 (raw file):

Previously, Rawa (David Göransson) wrote…

Just wondering, these are the names for the previews with the order they were passed into the preview, correct? | is a magical divider for preview names?

| does not have any special meaning. There's no way to specify a preview name for an individual preview when using preview parameters so I put the all the names separated by | on the on the preview composable.

Rawa
Rawa previously approved these changes Sep 18, 2024
Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 4 of 4 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved


android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/lib/model/Port.kt line 15 at r2 (raw file):

    override fun toString(): String = value.toString()

    operator fun rangeTo(other: Port): PortRange = PortRange(value..other.value)

🌟

@kl kl force-pushed the refactor-preview-parameters-droid-1012 branch 2 times, most recently from 4ea30b3 to 9dfe743 Compare September 18, 2024 13:12
@kl kl force-pushed the refactor-preview-parameters-droid-1012 branch from 9dfe743 to 7f99e9a Compare September 18, 2024 14:10
Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 3 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@Rawa Rawa merged commit 9657779 into main Sep 18, 2024
18 of 24 checks passed
@Rawa Rawa deleted the refactor-preview-parameters-droid-1012 branch September 18, 2024 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issues related to Android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants