All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.softartdev.theme.material.SettingsScaffold.kt Maven / Gradle / Ivy

Go to download

Kotlin Multiplatform library for easy switching Dark/Light Material themes on Compose.

There is a newer version: 0.9.1
Show newest version
package com.softartdev.theme.material

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.RowScope
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.vector.ImageVector
import io.github.softartdev.theme_prefs.generated.resources.Res
import io.github.softartdev.theme_prefs.generated.resources.settings
import org.jetbrains.compose.resources.stringResource

@Composable
fun SettingsScaffold(
    onBackClick: () -> Unit = {},
    actions: @Composable RowScope.() -> Unit = {},
    content: @Composable (PaddingValues) -> Unit
) = Scaffold(
    topBar = { SettingsTopAppBar(onBackClick, actions) },
    content = content
)

@Composable
fun SettingsTopAppBar(
    onBackClick: () -> Unit = {},
    actions: @Composable RowScope.() -> Unit = {},
    localizedText: String = stringResource(Res.string.settings),
    backVector: ImageVector = Icons.AutoMirrored.Filled.ArrowBack,
) = TopAppBar(
    title = { Text(localizedText) },
    navigationIcon = {
        IconButton(onClick = onBackClick) {
            Icon(imageVector = backVector, contentDescription = backVector.name)
        }
    },
    actions = actions
)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy