mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Semantic fixes: clearer naming conventions, when statements
This commit is contained in:
+4
-3
@@ -278,9 +278,10 @@ class TimelinePresenter(
|
|||||||
computeNewItemState(timelineItems, prevMostRecentItemId, newEventState)
|
computeNewItemState(timelineItems, prevMostRecentItemId, newEventState)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read marker position + unread count, scanned off the main thread. The UI gates display via
|
// Keyed on the full [timelineItems] reference (not just .size) so we re-scan when the
|
||||||
// [displayJumpToUnread]; the values are always computed so the state stays up to date if the
|
// read marker advances in place — the SDK swaps the marker virtual item to a new position
|
||||||
// feature flag flips at runtime.
|
// without changing the list length, e.g. when [markRoomAsFullyRead] is sent while at the
|
||||||
|
// bottom of the room.
|
||||||
val readMarkerIndex = remember { mutableIntStateOf(-1) }
|
val readMarkerIndex = remember { mutableIntStateOf(-1) }
|
||||||
val unreadMessagesCount = remember { mutableIntStateOf(0) }
|
val unreadMessagesCount = remember { mutableIntStateOf(0) }
|
||||||
LaunchedEffect(timelineItems) {
|
LaunchedEffect(timelineItems) {
|
||||||
|
|||||||
+17
-18
@@ -322,15 +322,15 @@ private fun BoxScope.TimelineScrollHelper(
|
|||||||
lazyListState.firstVisibleItemIndex < 3 && isLive
|
lazyListState.firstVisibleItemIndex < 3 && isLive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val isReadMarkerOffTop by remember {
|
val isJumpToUnreadVisible by remember {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
if (!displayJumpToUnread || readMarkerIndex < 0) {
|
when {
|
||||||
false
|
forceJumpToReadMarkerVisibility -> true
|
||||||
} else if (forceJumpToReadMarkerVisibility) {
|
!displayJumpToUnread || readMarkerIndex < 0 -> false
|
||||||
true
|
else -> {
|
||||||
} else {
|
val lastVisibleIndex = lazyListState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: return@derivedStateOf false
|
||||||
val lastVisibleIndex = lazyListState.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: return@derivedStateOf false
|
readMarkerIndex > lastVisibleIndex
|
||||||
readMarkerIndex > lastVisibleIndex
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -402,7 +402,7 @@ private fun BoxScope.TimelineScrollHelper(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TimelineFab(
|
JumpToPositionButton(
|
||||||
icon = CompoundIcons.ChevronDown(),
|
icon = CompoundIcons.ChevronDown(),
|
||||||
contentDescription = stringResource(id = CommonStrings.a11y_jump_to_bottom),
|
contentDescription = stringResource(id = CommonStrings.a11y_jump_to_bottom),
|
||||||
isVisible = isJumpToBottomVisible,
|
isVisible = isJumpToBottomVisible,
|
||||||
@@ -418,10 +418,10 @@ private fun BoxScope.TimelineScrollHelper(
|
|||||||
} else {
|
} else {
|
||||||
stringResource(id = CommonStrings.a11y_jump_to_unread_messages)
|
stringResource(id = CommonStrings.a11y_jump_to_unread_messages)
|
||||||
}
|
}
|
||||||
TimelineFab(
|
JumpToPositionButton(
|
||||||
icon = CompoundIcons.ChevronUp(),
|
icon = CompoundIcons.ChevronUp(),
|
||||||
contentDescription = jumpToUnreadDescription,
|
contentDescription = jumpToUnreadDescription,
|
||||||
isVisible = isReadMarkerOffTop,
|
isVisible = isJumpToUnreadVisible,
|
||||||
count = unreadMessagesCount,
|
count = unreadMessagesCount,
|
||||||
// Top padding includes [topInset] so the FAB sits below any pinned-events banner.
|
// Top padding includes [topInset] so the FAB sits below any pinned-events banner.
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -432,7 +432,7 @@ private fun BoxScope.TimelineScrollHelper(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun TimelineFab(
|
private fun JumpToPositionButton(
|
||||||
icon: ImageVector,
|
icon: ImageVector,
|
||||||
contentDescription: String,
|
contentDescription: String,
|
||||||
isVisible: Boolean,
|
isVisible: Boolean,
|
||||||
@@ -480,9 +480,9 @@ private fun TimelineCountBadge(
|
|||||||
count: Int,
|
count: Int,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
if (count <= 0) return
|
when {
|
||||||
if (count <= 9) {
|
count <= 0 -> return
|
||||||
Box(
|
count <= 9 -> Box(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.defaultMinSize(minWidth = 16.dp, minHeight = 16.dp)
|
.defaultMinSize(minWidth = 16.dp, minHeight = 16.dp)
|
||||||
.background(color = ElementTheme.colors.bgActionPrimaryRest, shape = CircleShape)
|
.background(color = ElementTheme.colors.bgActionPrimaryRest, shape = CircleShape)
|
||||||
@@ -497,8 +497,7 @@ private fun TimelineCountBadge(
|
|||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
else -> Box(
|
||||||
Box(
|
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.size(12.dp)
|
.size(12.dp)
|
||||||
.background(color = ElementTheme.colors.bgActionPrimaryRest, shape = CircleShape)
|
.background(color = ElementTheme.colors.bgActionPrimaryRest, shape = CircleShape)
|
||||||
@@ -592,7 +591,7 @@ internal fun TimelineViewWithReadMarkerNoBadgesPreview() = ElementPreview {
|
|||||||
|
|
||||||
@PreviewsDayNight
|
@PreviewsDayNight
|
||||||
@Composable
|
@Composable
|
||||||
internal fun TimelineViewWithReadMarkerPreview() = ElementPreview {
|
internal fun TimelineViewWithReadMarkerNumericBadgePreview() = ElementPreview {
|
||||||
TimelineViewWithReadMarker(unreadMessagesCount = 3, newMessagesCount = 0)
|
TimelineViewWithReadMarker(unreadMessagesCount = 3, newMessagesCount = 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ class KonsistPreviewTest {
|
|||||||
"TimelineViewWithReadMarkerBothCountsPreview",
|
"TimelineViewWithReadMarkerBothCountsPreview",
|
||||||
"TimelineViewWithReadMarkerDotBadgesPreview",
|
"TimelineViewWithReadMarkerDotBadgesPreview",
|
||||||
"TimelineViewWithReadMarkerNoBadgesPreview",
|
"TimelineViewWithReadMarkerNoBadgesPreview",
|
||||||
|
"TimelineViewWithReadMarkerNumericBadgePreview",
|
||||||
"UserAvatarColorsPreview",
|
"UserAvatarColorsPreview",
|
||||||
"UserProfileHeaderSectionWithVerificationViolationPreview",
|
"UserProfileHeaderSectionWithVerificationViolationPreview",
|
||||||
"VoiceItemViewPlayPreview",
|
"VoiceItemViewPlayPreview",
|
||||||
|
|||||||
Reference in New Issue
Block a user