Skip to content

Commit bcfe2ea

Browse files
committed
DebugModalBottomSheetFragment: Use SegmentedListItem from M3 library
1 parent 1704d5e commit bcfe2ea

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

app/src/main/java/com/edricchan/studybuddy/ui/modules/debug/DebugModalBottomSheetFragment.kt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ import androidx.compose.material.icons.Icons
1818
import androidx.compose.material.icons.outlined.PlayArrow
1919
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
2020
import androidx.compose.material3.Icon
21+
import androidx.compose.material3.ListItemDefaults
22+
import androidx.compose.material3.ListItemShapes
2123
import androidx.compose.material3.MaterialShapes
2224
import androidx.compose.material3.MaterialTheme
2325
import androidx.compose.material3.Scaffold
26+
import androidx.compose.material3.SegmentedListItem
2427
import androidx.compose.material3.SnackbarDuration
2528
import androidx.compose.material3.SnackbarHost
2629
import androidx.compose.material3.SnackbarHostState
@@ -31,16 +34,13 @@ import androidx.compose.runtime.Composable
3134
import androidx.compose.runtime.Immutable
3235
import androidx.compose.runtime.remember
3336
import androidx.compose.ui.Modifier
34-
import androidx.compose.ui.graphics.Shape
3537
import androidx.compose.ui.unit.dp
3638
import androidx.lifecycle.lifecycleScope
3739
import com.edricchan.studybuddy.R
3840
import com.edricchan.studybuddy.constants.MimeTypeConstants
3941
import com.edricchan.studybuddy.exts.android.showToast
4042
import com.edricchan.studybuddy.exts.androidx.compose.plus
4143
import com.edricchan.studybuddy.ui.common.fragment.ComposableFragment
42-
import com.edricchan.studybuddy.ui.widgets.compose.list.m3.ExpListItem
43-
import com.edricchan.studybuddy.ui.widgets.compose.list.m3.ExpListItemDefaults
4444
import com.edricchan.studybuddy.ui.widgets.modalbottomsheet.select.dsl.showMultiSelectBottomSheet
4545
import com.edricchan.studybuddy.ui.widgets.modalbottomsheet.select.dsl.showSingleSelectBottomSheet
4646
import com.edricchan.studybuddy.ui.widgets.modalbottomsheet.views.ModalBottomSheetAdapter
@@ -109,6 +109,7 @@ class DebugModalBottomSheetFragment : ComposableFragment() {
109109

110110
private val snackbarHostState = SnackbarHostState()
111111

112+
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
112113
@Composable
113114
override fun Content(modifier: Modifier) {
114115
val demos = rememberDemos()
@@ -121,11 +122,11 @@ class DebugModalBottomSheetFragment : ComposableFragment() {
121122
LazyColumn(
122123
modifier = Modifier.consumeWindowInsets(innerPadding),
123124
contentPadding = innerPadding + PaddingValues(horizontal = 16.dp),
124-
verticalArrangement = Arrangement.spacedBy(ExpListItemDefaults.groupedItemsSpacing)
125+
verticalArrangement = Arrangement.spacedBy(ListItemDefaults.SegmentedGap)
125126
) {
126127
itemsIndexed(demos) { i, item ->
127128
DemoListItem(
128-
shape = ExpListItemDefaults.itemShape(
129+
shapes = ListItemDefaults.segmentedShapes(
129130
index = i, count = demos.size
130131
),
131132
iconRotationDeg = i * 15,
@@ -141,12 +142,12 @@ class DebugModalBottomSheetFragment : ComposableFragment() {
141142
@Composable
142143
private fun DemoListItem(
143144
modifier: Modifier = Modifier,
144-
shape: Shape,
145+
shapes: ListItemShapes,
145146
iconRotationDeg: Int,
146147
title: String,
147148
onClick: () -> Unit
148149
) {
149-
ExpListItem(
150+
SegmentedListItem(
150151
modifier = modifier,
151152
onClick = onClick,
152153
leadingContent = {
@@ -160,10 +161,14 @@ class DebugModalBottomSheetFragment : ComposableFragment() {
160161
)
161162
}
162163
},
163-
headlineContent = {
164+
content = {
164165
Text(text = title)
165166
},
166-
shape = shape
167+
colors = ListItemDefaults.segmentedColors(
168+
containerColor = MaterialTheme.colorScheme.surfaceContainer,
169+
contentColor = MaterialTheme.colorScheme.onSurface
170+
),
171+
shapes = shapes
167172
)
168173
}
169174

0 commit comments

Comments
 (0)