mirror of
https://github.com/lone-cloud/prism-android
synced 2026-06-04 04:04: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(
|
Dropdown(
|
||||||
state.menuExpanded,
|
state.menuExpanded,
|
||||||
state.showToasts,
|
state.showToasts,
|
||||||
|
state.showMigrations,
|
||||||
onRestart = {
|
onRestart = {
|
||||||
appBarViewModel.publishAction(AppAction(AppAction.Action.RestartService))
|
appBarViewModel.publishAction(AppAction(AppAction.Action.RestartService))
|
||||||
appBarViewModel.toggleMenu()
|
appBarViewModel.toggleMenu()
|
||||||
|
|
@ -85,13 +86,16 @@ fun AppBarUi(appBarViewModel: AppBarViewModel) {
|
||||||
onConfirmation = { appBarViewModel.newPushServer(it) }
|
onConfirmation = { appBarViewModel.newPushServer(it) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
DistribMigrationUi(appBarViewModel.migrationViewModel)
|
if (state.showMigrations) {
|
||||||
|
DistribMigrationUi(appBarViewModel.migrationViewModel)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Dropdown(
|
fun Dropdown(
|
||||||
expanded: Boolean,
|
expanded: Boolean,
|
||||||
showToasts: Boolean,
|
showToasts: Boolean,
|
||||||
|
showMigrations: Boolean,
|
||||||
onRestart: () -> Unit,
|
onRestart: () -> Unit,
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
onChangeServer: () -> Unit,
|
onChangeServer: () -> Unit,
|
||||||
|
|
@ -133,28 +137,30 @@ fun Dropdown(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
DropdownMenuItem(
|
if (showMigrations) {
|
||||||
onClick = {
|
DropdownMenuItem(
|
||||||
onSetFallbackService()
|
onClick = {
|
||||||
onDismiss()
|
onSetFallbackService()
|
||||||
},
|
onDismiss()
|
||||||
text = {
|
},
|
||||||
Text(
|
text = {
|
||||||
stringResource(LibR.string.dialog_fallback_title)
|
Text(
|
||||||
)
|
stringResource(LibR.string.dialog_fallback_title)
|
||||||
}
|
)
|
||||||
)
|
}
|
||||||
DropdownMenuItem(
|
)
|
||||||
onClick = {
|
DropdownMenuItem(
|
||||||
onMigrateToDistrib()
|
onClick = {
|
||||||
onDismiss()
|
onMigrateToDistrib()
|
||||||
},
|
onDismiss()
|
||||||
text = {
|
},
|
||||||
Text(
|
text = {
|
||||||
color = MaterialTheme.colorScheme.error,
|
Text(
|
||||||
text = stringResource(LibR.string.dialog_migration_title)
|
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 android.content.Context
|
||||||
import org.unifiedpush.distributor.sunup.AppStore
|
import org.unifiedpush.distributor.sunup.AppStore
|
||||||
|
import org.unifiedpush.distributor.utils.listOtherDistributors
|
||||||
|
|
||||||
data class AppBarUiState(
|
data class AppBarUiState(
|
||||||
val currentApiUrl: String,
|
val currentApiUrl: String,
|
||||||
val showToasts: Boolean,
|
val showToasts: Boolean,
|
||||||
val menuExpanded: Boolean = false,
|
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 {
|
companion object {
|
||||||
fun from(context: Context): AppBarUiState {
|
fun from(context: Context): AppBarUiState {
|
||||||
val store = AppStore(context)
|
val store = AppStore(context)
|
||||||
return AppBarUiState(
|
return AppBarUiState(
|
||||||
store.apiUrl,
|
store.apiUrl,
|
||||||
store.showToasts
|
store.showToasts,
|
||||||
|
showMigrations = context.listOtherDistributors().any()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue