refactor: remove moderator zone bottom sheet (#55)

* add some plural forms

* remove ModeratorZoneBottomSheet

* update usages
This commit is contained in:
akesi seli 2024-10-28 23:00:49 +01:00 committed by GitHub
parent ff9f9c9667
commit d054051033
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 96 additions and 94 deletions

View File

@ -1,79 +0,0 @@
package com.livefast.eattrash.raccoonforlemmy.core.commonui.modals
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.navigationBars
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import cafe.adriel.voyager.core.screen.Screen
import com.livefast.eattrash.raccoonforlemmy.core.appearance.theme.Spacing
import com.livefast.eattrash.raccoonforlemmy.core.commonui.components.BottomSheetHeader
import com.livefast.eattrash.raccoonforlemmy.core.commonui.lemmyui.ModeratorZoneAction
import com.livefast.eattrash.raccoonforlemmy.core.commonui.lemmyui.SettingsRow
import com.livefast.eattrash.raccoonforlemmy.core.commonui.lemmyui.toIcon
import com.livefast.eattrash.raccoonforlemmy.core.commonui.lemmyui.toInt
import com.livefast.eattrash.raccoonforlemmy.core.commonui.lemmyui.toReadableName
import com.livefast.eattrash.raccoonforlemmy.core.l10n.messages.LocalStrings
import com.livefast.eattrash.raccoonforlemmy.core.navigation.di.getNavigationCoordinator
import com.livefast.eattrash.raccoonforlemmy.core.notifications.NotificationCenterEvent
import com.livefast.eattrash.raccoonforlemmy.core.notifications.di.getNotificationCenter
class ModeratorZoneBottomSheet : Screen {
@Composable
override fun Content() {
val navigationCoordinator = remember { getNavigationCoordinator() }
val notificationCenter = remember { getNotificationCenter() }
Surface {
Column(
modifier =
Modifier
.windowInsetsPadding(WindowInsets.navigationBars)
.padding(
top = Spacing.s,
start = Spacing.s,
end = Spacing.s,
bottom = Spacing.m,
),
verticalArrangement = Arrangement.spacedBy(Spacing.s),
) {
BottomSheetHeader(LocalStrings.current.moderatorZoneTitle)
val values =
listOf(
ModeratorZoneAction.GlobalReports,
ModeratorZoneAction.GlobalModLog,
ModeratorZoneAction.ModeratedContents,
)
Column(
modifier = Modifier.fillMaxWidth().verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(Spacing.xxs),
) {
for (value in values) {
SettingsRow(
modifier = Modifier.padding(vertical = Spacing.xxs),
icon = value.toIcon(),
title = value.toReadableName(),
disclosureIndicator = true,
onTap = {
navigationCoordinator.hideBottomSheet()
notificationCenter.send(
NotificationCenterEvent.ModeratorZoneActionSelected(
value.toInt(),
),
)
},
)
}
}
}
}
}
}

View File

@ -440,7 +440,11 @@ internal open class DefaultStrings : Strings {
override val settingsManageBanSectionStopWords = "Words"
override val inboxNotificationTitle = "Unread items"
override fun inboxNotificationContent(count: Int): String = "There are $count unread items"
override fun inboxNotificationContent(count: Int): String =
when (count) {
1 -> "There is $count unread item"
else -> "There are $count unread items"
}
override val settingsAboutMatrix = "Join Matrix room"
}

View File

@ -455,7 +455,11 @@ internal val EsStrings =
override val settingsManageBanStopWordPlaceholder = "Expresión prohibida"
override val inboxNotificationTitle = "Elementos para leer"
override fun inboxNotificationContent(count: Int): String = "Hay $count elementos para leer"
override fun inboxNotificationContent(count: Int): String =
when (count) {
1 -> "Hay $count elemento para leer"
else -> "Hay $count elementos para leer"
}
override val settingsAboutMatrix = "Unirse a la sala Matrix"
}

View File

