@@ -42,7 +42,6 @@ import androidx.compose.foundation.layout.sizeIn
4242import androidx.compose.foundation.layout.wrapContentSize
4343import androidx.compose.foundation.shape.CircleShape
4444import androidx.compose.foundation.shape.RoundedCornerShape
45- import androidx.compose.material.icons.rounded.MoreVert
4645import androidx.compose.material3.DropdownMenu
4746import androidx.compose.material3.DropdownMenuItem
4847import androidx.compose.material3.ExperimentalMaterial3Api
@@ -52,6 +51,7 @@ import androidx.compose.material3.ListItem
5251import androidx.compose.material3.MaterialTheme
5352import androidx.compose.material3.Text
5453import androidx.compose.material3.TopAppBar
54+ import androidx.compose.material3.TopAppBarColors
5555import androidx.compose.material3.TopAppBarDefaults
5656import androidx.compose.material3.TopAppBarScrollBehavior
5757import androidx.compose.runtime.Composable
@@ -73,14 +73,13 @@ import app.ss.design.compose.extensions.haptics.LocalSsHapticFeedback
7373import app.ss.design.compose.theme.SsTheme
7474import app.ss.design.compose.widget.icon.IconBox
7575import app.ss.design.compose.widget.icon.IconButtonResSlot
76- import app.ss.design.compose.widget.icon.IconButtonSlot
7776import app.ss.design.compose.widget.icon.Icons
7877import io.adventech.blockkit.model.resource.Segment
7978import kotlinx.collections.immutable.ImmutableList
8079import kotlinx.collections.immutable.persistentListOf
8180import ss.misc.DateHelper
82- import androidx.compose.material.icons.Icons as MaterialIcons
8381import app.ss.translations.R as L10nR
82+ import com.pspdfkit.R as PspdfR
8483import ss.document.R as DocumentR
8584import ss.libraries.media.resources.R as MediaR
8685
@@ -113,6 +112,21 @@ enum class DocumentTopAppBarAction(
113112 iconRes = DocumentR .drawable.ic_text_format,
114113 title = L10nR .string.ss_settings_display_options,
115114 primary = false ,
115+ ),
116+ Annotations (
117+ iconRes = DocumentR .drawable.ic_pdf_annotations,
118+ title = L10nR .string.ss_annotations,
119+ primary = true ,
120+ ),
121+ Outline (
122+ iconRes = DocumentR .drawable.ic_pdf_bookmark,
123+ title = PspdfR .string.pspdf__activity_menu_outline,
124+ primary = true ,
125+ ),
126+ Settings (
127+ iconRes = DocumentR .drawable.ic_pdf_settings,
128+ title = PspdfR .string.pspdf__activity_menu_settings,
129+ primary = true ,
116130 )
117131}
118132
@@ -126,11 +140,21 @@ internal fun DocumentTopAppBar(
126140 contentColor : Color = SsTheme .colors.primaryForeground,
127141 scrollBehavior : TopAppBarScrollBehavior ? = null,
128142 actions : ImmutableList <DocumentTopAppBarAction > = persistentListOf(),
143+ colors : TopAppBarColors = TopAppBarDefaults .topAppBarColors(
144+ containerColor = Color .Transparent ,
145+ scrolledContainerColor = Color .Transparent ,
146+ ),
129147 onNavBack : () -> Unit = {},
130148 onActionClick : (DocumentTopAppBarAction ) -> Unit = {},
131149) {
132150 val hapticFeedback = LocalSsHapticFeedback .current
133151 var expanded by remember { mutableStateOf(false ) }
152+
153+ val primaryActions = remember(actions) { actions.filter { it.primary } }
154+ val nonPrimaryActions = remember(actions) { actions.filter { ! it.primary } }
155+ val visibleActions = remember(primaryActions) { primaryActions.take(2 ) }
156+ val overflowActions = remember(primaryActions, nonPrimaryActions) { primaryActions.drop(2 ) + nonPrimaryActions }
157+
134158 Box (
135159 modifier = Modifier
136160 .fillMaxWidth()
@@ -144,7 +168,7 @@ internal fun DocumentTopAppBar(
144168 shape = RoundedCornerShape (16 .dp),
145169 containerColor = SsTheme .colors.primaryBackground,
146170 ) {
147- actions.filter { ! it.primary } .forEach { action ->
171+ overflowActions .forEach { action ->
148172 DropdownMenuItem (
149173 text = {
150174 Text (
@@ -219,7 +243,8 @@ internal fun DocumentTopAppBar(
219243 },
220244 actions = {
221245 buildList {
222- actions.filter { it.primary }.forEach { action ->
246+ // Add the visible primary actions (up to 2)
247+ visibleActions.forEach { action ->
223248 add(
224249 IconButtonResSlot (
225250 iconRes = action.iconRes,
@@ -228,10 +253,12 @@ internal fun DocumentTopAppBar(
228253 )
229254 )
230255 }
231- if (actions.any { ! it.primary }) {
256+
257+ // Add the "More" icon if there are any secondary or overflowed primary actions
258+ if (overflowActions.isNotEmpty()) {
232259 add(
233- IconButtonSlot (
234- imageVector = MaterialIcons . Rounded . MoreVert ,
260+ IconButtonResSlot (
261+ iconRes = DocumentR .drawable.ic_more_vert ,
235262 contentDescription = stringResource(L10nR .string.ss_more),
236263 onClick = {
237264 expanded = true
@@ -242,12 +269,7 @@ internal fun DocumentTopAppBar(
242269 }
243270 }.forEach { icon ->
244271 val iconColor by topAppBarContentColor(collapsible, collapsed, contentColor)
245- val onClick = (icon as ? IconButtonSlot )?.onClick ? : (icon as ? IconButtonResSlot )?.onClick
246- IconButton (
247- onClick = {
248- onClick?.invoke()
249- },
250- ) {
272+ IconButton (onClick = { icon.onClick() }) {
251273 IconBox (
252274 icon = icon,
253275 contentColor = iconColor,
@@ -256,10 +278,7 @@ internal fun DocumentTopAppBar(
256278 }
257279 },
258280 scrollBehavior = scrollBehavior,
259- colors = TopAppBarDefaults .topAppBarColors(
260- containerColor = Color .Transparent ,
261- scrolledContainerColor = Color .Transparent ,
262- )
281+ colors = colors
263282 )
264283}
265284
0 commit comments