feat(ui): enhance overflow menu with custom shape and icons (#5733)

This commit adds custom icons to PreferenceDashboard's overflow menu and adds a custom shape to OverflowMenu's DropDown composable.

Co-authored-by: SuperDragonXD <70206496+SuperDragonXD@users.noreply.github.com>
This commit is contained in:
foXaCe
2025-09-08 07:19:38 +02:00
committed by GitHub
parent 80f375c710
commit cd8dbbfe6c
2 changed files with 90 additions and 30 deletions

View File

@@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.MoreVert
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
@@ -32,6 +33,7 @@ fun OverflowMenu(
expanded = showMenu.value,
onDismissRequest = { showMenu.value = false },
offset = DpOffset(x = (-2).dp, y = (-48).dp),
shape = MaterialTheme.shapes.large,
) {
block(overflowMenuScope)
}

View File

@@ -15,7 +15,14 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Backup
import androidx.compose.material.icons.outlined.Science
import androidx.compose.material.icons.outlined.SettingsBackupRestore
import androidx.compose.material.icons.rounded.Backup
import androidx.compose.material.icons.rounded.Build
import androidx.compose.material.icons.rounded.Refresh
import androidx.compose.material.icons.rounded.Science
import androidx.compose.material.icons.rounded.SettingsBackupRestore
import androidx.compose.material.icons.rounded.TipsAndUpdates
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Icon
@@ -28,6 +35,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.core.content.getSystemService
@@ -248,37 +256,87 @@ fun RowScope.PreferencesOverflowMenu(
},
) {
val context = LocalContext.current
DropdownMenuItem(onClick = {
openAppInfo(context)
hideMenu()
}, text = {
Text(text = stringResource(id = R.string.app_info_drop_target_label))
})
DropdownMenuItem(onClick = {
restartLauncher(context)
hideMenu()
}, text = {
Text(text = stringResource(id = R.string.debug_restart_launcher))
})
DropdownMenuItem(onClick = {
onNavigate(ExperimentalFeatures)
hideMenu()
}, text = {
Text(text = stringResource(id = R.string.experimental_features_label))
})
DropdownMenuItem(
leadingIcon = {
Icon(
painter = painterResource(R.drawable.ic_about),
contentDescription = null,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
)
},
onClick = {
openAppInfo(context)
hideMenu()
},
text = {
Text(text = stringResource(id = R.string.app_info_drop_target_label))
},
)
DropdownMenuItem(
leadingIcon = {
Icon(
imageVector = Icons.Rounded.Refresh,
contentDescription = null,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
)
},
onClick = {
restartLauncher(context)
hideMenu()
},
text = {
Text(text = stringResource(id = R.string.debug_restart_launcher))
},
)
DropdownMenuItem(
leadingIcon = {
Icon(
imageVector = Icons.Outlined.Science,
contentDescription = null,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
)
},
onClick = {
onNavigate(ExperimentalFeatures)
hideMenu()
},
text = {
Text(text = stringResource(id = R.string.experimental_features_label))
},
)
PreferenceDivider(modifier = Modifier.padding(vertical = 8.dp))
DropdownMenuItem(onClick = {
openCreateBackup()
hideMenu()
}, text = {
Text(text = stringResource(id = R.string.create_backup))
})
DropdownMenuItem(onClick = {
openRestoreBackup()
hideMenu()
}, text = {
Text(text = stringResource(id = R.string.restore_backup))
})
DropdownMenuItem(
leadingIcon = {
Icon(
imageVector = Icons.Outlined.Backup,
contentDescription = null,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
)
},
onClick = {
openCreateBackup()
hideMenu()
},
text = {
Text(text = stringResource(id = R.string.create_backup))
},
)
DropdownMenuItem(
leadingIcon = {
Icon(
imageVector = Icons.Rounded.SettingsBackupRestore,
contentDescription = null,
tint = MaterialTheme.colorScheme.onSurfaceVariant,
)
},
onClick = {
openRestoreBackup()
hideMenu()
},
text = {
Text(text = stringResource(id = R.string.restore_backup))
},
)
}
}