Skip to content

Commit

Permalink
Fix remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Nov 21, 2023
1 parent e982a43 commit b7dd1b8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun MtuDialog(mtuInitial: Int?, navigator: DestinationsNavigator) {
}
MtuDialog(
mtuInitial = mtuInitial,
onSaveMtu = { mtu -> viewModel.onSaveClick(mtu) },
onSaveMtu = viewModel::onSaveClick,
onResetMtu = viewModel::onRestoreClick,
onDismiss = navigator::navigateUp
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ fun RedeemVoucher(resultBackNavigator: ResultBackNavigator<Boolean>) {
val vm = koinViewModel<VoucherDialogViewModel>()
RedeemVoucherDialog(
uiState = vm.uiState.collectAsState().value,
onVoucherInputChange = { vm.onVoucherInputChange(it) },
onRedeem = { vm.onRedeem(it) },
onVoucherInputChange = vm::onVoucherInputChange,
onRedeem = vm::onRedeem,
onDismiss = { resultBackNavigator.navigateBack(result = it) }
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ import org.koin.androidx.compose.koinViewModel
private fun PreviewOutOfTimeScreenDisconnected() {
AppTheme {
OutOfTimeScreen(
showSitePayment = true,
uiState = OutOfTimeUiState(tunnelState = TunnelState.Disconnected, "Heroic Frog"),
uiState =
OutOfTimeUiState(
tunnelState = TunnelState.Disconnected,
"Heroic Frog",
showSitePayment = true
),
)
}
}
Expand All @@ -72,9 +76,12 @@ private fun PreviewOutOfTimeScreenDisconnected() {
private fun PreviewOutOfTimeScreenConnecting() {
AppTheme {
OutOfTimeScreen(
showSitePayment = true,
uiState =
OutOfTimeUiState(tunnelState = TunnelState.Connecting(null, null), "Strong Rabbit"),
OutOfTimeUiState(
tunnelState = TunnelState.Connecting(null, null),
"Strong Rabbit",
showSitePayment = true
),
)
}
}
Expand All @@ -84,14 +91,14 @@ private fun PreviewOutOfTimeScreenConnecting() {
private fun PreviewOutOfTimeScreenError() {
AppTheme {
OutOfTimeScreen(
showSitePayment = true,
uiState =
OutOfTimeUiState(
tunnelState =
TunnelState.Error(
ErrorState(cause = ErrorStateCause.IsOffline, isBlocking = true)
),
deviceName = "Stable Horse"
deviceName = "Stable Horse",
showSitePayment = true
),
)
}
Expand Down Expand Up @@ -142,7 +149,6 @@ fun OutOfTime(
}

OutOfTimeScreen(
showSitePayment = IS_PLAY_BUILD.not(),
uiState = state,
onSitePaymentClick = vm::onSitePaymentClick,
onRedeemVoucherClick = {
Expand All @@ -162,7 +168,6 @@ fun OutOfTime(

@Composable
fun OutOfTimeScreen(
showSitePayment: Boolean,
uiState: OutOfTimeUiState,
onDisconnectClick: () -> Unit = {},
onSitePaymentClick: () -> Unit = {},
Expand Down Expand Up @@ -222,7 +227,7 @@ fun OutOfTimeScreen(
text =
buildString {
append(stringResource(R.string.account_credit_has_expired))
if (showSitePayment) {
if (uiState.showSitePayment) {
append(" ")
append(stringResource(R.string.add_time_to_account))
}
Expand Down Expand Up @@ -266,7 +271,7 @@ fun OutOfTimeScreen(
.align(Alignment.CenterHorizontally)
)
}
if (showSitePayment) {
if (uiState.showSitePayment) {
SitePaymentButton(
onClick = onSitePaymentClick,
isEnabled = uiState.tunnelState.enableSitePaymentButton(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import net.mullvad.mullvadvpn.model.TunnelState
data class OutOfTimeUiState(
val tunnelState: TunnelState = TunnelState.Disconnected,
val deviceName: String = "",
val showSitePayment: Boolean = true,
val billingPaymentState: PaymentState? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import net.mullvad.mullvadvpn.compose.state.OutOfTimeUiState
import net.mullvad.mullvadvpn.constant.ACCOUNT_EXPIRY_POLL_INTERVAL
import net.mullvad.mullvadvpn.constant.IS_PLAY_BUILD
import net.mullvad.mullvadvpn.model.TunnelState
import net.mullvad.mullvadvpn.repository.AccountRepository
import net.mullvad.mullvadvpn.repository.DeviceRepository
Expand Down Expand Up @@ -58,6 +59,7 @@ class OutOfTimeViewModel(
OutOfTimeUiState(
tunnelState = tunnelState,
deviceName = deviceState.deviceName() ?: "",
showSitePayment = IS_PLAY_BUILD.not(),
billingPaymentState = paymentAvailability?.toPaymentState(),
)
}
Expand Down

0 comments on commit b7dd1b8

Please sign in to comment.