Skip to content

Commit

Permalink
Migrate info dialogs to destinations
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Nov 10, 2023
1 parent 99a3672 commit 9d72e87
Show file tree
Hide file tree
Showing 23 changed files with 243 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import net.mullvad.mullvadvpn.model.QuantumResistantState
import net.mullvad.mullvadvpn.onNodeWithTagAndText
import net.mullvad.mullvadvpn.viewmodel.CustomDnsItem
import net.mullvad.mullvadvpn.viewmodel.StagedDns
import net.mullvad.mullvadvpn.viewmodel.VpnSettingsSideEffect
import org.junit.Before
import org.junit.Rule
import org.junit.Test
Expand All @@ -51,7 +52,7 @@ class VpnSettingsScreenTest {
composeTestRule.setContentWithTheme {
VpnSettingsScreen(
uiState = VpnSettingsUiState.createDefault(),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -74,7 +75,7 @@ class VpnSettingsScreenTest {
composeTestRule.setContentWithTheme {
VpnSettingsScreen(
uiState = VpnSettingsUiState.createDefault(mtu = VALID_DUMMY_MTU_VALUE),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -94,7 +95,7 @@ class VpnSettingsScreenTest {
VpnSettingsScreen(
uiState = VpnSettingsUiState.createDefault(),
onMtuCellClick = mockedClickHandler,
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -118,7 +119,7 @@ class VpnSettingsScreenTest {
VpnSettingsUiState.createDefault(
dialog = VpnSettingsDialog.Mtu(mtuEditValue = EMPTY_STRING),
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -135,7 +136,7 @@ class VpnSettingsScreenTest {
VpnSettingsUiState.createDefault(
dialog = VpnSettingsDialog.Mtu(mtuEditValue = VALID_DUMMY_MTU_VALUE)
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -152,7 +153,7 @@ class VpnSettingsScreenTest {
VpnSettingsUiState.createDefault(
dialog = VpnSettingsDialog.Mtu(mtuEditValue = EMPTY_STRING)
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -174,7 +175,7 @@ class VpnSettingsScreenTest {
dialog = VpnSettingsDialog.Mtu(mtuEditValue = VALID_DUMMY_MTU_VALUE)
),
onSaveMtuClick = mockedSubmitHandler,
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -194,7 +195,7 @@ class VpnSettingsScreenTest {
VpnSettingsUiState.createDefault(
dialog = VpnSettingsDialog.Mtu(mtuEditValue = INVALID_DUMMY_MTU_VALUE)
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -213,7 +214,7 @@ class VpnSettingsScreenTest {
dialog = VpnSettingsDialog.Mtu(mtuEditValue = EMPTY_STRING)
),
onRestoreMtuClick = mockedClickHandler,
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -235,7 +236,7 @@ class VpnSettingsScreenTest {
dialog = VpnSettingsDialog.Mtu(mtuEditValue = EMPTY_STRING)
),
onCancelMtuDialogClick = mockedClickHandler,
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -262,7 +263,7 @@ class VpnSettingsScreenTest {
CustomDnsItem(address = DUMMY_DNS_ADDRESS_3, false)
)
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -285,7 +286,7 @@ class VpnSettingsScreenTest {
isCustomDnsEnabled = false,
customDnsItems = listOf(CustomDnsItem(address = DUMMY_DNS_ADDRESS, false))
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}
composeTestRule
Expand All @@ -308,7 +309,7 @@ class VpnSettingsScreenTest {
customDnsItems =
listOf(CustomDnsItem(address = DUMMY_DNS_ADDRESS, isLocal = true))
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -328,7 +329,7 @@ class VpnSettingsScreenTest {
customDnsItems =
listOf(CustomDnsItem(address = DUMMY_DNS_ADDRESS, isLocal = false))
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -348,7 +349,7 @@ class VpnSettingsScreenTest {
customDnsItems =
listOf(CustomDnsItem(address = DUMMY_DNS_ADDRESS, isLocal = false))
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -368,7 +369,7 @@ class VpnSettingsScreenTest {
customDnsItems =
listOf(CustomDnsItem(address = DUMMY_DNS_ADDRESS, isLocal = true))
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -386,7 +387,7 @@ class VpnSettingsScreenTest {
VpnSettingsScreen(
uiState = VpnSettingsUiState.createDefault(isCustomDnsEnabled = true),
onDnsClick = mockedClickHandler,
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -412,7 +413,7 @@ class VpnSettingsScreenTest {
),
)
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -436,7 +437,7 @@ class VpnSettingsScreenTest {
)
)
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -461,7 +462,7 @@ class VpnSettingsScreenTest {
),
isAllowLanEnabled = false
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -486,7 +487,7 @@ class VpnSettingsScreenTest {
),
isAllowLanEnabled = true
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -511,7 +512,7 @@ class VpnSettingsScreenTest {
),
isAllowLanEnabled = true
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -536,7 +537,7 @@ class VpnSettingsScreenTest {
),
isAllowLanEnabled = false
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -560,7 +561,7 @@ class VpnSettingsScreenTest {
)
)
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -585,7 +586,7 @@ class VpnSettingsScreenTest {
)
),
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -600,7 +601,7 @@ class VpnSettingsScreenTest {
VpnSettingsScreen(
uiState =
VpnSettingsUiState.createDefault(quantumResistant = QuantumResistantState.On),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}
composeTestRule
Expand All @@ -625,7 +626,7 @@ class VpnSettingsScreenTest {
quantumResistant = QuantumResistantState.Auto,
),
onSelectQuantumResistanceSetting = mockSelectQuantumResistantSettingListener,
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}
composeTestRule
Expand All @@ -650,7 +651,7 @@ class VpnSettingsScreenTest {
VpnSettingsUiState.createDefault(
dialog = VpnSettingsDialog.QuantumResistanceInfo
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -667,7 +668,7 @@ class VpnSettingsScreenTest {
VpnSettingsUiState.createDefault(
selectedWireguardPort = Constraint.Only(Port(53))
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand Down Expand Up @@ -699,7 +700,7 @@ class VpnSettingsScreenTest {
selectedWireguardPort = Constraint.Only(Port(53))
),
onWireguardPortSelected = mockSelectWireguardPortSelectionListener,
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand Down Expand Up @@ -734,7 +735,7 @@ class VpnSettingsScreenTest {
availablePortRanges = listOf(PortRange(53, 53), PortRange(120, 121))
)
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -758,7 +759,7 @@ class VpnSettingsScreenTest {
availablePortRanges = listOf(PortRange(53, 53), PortRange(120, 121))
)
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -775,7 +776,7 @@ class VpnSettingsScreenTest {
VpnSettingsUiState.createDefault(
selectedWireguardPort = Constraint.Only(Port(4000))
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -796,7 +797,7 @@ class VpnSettingsScreenTest {
VpnSettingsScreen(
uiState = VpnSettingsUiState.createDefault(),
onShowCustomPortDialog = mockOnShowCustomPortDialog,
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -821,7 +822,7 @@ class VpnSettingsScreenTest {
selectedWireguardPort = Constraint.Only(Port(4000))
),
onShowCustomPortDialog = mockOnShowCustomPortDialog,
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand All @@ -848,7 +849,7 @@ class VpnSettingsScreenTest {
selectedWireguardPort = Constraint.Only(Port(4000))
),
onWireguardPortSelected = onWireguardPortSelected,
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand Down Expand Up @@ -879,7 +880,7 @@ class VpnSettingsScreenTest {
availablePortRanges = listOf(PortRange(53, 53), PortRange(120, 121))
)
),
toastMessagesSharedFlow = MutableSharedFlow<String>().asSharedFlow()
sideEffect = MutableSharedFlow<VpnSettingsSideEffect>().asSharedFlow()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ fun Changelog(navController: NavController) {
return
}

if (changeLog != null) {
ChangelogDialog(changeLog, onDismiss)
}
ChangelogDialog(changeLog, onDismiss)
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ package net.mullvad.mullvadvpn.compose.dialog

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import com.ramcosta.composedestinations.spec.DestinationStyle
import net.mullvad.mullvadvpn.R
import net.mullvad.mullvadvpn.compose.component.textResource

@Destination(
style = DestinationStyle.Dialog::class
)
@Composable
fun ContentBlockersInfoDialog(onDismiss: () -> Unit) {
fun ContentBlockersInfoDialog(navigator: DestinationsNavigator) {
InfoDialog(
message =
buildString {
Expand All @@ -20,6 +26,6 @@ fun ContentBlockersInfoDialog(onDismiss: () -> Unit) {
stringResource(id = R.string.settings_changes_effect_warning_content_blocker)
)
},
onDismiss = onDismiss
onDismiss = navigator::navigateUp
)
}
Loading

0 comments on commit 9d72e87

Please sign in to comment.