@ -458,7 +458,11 @@ internal val FrStrings =
override val settingsManageBanSectionDomains = "Domaines"
override val inboxNotificationTitle = "Éléments non lus"
override fun inboxNotificationContent(count: Int): String = "Il y a $count éléments non lus"
override fun inboxNotificationContent(count: Int): String =
when (count) {
1 -> "Il y a $count élément non lu"
else -> "Il y a $count éléments non lus"
}
override val settingsAboutMatrix = "Rejoindre la salle Matrix"
}

View File

@ -455,7 +455,11 @@ internal val ItStrings =
override val settingsManageBanStopWordPlaceholder = "Espressione vietata"
override val inboxNotificationTitle = "Elementi non letti"
override fun inboxNotificationContent(count: Int): String = "Ci sono $count elementi non letti"
override fun inboxNotificationContent(count: Int): String =
when (count) {
1 -> "C'è $count elemento non letto"
else -> "Ci sono $count elementi non letti"
}
override val settingsAboutMatrix = "Entra nella room Matrix"
}

View File

@ -448,7 +448,11 @@ internal val PtBrStrings =
override val settingsManageBanStopWordPlaceholder = "Frases proibidas"
override val inboxNotificationTitle = "Itens não lidos"
override fun inboxNotificationContent(count: Int): String = "Você tem $count itens não lidos"
override fun inboxNotificationContent(count: Int): String =
when (count) {
1 -> "Você tem $count item não lido"
else -> "Você tem $count itens não lidos"
}
override val settingsAboutMatrix = "Entre na sala Matrix"
}

View File

@ -452,7 +452,11 @@ internal val PtStrings =
override val messageAuthIssueSegue2 = "fazer login novamente"
override val inboxNotificationTitle = "Itens não lidos"
override fun inboxNotificationContent(count: Int): String = "Existem $count itens não lidos"
override fun inboxNotificationContent(count: Int): String =
when (count) {
1 -> "Existe $count item não lido"
else -> "Existem $count itens não lidos"
}
override val settingsAboutMatrix = "Entre na sala Matrix"
}

View File

@ -451,7 +451,11 @@ internal val RoStrings =
override val settingsManageBanStopWordPlaceholder = "Expresie interzisă"
override val inboxNotificationTitle = "Elemente necitite"
override fun inboxNotificationContent(count: Int): String = "Există $count elemente necitite"
override fun inboxNotificationContent(count: Int): String =
when (count) {
1 -> "Există $count element necitit"
else -> "Există $count elemente necitite"
}
override val settingsAboutMatrix = "Intră în camera Matrix"
}

View File

@ -1,10 +1,14 @@
package com.livefast.eattrash.raccoonforlemmy.feature.profile.main
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.MenuOpen
import androidx.compose.material.icons.filled.ChevronRight
import androidx.compose.material.icons.filled.Menu
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
@ -36,11 +40,16 @@ import cafe.adriel.voyager.navigator.tab.Tab
import cafe.adriel.voyager.navigator.tab.TabNavigator
import cafe.adriel.voyager.navigator.tab.TabOptions
import com.livefast.eattrash.raccoonforlemmy.core.appearance.theme.Dimensions
import com.livefast.eattrash.raccoonforlemmy.core.appearance.theme.IconSize
import com.livefast.eattrash.raccoonforlemmy.core.appearance.theme.Spacing
import com.livefast.eattrash.raccoonforlemmy.core.commonui.lemmyui.ModeratorZoneAction
import com.livefast.eattrash.raccoonforlemmy.core.commonui.lemmyui.di.getFabNestedScrollConnection
import com.livefast.eattrash.raccoonforlemmy.core.commonui.lemmyui.toIcon
import com.livefast.eattrash.raccoonforlemmy.core.commonui.lemmyui.toInt
import com.livefast.eattrash.raccoonforlemmy.core.commonui.lemmyui.toModeratorZoneAction
import com.livefast.eattrash.raccoonforlemmy.core.commonui.modals.ModeratorZoneBottomSheet
import com.livefast.eattrash.raccoonforlemmy.core.commonui.lemmyui.toReadableName
import com.livefast.eattrash.raccoonforlemmy.core.commonui.modals.CustomModalBottomSheet
import com.livefast.eattrash.raccoonforlemmy.core.commonui.modals.CustomModalBottomSheetItem
import com.livefast.eattrash.raccoonforlemmy.core.l10n.messages.LocalStrings
import com.livefast.eattrash.raccoonforlemmy.core.navigation.di.getDrawerCoordinator
import com.livefast.eattrash.raccoonforlemmy.core.navigation.di.getNavigationCoordinator
@ -87,7 +96,8 @@ internal object ProfileMainScreen : Tab {
val scope = rememberCoroutineScope()
val notificationCenter = remember { getNotificationCenter() }
val fabNestedScrollConnection = remember { getFabNestedScrollConnection() }
var logoutConfirmDialogOpen by remember { mutableStateOf(false) }
var logoutConfirmDialogOpened by remember { mutableStateOf(false) }
var moderatorZoneBottomSheetOpened by remember { mutableStateOf(false) }
LaunchedEffect(notificationCenter) {
notificationCenter
@ -139,11 +149,11 @@ internal object ProfileMainScreen : Tab {
}
NotificationCenterEvent.ProfileSideMenuAction.ModeratorZone -> {
navigationCoordinator.showBottomSheet(ModeratorZoneBottomSheet())
moderatorZoneBottomSheetOpened = true
}
NotificationCenterEvent.ProfileSideMenuAction.Logout -> {
logoutConfirmDialogOpen = true
logoutConfirmDialogOpened = true
}
NotificationCenterEvent.ProfileSideMenuAction.CreateCommunity -> {
@ -260,10 +270,10 @@ internal object ProfileMainScreen : Tab {
}
}
if (logoutConfirmDialogOpen) {
if (logoutConfirmDialogOpened) {
AlertDialog(
onDismissRequest = {
logoutConfirmDialogOpen = false
logoutConfirmDialogOpened = false
},
title = {
Text(
@ -277,7 +287,7 @@ internal object ProfileMainScreen : Tab {
dismissButton = {
Button(
onClick = {
logoutConfirmDialogOpen = false
logoutConfirmDialogOpened = false
},
) {
Text(text = LocalStrings.current.buttonCancel)
@ -286,7 +296,7 @@ internal object ProfileMainScreen : Tab {
confirmButton = {
Button(
onClick = {
logoutConfirmDialogOpen = false
logoutConfirmDialogOpened = false
model.reduce(ProfileMainMviModel.Intent.Logout)
},
) {
@ -295,5 +305,48 @@ internal object ProfileMainScreen : Tab {
},
)
}
if (moderatorZoneBottomSheetOpened) {
val values =
listOf(
ModeratorZoneAction.GlobalReports,
ModeratorZoneAction.GlobalModLog,
ModeratorZoneAction.ModeratedContents,
)
CustomModalBottomSheet(
title = LocalStrings.current.moderatorZoneTitle,
items =
values.map {
CustomModalBottomSheetItem(
label = it.toReadableName(),
trailingContent = {
Row(
horizontalArrangement = Arrangement.spacedBy(Spacing.s),
) {
Icon(
modifier = Modifier.size(IconSize.m),
imageVector = it.toIcon(),
contentDescription = null,
tint = MaterialTheme.colorScheme.onBackground,
)
Icon(
imageVector = Icons.Default.ChevronRight,
tint = MaterialTheme.colorScheme.onBackground,
contentDescription = null,
)
}
},
)
},
onSelected = { index ->
moderatorZoneBottomSheetOpened = false
if (index != null) {
notificationCenter.send(
NotificationCenterEvent.ModeratorZoneActionSelected(values[index].toInt()),
)
}
},
)
}
}
}