Add a shortcut to navigate to the notification settings in case of error.
This commit is contained in:
parent
2533dff00c
commit
2e8b63c006
6 changed files with 37 additions and 3 deletions
|
|
@ -238,7 +238,12 @@ class LoggedInFlowNode @AssistedInject constructor(
|
||||||
return when (navTarget) {
|
return when (navTarget) {
|
||||||
NavTarget.Placeholder -> createNode<PlaceholderNode>(buildContext)
|
NavTarget.Placeholder -> createNode<PlaceholderNode>(buildContext)
|
||||||
NavTarget.LoggedInPermanent -> {
|
NavTarget.LoggedInPermanent -> {
|
||||||
createNode<LoggedInNode>(buildContext)
|
val callback = object : LoggedInNode.Callback {
|
||||||
|
override fun navigateToNotificationTroubleshoot() {
|
||||||
|
backstack.push(NavTarget.Settings(PreferencesEntryPoint.InitialTarget.NotificationTroubleshoot))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
createNode<LoggedInNode>(buildContext, listOf(callback))
|
||||||
}
|
}
|
||||||
NavTarget.RoomList -> {
|
NavTarget.RoomList -> {
|
||||||
val callback = object : RoomListEntryPoint.Callback {
|
val callback = object : RoomListEntryPoint.Callback {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import androidx.compose.ui.Modifier
|
||||||
import com.bumble.appyx.core.modality.BuildContext
|
import com.bumble.appyx.core.modality.BuildContext
|
||||||
import com.bumble.appyx.core.node.Node
|
import com.bumble.appyx.core.node.Node
|
||||||
import com.bumble.appyx.core.plugin.Plugin
|
import com.bumble.appyx.core.plugin.Plugin
|
||||||
|
import com.bumble.appyx.core.plugin.plugins
|
||||||
import dagger.assisted.Assisted
|
import dagger.assisted.Assisted
|
||||||
import dagger.assisted.AssistedInject
|
import dagger.assisted.AssistedInject
|
||||||
import io.element.android.anvilannotations.ContributesNode
|
import io.element.android.anvilannotations.ContributesNode
|
||||||
|
|
@ -35,11 +36,22 @@ class LoggedInNode @AssistedInject constructor(
|
||||||
buildContext = buildContext,
|
buildContext = buildContext,
|
||||||
plugins = plugins
|
plugins = plugins
|
||||||
) {
|
) {
|
||||||
|
interface Callback : Plugin {
|
||||||
|
fun navigateToNotificationTroubleshoot()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun navigateToNotificationTroubleshoot() {
|
||||||
|
plugins<Callback>().forEach {
|
||||||
|
it.navigateToNotificationTroubleshoot()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun View(modifier: Modifier) {
|
override fun View(modifier: Modifier) {
|
||||||
val loggedInState = loggedInPresenter.present()
|
val loggedInState = loggedInPresenter.present()
|
||||||
LoggedInView(
|
LoggedInView(
|
||||||
state = loggedInState,
|
state = loggedInState,
|
||||||
|
navigateToNotificationTroubleshoot = ::navigateToNotificationTroubleshoot,
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import io.element.android.libraries.ui.strings.CommonStrings
|
||||||
@Composable
|
@Composable
|
||||||
fun LoggedInView(
|
fun LoggedInView(
|
||||||
state: LoggedInState,
|
state: LoggedInState,
|
||||||
|
navigateToNotificationTroubleshoot: () -> Unit,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
|
|
@ -57,7 +58,14 @@ fun LoggedInView(
|
||||||
?.let { reason ->
|
?.let { reason ->
|
||||||
ErrorDialogWithDoNotShowAgain(
|
ErrorDialogWithDoNotShowAgain(
|
||||||
content = stringResource(id = CommonStrings.common_error_registering_pusher_android, reason),
|
content = stringResource(id = CommonStrings.common_error_registering_pusher_android, reason),
|
||||||
onDismiss = { state.eventSink(LoggedInEvents.CloseErrorDialog(it)) },
|
cancelText = stringResource(id = CommonStrings.common_settings),
|
||||||
|
onDismiss = {
|
||||||
|
state.eventSink(LoggedInEvents.CloseErrorDialog(it))
|
||||||
|
},
|
||||||
|
onCancel = {
|
||||||
|
state.eventSink(LoggedInEvents.CloseErrorDialog(false))
|
||||||
|
navigateToNotificationTroubleshoot()
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -85,6 +93,7 @@ private fun Throwable.getReason(): String? {
|
||||||
@Composable
|
@Composable
|
||||||
internal fun LoggedInViewPreview(@PreviewParameter(LoggedInStateProvider::class) state: LoggedInState) = ElementPreview {
|
internal fun LoggedInViewPreview(@PreviewParameter(LoggedInStateProvider::class) state: LoggedInState) = ElementPreview {
|
||||||
LoggedInView(
|
LoggedInView(
|
||||||
state = state
|
state = state,
|
||||||
|
navigateToNotificationTroubleshoot = {},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,9 @@ interface PreferencesEntryPoint : FeatureEntryPoint {
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
data object NotificationSettings : InitialTarget
|
data object NotificationSettings : InitialTarget
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
data object NotificationTroubleshoot : InitialTarget
|
||||||
}
|
}
|
||||||
|
|
||||||
data class Params(val initialElement: InitialTarget) : NodeInputs
|
data class Params(val initialElement: InitialTarget) : NodeInputs
|
||||||
|
|
|
||||||
|
|
@ -51,4 +51,5 @@ class DefaultPreferencesEntryPoint @Inject constructor() : PreferencesEntryPoint
|
||||||
internal fun PreferencesEntryPoint.InitialTarget.toNavTarget() = when (this) {
|
internal fun PreferencesEntryPoint.InitialTarget.toNavTarget() = when (this) {
|
||||||
is PreferencesEntryPoint.InitialTarget.Root -> PreferencesFlowNode.NavTarget.Root
|
is PreferencesEntryPoint.InitialTarget.Root -> PreferencesFlowNode.NavTarget.Root
|
||||||
is PreferencesEntryPoint.InitialTarget.NotificationSettings -> PreferencesFlowNode.NavTarget.NotificationSettings
|
is PreferencesEntryPoint.InitialTarget.NotificationSettings -> PreferencesFlowNode.NavTarget.NotificationSettings
|
||||||
|
PreferencesEntryPoint.InitialTarget.NotificationTroubleshoot -> PreferencesFlowNode.NavTarget.TroubleshootNotifications
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,8 @@ fun ErrorDialogWithDoNotShowAgain(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
title: String = ErrorDialogDefaults.title,
|
title: String = ErrorDialogDefaults.title,
|
||||||
submitText: String = ErrorDialogDefaults.submitText,
|
submitText: String = ErrorDialogDefaults.submitText,
|
||||||
|
cancelText: String? = null,
|
||||||
|
onCancel: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
var doNotShowAgain by remember { mutableStateOf(false) }
|
var doNotShowAgain by remember { mutableStateOf(false) }
|
||||||
BasicAlertDialog(
|
BasicAlertDialog(
|
||||||
|
|
@ -56,7 +58,9 @@ fun ErrorDialogWithDoNotShowAgain(
|
||||||
SimpleAlertDialogContent(
|
SimpleAlertDialogContent(
|
||||||
title = title,
|
title = title,
|
||||||
submitText = submitText,
|
submitText = submitText,
|
||||||
|
cancelText = cancelText,
|
||||||
onSubmitClick = { onDismiss(doNotShowAgain) },
|
onSubmitClick = { onDismiss(doNotShowAgain) },
|
||||||
|
onCancelClick = onCancel,
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
Text(
|
Text(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue