Fix detekted issues.
This commit is contained in:
parent
e777bcc20a
commit
70d79f2d7a
9 changed files with 86 additions and 74 deletions
|
|
@ -198,9 +198,11 @@ fun MessagesScreenContent(
|
||||||
composerCanSendMessage: Boolean,
|
composerCanSendMessage: Boolean,
|
||||||
composerText: StableCharSequence?,
|
composerText: StableCharSequence?,
|
||||||
snackbarHostState: SnackbarHostState,
|
snackbarHostState: SnackbarHostState,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
LogCompositions(tag = "MessagesScreen", msg = "Content")
|
LogCompositions(tag = "MessagesScreen", msg = "Content")
|
||||||
Scaffold(
|
Scaffold(
|
||||||
|
modifier = modifier,
|
||||||
contentWindowInsets = WindowInsets.statusBars,
|
contentWindowInsets = WindowInsets.statusBars,
|
||||||
topBar = {
|
topBar = {
|
||||||
MessagesTopAppBar(
|
MessagesTopAppBar(
|
||||||
|
|
@ -255,7 +257,6 @@ fun MessagesContent(
|
||||||
composerText: StableCharSequence?,
|
composerText: StableCharSequence?,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val lazyListState = rememberLazyListState()
|
val lazyListState = rememberLazyListState()
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
|
|
@ -301,9 +302,11 @@ fun MessagesContent(
|
||||||
fun MessagesTopAppBar(
|
fun MessagesTopAppBar(
|
||||||
roomTitle: String?,
|
roomTitle: String?,
|
||||||
roomAvatar: AvatarData?,
|
roomAvatar: AvatarData?,
|
||||||
onBackPressed: () -> Unit,
|
modifier: Modifier = Modifier,
|
||||||
|
onBackPressed: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
|
modifier = modifier,
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
IconButton(onClick = onBackPressed) {
|
IconButton(onClick = onBackPressed) {
|
||||||
Icon(
|
Icon(
|
||||||
|
|
@ -521,7 +524,7 @@ private fun MessageSenderInformation(
|
||||||
internal fun BoxScope.MessagesScrollHelper(
|
internal fun BoxScope.MessagesScrollHelper(
|
||||||
lazyListState: LazyListState,
|
lazyListState: LazyListState,
|
||||||
timelineItems: List<MessagesTimelineItemState>,
|
timelineItems: List<MessagesTimelineItemState>,
|
||||||
onLoadMore: () -> Unit,
|
onLoadMore: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
val firstVisibleItemIndex by remember { derivedStateOf { lazyListState.firstVisibleItemIndex } }
|
val firstVisibleItemIndex by remember { derivedStateOf { lazyListState.firstVisibleItemIndex } }
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,9 @@ fun MessageEventBubble(
|
||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
isHighlighted: Boolean,
|
isHighlighted: Boolean,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit = {},
|
||||||
onLongClick: () -> Unit,
|
onLongClick: () -> Unit = {},
|
||||||
content: @Composable () -> Unit,
|
content: @Composable () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
fun bubbleShape(): Shape {
|
fun bubbleShape(): Shape {
|
||||||
return when (groupPosition) {
|
return when (groupPosition) {
|
||||||
|
|
|
||||||
|
|
@ -95,36 +95,36 @@ fun TimelineItemActionsScreen(
|
||||||
@Composable
|
@Composable
|
||||||
private fun SheetContent(
|
private fun SheetContent(
|
||||||
actionsSheetState: MessagesItemActionsSheetState?,
|
actionsSheetState: MessagesItemActionsSheetState?,
|
||||||
onActionClicked: (MessagesItemAction, MessagesTimelineItemState.MessageEvent) -> Unit,
|
modifier: Modifier = Modifier,
|
||||||
modifier: Modifier = Modifier
|
onActionClicked: (MessagesItemAction, MessagesTimelineItemState.MessageEvent) -> Unit = { _, _ -> },
|
||||||
) {
|
) {
|
||||||
if (actionsSheetState == null || actionsSheetState.actions.isEmpty()) {
|
if (actionsSheetState == null || actionsSheetState.actions.isEmpty()) {
|
||||||
// Crashes if sheetContent size is zero
|
// Crashes if sheetContent size is zero
|
||||||
Box(modifier = modifier.size(1.dp))
|
Box(modifier = modifier.size(1.dp))
|
||||||
return
|
} else {
|
||||||
}
|
LazyColumn(
|
||||||
LazyColumn(
|
modifier = modifier
|
||||||
modifier = modifier
|
.fillMaxWidth()
|
||||||
.fillMaxWidth()
|
) {
|
||||||
) {
|
items(actionsSheetState.actions) {
|
||||||
items(actionsSheetState.actions) {
|
ListItem(
|
||||||
ListItem(
|
modifier = Modifier.clickable {
|
||||||
modifier = Modifier.clickable {
|
onActionClicked(it, actionsSheetState.targetItem)
|
||||||
onActionClicked(it, actionsSheetState.targetItem)
|
},
|
||||||
},
|
text = {
|
||||||
text = {
|
Text(
|
||||||
Text(
|
text = it.title,
|
||||||
text = it.title,
|
color = if (it.destructive) MaterialTheme.colors.error else Color.Unspecified,
|
||||||
color = if (it.destructive) MaterialTheme.colors.error else Color.Unspecified,
|
)
|
||||||
)
|
},
|
||||||
},
|
icon = {
|
||||||
icon = {
|
VectorIcon(
|
||||||
VectorIcon(
|
resourceId = it.icon,
|
||||||
resourceId = it.icon,
|
tint = if (it.destructive) MaterialTheme.colors.error else LocalContentColor.current,
|
||||||
tint = if (it.destructive) MaterialTheme.colors.error else LocalContentColor.current,
|
)
|
||||||
)
|
}
|
||||||
}
|
)
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ fun MessagesTimelineItemTextView(
|
||||||
content: MessagesTimelineItemTextBasedContent,
|
content: MessagesTimelineItemTextBasedContent,
|
||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
onTextClicked: () -> Unit,
|
onTextClicked: () -> Unit = {},
|
||||||
onTextLongClicked: () -> Unit,
|
onTextLongClicked: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
val htmlDocument = content.htmlDocument
|
val htmlDocument = content.htmlDocument
|
||||||
if (htmlDocument != null) {
|
if (htmlDocument != null) {
|
||||||
|
|
|
||||||
|
|
@ -46,34 +46,33 @@ private const val chipId = "chip"
|
||||||
fun HtmlDocument(
|
fun HtmlDocument(
|
||||||
document: Document,
|
document: Document,
|
||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
onTextClicked: () -> Unit,
|
|
||||||
onTextLongClicked: () -> Unit,
|
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
onTextClicked: () -> Unit = {},
|
||||||
|
onTextLongClicked: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
HtmlBody(
|
HtmlBody(
|
||||||
body = document.body(),
|
body = document.body(),
|
||||||
|
interactionSource = interactionSource,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
onTextClicked = onTextClicked,
|
onTextClicked = onTextClicked,
|
||||||
onTextLongClicked = onTextLongClicked,
|
onTextLongClicked = onTextLongClicked,
|
||||||
interactionSource = interactionSource
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun HtmlBody(
|
private fun HtmlBody(
|
||||||
body: Element,
|
body: Element,
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
onTextClicked: () -> Unit,
|
|
||||||
onTextLongClicked: () -> Unit,
|
|
||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
onTextClicked: () -> Unit = {},
|
||||||
|
onTextLongClicked: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun NodesFlowRode(
|
fun NodesFlowRode(
|
||||||
nodes: Iterator<Node>,
|
nodes: Iterator<Node>,
|
||||||
onTextClicked: () -> Unit,
|
|
||||||
onTextLongClicked: () -> Unit,
|
|
||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
|
onTextClicked: () -> Unit = {},
|
||||||
|
onTextLongClicked: () -> Unit = {},
|
||||||
) = FlowRow(
|
) = FlowRow(
|
||||||
mainAxisSpacing = 2.dp,
|
mainAxisSpacing = 2.dp,
|
||||||
crossAxisSpacing = 8.dp,
|
crossAxisSpacing = 8.dp,
|
||||||
|
|
@ -114,9 +113,9 @@ private fun HtmlBody(
|
||||||
while (nodesIterator.hasNext()) {
|
while (nodesIterator.hasNext()) {
|
||||||
NodesFlowRode(
|
NodesFlowRode(
|
||||||
nodes = nodesIterator,
|
nodes = nodesIterator,
|
||||||
|
interactionSource = interactionSource,
|
||||||
onTextClicked = onTextClicked,
|
onTextClicked = onTextClicked,
|
||||||
onTextLongClicked = onTextLongClicked,
|
onTextLongClicked = onTextLongClicked,
|
||||||
interactionSource = interactionSource
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -133,10 +132,10 @@ private fun Element.isInline(): Boolean {
|
||||||
@Composable
|
@Composable
|
||||||
private fun HtmlBlock(
|
private fun HtmlBlock(
|
||||||
element: Element,
|
element: Element,
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
onTextClicked: () -> Unit,
|
|
||||||
onTextLongClicked: () -> Unit,
|
|
||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
onTextClicked: () -> Unit = {},
|
||||||
|
onTextLongClicked: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
val blockModifier = modifier
|
val blockModifier = modifier
|
||||||
.padding(top = 4.dp)
|
.padding(top = 4.dp)
|
||||||
|
|
@ -191,10 +190,10 @@ private fun HtmlBlock(
|
||||||
@Composable
|
@Composable
|
||||||
private fun HtmlInline(
|
private fun HtmlInline(
|
||||||
element: Element,
|
element: Element,
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
onTextClicked: () -> Unit,
|
|
||||||
onTextLongClicked: () -> Unit,
|
|
||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
onTextClicked: () -> Unit = {},
|
||||||
|
onTextLongClicked: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
Box(modifier) {
|
Box(modifier) {
|
||||||
val styledText = buildAnnotatedString {
|
val styledText = buildAnnotatedString {
|
||||||
|
|
@ -210,7 +209,10 @@ private fun HtmlInline(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun HtmlPreformatted(pre: Element, modifier: Modifier = Modifier) {
|
private fun HtmlPreformatted(
|
||||||
|
pre: Element,
|
||||||
|
modifier: Modifier = Modifier
|
||||||
|
) {
|
||||||
val isCode = pre.firstElementChild()?.normalName() == "code"
|
val isCode = pre.firstElementChild()?.normalName() == "code"
|
||||||
val backgroundColor =
|
val backgroundColor =
|
||||||
if (isCode) MaterialTheme.colorScheme.codeBackground() else Color.Unspecified
|
if (isCode) MaterialTheme.colorScheme.codeBackground() else Color.Unspecified
|
||||||
|
|
@ -229,9 +231,10 @@ private fun HtmlPreformatted(pre: Element, modifier: Modifier = Modifier) {
|
||||||
@Composable
|
@Composable
|
||||||
private fun HtmlParagraph(
|
private fun HtmlParagraph(
|
||||||
paragraph: Element,
|
paragraph: Element,
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
onTextClicked: () -> Unit, onTextLongClicked: () -> Unit,
|
|
||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
onTextClicked: () -> Unit = {},
|
||||||
|
onTextLongClicked: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
Box(modifier) {
|
Box(modifier) {
|
||||||
val styledText = buildAnnotatedString {
|
val styledText = buildAnnotatedString {
|
||||||
|
|
@ -247,9 +250,10 @@ private fun HtmlParagraph(
|
||||||
@Composable
|
@Composable
|
||||||
private fun HtmlBlockquote(
|
private fun HtmlBlockquote(
|
||||||
blockquote: Element,
|
blockquote: Element,
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
onTextClicked: () -> Unit, onTextLongClicked: () -> Unit,
|
|
||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
onTextClicked: () -> Unit = {},
|
||||||
|
onTextLongClicked: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
val color = MaterialTheme.colorScheme.onBackground
|
val color = MaterialTheme.colorScheme.onBackground
|
||||||
Box(
|
Box(
|
||||||
|
|
@ -279,9 +283,10 @@ private fun HtmlBlockquote(
|
||||||
@Composable
|
@Composable
|
||||||
private fun HtmlHeading(
|
private fun HtmlHeading(
|
||||||
heading: Element,
|
heading: Element,
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
onTextClicked: () -> Unit, onTextLongClicked: () -> Unit,
|
|
||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
onTextClicked: () -> Unit = {},
|
||||||
|
onTextLongClicked: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
val style = when (heading.normalName()) {
|
val style = when (heading.normalName()) {
|
||||||
"h1" -> MaterialTheme.typography.headlineLarge.copy(fontSize = 30.sp)
|
"h1" -> MaterialTheme.typography.headlineLarge.copy(fontSize = 30.sp)
|
||||||
|
|
@ -311,9 +316,10 @@ private fun HtmlHeading(
|
||||||
@Composable
|
@Composable
|
||||||
private fun HtmlMxReply(
|
private fun HtmlMxReply(
|
||||||
mxReply: Element,
|
mxReply: Element,
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
onTextClicked: () -> Unit, onTextLongClicked: () -> Unit,
|
|
||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
onTextClicked: () -> Unit = {},
|
||||||
|
onTextLongClicked: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
val blockquote = mxReply.childNodes().firstOrNull() ?: return
|
val blockquote = mxReply.childNodes().firstOrNull() ?: return
|
||||||
val shape = RoundedCornerShape(12.dp)
|
val shape = RoundedCornerShape(12.dp)
|
||||||
|
|
@ -363,9 +369,10 @@ private fun HtmlMxReply(
|
||||||
@Composable
|
@Composable
|
||||||
private fun HtmlOrderedList(
|
private fun HtmlOrderedList(
|
||||||
orderedList: Element,
|
orderedList: Element,
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
onTextClicked: () -> Unit, onTextLongClicked: () -> Unit,
|
|
||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
onTextClicked: () -> Unit = {},
|
||||||
|
onTextLongClicked: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
var number = 1
|
var number = 1
|
||||||
val delimiter = "."
|
val delimiter = "."
|
||||||
|
|
@ -388,9 +395,10 @@ private fun HtmlOrderedList(
|
||||||
@Composable
|
@Composable
|
||||||
private fun HtmlUnorderedList(
|
private fun HtmlUnorderedList(
|
||||||
unorderedList: Element,
|
unorderedList: Element,
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
onTextClicked: () -> Unit, onTextLongClicked: () -> Unit,
|
|
||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
onTextClicked: () -> Unit = {},
|
||||||
|
onTextLongClicked: () -> Unit = {},
|
||||||
) {
|
) {
|
||||||
val marker = "・"
|
val marker = "・"
|
||||||
HtmlListItems(
|
HtmlListItems(
|
||||||
|
|
@ -412,10 +420,11 @@ private fun HtmlUnorderedList(
|
||||||
@Composable
|
@Composable
|
||||||
private fun HtmlListItems(
|
private fun HtmlListItems(
|
||||||
list: Element,
|
list: Element,
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
onTextClicked: () -> Unit, onTextLongClicked: () -> Unit,
|
|
||||||
interactionSource: MutableInteractionSource,
|
interactionSource: MutableInteractionSource,
|
||||||
content: @Composable (node: TextNode) -> Unit
|
modifier: Modifier = Modifier,
|
||||||
|
onTextClicked: () -> Unit = {},
|
||||||
|
onTextLongClicked: () -> Unit = {},
|
||||||
|
content: @Composable (node: TextNode) -> Unit = {}
|
||||||
) {
|
) {
|
||||||
Column(modifier = modifier) {
|
Column(modifier = modifier) {
|
||||||
for (node in list.children()) {
|
for (node in list.children()) {
|
||||||
|
|
@ -426,7 +435,7 @@ private fun HtmlListItems(
|
||||||
}
|
}
|
||||||
is Element -> HtmlBlock(
|
is Element -> HtmlBlock(
|
||||||
element = innerNode,
|
element = innerNode,
|
||||||
modifier = modifier.padding(start = 4.dp),
|
modifier = Modifier.padding(start = 4.dp),
|
||||||
onTextClicked = onTextClicked, onTextLongClicked = onTextLongClicked,
|
onTextClicked = onTextClicked, onTextLongClicked = onTextLongClicked,
|
||||||
interactionSource = interactionSource
|
interactionSource = interactionSource
|
||||||
)
|
)
|
||||||
|
|
@ -524,11 +533,11 @@ private fun AnnotatedString.Builder.appendLink(link: Element) {
|
||||||
@Composable
|
@Composable
|
||||||
private fun HtmlText(
|
private fun HtmlText(
|
||||||
text: AnnotatedString,
|
text: AnnotatedString,
|
||||||
|
interactionSource: MutableInteractionSource,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
style: TextStyle = LocalTextStyle.current,
|
style: TextStyle = LocalTextStyle.current,
|
||||||
onClick: () -> Unit,
|
onClick: () -> Unit = {},
|
||||||
onLongClick: () -> Unit,
|
onLongClick: () -> Unit = {},
|
||||||
interactionSource: MutableInteractionSource,
|
|
||||||
) {
|
) {
|
||||||
val inlineContentMap = emptyMap<String, InlineTextContent>()
|
val inlineContentMap = emptyMap<String, InlineTextContent>()
|
||||||
ClickableLinkText(
|
ClickableLinkText(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue