Skip to content

Commit c3ca2c2

Browse files
committed
Bug fixes
1 parent 1f25c0d commit c3ca2c2

4 files changed

Lines changed: 74 additions & 88 deletions

File tree

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ junit = "4.13.2"
66
junit-version = "1.3.0"
77
espresso-core = "3.7.0"
88
lifecycle-runtime = "2.10.0"
9-
activity-compose = "1.12.2"
10-
compose-bom = "2026.01.00"
9+
activity-compose = "1.12.3"
10+
compose-bom = "2026.01.01"
1111
material-icons = "1.7.8"
1212
graphics-shapes = "1.1.0"
1313
kotlinx-serialization-json = "1.10.0"
1414
kotlinx-collections-immutable = "0.4.0"
1515
kotlinx-datetime = "0.7.1"
1616
kotlinx-io = "0.8.2"
1717
datastore-preferences = "1.2.0"
18-
navigation-compose = "2.9.6"
18+
navigation-compose = "2.9.7"
1919
coil-kt = "3.3.0"
2020

2121
[libraries]

jetpack-ui/src/main/kotlin/io/bashpsk/emptylibs/jetpackui/optionbar/BottomOptionBar.kt

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,17 @@ fun BottomOptionBar(
5959
derivedStateOf { optionList.subList(shownItemCount, optionList.size) }
6060
}
6161

62-
val onOptionItemClick = remember<(OptionBarData) -> Unit> {
63-
{ option ->
64-
65-
onOptionClick(option)
66-
isMoreOptionMenuExpanded = false
67-
}
68-
}
69-
70-
val onMoreOptionItemClick = remember<(OptionBarData) -> Unit> {
71-
{ option ->
72-
73-
onOptionClick(option)
74-
isMoreOptionMenuExpanded = true
75-
}
76-
}
77-
7862
val expandIndicator = @Composable { scope: ContextualFlowRowOverflowScope ->
7963

8064
shownItemCount = scope.shownItemCount
81-
OptionBarItem(optionData = moreOption, onClick = onMoreOptionItemClick)
65+
OptionBarItem(
66+
optionData = moreOption,
67+
onClick = {
68+
69+
onOptionClick(moreOption)
70+
isMoreOptionMenuExpanded = true
71+
}
72+
)
8273
}
8374

8475
Box(
@@ -115,7 +106,14 @@ fun BottomOptionBar(
115106

116107
option?.let { optionItem ->
117108

118-
OptionBarItem(optionData = optionItem, onClick = onOptionItemClick)
109+
OptionBarItem(
110+
optionData = optionItem,
111+
onClick = {
112+
113+
onOptionClick(optionItem)
114+
isMoreOptionMenuExpanded = false
115+
}
116+
)
119117
}
120118
}
121119

@@ -130,9 +128,16 @@ fun BottomOptionBar(
130128

131129
HorizontalDivider()
132130

133-
remainingItems.forEach { item ->
131+
remainingItems.forEach { optionItem ->
132+
133+
OptionMenuItem(
134+
optionData = optionItem,
135+
onClick = {
134136

135-
OptionMenuItem(optionData = item, onClick = onOptionItemClick)
137+
onOptionClick(optionItem)
138+
isMoreOptionMenuExpanded = false
139+
}
140+
)
136141
}
137142

138143
HorizontalDivider()

jetpack-ui/src/main/kotlin/io/bashpsk/emptylibs/jetpackui/optionbar/OptionBarItem.kt

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import androidx.compose.foundation.layout.padding
88
import androidx.compose.foundation.layout.size
99
import androidx.compose.material3.Card
1010
import androidx.compose.material3.CardDefaults
11+
import androidx.compose.material3.DropdownMenuItem
1112
import androidx.compose.material3.Icon
1213
import androidx.compose.material3.MaterialTheme
1314
import androidx.compose.material3.Text
1415
import androidx.compose.runtime.Composable
15-
import androidx.compose.runtime.remember
1616
import androidx.compose.ui.Alignment
1717
import androidx.compose.ui.Modifier
1818
import androidx.compose.ui.graphics.Color
@@ -30,17 +30,14 @@ import androidx.compose.ui.unit.dp
3030
* @param optionData The [OptionBarData] object containing the icon, label, and enabled state for
3131
* this item.
3232
* @param onClick A lambda function that will be invoked when this option item is clicked.
33-
* It receives the [OptionBarData] of the clicked item as a parameter.
3433
*/
3534
@Composable
3635
internal fun OptionBarItem(
3736
modifier: Modifier = Modifier,
3837
optionData: OptionBarData,
39-
onClick: (option: OptionBarData) -> Unit = {}
38+
onClick: () -> Unit = {}
4039
) {
4140

42-
val onOptionClick = remember(optionData) { { onClick(optionData) } }
43-
4441
val cardColors = CardDefaults.cardColors(
4542
containerColor = Color.Transparent,
4643
contentColor = MaterialTheme.colorScheme.onSurface,
@@ -53,7 +50,7 @@ internal fun OptionBarItem(
5350
shape = MaterialTheme.shapes.extraSmall,
5451
enabled = optionData.enabled,
5552
colors = cardColors,
56-
onClick = onOptionClick
53+
onClick = onClick
5754
) {
5855

5956
Column(
@@ -79,4 +76,47 @@ internal fun OptionBarItem(
7976
)
8077
}
8178
}
79+
}
80+
81+
/**
82+
* A composable function that displays a single option item within a dropdown menu.
83+
*
84+
* This item typically consists of an icon, a label, and an action to be performed on click.
85+
* It's designed to be used as part of an `OptionBar` or similar dropdown structure.
86+
*
87+
* @param modifier Optional [Modifier] to be applied to the `DropdownMenuItem`.
88+
* @param optionData The [OptionBarData] containing the information for this menu item,
89+
* such as its label, icon, and enabled state.
90+
* @param onClick A lambda function that will be invoked when this menu item is clicked.
91+
*/
92+
@Composable
93+
internal fun OptionMenuItem(
94+
modifier: Modifier = Modifier,
95+
optionData: OptionBarData,
96+
onClick: () -> Unit = {}
97+
) {
98+
99+
DropdownMenuItem(
100+
modifier = modifier,
101+
enabled = optionData.enabled,
102+
text = {
103+
104+
Text(
105+
text = optionData.label,
106+
textAlign = TextAlign.Start,
107+
maxLines = 1,
108+
style = MaterialTheme.typography.bodyMedium,
109+
overflow = TextOverflow.Ellipsis
110+
)
111+
},
112+
leadingIcon = {
113+
114+
Icon(
115+
modifier = Modifier.size(size = 20.dp),
116+
imageVector = optionData.icon,
117+
contentDescription = optionData.label
118+
)
119+
},
120+
onClick = onClick
121+
)
82122
}

jetpack-ui/src/main/kotlin/io/bashpsk/emptylibs/jetpackui/optionbar/OptionMenuItem.kt

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)