Rebase on develop and refactoring
This commit is contained in:
parent
538a229fc7
commit
69905afbd9
10 changed files with 37 additions and 26 deletions
|
|
@ -21,4 +21,5 @@ import io.element.android.features.analytics.api.AnalyticsOptInEvents
|
|||
data class AnalyticsPreferencesState(
|
||||
val applicationName: String,
|
||||
val isEnabled: Boolean,
|
||||
val eventSink: (AnalyticsOptInEvents) -> Unit,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import io.element.android.features.preferences.api.PreferencesEntryPoint
|
|||
import io.element.android.features.preferences.impl.about.AboutNode
|
||||
import io.element.android.features.preferences.impl.analytics.AnalyticsSettingsNode
|
||||
import io.element.android.features.preferences.impl.developer.DeveloperSettingsNode
|
||||
import io.element.android.features.preferences.impl.notifications.NotificationsSettingsNode
|
||||
import io.element.android.features.preferences.impl.notifications.NotificationSettingsNode
|
||||
import io.element.android.features.preferences.impl.root.PreferencesRootNode
|
||||
import io.element.android.libraries.architecture.BackstackNode
|
||||
import io.element.android.libraries.architecture.animation.rememberDefaultTransitionHandler
|
||||
|
|
@ -68,7 +68,7 @@ class PreferencesFlowNode @AssistedInject constructor(
|
|||
object About : NavTarget
|
||||
|
||||
@Parcelize
|
||||
object NotificationsSettings : NavTarget
|
||||
object NotificationSettings : NavTarget
|
||||
}
|
||||
|
||||
override fun resolve(navTarget: NavTarget, buildContext: BuildContext): Node {
|
||||
|
|
@ -95,8 +95,8 @@ class PreferencesFlowNode @AssistedInject constructor(
|
|||
backstack.push(NavTarget.DeveloperSettings)
|
||||
}
|
||||
|
||||
override fun onOpenNotificationsSettings() {
|
||||
backstack.push(NavTarget.NotificationsSettings)
|
||||
override fun onOpenNotificationSettings() {
|
||||
backstack.push(NavTarget.NotificationSettings)
|
||||
}
|
||||
}
|
||||
createNode<PreferencesRootNode>(buildContext, plugins = listOf(callback))
|
||||
|
|
@ -110,8 +110,8 @@ class PreferencesFlowNode @AssistedInject constructor(
|
|||
NavTarget.AnalyticsSettings -> {
|
||||
createNode<AnalyticsSettingsNode>(buildContext)
|
||||
}
|
||||
NavTarget.NotificationsSettings -> {
|
||||
createNode<NotificationsSettingsNode>(buildContext)
|
||||
NavTarget.NotificationSettings -> {
|
||||
createNode<NotificationSettingsNode>(buildContext)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package io.element.android.features.preferences.impl.notifications
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.bumble.appyx.core.modality.BuildContext
|
||||
import com.bumble.appyx.core.node.Node
|
||||
import com.bumble.appyx.core.plugin.Plugin
|
||||
|
|
@ -25,10 +27,18 @@ import io.element.android.anvilannotations.ContributesNode
|
|||
import io.element.android.libraries.di.SessionScope
|
||||
|
||||
@ContributesNode(SessionScope::class)
|
||||
class NotificationsSettingsNode @AssistedInject constructor(
|
||||
class NotificationSettingsNode @AssistedInject constructor(
|
||||
@Assisted buildContext: BuildContext,
|
||||
@Assisted plugins: List<Plugin>,
|
||||
private val presenter: NotificationsSettingsPresenter,
|
||||
private val presenter: NotificationSettingsPresenter,
|
||||
) : Node(buildContext, plugins = plugins) {
|
||||
|
||||
@Composable
|
||||
override fun View(modifier: Modifier) {
|
||||
val state = presenter.present()
|
||||
NotificationSettingsView(
|
||||
state = state,
|
||||
onBackPressed = ::navigateUp,
|
||||
modifier = modifier
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -20,11 +20,11 @@ import androidx.compose.runtime.Composable
|
|||
import io.element.android.libraries.architecture.Presenter
|
||||
import javax.inject.Inject
|
||||
|
||||
class NotificationsSettingsPresenter @Inject constructor() : Presenter<NotificationsSettingsState> {
|
||||
class NotificationSettingsPresenter @Inject constructor() : Presenter<NotificationSettingsState> {
|
||||
|
||||
@Composable
|
||||
override fun present(): NotificationsSettingsState {
|
||||
return NotificationsSettingsState(
|
||||
override fun present(): NotificationSettingsState {
|
||||
return NotificationSettingsState(
|
||||
isEnabled = true,
|
||||
hasSystemPermission = true,
|
||||
notifyMeOnRoom = true,
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package io.element.android.features.preferences.impl.notifications
|
||||
|
||||
data class NotificationsSettingsState(
|
||||
data class NotificationSettingsState(
|
||||
val hasSystemPermission: Boolean,
|
||||
val isEnabled: Boolean,
|
||||
val notifyMeOnRoom: Boolean,
|
||||
|
|
@ -18,14 +18,14 @@ package io.element.android.features.preferences.impl.notifications
|
|||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
|
||||
open class NotificationsSettingsStateProvider : PreviewParameterProvider<NotificationsSettingsState> {
|
||||
override val values: Sequence<NotificationsSettingsState>
|
||||
open class NotificationSettingsStateProvider : PreviewParameterProvider<NotificationSettingsState> {
|
||||
override val values: Sequence<NotificationSettingsState>
|
||||
get() = sequenceOf(
|
||||
aNotificationsSettingsState(),
|
||||
aNotificationSettingsState(),
|
||||
)
|
||||
}
|
||||
|
||||
fun aNotificationsSettingsState() = NotificationsSettingsState(
|
||||
fun aNotificationSettingsState() = NotificationSettingsState(
|
||||
isEnabled = true,
|
||||
hasSystemPermission = false,
|
||||
notifyMeOnRoom = true,
|
||||
|
|
@ -33,8 +33,8 @@ import io.element.android.libraries.designsystem.preview.ElementPreviewLight
|
|||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
|
||||
@Composable
|
||||
fun NotificationsSettingsView(
|
||||
state: NotificationsSettingsState,
|
||||
fun NotificationSettingsView(
|
||||
state: NotificationSettingsState,
|
||||
onBackPressed: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
|
|
@ -100,17 +100,17 @@ fun NotificationsSettingsView(
|
|||
|
||||
@Preview
|
||||
@Composable
|
||||
internal fun AboutViewLightPreview(@PreviewParameter(NotificationsSettingsStateProvider::class) state: NotificationsSettingsState) =
|
||||
internal fun AboutViewLightPreview(@PreviewParameter(NotificationSettingsStateProvider::class) state: NotificationSettingsState) =
|
||||
ElementPreviewLight { ContentToPreview(state) }
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
internal fun AboutViewDarkPreview(@PreviewParameter(NotificationsSettingsStateProvider::class) state: NotificationsSettingsState) =
|
||||
internal fun AboutViewDarkPreview(@PreviewParameter(NotificationSettingsStateProvider::class) state: NotificationSettingsState) =
|
||||
ElementPreviewDark { ContentToPreview(state) }
|
||||
|
||||
@Composable
|
||||
private fun ContentToPreview(state: NotificationsSettingsState) {
|
||||
NotificationsSettingsView(
|
||||
private fun ContentToPreview(state: NotificationSettingsState) {
|
||||
NotificationSettingsView(
|
||||
state = state,
|
||||
onBackPressed = {},
|
||||
)
|
||||
|
|
@ -44,7 +44,7 @@ class PreferencesRootNode @AssistedInject constructor(
|
|||
fun onOpenAnalytics()
|
||||
fun onOpenAbout()
|
||||
fun onOpenDeveloperSettings()
|
||||
fun onOpenNotificationsSettings()
|
||||
fun onOpenNotificationSettings()
|
||||
}
|
||||
|
||||
private fun onOpenBugReport() {
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ fun PreferencesRootView(
|
|||
PreferenceText(
|
||||
title = stringResource(id = CommonStrings.screen_notification_settings_title),
|
||||
icon = Icons.Outlined.Notifications,
|
||||
onClick = onOpenNotificationsSettings,
|
||||
onClick = onOpenNotificationSettings,
|
||||
)
|
||||
PreferenceText(
|
||||
title = stringResource(id = CommonStrings.action_report_bug),
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ package io.element.android.features.preferences.impl.tasks
|
|||
|
||||
import android.content.Context
|
||||
import com.squareup.anvil.annotations.ContributesBinding
|
||||
import io.element.android.libraries.androidutils.filesize.FileSizeFormatter
|
||||
import io.element.android.libraries.androidutils.file.getSizeOfFiles
|
||||
import io.element.android.libraries.androidutils.filesize.FileSizeFormatter
|
||||
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
||||
import io.element.android.libraries.di.ApplicationContext
|
||||
import io.element.android.libraries.di.SessionScope
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue