mirror of
https://github.com/bitwarden/android.git
synced 2026-06-07 06:49:07 -05:00
Add a loading dialog to the Other Screen (#729)
This commit is contained in:
committed by
Álison Fernandes
parent
82d06f56b9
commit
8a20d0e57c
@@ -31,6 +31,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.ui.platform.base.util.EventsEffect
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenFilledTonalButton
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenLoadingDialog
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenScaffold
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenSelectionDialog
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenSelectionRow
|
||||
@@ -38,6 +39,7 @@ import com.x8bit.bitwarden.ui.platform.components.BitwardenTextRow
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenTopAppBar
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenTwoButtonDialog
|
||||
import com.x8bit.bitwarden.ui.platform.components.BitwardenWideSwitch
|
||||
import com.x8bit.bitwarden.ui.platform.components.LoadingDialogState
|
||||
|
||||
/**
|
||||
* Displays the other screen.
|
||||
@@ -56,6 +58,10 @@ fun OtherScreen(
|
||||
}
|
||||
}
|
||||
|
||||
OtherDialogs(
|
||||
dialogState = state.dialogState,
|
||||
)
|
||||
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
BitwardenScaffold(
|
||||
modifier = Modifier
|
||||
@@ -224,3 +230,16 @@ private fun ClearClipboardFrequencyRow(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun OtherDialogs(
|
||||
dialogState: OtherState.DialogState?,
|
||||
) {
|
||||
when (dialogState) {
|
||||
is OtherState.DialogState.Loading -> BitwardenLoadingDialog(
|
||||
visibilityState = LoadingDialogState.Shown(dialogState.message),
|
||||
)
|
||||
|
||||
null -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ class OtherViewModel @Inject constructor(
|
||||
allowSyncOnRefresh = settingsRepo.getPullToRefreshEnabledFlow().value,
|
||||
clearClipboardFrequency = OtherState.ClearClipboardFrequency.DEFAULT,
|
||||
lastSyncTime = "5/14/2023 4:52 PM",
|
||||
dialogState = null,
|
||||
),
|
||||
) {
|
||||
override fun handleAction(action: OtherAction): Unit = when (action) {
|
||||
@@ -80,6 +81,7 @@ data class OtherState(
|
||||
val allowSyncOnRefresh: Boolean,
|
||||
val clearClipboardFrequency: ClearClipboardFrequency,
|
||||
val lastSyncTime: String,
|
||||
val dialogState: DialogState?,
|
||||
) : Parcelable {
|
||||
/**
|
||||
* Represents the different frequencies with which the user clipboard can be cleared.
|
||||
@@ -93,6 +95,19 @@ data class OtherState(
|
||||
TWO_MINUTES(text = R.string.two_minutes.asText()),
|
||||
FIVE_MINUTES(text = R.string.five_minutes.asText()),
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the current state of any dialogs on the screen.
|
||||
*/
|
||||
sealed class DialogState : Parcelable {
|
||||
/**
|
||||
* Represents a loading dialog with the given [message].
|
||||
*/
|
||||
@Parcelize
|
||||
data class Loading(
|
||||
val message: Text,
|
||||
) : DialogState()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user