Skip to content

Commit 26daf56

Browse files
committed
Adding fade edge gradient
1 parent 321a3ea commit 26daf56

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

sample/common/src/commonMain/kotlin/com/kjcommunities/KJDemoPanel.kt

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ package com.kjcommunities
2727
import androidx.compose.foundation.background
2828
import androidx.compose.foundation.layout.Arrangement
2929
import androidx.compose.foundation.layout.Box
30+
import androidx.compose.foundation.layout.fillMaxWidth
3031
import androidx.compose.foundation.layout.height
3132
import androidx.compose.foundation.layout.width
3233
import androidx.compose.foundation.lazy.LazyRow
34+
import androidx.compose.foundation.lazy.rememberLazyListState
3335
import androidx.compose.material.icons.Icons
3436
import androidx.compose.material.icons.automirrored.outlined.FormatAlignLeft
3537
import androidx.compose.material.icons.automirrored.outlined.FormatAlignRight
@@ -38,8 +40,11 @@ import androidx.compose.material.icons.filled.Circle
3840
import androidx.compose.material.icons.outlined.*
3941
import androidx.compose.runtime.Composable
4042
import androidx.compose.runtime.MutableState
43+
import androidx.compose.runtime.derivedStateOf
44+
import androidx.compose.runtime.remember
4145
import androidx.compose.ui.Alignment
4246
import androidx.compose.ui.Modifier
47+
import androidx.compose.ui.graphics.Brush
4348
import androidx.compose.ui.graphics.Color
4449
import androidx.compose.ui.text.ParagraphStyle
4550
import androidx.compose.ui.text.SpanStyle
@@ -61,11 +66,22 @@ fun KJDemoPanel(
6166
openLinkDialog: MutableState<Boolean>,
6267
modifier: Modifier = Modifier,
6368
) {
64-
LazyRow(
65-
verticalAlignment = Alignment.CenterVertically,
66-
horizontalArrangement = Arrangement.spacedBy(2.dp),
67-
modifier = modifier
68-
) {
69+
val listState = rememberLazyListState()
70+
71+
// Check if there's content that can be scrolled to the right
72+
val showRightFade = remember {
73+
derivedStateOf {
74+
listState.canScrollForward
75+
}
76+
}
77+
78+
Box(modifier = modifier) {
79+
LazyRow(
80+
state = listState,
81+
verticalAlignment = Alignment.CenterVertically,
82+
horizontalArrangement = Arrangement.spacedBy(2.dp),
83+
modifier = Modifier.fillMaxWidth()
84+
) {
6985
// Text alignment buttons removed - not supported in Lexical format
7086
/*
7187
item {
@@ -347,5 +363,31 @@ fun KJDemoPanel(
347363
)
348364
}
349365
*/
366+
}
367+
368+
// Right fade gradient overlay - always present to maintain consistent layout
369+
Box(
370+
modifier = Modifier
371+
.align(Alignment.CenterEnd)
372+
.width(24.dp)
373+
.height(48.dp)
374+
.background(
375+
brush = if (showRightFade.value) {
376+
Brush.horizontalGradient(
377+
colors = listOf(
378+
Color.Transparent,
379+
Color(0xFF222528) // Match the panel background color
380+
)
381+
)
382+
} else {
383+
Brush.horizontalGradient(
384+
colors = listOf(
385+
Color.Transparent,
386+
Color.Transparent
387+
)
388+
)
389+
}
390+
)
391+
)
350392
}
351393
}

0 commit comments

Comments
 (0)