feat: specify user ban duration and data removal (#571)

This commit is contained in:
Diego Beraldin 2024-03-06 13:52:57 +01:00 committed by GitHub
parent 6d03b3b327
commit 90cf5be522
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
41 changed files with 290 additions and 22 deletions

View File

@ -0,0 +1,72 @@
package com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowCircleDown
import androidx.compose.material.icons.filled.ArrowCircleUp
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.FeedbackButton
@Composable
fun SettingsIntValueRow(
title: String,
value: Int,
subtitle: String? = null,
onIncrement: () -> Unit,
onDecrement: () -> Unit,
) {
Row(
modifier = Modifier.padding(horizontal = Spacing.m),
verticalAlignment = Alignment.CenterVertically,
) {
Column(
modifier = Modifier.weight(1f),
) {
Text(
text = title,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onBackground,
)
if (subtitle != null) {
Text(
text = subtitle,
style = MaterialTheme.typography.labelMedium,
color = MaterialTheme.colorScheme.onBackground,
)
}
}
Row(
verticalAlignment = Alignment.CenterVertically
) {
FeedbackButton(
imageVector = Icons.Default.ArrowCircleDown,
tintColor = MaterialTheme.colorScheme.secondary,
onClick = onDecrement,
)
Text(
modifier = Modifier
.sizeIn(minWidth = 40.dp)
.padding(horizontal = Spacing.s),
textAlign = TextAlign.Center,
text = value.toString(),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onBackground,
)
FeedbackButton(
imageVector = Icons.Default.ArrowCircleUp,
tintColor = MaterialTheme.colorScheme.secondary,
onClick = onIncrement,
)
}
}
}

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">تعليقات خاضعة للإشراف</string>
<string name="moderator_zone_action_posts">المشاركات الخاضعة للإشراف</string>
<string name="message_auth_issue">حدث خطأ أثناء جلب بيانات المستخدم، حاول تحديث الشاشة</string>
<string name="ban_reason_placeholder">لسبب (اختياري)</string>
<string name="ban_item_permanent">فرض حظر دائم</string>
<string name="ban_item_remove_data">إزالة البيانات</string>
<string name="ban_item_duration_days">المدة (أيام)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Модерирани коментари</string>
<string name="moderator_zone_action_posts">Модерирани публикации</string>
<string name="message_auth_issue">Възникна грешка при извличането на потребителски данни, опитайте да обновите екрана</string>
<string name="ban_reason_placeholder">Причина (по избор)</string>
<string name="ban_item_permanent">Постоянна забрана</string>
<string name="ban_item_remove_data">Премахване на данни</string>
<string name="ban_item_duration_days">Продължителност (дни)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Moderované komentáře</string>
<string name="moderator_zone_action_posts">Moderované příspěvky</string>
<string name="message_auth_issue">Při načítání uživatelských dat došlo k chybě, zkuste obnovit obrazovku</string>
<string name="ban_reason_placeholder">Důvod (volitelné)</string>
<string name="ban_item_permanent">Trvalý zákaz</string>
<string name="ban_item_remove_data">Odebrat data</string>
<string name="ban_item_duration_days">Délka (dny)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Modererede kommentarer</string>
<string name="moderator_zone_action_posts">Modererede indlæg</string>
<string name="message_auth_issue">Der opstod en fejl under hentning af brugerdata. Prøv at opdatere skærmen</string>
<string name="ban_reason_placeholder">Årsag (valgfrit)</string>
<string name="ban_item_permanent">Permanent forbud</string>
<string name="ban_item_remove_data">Fjern data</string>
<string name="ban_item_duration_days">Varighed (dage)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Moderierte Kommentare</string>
<string name="moderator_zone_action_posts">Moderierte Beiträge</string>
<string name="message_auth_issue">Beim Abrufen der Benutzerdaten ist ein Fehler aufgetreten. Versuchen Sie, den Bildschirm zu aktualisieren</string>
<string name="ban_reason_placeholder">Grund (optional)</string>
<string name="ban_item_permanent">Permanenter Bann</string>
<string name="ban_item_remove_data">Daten entfernen</string>
<string name="ban_item_duration_days">Dauer (Tage)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Εποπτευμένα σχόλια</string>
<string name="moderator_zone_action_posts">Εποπτευόμενες αναρτήσεις</string>
<string name="message_auth_issue">Παρουσιάστηκε σφάλμα κατά την ανάκτηση δεδομένων χρήστη, δοκιμάστε να ανανεώσετε την οθόνη</string>
<string name="ban_reason_placeholder">Αιτία (προαιρετικό)</string>
<string name="ban_item_permanent">Μόνιμη απαγόρευση</string>
<string name="ban_item_remove_data">Κατάργηση δεδομένων</string>
<string name="ban_item_duration_days">Διάρκεια (ημέρες)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Moderigitaj komentoj</string>
<string name="moderator_zone_action_posts">Moderigitaj afiŝoj</string>
<string name="message_auth_issue">Okazis eraro dum venigado de uzantdatenoj, provu refreŝigi la ekranon</string>
<string name="ban_reason_placeholder">Kialo (laŭvola)</string>
<string name="ban_item_permanent">Konstanta malpermeso</string>
<string name="ban_item_remove_data">Forigi datumojn</string>
<string name="ban_item_duration_days">Daŭro (tagoj)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Comentarios por moderar</string>
<string name="moderator_zone_action_posts">Publicaciones por moderar</string>
<string name="message_auth_issue">Se produjo un error al obtener los datos del usuario, intente actualizar la pantalla</string>
<string name="ban_reason_placeholder">Razón (opcional)</string>
<string name="ban_item_permanent">Prohibición permanente</string>
<string name="ban_item_remove_data">Eliminar datos</string>
<string name="ban_item_duration_days">Duración (días)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Modereeritud kommentaarid</string>
<string name="moderator_zone_action_posts">Modereeritud postitused</string>
<string name="message_auth_issue">Kasutajaandmete toomisel ilmnes viga. Proovige ekraani värskendada</string>
<string name="ban_reason_placeholder">Põhjus (valikuline)</string>
<string name="ban_item_permanent">Alaline keeld</string>
<string name="ban_item_remove_data">Eemalda andmed</string>
<string name="ban_item_duration_days">Kestus (päeva)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Moderoidut kommentit</string>
<string name="moderator_zone_action_posts">Valvotut viestit</string>
<string name="message_auth_issue">Käyttäjätietoja haettaessa tapahtui virhe. Yritä päivittää näyttö</string>
<string name="ban_reason_placeholder">Syy (valinnainen)</string>
<string name="ban_item_permanent">Pysyvä kielto</string>
<string name="ban_item_remove_data">Poista tiedot</string>
<string name="ban_item_duration_days">Kesto (päivää)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Commentaires à modérer</string>
<string name="moderator_zone_action_posts">Publications à modérer</string>
<string name="message_auth_issue">Une erreur s\'est produite lors de la récupération des données utilisateur, essayez d\'actualiser l\'écran</string>
<string name="ban_reason_placeholder">Raison (facultatif)</string>
<string name="ban_item_permanent">Interdiction permanente</string>
<string name="ban_item_remove_data">Supprimer données</string>
<string name="ban_item_duration_days">Durée (jours)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Tráchtanna modhnaithe</string>
<string name="moderator_zone_action_posts">Poist mhodhnaithe</string>
<string name="message_auth_issue">Tharla earráid agus sonraí úsáideora á bhfáil agat, bain triail as an scáileán a athnuachan</string>
<string name="ban_reason_placeholder">Fáth (roghnach)</string>
<string name="ban_item_permanent">Cosc buan</string>
<string name="ban_item_remove_data">Bain sonraí</string>
<string name="ban_item_duration_days">Fad (laethanta)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Moderirani komentari</string>
<string name="moderator_zone_action_posts">Moderirani postovi</string>
<string name="message_auth_issue">Došlo je do pogreške prilikom dohvaćanja korisničkih podataka, pokušajte osvježiti zaslon</string>
<string name="ban_reason_placeholder">Razlog (neobavezno)</string>
<string name="ban_item_permanent">Trajna zabrana</string>
<string name="ban_item_remove_data">Ukloni podatke</string>
<string name="ban_item_duration_days">Trajanje (dani)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Moderált megjegyzések</string>
<string name="moderator_zone_action_posts">Moderált bejegyzések</string>
<string name="message_auth_issue">Hiba történt a felhasználói adatok lekérése közben, próbálja meg frissíteni a képernyőt</string>
<string name="ban_reason_placeholder">Ok (nem kötelező)</string>
<string name="ban_item_permanent">Végleges eltiltás</string>
<string name="ban_item_remove_data">Távolítsa el az adatokat</string>
<string name="ban_item_duration_days">Időtartam (nap)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Commenti da moderare</string>
<string name="moderator_zone_action_posts">Post da moderare</string>
<string name="message_auth_issue">Si è verificato un errore nel recupero dei dati utente, fare refresh della schermata</string>
<string name="ban_reason_placeholder">Motivazione (opzionale)</string>
<string name="ban_item_permanent">Ban permanente</string>
<string name="ban_item_remove_data">Rimuovi dati</string>
<string name="ban_item_duration_days">Durata (giorni)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Moderuojami komentarai</string>
<string name="moderator_zone_action_posts">Moderuojami įrašai</string>
<string name="message_auth_issue">Gaunant vartotojo duomenis įvyko klaida. Pabandykite atnaujinti ekraną</string>
<string name="ban_reason_placeholder">Priežastis (neprivaloma)</string>
<string name="ban_item_permanent">Nuolatinis draudimas</string>
<string name="ban_item_remove_data">Pašalinti duomenis</string>
<string name="ban_item_duration_days">Trukmė (dienomis)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Regulēti komentāri</string>
<string name="moderator_zone_action_posts">Regulētas ziņas</string>
<string name="message_auth_issue">Ienesot lietotāja datus, radās kļūda. Mēģiniet atsvaidzināt ekrānu</string>
<string name="ban_reason_placeholder">Iemesls (pēc izvēles)</string>
<string name="ban_item_permanent">Pastāvīgs aizliegums</string>
<string name="ban_item_remove_data">Noņemiet datus</string>
<string name="ban_item_duration_days">Ilgums (dienas)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Kummenti moderati</string>
<string name="moderator_zone_action_posts">Postijiet moderati</string>
<string name="message_auth_issue">Żball seħħ waqt li ġġib id-dejta tal-utent, ipprova aġġorna l-iskrin</string>
<string name="ban_reason_placeholder">Raġuni (mhux obbligatorju)</string>
<string name="ban_item_permanent">Projbizzjoni permanenti</string>
<string name="ban_item_remove_data">Neħħi d-data</string>
<string name="ban_item_duration_days">Tul (jiem)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Gemodereerde opmerkingen</string>
<string name="moderator_zone_action_posts">Gemodereerde berichten</string>
<string name="message_auth_issue">Er is een fout opgetreden tijdens het ophalen van gebruikersgegevens. Probeer het scherm te vernieuwen</string>
<string name="ban_reason_placeholder">Reden (optioneel)</string>
<string name="ban_item_permanent">Permanente verbanning</string>
<string name="ban_item_remove_data">Gegevens verwijderen</string>
<string name="ban_item_duration_days">Duur (dagen)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Modererte kommentarer</string>
<string name="moderator_zone_action_posts">Modererte innlegg</string>
<string name="message_auth_issue">Det oppstod en feil under henting av brukerdata. Prøv å oppdatere skjermen</string>
<string name="ban_reason_placeholder">Årsak (valgfritt)</string>
<string name="ban_item_permanent">Permanent forbud</string>
<string name="ban_item_remove_data">Fjern data</string>
<string name="ban_item_duration_days">Varighet (dager)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Moderowane komentarze</string>
<string name="moderator_zone_action_posts">Moderowane posty</string>
<string name="message_auth_issue">Wystąpił błąd podczas pobierania danych użytkownika. Spróbuj odświeżyć ekran</string>
<string name="ban_reason_placeholder">Powód (opcjonalnie)</string>
<string name="ban_item_permanent">Stały zakaz</string>
<string name="ban_item_remove_data">Usuń dane</string>
<string name="ban_item_duration_days">Czas trwania (dni)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Comentários moderados</string>
<string name="moderator_zone_action_posts">Posts moderados</string>
<string name="message_auth_issue">Ocorreu um erro ao buscar dados do usuário. Tente atualizar a tela</string>
<string name="ban_reason_placeholder">Razão (opcional)</string>
<string name="ban_item_permanent">Proibição permanente</string>
<string name="ban_item_remove_data">Remover dados</string>
<string name="ban_item_duration_days">Duração (dias)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Comentários moderados</string>
<string name="moderator_zone_action_posts">Postagens moderadas</string>
<string name="message_auth_issue">Ocorreu um erro ao buscar dados do usuário. Tente atualizar a tela</string>
<string name="ban_reason_placeholder">Razão (opcional)</string>
<string name="ban_item_permanent">Proibição permanente</string>
<string name="ban_item_remove_data">Remover dados</string>
<string name="ban_item_duration_days">Duração (dias)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Comentarii moderate</string>
<string name="moderator_zone_action_posts">Postări moderate</string>
<string name="message_auth_issue">A apărut o eroare la preluarea datelor utilizatorului, încercearcă să reîmprospătezi ecranul</string>
<string name="ban_reason_placeholder">Motiv (opțional)</string>
<string name="ban_item_permanent">Interdicție permanentă</string>
<string name="ban_item_remove_data">Elimină datele</string>
<string name="ban_item_duration_days">Durată (zile)</string>
</resources>

View File

@ -332,4 +332,8 @@
<string name="moderator_zone_action_comments">Модерируемые комментарии</string>
<string name="moderator_zone_action_posts">Модерируемые сообщения</string>
<string name="message_auth_issue">Произошла ошибка при получении пользовательских данных. Попробуйте обновить экран.</string>
<string name="ban_reason_placeholder">Причина (необязательно)</string>
<string name="ban_item_permanent">Постоянный бан</string>
<string name="ban_item_remove_data">Удалить данные</string>
<string name="ban_item_duration_days">Продолжительность (дни)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Modererade kommentarer</string>
<string name="moderator_zone_action_posts">Modererade inlägg</string>
<string name="message_auth_issue">Ett fel uppstod när användardata skulle hämtas, försök att uppdatera skärmen</string>
<string name="ban_reason_placeholder">Orsak (valfritt)</string>
<string name="ban_item_permanent">Permanent förbud</string>
<string name="ban_item_remove_data">Ta bort data</string>
<string name="ban_item_duration_days">Varaktighet (dagar)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Moderované komentáre</string>
<string name="moderator_zone_action_posts">Moderované príspevky</string>
<string name="message_auth_issue">Pri načítavaní údajov používateľa sa vyskytla chyba, skúste obnoviť obrazovku</string>
<string name="ban_reason_placeholder">Dôvod (voliteľné)</string>
<string name="ban_item_permanent">Trvalý zákaz</string>
<string name="ban_item_remove_data">Odstráňte údaje</string>
<string name="ban_item_duration_days">Trvanie (dni)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Moderirani komentarji</string>
<string name="moderator_zone_action_posts">Moderirane objave</string>
<string name="message_auth_issue">Pri pridobivanju uporabniških podatkov je prišlo do napake, poskusite osvežiti zaslon</string>
<string name="ban_reason_placeholder">Razlog (neobvezno)</string>
<string name="ban_item_permanent">Trajna prepoved</string>
<string name="ban_item_remove_data">Odstrani podatke</string>
<string name="ban_item_duration_days">Trajanje (dnevi)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Komentet e moderuara</string>
<string name="moderator_zone_action_posts">Postimet e moderuara</string>
<string name="message_auth_issue">Ndodhi një gabim gjatë marrjes së të dhënave të përdoruesit, provoni të rifreskoni ekranin</string>
<string name="ban_reason_placeholder">Arsyeja (opsionale)</string>
<string name="ban_item_permanent">Ndalim i përhershëm</string>
<string name="ban_item_remove_data">Hiq të dhënat</string>
<string name="ban_item_duration_days">Kohëzgjatja (ditë)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">toki lili pi kulupu lawa</string>
<string name="moderator_zone_action_posts">lipu pi kulupu lawa</string>
<string name="message_auth_issue">kama sona ijo la, pakala wan li lon. o lukin open e lipu ni lon tenpo nanpa tu</string>
<string name="ban_reason_placeholder">Tan (sina wile la)</string>
<string name="ban_item_permanent">lon tenpo ale</string>
<string name="ban_item_remove_data">o weka e sona</string>
<string name="ban_item_duration_days">tenpo suno</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Denetlenen yorumlar</string>
<string name="moderator_zone_action_posts">Denetlenen gönderiler</string>
<string name="message_auth_issue">Kullanıcı verileri alınırken bir hata oluştu, ekranı yenilemeyi deneyin</string>
<string name="ban_reason_placeholder">Sebep (isteğe bağlı)</string>
<string name="ban_item_permanent">Kalıcı yasak</string>
<string name="ban_item_remove_data">Verileri kaldır</string>
<string name="ban_item_duration_days">Süre (gün)</string>
</resources>

View File

@ -332,4 +332,8 @@
<string name="moderator_zone_action_comments">Модеровані коментарі</string>
<string name="moderator_zone_action_posts">Модеровані дописи</string>
<string name="message_auth_issue">Під час отримання даних користувача сталася помилка. Спробуйте оновити екран</string>
<string name="ban_reason_placeholder">Причина (необов\'язково)</string>
<string name="ban_item_permanent">Постійний бан</string>
<string name="ban_item_remove_data">Видалити дані</string>
<string name="ban_item_duration_days">Тривалість (дні)</string>
</resources>

View File

@ -333,4 +333,8 @@
<string name="moderator_zone_action_comments">Moderated comments</string>
<string name="moderator_zone_action_posts">Moderated posts</string>
<string name="message_auth_issue">An error occurred while fetching user data, try refreshing the screen</string>
<string name="ban_reason_placeholder">Reason (optional)</string>
<string name="ban_item_permanent">Permanent ban</string>
<string name="ban_item_remove_data">Remove data</string>
<string name="ban_item_duration_days">Duration (days)</string>
</resources>

View File

@ -12,10 +12,18 @@ interface BanUserMviModel :
sealed interface Intent {
data class SetText(val value: String) : Intent
data class ChangePermanent(val value: Boolean) : Intent
data class ChangeRemoveData(val value: Boolean) : Intent
data object DecrementDays : Intent
data object IncrementDays : Intent
data object Submit : Intent
}
data class UiState(
val permanent: Boolean = true,
val days: Int = 1,
val targetBanValue: Boolean = false,
val removeData: Boolean = false,
val text: String = "",
val textError: ValidationError? = null,
val loading: Boolean = false,

View File

@ -12,8 +12,8 @@ import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.Send
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Send
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@ -46,10 +46,13 @@ import cafe.adriel.voyager.koin.getScreenModel
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.bindToLifecycle
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.ProgressHud
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.SettingsIntValueRow
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.SettingsSwitchRow
import com.github.diegoberaldin.raccoonforlemmy.core.l10n.LocalXmlStrings
import com.github.diegoberaldin.raccoonforlemmy.core.navigation.di.getNavigationCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.onClick
import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.rememberCallback
import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.rememberCallbackArgs
import com.github.diegoberaldin.raccoonforlemmy.core.utils.toReadableMessage
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
@ -131,7 +134,7 @@ class BanUserScreen(
IconButton(
content = {
Icon(
imageVector = Icons.Filled.Send,
imageVector = Icons.AutoMirrored.Filled.Send,
contentDescription = null,
)
},
@ -157,10 +160,10 @@ class BanUserScreen(
verticalArrangement = Arrangement.spacedBy(Spacing.s),
horizontalAlignment = Alignment.CenterHorizontally,
) {
val commentFocusRequester = remember { FocusRequester() }
val focusRequester = remember { FocusRequester() }
TextField(
modifier = Modifier
.focusRequester(commentFocusRequester)
.focusRequester(focusRequester)
.heightIn(min = 300.dp, max = 500.dp)
.fillMaxWidth(),
colors = TextFieldDefaults.colors(
@ -169,7 +172,7 @@ class BanUserScreen(
disabledContainerColor = Color.Transparent,
),
label = {
Text(text = LocalXmlStrings.current.createReportPlaceholder)
Text(text = LocalXmlStrings.current.banReasonPlaceholder)
},
textStyle = MaterialTheme.typography.bodyMedium,
value = uiState.text,
@ -191,6 +194,39 @@ class BanUserScreen(
}
},
)
if (uiState.targetBanValue) {
// it is a ban (as opposed to unban)
SettingsSwitchRow(
title = LocalXmlStrings.current.banItemPermanent,
value = uiState.permanent,
onValueChanged = rememberCallbackArgs(model) { value ->
model.reduce(BanUserMviModel.Intent.ChangePermanent(value))
},
)
if (!uiState.permanent) {
SettingsIntValueRow(
title = LocalXmlStrings.current.banItemDurationDays,
value = uiState.days,
onIncrement = rememberCallback {
model.reduce(BanUserMviModel.Intent.IncrementDays)
},
onDecrement = rememberCallback {
model.reduce(BanUserMviModel.Intent.DecrementDays)
},
)
}
SettingsSwitchRow(
title = LocalXmlStrings.current.banItemRemoveData,
value = uiState.removeData,
onValueChanged = rememberCallbackArgs(model) { value ->
model.reduce(BanUserMviModel.Intent.ChangeRemoveData(value))
},
)
}
Spacer(Modifier.height(Spacing.xxl))
}

View File

@ -23,23 +23,42 @@ class BanUserViewModel(
initialState = BanUserMviModel.UiState(),
) {
override fun onStarted() {
super.onStarted()
updateState {
it.copy(targetBanValue = newValue)
}
}
override fun reduce(intent: BanUserMviModel.Intent) {
when (intent) {
is BanUserMviModel.Intent.SetText -> {
updateState {
it.copy(text = intent.value)
}
}
BanUserMviModel.Intent.IncrementDays -> incrementDays()
BanUserMviModel.Intent.DecrementDays -> decrementDays()
is BanUserMviModel.Intent.ChangePermanent -> updateState { it.copy(permanent = intent.value) }
is BanUserMviModel.Intent.ChangeRemoveData -> updateState { it.copy(removeData = intent.value) }
is BanUserMviModel.Intent.SetText -> updateState { it.copy(text = intent.value) }
BanUserMviModel.Intent.Submit -> submit()
}
}
private fun incrementDays() {
val newValue = uiState.value.days + 1
updateState { it.copy(days = newValue) }
}
private fun decrementDays() {
val newValue = (uiState.value.days - 1).coerceAtLeast(1)
updateState { it.copy(days = newValue) }
}
private fun submit() {
if (uiState.value.loading) {
val currentState = uiState.value
if (currentState.loading) {
return
}
val text = uiState.value.text
val text = currentState.text
val removeData = currentState.removeData.takeIf { newValue } ?: false
val days = currentState.days.toLong().takeIf { newValue }
updateState { it.copy(loading = true) }
scope?.launch(Dispatchers.IO) {
@ -50,8 +69,9 @@ class BanUserViewModel(
userId = userId,
communityId = communityId,
ban = newValue,
expires = days,
reason = text,
removeData = false,
removeData = removeData,
)
if (newUser != null) {
postId?.also {

View File

@ -21,7 +21,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Send
import androidx.compose.material.icons.automirrored.filled.Send
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
@ -174,7 +174,7 @@ class InboxChatScreen(
onSelectImage = {
openImagePicker = true
},
lastActionIcon = Icons.Filled.Send,
lastActionIcon = Icons.AutoMirrored.Filled.Send,
onLastAction = rememberCallback {
model.reduce(
InboxChatMviModel.Intent.SubmitNewMessage(

View File

@ -15,11 +15,11 @@ import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.Send
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Groups
import androidx.compose.material.icons.filled.Image
import androidx.compose.material.icons.filled.Save
import androidx.compose.material.icons.filled.Send
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@ -266,7 +266,7 @@ class CreatePostScreen(
IconButton(
content = {
Icon(
imageVector = Icons.Filled.Send,
imageVector = Icons.AutoMirrored.Filled.Send,
contentDescription = null,
)
},

View File

@ -12,8 +12,8 @@ import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.Send
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Send
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@ -124,7 +124,7 @@ class CreateReportScreen(
IconButton(
content = {
Icon(
imageVector = Icons.Filled.Send,
imageVector = Icons.AutoMirrored.Filled.Send,
contentDescription = null,
)
},

View File

@ -12,8 +12,8 @@ import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.Send
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Send
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@ -120,7 +120,7 @@ class RemoveScreen(
IconButton(
content = {
Icon(
imageVector = Icons.Filled.Send,
imageVector = Icons.AutoMirrored.Filled.Send,
contentDescription = null,
)
},