Skip to content

Latest commit

 

History

History
60 lines (52 loc) · 1.98 KB

File metadata and controls

60 lines (52 loc) · 1.98 KB
Screenshot

This shows a simple button preference. It allows you to handle a click action.

Check out the composable and it's documentation in the code snipplet below.

Example

PreferenceButton(
    title = "Button 1",
    subtitle = "Clicking this button will increase counter 1",
    icon = { Icon(Icons.Default.AdsClick, null) },
    onClick = {
        showInfo("Button 1 clicked!")
        counter1++
    }
)

Composable

/**
 * A button preference item - this item simply executes an action on click
 *
 *  
 *
 * **Basic Parameters:** all params not described here are derived from [com.michaelflisar.composepreferences.core.composables.BasePreference], check it out for more details
 *
 * @param onClick the click callback of this item
 */
@Composable
fun PreferenceScope.PreferenceButton(
    // Special
    onClick: (() -> Unit),
    // Base Preference
    title: String,
    enabled: Dependency = Dependency.Enabled,
    visible: Dependency = Dependency.Enabled,
    subtitle: String? = null,
    icon: (@Composable () -> Unit)? = null,
    itemStyle: PreferenceItemStyle = LocalPreferenceSettings.current.style.defaultItemStyle,
    titleRenderer: @Composable (text: AnnotatedString) -> Unit = { Text(it) },
    subtitleRenderer: @Composable (text: AnnotatedString) -> Unit = { Text(it) },
    filterTags: List<String> = emptyList()
)

Screenshots

Screenshot Screenshot