Moves community description and rules to a single Translateable text
This commit is contained in:
@@ -15,6 +15,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.AppBarDefaults
|
import androidx.compose.material.AppBarDefaults
|
||||||
import androidx.compose.material.ContentAlpha
|
import androidx.compose.material.ContentAlpha
|
||||||
import androidx.compose.material.Divider
|
import androidx.compose.material.Divider
|
||||||
@@ -108,6 +110,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.ShowVideoStreaming
|
|||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.SpinnerSelectionDialog
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.SpinnerSelectionDialog
|
||||||
import com.vitorpamplona.amethyst.ui.theme.BottomTopHeight
|
import com.vitorpamplona.amethyst.ui.theme.BottomTopHeight
|
||||||
import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer
|
import com.vitorpamplona.amethyst.ui.theme.DoubleHorzSpacer
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.HalfVertSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.HeaderPictureModifier
|
import com.vitorpamplona.amethyst.ui.theme.HeaderPictureModifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size22Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size22Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size34dp
|
import com.vitorpamplona.amethyst.ui.theme.Size34dp
|
||||||
@@ -231,7 +234,9 @@ private fun CommunityTopBar(
|
|||||||
ShortCommunityHeader(baseNote, fontWeight = FontWeight.Medium, accountViewModel, nav)
|
ShortCommunityHeader(baseNote, fontWeight = FontWeight.Medium, accountViewModel, nav)
|
||||||
},
|
},
|
||||||
extendableRow = {
|
extendableRow = {
|
||||||
LongCommunityHeader(baseNote = baseNote, accountViewModel = accountViewModel, nav = nav)
|
Column(Modifier.verticalScroll(rememberScrollState())) {
|
||||||
|
LongCommunityHeader(baseNote = baseNote, accountViewModel = accountViewModel, nav = nav)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
popBack = navPopBack
|
popBack = navPopBack
|
||||||
)
|
)
|
||||||
@@ -698,6 +703,7 @@ fun FlexibleTopBarWithBackButton(
|
|||||||
},
|
},
|
||||||
actions = {}
|
actions = {}
|
||||||
)
|
)
|
||||||
|
Spacer(modifier = HalfVertSpacer)
|
||||||
Divider(thickness = 0.25.dp)
|
Divider(thickness = 0.25.dp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,11 @@ import androidx.compose.foundation.layout.height
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.shape.CutCornerShape
|
import androidx.compose.foundation.shape.CutCornerShape
|
||||||
import androidx.compose.foundation.text.ClickableText
|
import androidx.compose.foundation.text.ClickableText
|
||||||
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.Button
|
import androidx.compose.material.Button
|
||||||
import androidx.compose.material.ButtonDefaults
|
import androidx.compose.material.ButtonDefaults
|
||||||
import androidx.compose.material.Divider
|
import androidx.compose.material.Divider
|
||||||
@@ -536,7 +538,14 @@ fun CommunityHeader(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (expanded.value) {
|
if (expanded.value) {
|
||||||
LongCommunityHeader(baseNote = baseNote, lineModifier = modifier, accountViewModel = accountViewModel, nav = nav)
|
Column(Modifier.verticalScroll(rememberScrollState())) {
|
||||||
|
LongCommunityHeader(
|
||||||
|
baseNote = baseNote,
|
||||||
|
lineModifier = modifier,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
nav = nav
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,8 +570,25 @@ fun LongCommunityHeader(
|
|||||||
Row(
|
Row(
|
||||||
lineModifier
|
lineModifier
|
||||||
) {
|
) {
|
||||||
|
val rulesLabel = stringResource(id = R.string.rules)
|
||||||
val summary = remember(noteState) {
|
val summary = remember(noteState) {
|
||||||
noteEvent.description()?.ifBlank { null }
|
val subject = noteEvent.subject()?.ifEmpty { null }
|
||||||
|
val body = noteEvent.description()?.ifBlank { null }
|
||||||
|
val rules = noteEvent.rules()?.ifBlank { null }
|
||||||
|
|
||||||
|
if (!subject.isNullOrBlank() && body?.split("\n")?.get(0)?.contains(subject) == false) {
|
||||||
|
if (rules == null) {
|
||||||
|
"## $subject\n$body"
|
||||||
|
} else {
|
||||||
|
"## $subject\n$body\n\n## $rulesLabel\n\n$rules"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (rules == null) {
|
||||||
|
body
|
||||||
|
} else {
|
||||||
|
"$body\n\n$rulesLabel\n$rules"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
@@ -596,31 +622,6 @@ fun LongCommunityHeader(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val rules = remember(noteState) {
|
|
||||||
noteEvent.rules()?.ifBlank { null }
|
|
||||||
}
|
|
||||||
|
|
||||||
rules?.let {
|
|
||||||
Row(
|
|
||||||
lineModifier
|
|
||||||
) {
|
|
||||||
val defaultBackground = MaterialTheme.colors.background
|
|
||||||
val background = remember {
|
|
||||||
mutableStateOf(defaultBackground)
|
|
||||||
}
|
|
||||||
val tags = remember(noteEvent) { noteEvent.tags().toImmutableListOfLists() }
|
|
||||||
|
|
||||||
TranslatableRichTextViewer(
|
|
||||||
content = it,
|
|
||||||
canPreview = false,
|
|
||||||
tags = tags,
|
|
||||||
backgroundColor = background,
|
|
||||||
accountViewModel = accountViewModel,
|
|
||||||
nav = nav
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
lineModifier,
|
lineModifier,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
|||||||
@@ -548,4 +548,5 @@
|
|||||||
<string name="copy_the_note_id_to_the_clipboard">Copy Note ID to clipboard</string>
|
<string name="copy_the_note_id_to_the_clipboard">Copy Note ID to clipboard</string>
|
||||||
|
|
||||||
<string name="created_at">Created at</string>
|
<string name="created_at">Created at</string>
|
||||||
|
<string name="rules">Rules</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user