Skip to content

Commit 23fb6f9

Browse files
committed
ListDialog: Use SegmentedListItem from M3 library
1 parent a809158 commit 23fb6f9

File tree

1 file changed

+8
-17
lines changed
  • ui/widgets/compose/src/main/kotlin/com/edricchan/studybuddy/ui/widgets/compose

1 file changed

+8
-17
lines changed

ui/widgets/compose/src/main/kotlin/com/edricchan/studybuddy/ui/widgets/compose/Dialog.kt

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ import androidx.compose.material3.ButtonDefaults
1616
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
1717
import androidx.compose.material3.Icon
1818
import androidx.compose.material3.IconButton
19+
import androidx.compose.material3.ListItemDefaults
1920
import androidx.compose.material3.MaterialTheme
2021
import androidx.compose.material3.OutlinedButton
2122
import androidx.compose.material3.OutlinedTextField
2223
import androidx.compose.material3.RadioButton
2324
import androidx.compose.material3.RadioButtonDefaults
25+
import androidx.compose.material3.SegmentedListItem
2426
import androidx.compose.material3.Text
2527
import androidx.compose.runtime.Composable
2628
import androidx.compose.runtime.Stable
@@ -31,8 +33,6 @@ import androidx.compose.runtime.setValue
3133
import androidx.compose.ui.Modifier
3234
import androidx.compose.ui.res.stringResource
3335
import androidx.compose.ui.text.input.VisualTransformation
34-
import com.edricchan.studybuddy.exts.androidx.compose.ui.graphics.animateInterpolatableAsState
35-
import com.edricchan.studybuddy.ui.widgets.compose.list.m3.ExpListItem
3636
import com.edricchan.studybuddy.ui.widgets.compose.list.m3.ExpListItemDefaults
3737
import com.edricchan.studybuddy.core.resources.R as CoreResR
3838

@@ -96,31 +96,22 @@ fun <T> ListDialog(
9696
) {
9797
itemsIndexed(items) { i, item ->
9898
val isSelected = item == dialogSelectedItem
99-
val shape by animateInterpolatableAsState(
100-
targetValue = ExpListItemDefaults.itemShape(
99+
SegmentedListItem(
100+
shapes = ListItemDefaults.segmentedShapes(
101101
index = i,
102-
count = items.size,
103-
selected = isSelected
104-
),
105-
animationSpec = MaterialTheme.motionScheme.fastSpatialSpec()
106-
)
107-
ExpListItem(
108-
shape = shape,
109-
colors = ExpListItemDefaults.colors(
110-
containerColor = MaterialTheme.colorScheme.surfaceContainerHighest,
111-
selectedContainerColor = MaterialTheme.colorScheme.secondaryContainer
102+
count = items.size
112103
),
113104
selected = isSelected,
114105
onClick = { dialogSelectedItem = item },
115-
headlineContent = { itemContent(item) },
116-
trailingContent = {
106+
content = { itemContent(item) },
107+
leadingContent = {
117108
RadioButton(
118109
selected = isSelected, onClick = null,
119110
colors = RadioButtonDefaults.colors(
120111
selectedColor = MaterialTheme.colorScheme.onSecondaryContainer
121112
)
122113
)
123-
}
114+
},
124115
)
125116
}
126117
}

0 commit comments

Comments
 (0)