add PollNote type to ThreadFeedView,

simplify PollNote() arguments,
use parent's backgroundColor,
breakout PollNote modifier
This commit is contained in:
toadlyBroodle
2023-03-21 20:52:30 +09:00
parent 771cdd6ebe
commit ef31f56eab
3 changed files with 29 additions and 14 deletions

View File

@@ -446,7 +446,13 @@ fun NoteCompose(
)
if (noteEvent is PollNoteEvent) {
PollNote(noteEvent, canPreview, makeItShort, accountViewModel, navController)
PollNote(
noteEvent,
canPreview = canPreview && !makeItShort,
backgroundColor,
accountViewModel,
navController
)
}
}

View File

@@ -3,10 +3,11 @@ package com.vitorpamplona.amethyst.ui.note
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.SnackbarDefaults.backgroundColor
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.vitorpamplona.amethyst.service.model.PollNoteEvent
@@ -17,15 +18,19 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
fun PollNote(
pollEvent: PollNoteEvent,
canPreview: Boolean,
makeItShort: Boolean,
backgroundColor: Color,
accountViewModel: AccountViewModel,
navController: NavController
) {
val modifier = Modifier.fillMaxWidth()
.border(BorderStroke(1.dp, MaterialTheme.colors.onSurface.copy(alpha = 0.32f)))
.padding(4.dp)
pollEvent.pollOptions().values.forEachIndexed { index, string ->
TranslateableRichTextViewer(
string,
canPreview = canPreview && !makeItShort,
Modifier.fillMaxWidth().border(BorderStroke(1.dp, MaterialTheme.colors.onSurface.copy(alpha = 0.32f))),
canPreview,
modifier,
pollEvent.tags(),
backgroundColor,
accountViewModel,

View File

@@ -17,6 +17,7 @@ import androidx.compose.material.Divider
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.SnackbarDefaults.backgroundColor
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.MoreVert
@@ -48,17 +49,10 @@ import com.vitorpamplona.amethyst.R
import com.vitorpamplona.amethyst.model.Note
import com.vitorpamplona.amethyst.service.model.BadgeDefinitionEvent
import com.vitorpamplona.amethyst.service.model.LongTextNoteEvent
import com.vitorpamplona.amethyst.service.model.PollNoteEvent
import com.vitorpamplona.amethyst.ui.components.ObserveDisplayNip05Status
import com.vitorpamplona.amethyst.ui.components.TranslateableRichTextViewer
import com.vitorpamplona.amethyst.ui.note.BadgeDisplay
import com.vitorpamplona.amethyst.ui.note.BlankNote
import com.vitorpamplona.amethyst.ui.note.HiddenNote
import com.vitorpamplona.amethyst.ui.note.NoteAuthorPicture
import com.vitorpamplona.amethyst.ui.note.NoteCompose
import com.vitorpamplona.amethyst.ui.note.NoteDropDownMenu
import com.vitorpamplona.amethyst.ui.note.NoteUsernameDisplay
import com.vitorpamplona.amethyst.ui.note.ReactionsRow
import com.vitorpamplona.amethyst.ui.note.timeAgo
import com.vitorpamplona.amethyst.ui.note.*
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
import kotlinx.coroutines.delay
@@ -332,6 +326,16 @@ fun NoteMaster(
accountViewModel,
navController
)
if (noteEvent is PollNoteEvent) {
PollNote(
noteEvent,
canPreview,
backgroundColor,
accountViewModel,
navController
)
}
}
ReactionsRow(note, accountViewModel)