-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37c51c7
commit 92cf778
Showing
8 changed files
with
156 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeviceNameInfoDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package net.mullvad.mullvadvpn.compose.dialog | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.res.stringResource | ||
import net.mullvad.mullvadvpn.R | ||
|
||
@Composable | ||
fun DeviceNameInfoDialog(onDismiss: () -> Unit) { | ||
InfoDialog( | ||
message = stringResource(id = R.string.local_network_sharing_info), | ||
additionalInfo = | ||
buildString { | ||
appendLine(stringResource(id = R.string.device_name_info_part1)) | ||
appendLine(stringResource(id = R.string.device_name_info_part2)) | ||
appendLine(stringResource(id = R.string.device_name_info_part3)) | ||
}, | ||
onDismiss = onDismiss | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/AccountViewModelState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package net.mullvad.mullvadvpn.viewmodel | ||
|
||
import net.mullvad.mullvadvpn.compose.state.AccountUiState | ||
import net.mullvad.mullvadvpn.model.AccountExpiry | ||
import net.mullvad.mullvadvpn.model.DeviceState | ||
|
||
data class AccountViewModelState( | ||
val deviceState: DeviceState, | ||
val accountExpiry: AccountExpiry, | ||
val dialogState: AccountScreenDialogState | ||
) { | ||
fun toUiState(): AccountUiState { | ||
return when (dialogState) { | ||
is AccountScreenDialogState.NoDialog -> | ||
AccountUiState.DefaultUiState( | ||
deviceName = deviceState.deviceName() ?: "", | ||
accountNumber = deviceState.token() ?: "", | ||
accountExpiry = accountExpiry.date() | ||
) | ||
is AccountScreenDialogState.DeviceNameInfoDialog -> | ||
AccountUiState.DeviceNameDialogUiState( | ||
deviceName = deviceState.deviceName() ?: "", | ||
accountNumber = deviceState.token() ?: "", | ||
accountExpiry = accountExpiry.date() | ||
) | ||
} | ||
} | ||
|
||
companion object { | ||
fun default() = | ||
AccountViewModelState( | ||
deviceState = DeviceState.Unknown, | ||
accountExpiry = AccountExpiry.Missing, | ||
dialogState = AccountScreenDialogState.NoDialog | ||
) | ||
} | ||
} | ||
|
||
sealed class AccountScreenDialogState { | ||
data object NoDialog : AccountScreenDialogState() | ||
|
||
data object DeviceNameInfoDialog : AccountScreenDialogState() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters