feat: configurable comment indent amount (#839)

This commit is contained in:
Diego Beraldin 2024-05-12 13:41:36 +02:00 committed by GitHub
parent 7112c9f153
commit 236590c0f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
61 changed files with 201 additions and 142 deletions

View File

@ -24,7 +24,6 @@ internal class DefaultThemeRepository : ThemeRepository {
override val saveColor = MutableStateFlow<Color?>(null) override val saveColor = MutableStateFlow<Color?>(null)
override val postLayout = MutableStateFlow<PostLayout>(PostLayout.Card) override val postLayout = MutableStateFlow<PostLayout>(PostLayout.Card)
override val commentBarTheme = MutableStateFlow<CommentBarTheme>(CommentBarTheme.Blue) override val commentBarTheme = MutableStateFlow<CommentBarTheme>(CommentBarTheme.Blue)
override val commentBarThickness = MutableStateFlow(1)
override fun changeUiTheme(value: UiTheme?) { override fun changeUiTheme(value: UiTheme?) {
uiTheme.value = value uiTheme.value = value
@ -129,8 +128,4 @@ internal class DefaultThemeRepository : ThemeRepository {
this += Color(0xFFFF0000) this += Color(0xFFFF0000)
} }
} }
override fun changeCommentBarThickness(value: Int) {
commentBarThickness.value = value
}
} }

View File

@ -25,7 +25,6 @@ interface ThemeRepository {
val saveColor: StateFlow<Color?> val saveColor: StateFlow<Color?>
val postLayout: StateFlow<PostLayout> val postLayout: StateFlow<PostLayout>
val commentBarTheme: StateFlow<CommentBarTheme> val commentBarTheme: StateFlow<CommentBarTheme>
val commentBarThickness: StateFlow<Int>
fun changeUiTheme(value: UiTheme?) fun changeUiTheme(value: UiTheme?)
@ -55,7 +54,6 @@ interface ThemeRepository {
fun changePostLayout(value: PostLayout) fun changePostLayout(value: PostLayout)
fun changeCommentBarTheme(value: CommentBarTheme) fun changeCommentBarTheme(value: CommentBarTheme)
fun changeCommentBarThickness(value: Int)
fun getCommentBarColors(commentBarTheme: CommentBarTheme): List<Color> fun getCommentBarColors(commentBarTheme: CommentBarTheme): List<Color>
} }

View File

@ -40,8 +40,7 @@ import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.CommunityModel
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.PostModel import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.PostModel
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.UserModel import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.data.UserModel
private val barWidth = 1.25.dp private val BAR_BASE_WIDTH_UNIT = 1.25.dp
private const val INDENT_AMOUNT = 3
private const val COMMENT_TEXT_SCALE_FACTOR = 0.97f private const val COMMENT_TEXT_SCALE_FACTOR = 0.97f
@Composable @Composable
@ -51,7 +50,8 @@ fun CommentCard(
voteFormat: VoteFormat = VoteFormat.Aggregated, voteFormat: VoteFormat = VoteFormat.Aggregated,
hideAuthor: Boolean = false, hideAuthor: Boolean = false,
hideCommunity: Boolean = true, hideCommunity: Boolean = true,
hideIndent: Boolean = false, indentAmount: Int = 2,
barThickness: Int = 1,
autoLoadImages: Boolean = true, autoLoadImages: Boolean = true,
preferNicknames: Boolean = true, preferNicknames: Boolean = true,
showScores: Boolean = true, showScores: Boolean = true,
@ -77,11 +77,11 @@ fun CommentCard(
val themeRepository = remember { getThemeRepository() } val themeRepository = remember { getThemeRepository() }
var commentHeight by remember { mutableStateOf(0f) } var commentHeight by remember { mutableStateOf(0f) }
val commentBarTheme by themeRepository.commentBarTheme.collectAsState() val commentBarTheme by themeRepository.commentBarTheme.collectAsState()
val commentBarThickness by themeRepository.commentBarThickness.collectAsState()
val barColor = themeRepository.getCommentBarColor( val barColor = themeRepository.getCommentBarColor(
depth = comment.depth, depth = comment.depth,
commentBarTheme = commentBarTheme, commentBarTheme = commentBarTheme,
) )
val barWidth = BAR_BASE_WIDTH_UNIT * barThickness
Column( Column(
modifier = modifier, modifier = modifier,
@ -91,12 +91,14 @@ fun CommentCard(
onClick = onClick ?: {}, onClick = onClick ?: {},
onDoubleClick = onDoubleClick ?: {} onDoubleClick = onDoubleClick ?: {}
).padding( ).padding(
start = if (hideIndent) 0.dp else (INDENT_AMOUNT * comment.depth).dp start = indentAmount.takeIf { it > 0 }?.let {
(it * comment.depth).dp + Spacing.xxxs
} ?: 0.dp
), ),
) { ) {
Column( Column(
modifier = Modifier modifier = Modifier
.padding(start = barWidth) .padding(start = barWidth + Spacing.xxs)
.fillMaxWidth() .fillMaxWidth()
.padding( .padding(
vertical = Spacing.xxs, vertical = Spacing.xxs,
@ -176,14 +178,13 @@ fun CommentCard(
onOptionSelected = onOptionSelected, onOptionSelected = onOptionSelected,
) )
} }
if (!hideIndent && comment.depth > 0) { if (indentAmount > 0 && comment.depth > 0) {
val width = barWidth * commentBarThickness
Box( Box(
modifier = Modifier modifier = Modifier
.padding(top = Spacing.xxs) .padding(top = Spacing.xxs)
.width(width) .width(barWidth)
.height(commentHeight.toLocalDp()) .height(commentHeight.toLocalDp())
.background(color = barColor, shape = RoundedCornerShape(width / 2)) .background(color = barColor, shape = RoundedCornerShape(barWidth / 2))
) )
} }
} }

View File

@ -5,8 +5,8 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.sizeIn import androidx.compose.foundation.layout.sizeIn
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowCircleDown import androidx.compose.material.icons.filled.AddCircleOutline
import androidx.compose.material.icons.filled.ArrowCircleUp import androidx.compose.material.icons.filled.RemoveCircleOutline
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -33,7 +33,9 @@ fun SettingsIntValueRow(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
) { ) {
Column( Column(
modifier = Modifier.weight(1f), modifier = Modifier
.weight(1f)
.padding(vertical = Spacing.s),
) { ) {
Text( Text(
text = title, text = title,
@ -52,7 +54,7 @@ fun SettingsIntValueRow(
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
FeedbackButton( FeedbackButton(
imageVector = Icons.Default.ArrowCircleDown, imageVector = Icons.Default.RemoveCircleOutline,
tintColor = MaterialTheme.colorScheme.secondary, tintColor = MaterialTheme.colorScheme.secondary,
onClick = onDecrement, onClick = onDecrement,
) )
@ -66,7 +68,7 @@ fun SettingsIntValueRow(
color = fullColor, color = fullColor,
) )
FeedbackButton( FeedbackButton(
imageVector = Icons.Default.ArrowCircleUp, imageVector = Icons.Default.AddCircleOutline,
tintColor = MaterialTheme.colorScheme.secondary, tintColor = MaterialTheme.colorScheme.secondary,
onClick = onIncrement, onClick = onIncrement,
) )

View File

@ -1,82 +0,0 @@
package com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
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.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import cafe.adriel.voyager.core.screen.Screen
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.components.BottomSheetHeader
import com.github.diegoberaldin.raccoonforlemmy.core.l10n.LocalXmlStrings
import com.github.diegoberaldin.raccoonforlemmy.core.navigation.di.getNavigationCoordinator
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.NotificationCenterEvent
import com.github.diegoberaldin.raccoonforlemmy.core.notifications.di.getNotificationCenter
import com.github.diegoberaldin.raccoonforlemmy.core.utils.compose.onClick
class CommentBarThicknessBottomSheet(
private val values: List<Int> = listOf(
1,
2,
3,
),
) : Screen {
@Composable
override fun Content() {
val navigationCoordinator = remember { getNavigationCoordinator() }
val notificationCenter = remember { getNotificationCenter() }
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(LocalXmlStrings.current.settingsCommentBarThickness)
Column(
modifier = Modifier.fillMaxWidth().verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(Spacing.xxs),
) {
for (value in values) {
Row(
modifier = Modifier
.padding(
horizontal = Spacing.s,
vertical = Spacing.s,
)
.fillMaxWidth()
.onClick(
onClick = {
notificationCenter.send(
NotificationCenterEvent.ChangeCommentBarThickness(value)
)
navigationCoordinator.hideBottomSheet()
},
),
) {
Text(
text = value.toString(),
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onBackground,
)
}
}
}
}
}
}

View File

@ -17,6 +17,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import cafe.adriel.voyager.core.screen.Screen import cafe.adriel.voyager.core.screen.Screen
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
@ -46,6 +47,7 @@ class SliderBottomSheet(
bottom = Spacing.m, bottom = Spacing.m,
), ),
verticalArrangement = Arrangement.spacedBy(Spacing.s), verticalArrangement = Arrangement.spacedBy(Spacing.s),
horizontalAlignment = Alignment.CenterHorizontally,
) { ) {
BottomSheetHeader(LocalXmlStrings.current.settingsZombieModeScrollAmount) BottomSheetHeader(LocalXmlStrings.current.settingsZombieModeScrollAmount)
var value by remember { var value by remember {

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">ناسب الحجم</string> <string name="content_scale_fit">ناسب الحجم</string>
<string name="content_scale_fill_width">ملء العرض</string> <string name="content_scale_fill_width">ملء العرض</string>
<string name="content_scale_fill_height">ملء الارتفاع</string> <string name="content_scale_fill_height">ملء الارتفاع</string>
<string name="settings_comment_indent_amount">عرض المسافة البادئة للتعليقات</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Съответства на размера</string> <string name="content_scale_fit">Съответства на размера</string>
<string name="content_scale_fill_width">Попълнете ширината</string> <string name="content_scale_fill_width">Попълнете ширината</string>
<string name="content_scale_fill_height">Запълнете височината</string> <string name="content_scale_fill_height">Запълнете височината</string>
<string name="settings_comment_indent_amount">Ширина на отстъпа на коментарите</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Přizpůsobit velikost</string> <string name="content_scale_fit">Přizpůsobit velikost</string>
<string name="content_scale_fill_width">Vyplňte šířku</string> <string name="content_scale_fill_width">Vyplňte šířku</string>
<string name="content_scale_fill_height">Vyplňte výšku</string> <string name="content_scale_fill_height">Vyplňte výšku</string>
<string name="settings_comment_indent_amount">Šířka odsazení komentářů</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Tilpas størrelsen</string> <string name="content_scale_fit">Tilpas størrelsen</string>
<string name="content_scale_fill_width">Fyld bredden</string> <string name="content_scale_fill_width">Fyld bredden</string>
<string name="content_scale_fill_height">Fyld højden</string> <string name="content_scale_fill_height">Fyld højden</string>
<string name="settings_comment_indent_amount">Bredde på indrykning af kommentarer</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Passen Sie die Größe an</string> <string name="content_scale_fit">Passen Sie die Größe an</string>
<string name="content_scale_fill_width">Füllen Sie die Breite</string> <string name="content_scale_fill_width">Füllen Sie die Breite</string>
<string name="content_scale_fill_height">Füllen Sie die Höhe aus</string> <string name="content_scale_fill_height">Füllen Sie die Höhe aus</string>
<string name="settings_comment_indent_amount">Breite der Einrückung von Kommentaren</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Ταιριάζει στο μέγεθος</string> <string name="content_scale_fit">Ταιριάζει στο μέγεθος</string>
<string name="content_scale_fill_width">Γεμίστε το πλάτος</string> <string name="content_scale_fill_width">Γεμίστε το πλάτος</string>
<string name="content_scale_fill_height">Συμπληρώστε το ύψος</string> <string name="content_scale_fill_height">Συμπληρώστε το ύψος</string>
<string name="settings_comment_indent_amount">Πλάτος εσοχής σχολίων</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Konveni la grandecon</string> <string name="content_scale_fit">Konveni la grandecon</string>
<string name="content_scale_fill_width">Plenigi la larĝon</string> <string name="content_scale_fill_width">Plenigi la larĝon</string>
<string name="content_scale_fill_height">Plenigi la altecon</string> <string name="content_scale_fill_height">Plenigi la altecon</string>
<string name="settings_comment_indent_amount">Larĝeco de indentaĵo de komentoj</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Ajustar el tamaño</string> <string name="content_scale_fit">Ajustar el tamaño</string>
<string name="content_scale_fill_width">Llenar el ancho</string> <string name="content_scale_fill_width">Llenar el ancho</string>
<string name="content_scale_fill_height">Llenar la altura</string> <string name="content_scale_fill_height">Llenar la altura</string>
<string name="settings_comment_indent_amount">Ancho de indentación de los comentarios</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Sobivad suurusele</string> <string name="content_scale_fit">Sobivad suurusele</string>
<string name="content_scale_fill_width">Täida laius</string> <string name="content_scale_fill_width">Täida laius</string>
<string name="content_scale_fill_height">Täida kõrgus</string> <string name="content_scale_fill_height">Täida kõrgus</string>
<string name="settings_comment_indent_amount">Kommentaaride taande laius</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Sopiva kokoon</string> <string name="content_scale_fit">Sopiva kokoon</string>
<string name="content_scale_fill_width">Täytä leveys</string> <string name="content_scale_fill_width">Täytä leveys</string>
<string name="content_scale_fill_height">Täytä korkeus</string> <string name="content_scale_fill_height">Täytä korkeus</string>
<string name="settings_comment_indent_amount">Kommenttien sisennyksen leveys</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Ajuster la taille</string> <string name="content_scale_fit">Ajuster la taille</string>
<string name="content_scale_fill_width">Remplissez la largeur</string> <string name="content_scale_fill_width">Remplissez la largeur</string>
<string name="content_scale_fill_height">Remplissez la hauteur</string> <string name="content_scale_fill_height">Remplissez la hauteur</string>
<string name="settings_comment_indent_amount">Largeur d\'indentation des commentaires</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Fit an méid</string> <string name="content_scale_fit">Fit an méid</string>
<string name="content_scale_fill_width">Líon isteach an leithead</string> <string name="content_scale_fill_width">Líon isteach an leithead</string>
<string name="content_scale_fill_height">Líon an airde</string> <string name="content_scale_fill_height">Líon an airde</string>
<string name="settings_comment_indent_amount">Leithead eangú na dtuairimí</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Odgovara veličini</string> <string name="content_scale_fit">Odgovara veličini</string>
<string name="content_scale_fill_width">Ispunite širinu</string> <string name="content_scale_fill_width">Ispunite širinu</string>
<string name="content_scale_fill_height">Ispunite visinu</string> <string name="content_scale_fill_height">Ispunite visinu</string>
<string name="settings_comment_indent_amount">Širina uvlačenja komentara</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Illessze a méretet</string> <string name="content_scale_fit">Illessze a méretet</string>
<string name="content_scale_fill_width">Töltse ki a szélességet</string> <string name="content_scale_fill_width">Töltse ki a szélességet</string>
<string name="content_scale_fill_height">Töltse ki a magasságot</string> <string name="content_scale_fill_height">Töltse ki a magasságot</string>
<string name="settings_comment_indent_amount">A megjegyzések behúzásának szélessége</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Adatta alla dimensione</string> <string name="content_scale_fit">Adatta alla dimensione</string>
<string name="content_scale_fill_width">Adatta alla larghezza</string> <string name="content_scale_fill_width">Adatta alla larghezza</string>
<string name="content_scale_fill_height">Adatta alla altezza</string> <string name="content_scale_fill_height">Adatta alla altezza</string>
<string name="settings_comment_indent_amount">Larghezza rientro dei commenti</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Atitinka dydį</string> <string name="content_scale_fit">Atitinka dydį</string>
<string name="content_scale_fill_width">Užpildykite plotį</string> <string name="content_scale_fill_width">Užpildykite plotį</string>
<string name="content_scale_fill_height">Užpildykite aukštį</string> <string name="content_scale_fill_height">Užpildykite aukštį</string>
<string name="settings_comment_indent_amount">Komentarų įtraukos plotis</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Atbilst izmēram</string> <string name="content_scale_fit">Atbilst izmēram</string>
<string name="content_scale_fill_width">Aizpildiet platumu</string> <string name="content_scale_fill_width">Aizpildiet platumu</string>
<string name="content_scale_fill_height">Aizpildiet augstumu</string> <string name="content_scale_fill_height">Aizpildiet augstumu</string>
<string name="settings_comment_indent_amount">Komentāru atkāpes platums</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Waħħal id-daqs</string> <string name="content_scale_fit">Waħħal id-daqs</string>
<string name="content_scale_fill_width">Imla l-wisa</string> <string name="content_scale_fill_width">Imla l-wisa</string>
<string name="content_scale_fill_height">Imla l-għoli</string> <string name="content_scale_fill_height">Imla l-għoli</string>
<string name="settings_comment_indent_amount">Wisa\' ta\' indentazzjoni tal-kummenti</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Pas de maat aan</string> <string name="content_scale_fit">Pas de maat aan</string>
<string name="content_scale_fill_width">Vul de breedte</string> <string name="content_scale_fill_width">Vul de breedte</string>
<string name="content_scale_fill_height">Vul de hoogte</string> <string name="content_scale_fill_height">Vul de hoogte</string>
<string name="settings_comment_indent_amount">Breedte van de inspringing van opmerkingen</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Passer størrelsen</string> <string name="content_scale_fit">Passer størrelsen</string>
<string name="content_scale_fill_width">Fyll bredden</string> <string name="content_scale_fill_width">Fyll bredden</string>
<string name="content_scale_fill_height">Fyll høyden</string> <string name="content_scale_fill_height">Fyll høyden</string>
<string name="settings_comment_indent_amount">Bredde på innrykk av kommentarer</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Dopasuj rozmiar</string> <string name="content_scale_fit">Dopasuj rozmiar</string>
<string name="content_scale_fill_width">Wypełnij szerokość</string> <string name="content_scale_fill_width">Wypełnij szerokość</string>
<string name="content_scale_fill_height">Wypełnij wysokość</string> <string name="content_scale_fill_height">Wypełnij wysokość</string>
<string name="settings_comment_indent_amount">Szerokość wcięcia komentarzy</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Ajuste o tamanho</string> <string name="content_scale_fit">Ajuste o tamanho</string>
<string name="content_scale_fill_width">Preencha a largura</string> <string name="content_scale_fill_width">Preencha a largura</string>
<string name="content_scale_fill_height">Preencha a altura</string> <string name="content_scale_fill_height">Preencha a altura</string>
<string name="settings_comment_indent_amount">Largura de recuo dos comentários</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Ajuste o tamanho</string> <string name="content_scale_fit">Ajuste o tamanho</string>
<string name="content_scale_fill_width">Preencha a largura</string> <string name="content_scale_fill_width">Preencha a largura</string>
<string name="content_scale_fill_height">Preencha a altura</string> <string name="content_scale_fill_height">Preencha a altura</string>
<string name="settings_comment_indent_amount">Largura de recuo dos comentários</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Se potrivește mărimii</string> <string name="content_scale_fit">Se potrivește mărimii</string>
<string name="content_scale_fill_width">Umpleți lățimea</string> <string name="content_scale_fill_width">Umpleți lățimea</string>
<string name="content_scale_fill_height">Umpleți înălțimea</string> <string name="content_scale_fill_height">Umpleți înălțimea</string>
<string name="settings_comment_indent_amount">Lățimea indentării comentariilor</string>
</resources> </resources>

View File

@ -392,4 +392,5 @@
<string name="content_scale_fit">Подогнать размер</string> <string name="content_scale_fit">Подогнать размер</string>
<string name="content_scale_fill_width">Заполните ширину</string> <string name="content_scale_fill_width">Заполните ширину</string>
<string name="content_scale_fill_height">Заполните высоту</string> <string name="content_scale_fill_height">Заполните высоту</string>
<string name="settings_comment_indent_amount">Ширина отступа комментариев</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Passa storleken</string> <string name="content_scale_fit">Passa storleken</string>
<string name="content_scale_fill_width">Fyll bredden</string> <string name="content_scale_fill_width">Fyll bredden</string>
<string name="content_scale_fill_height">Fyll höjden</string> <string name="content_scale_fill_height">Fyll höjden</string>
<string name="settings_comment_indent_amount">Bredd på indrag av kommentarer</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Prispôsobte sa veľkosti</string> <string name="content_scale_fit">Prispôsobte sa veľkosti</string>
<string name="content_scale_fill_width">Vyplňte šírku</string> <string name="content_scale_fill_width">Vyplňte šírku</string>
<string name="content_scale_fill_height">Vyplňte výšku</string> <string name="content_scale_fill_height">Vyplňte výšku</string>
<string name="settings_comment_indent_amount">Šírka odsadenia komentárov</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Prilagodite velikost</string> <string name="content_scale_fit">Prilagodite velikost</string>
<string name="content_scale_fill_width">Izpolnite širino</string> <string name="content_scale_fill_width">Izpolnite širino</string>
<string name="content_scale_fill_height">Izpolnite višino</string> <string name="content_scale_fill_height">Izpolnite višino</string>
<string name="settings_comment_indent_amount">Širina zamika komentarjev</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Përshtatet me madhësinë</string> <string name="content_scale_fit">Përshtatet me madhësinë</string>
<string name="content_scale_fill_width">Mbushni gjerësinë</string> <string name="content_scale_fill_width">Mbushni gjerësinë</string>
<string name="content_scale_fill_height">Mbushni lartësinë</string> <string name="content_scale_fill_height">Mbushni lartësinë</string>
<string name="settings_comment_indent_amount">Gjerësia e dhëmbëzimit të komenteve</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Прилагодите величину</string> <string name="content_scale_fit">Прилагодите величину</string>
<string name="content_scale_fill_width">Попуните ширину</string> <string name="content_scale_fill_width">Попуните ширину</string>
<string name="content_scale_fill_height">Попуните висину</string> <string name="content_scale_fill_height">Попуните висину</string>
<string name="settings_comment_indent_amount">Ширина увлачења коментара</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">suli tu</string> <string name="content_scale_fit">suli tu</string>
<string name="content_scale_fill_width">suli poka</string> <string name="content_scale_fill_width">suli poka</string>
<string name="content_scale_fill_height">suli sewi</string> <string name="content_scale_fill_height">suli sewi</string>
<string name="settings_comment_indent_amount">suli poka pi toki lili</string>
</resources> </resources>

View File

@ -393,4 +393,5 @@
<string name="content_scale_fit">Boyutu sığdır</string> <string name="content_scale_fit">Boyutu sığdır</string>
<string name="content_scale_fill_width">Genişliği doldurun</string> <string name="content_scale_fill_width">Genişliği doldurun</string>
<string name="content_scale_fill_height">Yüksekliği doldurun</string> <string name="content_scale_fill_height">Yüksekliği doldurun</string>
<string name="settings_comment_indent_amount">Yorum girintisinin genişliği</string>
</resources> </resources>

View File

@ -392,4 +392,5 @@
<string name="content_scale_fit">Підходить за розміром</string> <string name="content_scale_fit">Підходить за розміром</string>
<string name="content_scale_fill_width">Заповнити ширину</string> <string name="content_scale_fill_width">Заповнити ширину</string>
<string name="content_scale_fill_height">Заповнити висоту</string> <string name="content_scale_fill_height">Заповнити висоту</string>
<string name="settings_comment_indent_amount">Ширина відступу коментарів</string>
</resources> </resources>

View File

@ -401,4 +401,5 @@
<string name="content_scale_fit">Aspect fit</string> <string name="content_scale_fit">Aspect fit</string>
<string name="content_scale_fill_width">Fill width</string> <string name="content_scale_fill_width">Fill width</string>
<string name="content_scale_fill_height">Fill height</string> <string name="content_scale_fill_height">Fill height</string>
<string name="settings_comment_indent_amount">Comment indentation amount</string>
</resources> </resources>

View File

@ -66,7 +66,6 @@ sealed interface NotificationCenterEvent {
data class UserBannedPost(val postId: Long, val user: UserModel) : NotificationCenterEvent data class UserBannedPost(val postId: Long, val user: UserModel) : NotificationCenterEvent
data class UserBannedComment(val commentId: Long, val user: UserModel) : NotificationCenterEvent data class UserBannedComment(val commentId: Long, val user: UserModel) : NotificationCenterEvent
data class ChangeCommentBarTheme(val value: CommentBarTheme) : NotificationCenterEvent data class ChangeCommentBarTheme(val value: CommentBarTheme) : NotificationCenterEvent
data class ChangeCommentBarThickness(val value: Int) : NotificationCenterEvent
data class BlockActionSelected( data class BlockActionSelected(
val userId: Long? = null, val userId: Long? = null,
val communityId: Long? = null, val communityId: Long? = null,

View File

@ -61,4 +61,5 @@ data class SettingsModel(
val fadeReadPosts: Boolean = false, val fadeReadPosts: Boolean = false,
val showUnreadComments: Boolean = false, val showUnreadComments: Boolean = false,
val enableButtonsToScrollBetweenComments: Boolean = false, val enableButtonsToScrollBetweenComments: Boolean = false,
val commentIndentAmount: Int = 2,
) )

View File

@ -63,6 +63,7 @@ private object KeyStoreKeys {
const val FADE_READ_POSTS = "fadeReadPosts" const val FADE_READ_POSTS = "fadeReadPosts"
const val ENABLE_BUTTONS_TO_SCROLL_BETWEEN_COMMENTS = "enableButtonsToScrollBetweenComments" const val ENABLE_BUTTONS_TO_SCROLL_BETWEEN_COMMENTS = "enableButtonsToScrollBetweenComments"
const val FULL_WIDTH_IMAGES = "fullWidthImages" const val FULL_WIDTH_IMAGES = "fullWidthImages"
const val COMMENT_INDENT_AMOUNT = "commentIndentAmount"
} }
internal class DefaultSettingsRepository( internal class DefaultSettingsRepository(
@ -133,6 +134,7 @@ internal class DefaultSettingsRepository(
showScores = if (settings.showScores) 1L else 0L, showScores = if (settings.showScores) 1L else 0L,
preferUserNicknames = if (settings.preferUserNicknames) 1L else 0L, preferUserNicknames = if (settings.preferUserNicknames) 1L else 0L,
commentBarThickness = settings.commentBarThickness.toLong(), commentBarThickness = settings.commentBarThickness.toLong(),
commentIndentAmount = settings.commentIndentAmount.toLong(),
imageSourcePath = if (settings.imageSourcePath) 1L else 0L, imageSourcePath = if (settings.imageSourcePath) 1L else 0L,
defaultExploreType = settings.defaultExploreType.toLong(), defaultExploreType = settings.defaultExploreType.toLong(),
defaultLanguageId = settings.defaultLanguageId, defaultLanguageId = settings.defaultLanguageId,
@ -200,6 +202,7 @@ internal class DefaultSettingsRepository(
showScores = keyStore[KeyStoreKeys.SHOW_SCORES, true], showScores = keyStore[KeyStoreKeys.SHOW_SCORES, true],
preferUserNicknames = keyStore[KeyStoreKeys.PREFER_USER_NICKNAMES, true], preferUserNicknames = keyStore[KeyStoreKeys.PREFER_USER_NICKNAMES, true],
commentBarThickness = keyStore[KeyStoreKeys.COMMENT_BAR_THICKNESS, 1], commentBarThickness = keyStore[KeyStoreKeys.COMMENT_BAR_THICKNESS, 1],
commentIndentAmount = keyStore[KeyStoreKeys.COMMENT_INDENT_AMOUNT, 2],
imageSourcePath = keyStore[KeyStoreKeys.IMAGE_SOURCE_PATH, false], imageSourcePath = keyStore[KeyStoreKeys.IMAGE_SOURCE_PATH, false],
defaultLanguageId = if (keyStore.containsKey(KeyStoreKeys.DEFAULT_LANGUAGE_ID)) { defaultLanguageId = if (keyStore.containsKey(KeyStoreKeys.DEFAULT_LANGUAGE_ID)) {
keyStore[KeyStoreKeys.DEFAULT_LANGUAGE_ID, 0L] keyStore[KeyStoreKeys.DEFAULT_LANGUAGE_ID, 0L]
@ -308,6 +311,7 @@ internal class DefaultSettingsRepository(
keyStore.save(KeyStoreKeys.SHOW_SCORES, settings.showScores) keyStore.save(KeyStoreKeys.SHOW_SCORES, settings.showScores)
keyStore.save(KeyStoreKeys.PREFER_USER_NICKNAMES, settings.preferUserNicknames) keyStore.save(KeyStoreKeys.PREFER_USER_NICKNAMES, settings.preferUserNicknames)
keyStore.save(KeyStoreKeys.COMMENT_BAR_THICKNESS, settings.commentBarThickness) keyStore.save(KeyStoreKeys.COMMENT_BAR_THICKNESS, settings.commentBarThickness)
keyStore.save(KeyStoreKeys.COMMENT_INDENT_AMOUNT, settings.commentIndentAmount)
keyStore.save(KeyStoreKeys.IMAGE_SOURCE_PATH, settings.imageSourcePath) keyStore.save(KeyStoreKeys.IMAGE_SOURCE_PATH, settings.imageSourcePath)
if (settings.defaultLanguageId != null) { if (settings.defaultLanguageId != null) {
keyStore.save(KeyStoreKeys.DEFAULT_LANGUAGE_ID, settings.defaultLanguageId) keyStore.save(KeyStoreKeys.DEFAULT_LANGUAGE_ID, settings.defaultLanguageId)
@ -378,6 +382,7 @@ internal class DefaultSettingsRepository(
showScores = if (settings.showScores) 1L else 0L, showScores = if (settings.showScores) 1L else 0L,
preferUserNicknames = if (settings.preferUserNicknames) 1L else 0L, preferUserNicknames = if (settings.preferUserNicknames) 1L else 0L,
commentBarThickness = settings.commentBarThickness.toLong(), commentBarThickness = settings.commentBarThickness.toLong(),
commentIndentAmount = settings.commentIndentAmount.toLong(),
imageSourcePath = if (settings.imageSourcePath) 1L else 0L, imageSourcePath = if (settings.imageSourcePath) 1L else 0L,
defaultExploreType = settings.defaultExploreType.toLong(), defaultExploreType = settings.defaultExploreType.toLong(),
defaultLanguageId = settings.defaultLanguageId, defaultLanguageId = settings.defaultLanguageId,
@ -460,6 +465,7 @@ private fun GetBy.toModel() = SettingsModel(
showScores = showScores == 1L, showScores = showScores == 1L,
preferUserNicknames = preferUserNicknames == 1L, preferUserNicknames = preferUserNicknames == 1L,
commentBarThickness = commentBarThickness.toInt(), commentBarThickness = commentBarThickness.toInt(),
commentIndentAmount = commentIndentAmount.toInt(),
imageSourcePath = imageSourcePath == 1L, imageSourcePath = imageSourcePath == 1L,
defaultExploreType = defaultExploreType.toInt(), defaultExploreType = defaultExploreType.toInt(),
defaultLanguageId = defaultLanguageId, defaultLanguageId = defaultLanguageId,

View File

@ -65,6 +65,7 @@ internal data class SerializableSettings(
val showScores: Boolean = true, val showScores: Boolean = true,
val preferUserNicknames: Boolean = true, val preferUserNicknames: Boolean = true,
val commentBarThickness: Int = 1, val commentBarThickness: Int = 1,
val commentIndentAmount: Int = 2,
val imageSourcePath: Boolean = false, val imageSourcePath: Boolean = false,
val defaultLanguageId: Long? = null, val defaultLanguageId: Long? = null,
val inboxBackgroundCheckPeriod: Duration? = null, val inboxBackgroundCheckPeriod: Duration? = null,
@ -127,6 +128,7 @@ internal fun SerializableSettings.toModel() = SettingsModel(
showScores = showScores, showScores = showScores,
preferUserNicknames = preferUserNicknames, preferUserNicknames = preferUserNicknames,
commentBarThickness = commentBarThickness, commentBarThickness = commentBarThickness,
commentIndentAmount = commentIndentAmount,
imageSourcePath = imageSourcePath, imageSourcePath = imageSourcePath,
defaultLanguageId = defaultLanguageId, defaultLanguageId = defaultLanguageId,
inboxBackgroundCheckPeriod = inboxBackgroundCheckPeriod, inboxBackgroundCheckPeriod = inboxBackgroundCheckPeriod,
@ -184,6 +186,7 @@ internal fun SettingsModel.toData() = SerializableSettings(
showScores = showScores, showScores = showScores,
preferUserNicknames = preferUserNicknames, preferUserNicknames = preferUserNicknames,
commentBarThickness = commentBarThickness, commentBarThickness = commentBarThickness,
commentIndentAmount= commentIndentAmount,
imageSourcePath = imageSourcePath, imageSourcePath = imageSourcePath,
defaultLanguageId = defaultLanguageId, defaultLanguageId = defaultLanguageId,
inboxBackgroundCheckPeriod = inboxBackgroundCheckPeriod, inboxBackgroundCheckPeriod = inboxBackgroundCheckPeriod,

View File

@ -49,7 +49,7 @@ CREATE TABLE SettingsEntity (
opaqueSystemBars INTEGER DEFAULT NULL, opaqueSystemBars INTEGER DEFAULT NULL,
showScores INTEGER NOT NULL DEFAULT 1, showScores INTEGER NOT NULL DEFAULT 1,
preferUserNicknames INTEGER NOT NULL DEFAULT 1, preferUserNicknames INTEGER NOT NULL DEFAULT 1,
commentBarThickness INTEGER NOT NULL DEFAULT 0, commentBarThickness INTEGER NOT NULL DEFAULT 1,
imageSourcePath INTEGER NOT NULL DEFAULT 0, imageSourcePath INTEGER NOT NULL DEFAULT 0,
defaultExploreType INTEGER NOT NULL DEFAULT 2, defaultExploreType INTEGER NOT NULL DEFAULT 2,
defaultLanguageId INTEGER DEFAULT NULL, defaultLanguageId INTEGER DEFAULT NULL,
@ -58,6 +58,7 @@ CREATE TABLE SettingsEntity (
showUnreadComments INTEGER NOT NULL DEFAULT 0, showUnreadComments INTEGER NOT NULL DEFAULT 0,
enableButtonsToScrollBetweenComments INTEGER NOT NULL DEFAULT 0, enableButtonsToScrollBetweenComments INTEGER NOT NULL DEFAULT 0,
fullWidthImages INTEGER NOT NULL DEFAULT 0, fullWidthImages INTEGER NOT NULL DEFAULT 0,
commentIndentAmount INTEGER NOT NULL DEFAULT 2,
FOREIGN KEY (account_id) REFERENCES AccountEntity(id) ON DELETE CASCADE, FOREIGN KEY (account_id) REFERENCES AccountEntity(id) ON DELETE CASCADE,
UNIQUE(account_id) UNIQUE(account_id)
); );
@ -121,6 +122,7 @@ INSERT OR IGNORE INTO SettingsEntity (
showUnreadComments, showUnreadComments,
enableButtonsToScrollBetweenComments, enableButtonsToScrollBetweenComments,
fullWidthImages, fullWidthImages,
commentIndentAmount,
account_id account_id
) VALUES ( ) VALUES (
?, ?,
@ -180,6 +182,7 @@ INSERT OR IGNORE INTO SettingsEntity (
?, ?,
?, ?,
?, ?,
?,
? ?
); );
@ -241,7 +244,8 @@ SET theme = ?,
fadeReadPosts = ?, fadeReadPosts = ?,
showUnreadComments = ?, showUnreadComments = ?,
enableButtonsToScrollBetweenComments = ?, enableButtonsToScrollBetweenComments = ?,
fullWidthImages = ? fullWidthImages = ?,
commentIndentAmount = ?
WHERE account_id = ?; WHERE account_id = ?;
getBy: getBy:
@ -303,6 +307,7 @@ SELECT
fadeReadPosts, fadeReadPosts,
showUnreadComments, showUnreadComments,
enableButtonsToScrollBetweenComments, enableButtonsToScrollBetweenComments,
fullWidthImages fullWidthImages,
commentIndentAmount
FROM SettingsEntity FROM SettingsEntity
WHERE account_id = ?; WHERE account_id = ?;

View File

@ -1,2 +1,2 @@
ALTER TABLE SettingsEntity ALTER TABLE SettingsEntity
ADD COLUMN commentBarTheme INTEGER NOT NULL DEFAULT 0; ADD COLUMN commentBarTheme INTEGER NOT NULL DEFAULT 1;

View File

@ -0,0 +1,2 @@
ALTER TABLE SettingsEntity
ADD COLUMN commentIndentAmount INTEGER NOT NULL DEFAULT 2;

View File

@ -124,7 +124,6 @@ fun App(onLoadingFinished: () -> Unit = {}) {
changeUiFontFamily(currentSettings.uiFontFamily.toUiFontFamily()) changeUiFontFamily(currentSettings.uiFontFamily.toUiFontFamily())
changeContentFontFamily(currentSettings.contentFontFamily.toUiFontFamily()) changeContentFontFamily(currentSettings.contentFontFamily.toUiFontFamily())
changeCommentBarTheme(currentSettings.commentBarTheme.toCommentBarTheme()) changeCommentBarTheme(currentSettings.commentBarTheme.toCommentBarTheme())
changeCommentBarThickness(currentSettings.commentBarThickness)
with(themeRepository) { with(themeRepository) {
changeUpVoteColor(currentSettings.upVoteColor?.let { Color(it) }) changeUpVoteColor(currentSettings.upVoteColor?.let { Color(it) })

View File

@ -16,12 +16,17 @@ interface ConfigureContentViewMviModel :
data class ChangePreferUserNicknames(val value: Boolean) : Intent data class ChangePreferUserNicknames(val value: Boolean) : Intent
data class ChangeFullHeightImages(val value: Boolean) : Intent data class ChangeFullHeightImages(val value: Boolean) : Intent
data class ChangeFullWidthImages(val value: Boolean) : Intent data class ChangeFullWidthImages(val value: Boolean) : Intent
data object IncrementCommentBarThickness : Intent
data object DecrementCommentBarThickness : Intent
data object IncrementCommentIndentAmount : Intent
data object DecrementCommentIndentAmount : Intent
} }
data class State( data class State(
val postLayout: PostLayout = PostLayout.Card, val postLayout: PostLayout = PostLayout.Card,
val commentBarTheme: CommentBarTheme = CommentBarTheme.Blue, val commentBarTheme: CommentBarTheme = CommentBarTheme.Blue,
val commentBarThickness: Int = 1, val commentBarThickness: Int = 1,
val commentIndentAmount: Int = 2,
val contentFontScale: ContentFontScales = ContentFontScales(), val contentFontScale: ContentFontScales = ContentFontScales(),
val contentFontFamily: UiFontFamily = UiFontFamily.Poppins, val contentFontFamily: UiFontFamily = UiFontFamily.Poppins,
val voteFormat: VoteFormat = VoteFormat.Aggregated, val voteFormat: VoteFormat = VoteFormat.Aggregated,

View File

@ -39,9 +39,9 @@ import com.github.diegoberaldin.raccoonforlemmy.core.appearance.data.toReadableN
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.repository.ContentFontClass import com.github.diegoberaldin.raccoonforlemmy.core.appearance.repository.ContentFontClass
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.SettingsHeader import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.SettingsHeader
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.SettingsIntValueRow
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.SettingsRow import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.SettingsRow
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.SettingsSwitchRow import com.github.diegoberaldin.raccoonforlemmy.core.commonui.lemmyui.SettingsSwitchRow
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.CommentBarThicknessBottomSheet
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.PostBodyMaxLinesBottomSheet import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.PostBodyMaxLinesBottomSheet
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.PostLayoutBottomSheet import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.PostLayoutBottomSheet
import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.VoteFormatBottomSheet import com.github.diegoberaldin.raccoonforlemmy.core.commonui.modals.VoteFormatBottomSheet
@ -230,13 +230,27 @@ class ConfigureContentViewScreen : Screen {
) )
// comment bar thickness // comment bar thickness
SettingsRow( SettingsIntValueRow(
title = LocalXmlStrings.current.settingsCommentBarThickness, title = LocalXmlStrings.current.settingsCommentBarThickness,
value = uiState.commentBarThickness.toString(), value = uiState.commentBarThickness,
onTap = rememberCallback { onIncrement = rememberCallback(model) {
val screen = CommentBarThicknessBottomSheet() model.reduce(ConfigureContentViewMviModel.Intent.IncrementCommentBarThickness)
navigationCoordinator.showBottomSheet(screen) },
} onDecrement = rememberCallback(model) {
model.reduce(ConfigureContentViewMviModel.Intent.DecrementCommentBarThickness)
},
)
// comment indent amount
SettingsIntValueRow(
title = LocalXmlStrings.current.settingsCommentIndentAmount,
value = uiState.commentIndentAmount,
onIncrement = rememberCallback(model) {
model.reduce(ConfigureContentViewMviModel.Intent.IncrementCommentIndentAmount)
},
onDecrement = rememberCallback(model) {
model.reduce(ConfigureContentViewMviModel.Intent.DecrementCommentIndentAmount)
},
) )
SettingsHeader( SettingsHeader(
@ -245,12 +259,16 @@ class ConfigureContentViewScreen : Screen {
) )
// preview // preview
ContentPreview( ContentPreview(
modifier = Modifier.padding(top = Spacing.xxs),
postLayout = uiState.postLayout, postLayout = uiState.postLayout,
preferNicknames = uiState.preferUserNicknames, preferNicknames = uiState.preferUserNicknames,
showScores = uiState.voteFormat != VoteFormat.Hidden, showScores = uiState.voteFormat != VoteFormat.Hidden,
voteFormat = uiState.voteFormat, voteFormat = uiState.voteFormat,
fullHeightImage = uiState.fullHeightImages, fullHeightImage = uiState.fullHeightImages,
fullWidthImage = uiState.fullWidthImages, fullWidthImage = uiState.fullWidthImages,
commentBarThickness = uiState.commentBarThickness,
commentIndentAmount = uiState.commentIndentAmount,
) )
Spacer(modifier = Modifier.height(Spacing.xxxl)) Spacer(modifier = Modifier.height(Spacing.xxxl))

View File

@ -19,6 +19,9 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
private val COMMENT_BAR_THICKNESS_RANGE = 1..5
private val COMMENT_INDENT_AMOUNT_RANGE = 1..20
class ConfigureContentViewViewModel( class ConfigureContentViewViewModel(
private val themeRepository: ThemeRepository, private val themeRepository: ThemeRepository,
private val settingsRepository: SettingsRepository, private val settingsRepository: SettingsRepository,
@ -40,9 +43,6 @@ class ConfigureContentViewViewModel(
themeRepository.contentFontFamily.onEach { value -> themeRepository.contentFontFamily.onEach { value ->
updateState { it.copy(contentFontFamily = value) } updateState { it.copy(contentFontFamily = value) }
}.launchIn(this) }.launchIn(this)
themeRepository.commentBarThickness.onEach { value ->
updateState { it.copy(commentBarThickness = value) }
}.launchIn(this)
notificationCenter.subscribe(NotificationCenterEvent.ChangePostLayout::class) notificationCenter.subscribe(NotificationCenterEvent.ChangePostLayout::class)
.onEach { evt -> .onEach { evt ->
@ -64,10 +64,6 @@ class ConfigureContentViewViewModel(
.onEach { evt -> .onEach { evt ->
changeContentFontFamily(evt.value) changeContentFontFamily(evt.value)
}.launchIn(this) }.launchIn(this)
notificationCenter.subscribe(NotificationCenterEvent.ChangeCommentBarThickness::class)
.onEach { evt ->
changeCommentBarThickness(evt.value)
}.launchIn(this)
val settings = settingsRepository.currentSettings.value val settings = settingsRepository.currentSettings.value
updateState { updateState {
@ -77,6 +73,8 @@ class ConfigureContentViewViewModel(
fullWidthImages = settings.fullWidthImages, fullWidthImages = settings.fullWidthImages,
postBodyMaxLines = settings.postBodyMaxLines, postBodyMaxLines = settings.postBodyMaxLines,
preferUserNicknames = settings.preferUserNicknames, preferUserNicknames = settings.preferUserNicknames,
commentBarThickness = settings.commentBarThickness,
commentIndentAmount = settings.commentIndentAmount,
) )
} }
} }
@ -84,18 +82,44 @@ class ConfigureContentViewViewModel(
override fun reduce(intent: ConfigureContentViewMviModel.Intent) { override fun reduce(intent: ConfigureContentViewMviModel.Intent) {
when (intent) { when (intent) {
is ConfigureContentViewMviModel.Intent.ChangeFullHeightImages -> changeFullHeightImages( is ConfigureContentViewMviModel.Intent.ChangeFullHeightImages -> {
changeFullHeightImages(
intent.value, intent.value,
) )
}
is ConfigureContentViewMviModel.Intent.ChangeFullWidthImages -> changeFullWidthImages( is ConfigureContentViewMviModel.Intent.ChangeFullWidthImages -> {
changeFullWidthImages(
intent.value, intent.value,
) )
}
is ConfigureContentViewMviModel.Intent.ChangePreferUserNicknames -> changePreferUserNicknames( is ConfigureContentViewMviModel.Intent.ChangePreferUserNicknames -> {
changePreferUserNicknames(
intent.value, intent.value,
) )
} }
ConfigureContentViewMviModel.Intent.IncrementCommentBarThickness -> {
val value = (uiState.value.commentBarThickness + 1).coerceIn(COMMENT_BAR_THICKNESS_RANGE)
changeCommentBarThickness(value)
}
ConfigureContentViewMviModel.Intent.DecrementCommentBarThickness -> {
val value = (uiState.value.commentBarThickness - 1).coerceIn(COMMENT_BAR_THICKNESS_RANGE)
changeCommentBarThickness(value)
}
ConfigureContentViewMviModel.Intent.IncrementCommentIndentAmount -> {
val value = (uiState.value.commentIndentAmount + 1).coerceIn(COMMENT_INDENT_AMOUNT_RANGE)
changeCommentIndentAmount(value)
}
ConfigureContentViewMviModel.Intent.DecrementCommentIndentAmount -> {
val value = (uiState.value.commentIndentAmount - 1).coerceIn(COMMENT_INDENT_AMOUNT_RANGE)
changeCommentIndentAmount(value)
}
}
} }
private fun changePostLayout(value: PostLayout) { private fun changePostLayout(value: PostLayout) {
@ -193,7 +217,7 @@ class ConfigureContentViewViewModel(
} }
private fun changeCommentBarThickness(value: Int) { private fun changeCommentBarThickness(value: Int) {
themeRepository.changeCommentBarThickness(value) updateState { it.copy(commentBarThickness = value) }
screenModelScope.launch(Dispatchers.IO) { screenModelScope.launch(Dispatchers.IO) {
val settings = settingsRepository.currentSettings.value.copy( val settings = settingsRepository.currentSettings.value.copy(
commentBarThickness = value, commentBarThickness = value,
@ -202,6 +226,16 @@ class ConfigureContentViewViewModel(
} }
} }
private fun changeCommentIndentAmount(value: Int) {
updateState { it.copy(commentIndentAmount = value) }
screenModelScope.launch(Dispatchers.IO) {
val settings = settingsRepository.currentSettings.value.copy(
commentIndentAmount = value,
)
saveSettings(settings)
}
}
private suspend fun saveSettings(settings: SettingsModel) { private suspend fun saveSettings(settings: SettingsModel) {
val accountId = accountRepository.getActive()?.id val accountId = accountRepository.getActive()?.id
settingsRepository.updateSettings(settings, accountId) settingsRepository.updateSettings(settings, accountId)

View File

@ -27,6 +27,8 @@ internal fun ContentPreview(
voteFormat: VoteFormat, voteFormat: VoteFormat,
fullHeightImage: Boolean, fullHeightImage: Boolean,
fullWidthImage : Boolean, fullWidthImage : Boolean,
commentBarThickness: Int,
commentIndentAmount: Int,
) { ) {
Column { Column {
PostCard( PostCard(
@ -53,6 +55,7 @@ internal fun ContentPreview(
voteFormat = voteFormat, voteFormat = voteFormat,
preferNicknames = preferNicknames, preferNicknames = preferNicknames,
showScores = showScores, showScores = showScores,
indentAmount = commentIndentAmount,
) )
HorizontalDivider( HorizontalDivider(
modifier = Modifier.padding(vertical = Spacing.xxxs), modifier = Modifier.padding(vertical = Spacing.xxxs),
@ -64,6 +67,20 @@ internal fun ContentPreview(
voteFormat = voteFormat, voteFormat = voteFormat,
preferNicknames = preferNicknames, preferNicknames = preferNicknames,
showScores = showScores, showScores = showScores,
barThickness = commentBarThickness,
indentAmount = commentIndentAmount,
)
HorizontalDivider(
modifier = Modifier.padding(vertical = Spacing.xxxs),
thickness = 0.25.dp
)
CommentCard(
comment = ContentPreviewData.comment3,
voteFormat = voteFormat,
preferNicknames = preferNicknames,
showScores = showScores,
barThickness = commentBarThickness,
indentAmount = commentIndentAmount,
) )
} }
} }
@ -111,7 +128,7 @@ velit esse cillum dolore eu fugiat nulla pariatur.
upvotes = 2, upvotes = 2,
downvotes = 1, downvotes = 1,
score = 1, score = 1,
comments = 1, comments = 2,
) )
val comment2 = CommentModel( val comment2 = CommentModel(
@ -128,4 +145,18 @@ velit esse cillum dolore eu fugiat nulla pariatur.
score = 1, score = 1,
comments = 1, comments = 1,
) )
val comment3 = CommentModel(
text = "Praesent sed congue leo, at hendrerit lorem.",
publishDate = "2024-01-03T12:00:00Z",
path = "0.1.2.3",
creator = UserModel(
name = "marysmith",
host = "example.com",
displayName = "Mary Smith",
),
upvotes = 1,
downvotes = -2,
score = -1,
comments = 0,
)
} }

View File

@ -248,7 +248,7 @@ class CreateCommentScreen(
modifier = referenceModifier, modifier = referenceModifier,
comment = originalComment, comment = originalComment,
preferNicknames = uiState.preferNicknames, preferNicknames = uiState.preferNicknames,
hideIndent = true, indentAmount = 0,
voteFormat = uiState.voteFormat, voteFormat = uiState.voteFormat,
autoLoadImages = uiState.autoLoadImages, autoLoadImages = uiState.autoLoadImages,
showScores = uiState.showScores, showScores = uiState.showScores,

View File

@ -639,7 +639,7 @@ class ExploreScreen(
showScores = uiState.showScores, showScores = uiState.showScores,
showBot = true, showBot = true,
showExpandedIndicator = false, showExpandedIndicator = false,
hideIndent = true, indentAmount = 0,
actionButtonsActive = uiState.isLogged, actionButtonsActive = uiState.isLogged,
onClick = { onClick = {
detailOpener.openPostDetail( detailOpener.openPostDetail(

View File

@ -91,7 +91,7 @@ fun ModdedCommentCard(
preferNicknames = preferNicknames, preferNicknames = preferNicknames,
showExpandedIndicator = false, showExpandedIndicator = false,
showBot = true, showBot = true,
hideIndent = true, indentAmount = 0,
onClick = onOpen, onClick = onOpen,
onOpenCreator = onOpenUser, onOpenCreator = onOpenUser,
onUpVote = onUpVote, onUpVote = onUpVote,

View File

@ -397,7 +397,7 @@ object ProfileLoggedScreen : Tab {
showScores = uiState.showScores, showScores = uiState.showScores,
hideCommunity = false, hideCommunity = false,
hideAuthor = true, hideAuthor = true,
hideIndent = true, indentAmount = 0,
onImageClick = rememberCallbackArgs { url -> onImageClick = rememberCallbackArgs { url ->
navigationCoordinator.pushScreen( navigationCoordinator.pushScreen(
ZoomableImageScreen( ZoomableImageScreen(

View File

@ -56,6 +56,8 @@ interface PostDetailMviModel :
val canFetchMore: Boolean = true, val canFetchMore: Boolean = true,
val sortType: SortType = SortType.New, val sortType: SortType = SortType.New,
val comments: List<CommentModel> = emptyList(), val comments: List<CommentModel> = emptyList(),
val commentBarThickness: Int = 1,
val commentIndentAmount: Int = 2,
val currentUserId: Long? = null, val currentUserId: Long? = null,
val swipeActionsEnabled: Boolean = true, val swipeActionsEnabled: Boolean = true,
val doubleTapActionEnabled: Boolean = true, val doubleTapActionEnabled: Boolean = true,

View File

@ -986,6 +986,8 @@ class PostDetailScreen(
comment = comment, comment = comment,
isOp = comment.creator?.id == uiState.post.creator?.id, isOp = comment.creator?.id == uiState.post.creator?.id,
showBot = true, showBot = true,
indentAmount = uiState.commentIndentAmount,
barThickness = uiState.commentBarThickness,
voteFormat = uiState.voteFormat, voteFormat = uiState.voteFormat,
autoLoadImages = uiState.autoLoadImages, autoLoadImages = uiState.autoLoadImages,
preferNicknames = uiState.preferNicknames, preferNicknames = uiState.preferNicknames,

View File

@ -110,6 +110,8 @@ class PostDetailViewModel(
actionsOnSwipeToEndComments = settings.actionsOnSwipeToEndComments, actionsOnSwipeToEndComments = settings.actionsOnSwipeToEndComments,
showScores = settings.showScores, showScores = settings.showScores,
enableButtonsToScrollBetweenComments = settings.enableButtonsToScrollBetweenComments, enableButtonsToScrollBetweenComments = settings.enableButtonsToScrollBetweenComments,
commentBarThickness = settings.commentBarThickness,
commentIndentAmount = settings.commentIndentAmount,
) )
} }
}.launchIn(this) }.launchIn(this)

View File

@ -384,7 +384,7 @@ class SavedItemsScreen : Screen {
preferNicknames = uiState.preferNicknames, preferNicknames = uiState.preferNicknames,
showScores = uiState.showScores, showScores = uiState.showScores,
showBot = true, showBot = true,
hideIndent = true, indentAmount = 0,
onClick = { onClick = {
detailOpener.openPostDetail( detailOpener.openPostDetail(
post = PostModel(id = comment.postId), post = PostModel(id = comment.postId),

View File

@ -910,7 +910,7 @@ class UserDetailScreen(
showScores = uiState.showScores, showScores = uiState.showScores,
hideCommunity = false, hideCommunity = false,
hideAuthor = true, hideAuthor = true,
hideIndent = true, indentAmount = 0,
actionButtonsActive = uiState.isLogged, actionButtonsActive = uiState.isLogged,
onClick = { onClick = {
detailOpener.openPostDetail( detailOpener.openPostDetail(