From a3f442df7d1c72efeb092c5dac5faf069b1bb0e3 Mon Sep 17 00:00:00 2001 From: Artur Babichev Date: Fri, 14 Feb 2025 21:43:52 +0400 Subject: [PATCH] explicit api --- theme/theme-material/build.gradle.kts | 1 + .../theme/material/MaterialThemePrefs.kt | 16 +++---- .../theme/material/MenuPreference.kt | 12 ++--- .../theme/material/PreferableMaterialTheme.kt | 2 +- .../theme/material/RadioDialogContent.kt | 44 +++++++++--------- .../theme/material/SettingsScaffold.kt | 8 ++-- .../softartdev/theme/material/ThemeDialog.kt | 2 +- theme/theme-material3/build.gradle.kts | 1 + .../theme/material3/Material3ThemePrefs.kt | 16 +++---- .../theme/material3/MenuPreference.kt | 12 ++--- .../material3/PreferableMaterialTheme.kt | 2 +- .../theme/material3/RadioDialogContent.kt | 46 ++++++++++--------- .../theme/material3/SettingsScaffold.kt | 8 ++-- .../softartdev/theme/material3/ThemeDialog.kt | 2 +- theme/theme-prefs/build.gradle.kts | 1 + .../theme/pref/AndroidPreferenceHelper.kt | 4 +- .../softartdev/theme/pref/PreferenceHelper.kt | 12 ++--- .../com/softartdev/theme/pref/ThemeEnum.kt | 2 +- .../com/softartdev/theme/pref/ThemePrefs.kt | 12 ++--- .../theme/pref/JvmPreferenceHelper.kt | 4 +- .../theme/pref/IosPreferenceHelper.kt | 4 +- 21 files changed, 109 insertions(+), 102 deletions(-) diff --git a/theme/theme-material/build.gradle.kts b/theme/theme-material/build.gradle.kts index 7c67a82..c2755b4 100644 --- a/theme/theme-material/build.gradle.kts +++ b/theme/theme-material/build.gradle.kts @@ -34,6 +34,7 @@ kotlin { implementation(kotlin("test")) } } + explicitApi() } android { compileSdk = rootProject.extra["android_compile_sdk_version"] as Int diff --git a/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/MaterialThemePrefs.kt b/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/MaterialThemePrefs.kt index 989dfac..a535c40 100644 --- a/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/MaterialThemePrefs.kt +++ b/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/MaterialThemePrefs.kt @@ -12,13 +12,13 @@ import com.softartdev.theme.pref.ThemeEnum import com.softartdev.theme.pref.ThemePrefs import com.softartdev.theme.pref.rememberPreferenceHelper -class MaterialThemePrefs( +public class MaterialThemePrefs( preferenceHelper: PreferenceHelper, - val darkColorPalette: Colors = darkColors(), - val lightColorPalette: Colors = lightColors() + private val darkColorPalette: Colors = darkColors(), + private val lightColorPalette: Colors = lightColors() ) : ThemePrefs(preferenceHelper) { - val colors: Colors + public val colors: Colors @Composable @ReadOnlyComposable get() = when (darkThemeState.value) { @@ -28,7 +28,7 @@ class MaterialThemePrefs( } } -val ThemePrefs.colors: Colors +public val ThemePrefs.colors: Colors @Composable @ReadOnlyComposable get() { @@ -37,17 +37,17 @@ val ThemePrefs.colors: Colors } @Composable -fun rememberThemePrefs(): MaterialThemePrefs { +public fun rememberThemePrefs(): MaterialThemePrefs { val preferenceHelper = rememberPreferenceHelper() return remember { MaterialThemePrefs(preferenceHelper) } } @Composable -fun rememberThemePrefs( +public fun rememberThemePrefs( preferHelper: PreferenceHelper = rememberPreferenceHelper(), darkColorPalette: Colors = darkColors(), lightColorPalette: Colors = lightColors() -) = remember( +): MaterialThemePrefs = remember( key1 = preferHelper, key2 = darkColorPalette, key3 = lightColorPalette diff --git a/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/MenuPreference.kt b/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/MenuPreference.kt index 607c992..47f2d57 100644 --- a/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/MenuPreference.kt +++ b/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/MenuPreference.kt @@ -22,16 +22,16 @@ import io.github.softartdev.theme_prefs.generated.resources.theme import org.jetbrains.compose.resources.stringResource @Composable -fun ThemePreferencesCategory() = PreferenceCategory( +public fun ThemePreferencesCategory(): Unit = PreferenceCategory( title = stringResource(Res.string.theme), vector = Icons.Filled.Brightness4 ) @Composable -fun ThemePreferenceItem( +public fun ThemePreferenceItem( themePrefs: ThemePrefs = LocalThemePrefs.current, onClick: () -> Unit = {} -) = PreferenceItem( +): Unit = PreferenceItem( title = stringResource(Res.string.choose_theme), vector = Icons.Filled.SettingsBrightness, secondaryText = { Text(text = stringResource(themePrefs.darkThemeState.value.stringRes)) }, @@ -39,7 +39,7 @@ fun ThemePreferenceItem( ) @Composable -fun PreferenceCategory(title: String, vector: ImageVector) = ListItem( +public fun PreferenceCategory(title: String, vector: ImageVector): Unit = ListItem( icon = { Icon(imageVector = vector, contentDescription = title) }, text = { Text(text = title, @@ -49,13 +49,13 @@ fun PreferenceCategory(title: String, vector: ImageVector) = ListItem( ) @Composable -fun PreferenceItem( +public fun PreferenceItem( title: String, vector: ImageVector, onClick: () -> Unit = {}, secondaryText: @Composable (() -> Unit)? = null, trailing: @Composable (() -> Unit)? = null, -) = ListItem( +): Unit = ListItem( modifier = Modifier.clickable(onClick = onClick), icon = { Icon(imageVector = vector, contentDescription = title) }, text = { Text(text = title) }, diff --git a/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/PreferableMaterialTheme.kt b/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/PreferableMaterialTheme.kt index 79ae66b..7887eb9 100644 --- a/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/PreferableMaterialTheme.kt +++ b/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/PreferableMaterialTheme.kt @@ -9,7 +9,7 @@ import androidx.compose.runtime.CompositionLocalProvider import com.softartdev.theme.pref.* @Composable -fun PreferableMaterialTheme( +public fun PreferableMaterialTheme( preferHelper: PreferenceHelper = rememberPreferenceHelper(), darkColorPalette: Colors = darkColors(), lightColorPalette: Colors = lightColors(), diff --git a/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/RadioDialogContent.kt b/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/RadioDialogContent.kt index a15ebbd..dced1cd 100644 --- a/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/RadioDialogContent.kt +++ b/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/RadioDialogContent.kt @@ -20,29 +20,31 @@ import com.softartdev.theme.pref.ThemeEnum import org.jetbrains.compose.resources.stringResource @Composable -fun RadioDialogContent(darkThemeState: MutableState) = Column(Modifier.selectableGroup()) { - ThemeEnum.entries.forEach { themeEnum: ThemeEnum -> - Row( - Modifier - .fillMaxWidth() - .height(56.dp) - .selectable( +public fun RadioDialogContent(darkThemeState: MutableState) { + Column(modifier = Modifier.selectableGroup()) { + ThemeEnum.entries.forEach { themeEnum: ThemeEnum -> + Row( + modifier = Modifier + .fillMaxWidth() + .height(56.dp) + .selectable( + selected = themeEnum == darkThemeState.value, + onClick = { darkThemeState.value = themeEnum }, + role = Role.RadioButton + ) + .padding(horizontal = 16.dp), + verticalAlignment = Alignment.CenterVertically + ) { + RadioButton( selected = themeEnum == darkThemeState.value, - onClick = { darkThemeState.value = themeEnum }, - role = Role.RadioButton + onClick = null // null recommended for accessibility with screenreaders ) - .padding(horizontal = 16.dp), - verticalAlignment = Alignment.CenterVertically - ) { - RadioButton( - selected = themeEnum == darkThemeState.value, - onClick = null // null recommended for accessibility with screenreaders - ) - Text( - text = stringResource(themeEnum.stringRes), - style = MaterialTheme.typography.body1.merge(), - modifier = Modifier.padding(start = 16.dp) - ) + Text( + text = stringResource(themeEnum.stringRes), + style = MaterialTheme.typography.body1.merge(), + modifier = Modifier.padding(start = 16.dp) + ) + } } } } \ No newline at end of file diff --git a/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/SettingsScaffold.kt b/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/SettingsScaffold.kt index eb8050d..bc069d6 100644 --- a/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/SettingsScaffold.kt +++ b/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/SettingsScaffold.kt @@ -16,22 +16,22 @@ import io.github.softartdev.theme_prefs.generated.resources.settings import org.jetbrains.compose.resources.stringResource @Composable -fun SettingsScaffold( +public fun SettingsScaffold( onBackClick: () -> Unit = {}, actions: @Composable RowScope.() -> Unit = {}, content: @Composable (PaddingValues) -> Unit -) = Scaffold( +): Unit = Scaffold( topBar = { SettingsTopAppBar(onBackClick, actions) }, content = content ) @Composable -fun SettingsTopAppBar( +public fun SettingsTopAppBar( onBackClick: () -> Unit = {}, actions: @Composable RowScope.() -> Unit = {}, localizedText: String = stringResource(Res.string.settings), backVector: ImageVector = Icons.AutoMirrored.Filled.ArrowBack, -) = TopAppBar( +): Unit = TopAppBar( title = { Text(localizedText) }, navigationIcon = { IconButton(onClick = onBackClick) { diff --git a/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/ThemeDialog.kt b/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/ThemeDialog.kt index b2be463..3c2c72b 100644 --- a/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/ThemeDialog.kt +++ b/theme/theme-material/src/commonMain/kotlin/com/softartdev/theme/material/ThemeDialog.kt @@ -15,7 +15,7 @@ import io.github.softartdev.theme_prefs.generated.resources.ok import org.jetbrains.compose.resources.stringResource @Composable -fun ThemeDialog( +public fun ThemeDialog( darkThemeState: MutableState = mutableStateOf(ThemeEnum.SystemDefault), writePref: (ThemeEnum) -> Unit = {}, dismissDialog: () -> Unit = {} diff --git a/theme/theme-material3/build.gradle.kts b/theme/theme-material3/build.gradle.kts index 7ac29d0..cda1507 100644 --- a/theme/theme-material3/build.gradle.kts +++ b/theme/theme-material3/build.gradle.kts @@ -35,6 +35,7 @@ kotlin { implementation(kotlin("test")) } } + explicitApi() } android { compileSdk = rootProject.extra["android_compile_sdk_version"] as Int diff --git a/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/Material3ThemePrefs.kt b/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/Material3ThemePrefs.kt index ea34fce..5f782bb 100644 --- a/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/Material3ThemePrefs.kt +++ b/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/Material3ThemePrefs.kt @@ -9,13 +9,13 @@ import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.runtime.remember import com.softartdev.theme.pref.* -class Material3ThemePrefs( +public class Material3ThemePrefs( preferenceHelper: PreferenceHelper, - val darkColorScheme: ColorScheme = darkColorScheme(), - val lightColorScheme: ColorScheme = lightColorScheme() + private val darkColorScheme: ColorScheme = darkColorScheme(), + private val lightColorScheme: ColorScheme = lightColorScheme() ) : ThemePrefs(preferenceHelper) { - val colorScheme: ColorScheme + public val colorScheme: ColorScheme @Composable @ReadOnlyComposable get() = when (darkThemeState.value) { @@ -25,7 +25,7 @@ class Material3ThemePrefs( } } -val ThemePrefs.colorScheme: ColorScheme +public val ThemePrefs.colorScheme: ColorScheme @Composable @ReadOnlyComposable get() { @@ -34,17 +34,17 @@ val ThemePrefs.colorScheme: ColorScheme } @Composable -fun rememberThemePrefs(): Material3ThemePrefs { +public fun rememberThemePrefs(): Material3ThemePrefs { val preferenceHelper = rememberPreferenceHelper() return remember { Material3ThemePrefs(preferenceHelper) } } @Composable -fun rememberThemePrefs( +public fun rememberThemePrefs( preferHelper: PreferenceHelper = rememberPreferenceHelper(), darkColorScheme: ColorScheme = darkColorScheme(), lightColorScheme: ColorScheme = lightColorScheme() -) = remember( +): Material3ThemePrefs = remember( key1 = preferHelper, key2 = darkColorScheme, key3 = lightColorScheme diff --git a/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/MenuPreference.kt b/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/MenuPreference.kt index b9e4d5d..a5abede 100644 --- a/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/MenuPreference.kt +++ b/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/MenuPreference.kt @@ -19,16 +19,16 @@ import io.github.softartdev.theme_prefs.generated.resources.theme import org.jetbrains.compose.resources.stringResource @Composable -fun ThemePreferencesCategory() = PreferenceCategory( +public fun ThemePreferencesCategory(): Unit = PreferenceCategory( title = stringResource(Res.string.theme), vector = Icons.Filled.Brightness4 ) @Composable -fun ThemePreferenceItem( +public fun ThemePreferenceItem( themePrefs: ThemePrefs = LocalThemePrefs.current, onClick: () -> Unit = {} -) = PreferenceItem( +): Unit = PreferenceItem( title = stringResource(Res.string.choose_theme), vector = Icons.Filled.SettingsBrightness, secondaryText = { Text(text = stringResource(themePrefs.darkThemeState.value.stringRes)) }, @@ -36,7 +36,7 @@ fun ThemePreferenceItem( ) @Composable -fun PreferenceCategory(title: String, vector: ImageVector) = ListItem( +public fun PreferenceCategory(title: String, vector: ImageVector): Unit = ListItem( leadingContent = { Icon(imageVector = vector, contentDescription = title) }, headlineContent = { Text(text = title, @@ -46,13 +46,13 @@ fun PreferenceCategory(title: String, vector: ImageVector) = ListItem( ) @Composable -fun PreferenceItem( +public fun PreferenceItem( title: String, vector: ImageVector, onClick: () -> Unit = {}, secondaryText: @Composable (() -> Unit)? = null, trailing: @Composable (() -> Unit)? = null, -) = ListItem( +): Unit = ListItem( modifier = Modifier.clickable(onClick = onClick), leadingContent = { Icon(imageVector = vector, contentDescription = title) }, headlineContent = { Text(text = title) }, diff --git a/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/PreferableMaterialTheme.kt b/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/PreferableMaterialTheme.kt index 0544007..4fec979 100644 --- a/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/PreferableMaterialTheme.kt +++ b/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/PreferableMaterialTheme.kt @@ -9,7 +9,7 @@ import androidx.compose.runtime.CompositionLocalProvider import com.softartdev.theme.pref.* @Composable -fun PreferableMaterialTheme( +public fun PreferableMaterialTheme( preferHelper: PreferenceHelper = rememberPreferenceHelper(), darkColorScheme: ColorScheme = darkColorScheme(), lightColorScheme: ColorScheme = lightColorScheme(), diff --git a/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/RadioDialogContent.kt b/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/RadioDialogContent.kt index 1d51440..7d2fa76 100644 --- a/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/RadioDialogContent.kt +++ b/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/RadioDialogContent.kt @@ -20,29 +20,31 @@ import com.softartdev.theme.pref.ThemeEnum import org.jetbrains.compose.resources.stringResource @Composable -fun RadioDialogContent(darkThemeState: MutableState) = Column(Modifier.selectableGroup()) { - ThemeEnum.entries.forEach { themeEnum: ThemeEnum -> - Row( - Modifier - .fillMaxWidth() - .height(56.dp) - .selectable( +public fun RadioDialogContent(darkThemeState: MutableState) { + Column(modifier = Modifier.selectableGroup()) { + ThemeEnum.entries.forEach { themeEnum: ThemeEnum -> + Row( + modifier = Modifier + .fillMaxWidth() + .height(56.dp) + .selectable( + selected = themeEnum == darkThemeState.value, + onClick = { darkThemeState.value = themeEnum }, + role = Role.RadioButton + ) + .padding(horizontal = 16.dp), + verticalAlignment = Alignment.CenterVertically + ) { + RadioButton( selected = themeEnum == darkThemeState.value, - onClick = { darkThemeState.value = themeEnum }, - role = Role.RadioButton + onClick = null // null recommended for accessibility with screenreaders ) - .padding(horizontal = 16.dp), - verticalAlignment = Alignment.CenterVertically - ) { - RadioButton( - selected = themeEnum == darkThemeState.value, - onClick = null // null recommended for accessibility with screenreaders - ) - Text( - text = stringResource(themeEnum.stringRes), - style = MaterialTheme.typography.bodyLarge.merge(), - modifier = Modifier.padding(start = 16.dp) - ) + Text( + text = stringResource(themeEnum.stringRes), + style = MaterialTheme.typography.bodyLarge.merge(), + modifier = Modifier.padding(start = 16.dp) + ) + } } } -} \ No newline at end of file +} diff --git a/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/SettingsScaffold.kt b/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/SettingsScaffold.kt index 4e8d856..a1a0de7 100644 --- a/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/SettingsScaffold.kt +++ b/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/SettingsScaffold.kt @@ -19,22 +19,22 @@ import io.github.softartdev.theme_prefs.generated.resources.settings import org.jetbrains.compose.resources.stringResource @Composable -fun SettingsScaffold( +public fun SettingsScaffold( onBackClick: () -> Unit = {}, actions: @Composable RowScope.() -> Unit = {}, content: @Composable (PaddingValues) -> Unit -) = Scaffold( +): Unit = Scaffold( topBar = { SettingsTopAppBar(onBackClick, actions) }, content = content ) @Composable -fun SettingsTopAppBar( +public fun SettingsTopAppBar( onBackClick: () -> Unit = {}, actions: @Composable RowScope.() -> Unit = {}, localizedText: String = stringResource(Res.string.settings), backVector: ImageVector = Icons.AutoMirrored.Filled.ArrowBack, -) = TopAppBar( +): Unit = TopAppBar( title = { Text(localizedText) }, navigationIcon = { IconButton(onClick = onBackClick) { diff --git a/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/ThemeDialog.kt b/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/ThemeDialog.kt index b6c0f86..b2d10f9 100644 --- a/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/ThemeDialog.kt +++ b/theme/theme-material3/src/commonMain/kotlin/com/softartdev/theme/material3/ThemeDialog.kt @@ -15,7 +15,7 @@ import io.github.softartdev.theme_prefs.generated.resources.ok import org.jetbrains.compose.resources.stringResource @Composable -fun ThemeDialog( +public fun ThemeDialog( darkThemeState: MutableState = mutableStateOf(ThemeEnum.SystemDefault), writePref: (ThemeEnum) -> Unit = {}, dismissDialog: () -> Unit = {} diff --git a/theme/theme-prefs/build.gradle.kts b/theme/theme-prefs/build.gradle.kts index e1abf30..44505d1 100644 --- a/theme/theme-prefs/build.gradle.kts +++ b/theme/theme-prefs/build.gradle.kts @@ -36,6 +36,7 @@ kotlin { api(compose.ui) } } + explicitApi() } android { compileSdk = rootProject.extra["android_compile_sdk_version"] as Int diff --git a/theme/theme-prefs/src/androidMain/kotlin/com/softartdev/theme/pref/AndroidPreferenceHelper.kt b/theme/theme-prefs/src/androidMain/kotlin/com/softartdev/theme/pref/AndroidPreferenceHelper.kt index 6248729..aa25bd4 100644 --- a/theme/theme-prefs/src/androidMain/kotlin/com/softartdev/theme/pref/AndroidPreferenceHelper.kt +++ b/theme/theme-prefs/src/androidMain/kotlin/com/softartdev/theme/pref/AndroidPreferenceHelper.kt @@ -5,7 +5,7 @@ import android.content.SharedPreferences import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalContext -class AndroidPreferenceHelper(context: Context) : PreferenceHelper { +internal class AndroidPreferenceHelper(context: Context) : PreferenceHelper { private val preferences: SharedPreferences = context.getSharedPreferences(context.packageName + "_ThemePref", Context.MODE_PRIVATE) @@ -18,7 +18,7 @@ class AndroidPreferenceHelper(context: Context) : PreferenceHelper { } @Composable -actual fun obtainPreferenceHelper(): PreferenceHelper { +internal actual fun obtainPreferenceHelper(): PreferenceHelper { val context = LocalContext.current.applicationContext return AndroidPreferenceHelper(context) } \ No newline at end of file diff --git a/theme/theme-prefs/src/commonMain/kotlin/com/softartdev/theme/pref/PreferenceHelper.kt b/theme/theme-prefs/src/commonMain/kotlin/com/softartdev/theme/pref/PreferenceHelper.kt index 2166acd..30a78ee 100644 --- a/theme/theme-prefs/src/commonMain/kotlin/com/softartdev/theme/pref/PreferenceHelper.kt +++ b/theme/theme-prefs/src/commonMain/kotlin/com/softartdev/theme/pref/PreferenceHelper.kt @@ -3,20 +3,20 @@ package com.softartdev.theme.pref import androidx.compose.runtime.Composable import androidx.compose.runtime.remember -interface PreferenceHelper { +public interface PreferenceHelper { - var themeEnum: ThemeEnum + public var themeEnum: ThemeEnum - fun clear() + public fun clear() } -const val THEME_KEY: String = "theme_key" +internal const val THEME_KEY: String = "theme_key" @Composable -expect fun obtainPreferenceHelper(): PreferenceHelper +internal expect fun obtainPreferenceHelper(): PreferenceHelper @Composable -fun rememberPreferenceHelper(): PreferenceHelper { +public fun rememberPreferenceHelper(): PreferenceHelper { val preferenceHelper = obtainPreferenceHelper() return remember { preferenceHelper } } \ No newline at end of file diff --git a/theme/theme-prefs/src/commonMain/kotlin/com/softartdev/theme/pref/ThemeEnum.kt b/theme/theme-prefs/src/commonMain/kotlin/com/softartdev/theme/pref/ThemeEnum.kt index 8a8550a..bae46a5 100644 --- a/theme/theme-prefs/src/commonMain/kotlin/com/softartdev/theme/pref/ThemeEnum.kt +++ b/theme/theme-prefs/src/commonMain/kotlin/com/softartdev/theme/pref/ThemeEnum.kt @@ -6,7 +6,7 @@ import io.github.softartdev.theme_prefs.generated.resources.light import io.github.softartdev.theme_prefs.generated.resources.system_default import org.jetbrains.compose.resources.StringResource -enum class ThemeEnum(val stringRes: StringResource) { +public enum class ThemeEnum(public val stringRes: StringResource) { Light(Res.string.light), Dark(Res.string.dark), SystemDefault(Res.string.system_default) diff --git a/theme/theme-prefs/src/commonMain/kotlin/com/softartdev/theme/pref/ThemePrefs.kt b/theme/theme-prefs/src/commonMain/kotlin/com/softartdev/theme/pref/ThemePrefs.kt index eeff0d6..d0d2d3c 100644 --- a/theme/theme-prefs/src/commonMain/kotlin/com/softartdev/theme/pref/ThemePrefs.kt +++ b/theme/theme-prefs/src/commonMain/kotlin/com/softartdev/theme/pref/ThemePrefs.kt @@ -2,19 +2,19 @@ package com.softartdev.theme.pref import androidx.compose.runtime.* -val LocalThemePrefs = staticCompositionLocalOf { +public val LocalThemePrefs: ProvidableCompositionLocal = staticCompositionLocalOf { error("CompositionLocal LocalThemePrefs not present") } -abstract class ThemePrefs( - val preferenceHelper: PreferenceHelper, +public abstract class ThemePrefs( + public val preferenceHelper: PreferenceHelper, ) { - val darkThemeState: MutableState = mutableStateOf(preferenceHelper.themeEnum) + public val darkThemeState: MutableState = mutableStateOf(preferenceHelper.themeEnum) } -object PreferableMaterialTheme { +public object PreferableMaterialTheme { - val themePrefs: ThemePrefs + public val themePrefs: ThemePrefs @Composable @ReadOnlyComposable get() = LocalThemePrefs.current diff --git a/theme/theme-prefs/src/desktopMain/kotlin/com/softartdev/theme/pref/JvmPreferenceHelper.kt b/theme/theme-prefs/src/desktopMain/kotlin/com/softartdev/theme/pref/JvmPreferenceHelper.kt index 32e4315..624a064 100644 --- a/theme/theme-prefs/src/desktopMain/kotlin/com/softartdev/theme/pref/JvmPreferenceHelper.kt +++ b/theme/theme-prefs/src/desktopMain/kotlin/com/softartdev/theme/pref/JvmPreferenceHelper.kt @@ -3,7 +3,7 @@ package com.softartdev.theme.pref import androidx.compose.runtime.Composable import java.util.prefs.Preferences -class JvmPreferenceHelper : PreferenceHelper { +internal class JvmPreferenceHelper : PreferenceHelper { private var preferences: Preferences = Preferences.userNodeForPackage(ThemeEnum::class.java) @@ -15,4 +15,4 @@ class JvmPreferenceHelper : PreferenceHelper { } @Composable -actual fun obtainPreferenceHelper(): PreferenceHelper = JvmPreferenceHelper() \ No newline at end of file +internal actual fun obtainPreferenceHelper(): PreferenceHelper = JvmPreferenceHelper() \ No newline at end of file diff --git a/theme/theme-prefs/src/iosMain/kotlin/com/softartdev/theme/pref/IosPreferenceHelper.kt b/theme/theme-prefs/src/iosMain/kotlin/com/softartdev/theme/pref/IosPreferenceHelper.kt index 0b925b5..2160f01 100644 --- a/theme/theme-prefs/src/iosMain/kotlin/com/softartdev/theme/pref/IosPreferenceHelper.kt +++ b/theme/theme-prefs/src/iosMain/kotlin/com/softartdev/theme/pref/IosPreferenceHelper.kt @@ -3,7 +3,7 @@ package com.softartdev.theme.pref import androidx.compose.runtime.Composable import platform.Foundation.NSUserDefaults -class IosPreferenceHelper : PreferenceHelper { +internal class IosPreferenceHelper : PreferenceHelper { private var preferences: NSUserDefaults = NSUserDefaults.standardUserDefaults @@ -15,4 +15,4 @@ class IosPreferenceHelper : PreferenceHelper { } @Composable -actual fun obtainPreferenceHelper(): PreferenceHelper = IosPreferenceHelper() \ No newline at end of file +internal actual fun obtainPreferenceHelper(): PreferenceHelper = IosPreferenceHelper() \ No newline at end of file