mirror of
https://github.com/lone-cloud/prism-android
synced 2026-06-03 19:54:44 -07:00
Show migrations menus and dialog only if there are other distributors
This commit is contained in:
parent
1b5ed3838c
commit
87bb550628
2 changed files with 38 additions and 26 deletions
|
|
@ -55,6 +55,7 @@ fun AppBarUi(appBarViewModel: AppBarViewModel) {
|
|||
Dropdown(
|
||||
state.menuExpanded,
|
||||
state.showToasts,
|
||||
state.showMigrations,
|
||||
onRestart = {
|
||||
appBarViewModel.publishAction(AppAction(AppAction.Action.RestartService))
|
||||
appBarViewModel.toggleMenu()
|
||||
|
|
@ -85,13 +86,16 @@ fun AppBarUi(appBarViewModel: AppBarViewModel) {
|
|||
onConfirmation = { appBarViewModel.newPushServer(it) }
|
||||
)
|
||||
}
|
||||
DistribMigrationUi(appBarViewModel.migrationViewModel)
|
||||
if (state.showMigrations) {
|
||||
DistribMigrationUi(appBarViewModel.migrationViewModel)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Dropdown(
|
||||
expanded: Boolean,
|
||||
showToasts: Boolean,
|
||||
showMigrations: Boolean,
|
||||
onRestart: () -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
onChangeServer: () -> Unit,
|
||||
|
|
@ -133,28 +137,30 @@ fun Dropdown(
|
|||
}
|
||||
}
|
||||
)
|
||||
DropdownMenuItem(
|
||||
onClick = {
|
||||
onSetFallbackService()
|
||||
onDismiss()
|
||||
},
|
||||
text = {
|
||||
Text(
|
||||
stringResource(LibR.string.dialog_fallback_title)
|
||||
)
|
||||
}
|
||||
)
|
||||
DropdownMenuItem(
|
||||
onClick = {
|
||||
onMigrateToDistrib()
|
||||
onDismiss()
|
||||
},
|
||||
text = {
|
||||
Text(
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
text = stringResource(LibR.string.dialog_migration_title)
|
||||
)
|
||||
}
|
||||
)
|
||||
if (showMigrations) {
|
||||
DropdownMenuItem(
|
||||
onClick = {
|
||||
onSetFallbackService()
|
||||
onDismiss()
|
||||
},
|
||||
text = {
|
||||
Text(
|
||||
stringResource(LibR.string.dialog_fallback_title)
|
||||
)
|
||||
}
|
||||
)
|
||||
DropdownMenuItem(
|
||||
onClick = {
|
||||
onMigrateToDistrib()
|
||||
onDismiss()
|
||||
},
|
||||
text = {
|
||||
Text(
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
text = stringResource(LibR.string.dialog_migration_title)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,19 +2,25 @@ package org.unifiedpush.distributor.sunup.activities.ui
|
|||
|
||||
import android.content.Context
|
||||
import org.unifiedpush.distributor.sunup.AppStore
|
||||
import org.unifiedpush.distributor.utils.listOtherDistributors
|
||||
|
||||
data class AppBarUiState(
|
||||
val currentApiUrl: String,
|
||||
val showToasts: Boolean,
|
||||
val menuExpanded: Boolean = false,
|
||||
val showChangeServerDialog: Boolean = false
|
||||
val showChangeServerDialog: Boolean = false,
|
||||
/**
|
||||
* Used for the fallback service dialog and migration dialog
|
||||
*/
|
||||
val showMigrations: Boolean = false
|
||||
) {
|
||||
companion object {
|
||||
fun from(context: Context): AppBarUiState {
|
||||
val store = AppStore(context)
|
||||
return AppBarUiState(
|
||||
store.apiUrl,
|
||||
store.showToasts
|
||||
store.showToasts,
|
||||
showMigrations = context.listOtherDistributors().any()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue