Minor refactoring

This commit is contained in:
Vitor Pamplona
2023-12-14 15:02:49 -05:00
parent 91b3b9e0e9
commit 3a76c2a2de
2 changed files with 53 additions and 95 deletions

View File

@ -156,6 +156,7 @@ import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
import com.vitorpamplona.amethyst.ui.theme.UserNameMaxRowHeight import com.vitorpamplona.amethyst.ui.theme.UserNameMaxRowHeight
import com.vitorpamplona.amethyst.ui.theme.UserNameRowHeight import com.vitorpamplona.amethyst.ui.theme.UserNameRowHeight
import com.vitorpamplona.amethyst.ui.theme.WidthAuthorPictureModifier import com.vitorpamplona.amethyst.ui.theme.WidthAuthorPictureModifier
import com.vitorpamplona.amethyst.ui.theme.channelNotePictureModifier
import com.vitorpamplona.amethyst.ui.theme.grayText import com.vitorpamplona.amethyst.ui.theme.grayText
import com.vitorpamplona.amethyst.ui.theme.lessImportantLink import com.vitorpamplona.amethyst.ui.theme.lessImportantLink
import com.vitorpamplona.amethyst.ui.theme.mediumImportanceLink import com.vitorpamplona.amethyst.ui.theme.mediumImportanceLink
@ -411,18 +412,18 @@ fun RenderReportState(
val canPreview = (!state.isAcceptable && showReportedNote) || state.canPreview val canPreview = (!state.isAcceptable && showReportedNote) || state.canPreview
NormalNote( NormalNote(
note, baseNote = note,
routeForLastRead, routeForLastRead = routeForLastRead,
modifier, modifier = modifier,
isBoostedNote, isBoostedNote = isBoostedNote,
isQuotedNote, isQuotedNote = isQuotedNote,
unPackReply, unPackReply = unPackReply,
makeItShort, makeItShort = makeItShort,
addMarginTop, addMarginTop = addMarginTop,
canPreview, canPreview = canPreview,
parentBackgroundColor, parentBackgroundColor = parentBackgroundColor,
accountViewModel, accountViewModel = accountViewModel,
nav nav = nav
) )
} }
} }
@ -522,19 +523,19 @@ fun NormalNote(
else -> else ->
LongPressToQuickAction(baseNote = baseNote, accountViewModel = accountViewModel) { showPopup -> LongPressToQuickAction(baseNote = baseNote, accountViewModel = accountViewModel) { showPopup ->
CheckNewAndRenderNote( CheckNewAndRenderNote(
baseNote, baseNote = baseNote,
routeForLastRead, routeForLastRead = routeForLastRead,
modifier, modifier = modifier,
isBoostedNote, isBoostedNote = isBoostedNote,
isQuotedNote, isQuotedNote = isQuotedNote,
unPackReply, unPackReply = unPackReply,
makeItShort, makeItShort = makeItShort,
addMarginTop, addMarginTop = addMarginTop,
canPreview, canPreview = canPreview,
parentBackgroundColor, parentBackgroundColor = parentBackgroundColor,
accountViewModel, accountViewModel = accountViewModel,
showPopup, showPopup = showPopup,
nav nav = nav
) )
} }
} }
@ -2880,27 +2881,12 @@ private fun ChannelNotePicture(baseChannel: Channel, loadProfilePicture: Boolean
it.channel.profilePicture() it.channel.profilePicture()
}.distinctUntilChanged().observeAsState() }.distinctUntilChanged().observeAsState()
val backgroundColor = MaterialTheme.colorScheme.background
val modifier = remember {
Modifier
.width(30.dp)
.height(30.dp)
.clip(shape = CircleShape)
.background(backgroundColor)
.border(
2.dp,
backgroundColor,
CircleShape
)
}
Box(Size30Modifier) { Box(Size30Modifier) {
RobohashFallbackAsyncImage( RobohashFallbackAsyncImage(
robot = baseChannel.idHex, robot = baseChannel.idHex,
model = model, model = model,
contentDescription = stringResource(R.string.group_picture), contentDescription = stringResource(R.string.group_picture),
modifier = modifier, modifier = MaterialTheme.colorScheme.channelNotePictureModifier,
loadProfilePicture = loadProfilePicture loadProfilePicture = loadProfilePicture
) )
} }
@ -2987,9 +2973,7 @@ fun DisplayHighlight(
val quote = val quote =
remember { remember {
highlight highlight
.split("\n") .split("\n").joinToString("\n") { "> *${it.removeSuffix(" ")}*" }
.map { "> *${it.removeSuffix(" ")}*" }
.joinToString("\n")
} }
TranslatableRichTextViewer( TranslatableRichTextViewer(

View File

@ -95,35 +95,18 @@ private val LightZapraiserBackground = BitcoinOrange.copy(0.52f).compositeOver(L
private val DarkOverPictureBackground = DarkColorPalette.background.copy(0.62f) private val DarkOverPictureBackground = DarkColorPalette.background.copy(0.62f)
private val LightOverPictureBackground = LightColorPalette.background.copy(0.62f) private val LightOverPictureBackground = LightColorPalette.background.copy(0.62f)
val RepostPictureBorderDark = Modifier.border( val RepostPictureBorderDark = Modifier.border(2.dp, DarkColorPalette.background, CircleShape)
2.dp, val RepostPictureBorderLight = Modifier.border(2.dp, LightColorPalette.background, CircleShape)
DarkColorPalette.background,
CircleShape
)
val RepostPictureBorderLight = Modifier.border(
2.dp,
LightColorPalette.background,
CircleShape
)
val DarkImageModifier = Modifier val DarkImageModifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.clip(shape = QuoteBorder) .clip(shape = QuoteBorder)
.border( .border(1.dp, DarkSubtleBorder, QuoteBorder)
1.dp,
DarkSubtleBorder,
QuoteBorder
)
val LightImageModifier = Modifier val LightImageModifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.clip(shape = QuoteBorder) .clip(shape = QuoteBorder)
.border( .border(1.dp, LightSubtleBorder, QuoteBorder)
1.dp,
LightSubtleBorder,
QuoteBorder
)
val DarkProfile35dpModifier = Modifier val DarkProfile35dpModifier = Modifier
.size(Size35dp) .size(Size35dp)
@ -137,41 +120,37 @@ val DarkReplyBorderModifier = Modifier
.padding(top = 5.dp) .padding(top = 5.dp)
.fillMaxWidth() .fillMaxWidth()
.clip(shape = QuoteBorder) .clip(shape = QuoteBorder)
.border( .border(1.dp, DarkSubtleBorder, QuoteBorder)
1.dp,
DarkSubtleBorder,
QuoteBorder
)
val LightReplyBorderModifier = Modifier val LightReplyBorderModifier = Modifier
.padding(top = 2.dp, bottom = 0.dp, start = 0.dp, end = 0.dp) .padding(top = 2.dp, bottom = 0.dp, start = 0.dp, end = 0.dp)
.fillMaxWidth() .fillMaxWidth()
.clip(shape = QuoteBorder) .clip(shape = QuoteBorder)
.border( .border(1.dp, LightSubtleBorder, QuoteBorder)
1.dp,
LightSubtleBorder,
QuoteBorder
)
val DarkInnerPostBorderModifier = Modifier val DarkInnerPostBorderModifier = Modifier
.padding(top = 5.dp) .padding(top = 5.dp)
.fillMaxWidth() .fillMaxWidth()
.clip(shape = QuoteBorder) .clip(shape = QuoteBorder)
.border( .border(1.dp, DarkSubtleBorder, QuoteBorder)
1.dp,
DarkSubtleBorder,
QuoteBorder
)
val LightInnerPostBorderModifier = Modifier val LightInnerPostBorderModifier = Modifier
.padding(top = 5.dp) .padding(top = 5.dp)
.fillMaxWidth() .fillMaxWidth()
.clip(shape = QuoteBorder) .clip(shape = QuoteBorder)
.border( .border(1.dp, LightSubtleBorder, QuoteBorder)
1.dp,
LightSubtleBorder, val DarkChannelNotePictureModifier = Modifier
QuoteBorder .size(30.dp)
) .clip(shape = CircleShape)
.background(DarkColorPalette.background)
.border(2.dp, DarkColorPalette.background, CircleShape)
val LightChannelNotePictureModifier = Modifier
.size(30.dp)
.clip(shape = CircleShape)
.background(LightColorPalette.background)
.border(2.dp, LightColorPalette.background, CircleShape)
val RichTextDefaults = RichTextStyle().resolveDefaults() val RichTextDefaults = RichTextStyle().resolveDefaults()
@ -190,11 +169,7 @@ val MarkDownStyleOnDark = RichTextDefaults.copy(
.padding(0.dp) .padding(0.dp)
.fillMaxWidth() .fillMaxWidth()
.clip(shape = QuoteBorder) .clip(shape = QuoteBorder)
.border( .border(1.dp, DarkSubtleBorder, QuoteBorder)
1.dp,
DarkSubtleBorder,
QuoteBorder
)
.background(DarkColorPalette.onSurface.copy(alpha = 0.05f)) .background(DarkColorPalette.onSurface.copy(alpha = 0.05f))
), ),
stringStyle = RichTextDefaults.stringStyle?.copy( stringStyle = RichTextDefaults.stringStyle?.copy(
@ -224,11 +199,7 @@ val MarkDownStyleOnLight = RichTextDefaults.copy(
.padding(0.dp) .padding(0.dp)
.fillMaxWidth() .fillMaxWidth()
.clip(shape = QuoteBorder) .clip(shape = QuoteBorder)
.border( .border(1.dp, LightSubtleBorder, QuoteBorder)
1.dp,
LightSubtleBorder,
QuoteBorder
)
.background(DarkColorPalette.onSurface.copy(alpha = 0.05f)) .background(DarkColorPalette.onSurface.copy(alpha = 0.05f))
), ),
stringStyle = RichTextDefaults.stringStyle?.copy( stringStyle = RichTextDefaults.stringStyle?.copy(
@ -320,6 +291,9 @@ val ColorScheme.replyModifier: Modifier
val ColorScheme.innerPostModifier: Modifier val ColorScheme.innerPostModifier: Modifier
get() = if (isLight) LightInnerPostBorderModifier else DarkInnerPostBorderModifier get() = if (isLight) LightInnerPostBorderModifier else DarkInnerPostBorderModifier
val ColorScheme.channelNotePictureModifier: Modifier
get() = if (isLight) LightChannelNotePictureModifier else DarkChannelNotePictureModifier
val ColorScheme.chartStyle: ChartStyle val ColorScheme.chartStyle: ChartStyle
get() { get() {
val defaultColors = if (isLight) DefaultColors.Light else DefaultColors.Dark val defaultColors = if (isLight) DefaultColors.Light else DefaultColors.Dark