refactor: migrate to simple commons theming and remove the POC from the app

This commit is contained in:
FunkyMuse 2023-07-31 10:19:45 +02:00
parent 4f3f7c7c66
commit c000b22899
21 changed files with 24 additions and 1131 deletions

View file

@ -10,14 +10,14 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.core.view.WindowCompat
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.simplemobiletools.calculator.compose.extensions.TransparentSystemBars
import com.simplemobiletools.calculator.compose.extensions.onEventValue
import com.simplemobiletools.calculator.compose.screens.SettingsScreen
import com.simplemobiletools.calculator.compose.theme.AppThemeSurface
import com.simplemobiletools.calculator.compose.theme.getAppIconIds
import com.simplemobiletools.calculator.compose.theme.getAppLauncherName
import com.simplemobiletools.calculator.extensions.*
import com.simplemobiletools.commons.activities.CustomizationActivity
import com.simplemobiletools.commons.compose.extensions.TransparentSystemBars
import com.simplemobiletools.commons.compose.extensions.onEventValue
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
import com.simplemobiletools.commons.compose.theme.getAppIconIds
import com.simplemobiletools.commons.compose.theme.getAppLauncherName
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import java.util.Locale

View file

@ -1,8 +0,0 @@
package com.simplemobiletools.calculator.compose.extensions
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
class BooleanPreviewParameterProvider : PreviewParameterProvider<Boolean> {
override val values: Sequence<Boolean>
get() = sequenceOf(false, true)
}

View file

@ -1,38 +0,0 @@
package com.simplemobiletools.calculator.compose.extensions
import android.app.Activity
import android.content.Context
import android.content.ContextWrapper
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.*
import androidx.compose.ui.graphics.Color
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LifecycleEventEffect
import com.google.accompanist.systemuicontroller.rememberSystemUiController
fun Context.getActivity(): Activity {
return when (this) {
is Activity -> this
is ContextWrapper -> baseContext.getActivity()
else -> getActivity()
}
}
@Composable
fun TransparentSystemBars() {
val systemUiController = rememberSystemUiController()
val isSystemInDarkTheme = isSystemInDarkTheme()
SideEffect {
systemUiController.setSystemBarsColor(Color.Transparent, darkIcons = !isSystemInDarkTheme)
}
}
@Composable
fun <T : Any> onEventValue(event: Lifecycle.Event = Lifecycle.Event.ON_START, value: () -> T): T {
val rememberLatestUpdateState by rememberUpdatedState(newValue = value)
var rememberedValue by remember { mutableStateOf(value()) }
LifecycleEventEffect(event = event) {
rememberedValue = rememberLatestUpdateState()
}
return rememberedValue
}

View file

@ -1,19 +0,0 @@
package com.simplemobiletools.calculator.compose.extensions
import androidx.compose.material.ripple.RippleAlpha
import androidx.compose.material.ripple.RippleTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
object NoRippleTheme : RippleTheme {
@Composable
override fun defaultColor(): Color = Color.Unspecified
@Composable
override fun rippleAlpha(): RippleAlpha = RippleAlpha(
draggedAlpha = 0f,
focusedAlpha = 0f,
hoveredAlpha = 0f,
pressedAlpha = 0f,
)
}

View file

@ -1,28 +0,0 @@
package com.simplemobiletools.calculator.compose.extensions
import android.content.res.Configuration
import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
const val LIGHT = "Light"
const val DARK = "Dark"
@MyDevicesDarkOnly
@MyDevicesLightOnly
annotation class MyDevices
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES, device = Devices.PIXEL_4_XL, name = "6.3 inches dark", group = DARK)
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES, device = Devices.PIXEL_2, name = "5.0 inches dark", group = DARK)
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES, device = Devices.PIXEL_2_XL, name = "6.0 inches dark", group = DARK)
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES, device = Devices.PIXEL_4_XL, name = "5.5 inches dark", group = DARK)
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES, device = Devices.PIXEL_4, name = "5.7 inches dark", group = DARK)
@Preview(showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES, device = Devices.TABLET, name = "Tablet", group = DARK)
annotation class MyDevicesDarkOnly
@Preview(showBackground = true, device = Devices.PIXEL_4_XL, name = "6.3 inches light", group = LIGHT)
@Preview(showBackground = true, device = Devices.PIXEL_2, name = "5.0 inches light", group = LIGHT)
@Preview(showBackground = true, device = Devices.PIXEL_2_XL, name = "6.0 inches light", group = LIGHT)
@Preview(showBackground = true, device = Devices.PIXEL_XL, name = "5.5 inches light", group = LIGHT)
@Preview(showBackground = true, device = Devices.PIXEL_4, name = "5.7 inches light", group = LIGHT)
@Preview(showBackground = true, device = Devices.TABLET, name = "Tablet", group = DARK)
annotation class MyDevicesLightOnly

View file

@ -22,16 +22,16 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.simplemobiletools.calculator.compose.extensions.MyDevices
import com.simplemobiletools.calculator.compose.settings.SettingsCheckBoxComponent
import com.simplemobiletools.calculator.compose.settings.SettingsGroup
import com.simplemobiletools.calculator.compose.settings.SettingsPreferenceComponent
import com.simplemobiletools.calculator.compose.settings.SettingsTitleTextComponent
import com.simplemobiletools.calculator.compose.theme.AppThemeSurface
import com.simplemobiletools.calculator.compose.theme.divider_grey
import com.simplemobiletools.calculator.compose.theme.isNotLitWell
import com.simplemobiletools.calculator.compose.theme.isSurfaceLitWell
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.compose.extensions.MyDevices
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
import com.simplemobiletools.commons.compose.theme.divider_grey
import com.simplemobiletools.commons.compose.theme.isNotLitWell
import com.simplemobiletools.commons.compose.theme.isSurfaceLitWell
import com.simplemobiletools.commons.helpers.isTiramisuPlus
import java.util.Locale
@ -147,7 +147,7 @@ fun SettingsScreen(
doOnPreferenceClick = customizeWidgetColors
)
}
Divider(color = divider_grey)
HorizontalDivider(color = divider_grey)
SettingsGroup(title = {
SettingsTitleTextComponent(text = stringResource(id = R.string.general_settings), modifier = startingPadding)
}) {

View file

@ -22,12 +22,12 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.dp
import com.simplemobiletools.calculator.compose.extensions.MyDevices
import com.simplemobiletools.calculator.compose.extensions.NoRippleTheme
import com.simplemobiletools.calculator.compose.theme.AppThemeSurface
import com.simplemobiletools.calculator.compose.theme.preferenceSummaryColor
import com.simplemobiletools.calculator.compose.theme.preferenceTitleColor
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.compose.extensions.MyDevices
import com.simplemobiletools.commons.compose.extensions.NoRippleTheme
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
import com.simplemobiletools.commons.compose.theme.preferenceSummaryColor
import com.simplemobiletools.commons.compose.theme.preferenceTitleColor
@Composable
fun SettingsCheckBoxComponent(

View file

@ -8,7 +8,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.simplemobiletools.calculator.compose.extensions.MyDevices
import com.simplemobiletools.commons.compose.extensions.MyDevices
@Composable
fun SettingsGroup(

View file

@ -13,11 +13,11 @@ import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.simplemobiletools.calculator.compose.extensions.MyDevices
import com.simplemobiletools.calculator.compose.theme.AppThemeSurface
import com.simplemobiletools.calculator.compose.theme.preferenceSummaryColor
import com.simplemobiletools.calculator.compose.theme.preferenceTitleColor
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.compose.extensions.MyDevices
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
import com.simplemobiletools.commons.compose.theme.preferenceSummaryColor
import com.simplemobiletools.commons.compose.theme.preferenceTitleColor
@Composable
fun SettingsPreferenceComponent(

View file

@ -9,8 +9,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.unit.dp
import com.simplemobiletools.calculator.compose.extensions.MyDevices
import com.simplemobiletools.calculator.compose.theme.AppThemeSurface
import com.simplemobiletools.commons.compose.extensions.MyDevices
import com.simplemobiletools.commons.compose.theme.AppThemeSurface
@Composable
fun SettingsTitleTextComponent(

View file

@ -1,47 +0,0 @@
package com.simplemobiletools.calculator.compose.theme
import android.app.Activity
import android.app.ActivityManager
import android.content.Context
import android.graphics.BitmapFactory
import com.simplemobiletools.calculator.compose.extensions.getActivity
import com.simplemobiletools.calculator.helpers.Config
import com.simplemobiletools.commons.R
import com.simplemobiletools.commons.helpers.APP_ICON_IDS
import com.simplemobiletools.commons.helpers.APP_LAUNCHER_NAME
fun Activity.getAppIconIds(): ArrayList<Int> = ArrayList(intent.getIntegerArrayListExtra(APP_ICON_IDS).orEmpty())
fun Activity.getAppLauncherName(): String = intent.getStringExtra(APP_LAUNCHER_NAME).orEmpty()
internal fun updateRecentsAppIcon(baseConfig: Config, context: Context) {
if (baseConfig.isUsingModifiedAppIcon) {
val appIconIDs = context.getAppIconIds()
val currentAppIconColorIndex = baseConfig.getCurrentAppIconColorIndex(context)
if (appIconIDs.size - 1 < currentAppIconColorIndex) {
return
}
val recentsIcon = BitmapFactory.decodeResource(context.resources, appIconIDs[currentAppIconColorIndex])
val title = context.getAppLauncherName()
val color = baseConfig.primaryColor
val description = ActivityManager.TaskDescription(title, recentsIcon, color)
context.getActivity().setTaskDescription(description)
}
}
private fun Config.getCurrentAppIconColorIndex(context: Context): Int {
val appIconColor = appIconColor
context.getAppIconColors().forEachIndexed { index, color ->
if (color == appIconColor) {
return index
}
}
return 0
}
private fun Context.getAppIconColors() = resources.getIntArray(R.array.md_app_icon_colors).toCollection(ArrayList())
private fun Context.getAppIconIds(): List<Int> = getActivity().getAppIconIds()
private fun Context.getAppLauncherName(): String = getActivity().getAppLauncherName()

View file

@ -1,40 +0,0 @@
package com.simplemobiletools.calculator.compose.theme
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Surface
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LifecycleEventEffect
import com.simplemobiletools.calculator.compose.theme.model.Theme.Companion.systemDefaultMaterialYou
@Composable
fun AppThemeSurface(
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
) {
val view = LocalView.current
val context = LocalContext.current
val materialYouTheme = systemDefaultMaterialYou()
var currentTheme by remember {
mutableStateOf(
if (view.isInEditMode) materialYouTheme else getTheme(
context = context,
materialYouTheme = materialYouTheme
)
)
}
LifecycleEventEffect(event = Lifecycle.Event.ON_START) {
if (!view.isInEditMode) {
currentTheme = getTheme(context = context, materialYouTheme = materialYouTheme)
}
}
Theme(theme = currentTheme) {
Surface(modifier = modifier.fillMaxSize()) {
content()
}
}
}

View file

@ -1,9 +0,0 @@
package com.simplemobiletools.calculator.compose.theme
import androidx.compose.material3.darkColorScheme
internal val darkColorScheme = darkColorScheme(
primary = color_primary,
secondary = color_primary_dark,
tertiary = color_accent,
)

View file

@ -1,444 +0,0 @@
package com.simplemobiletools.calculator.compose.theme
import androidx.compose.ui.graphics.Color
val color_primary = Color(0xFFF57C00)
val color_primary_dark = Color(0xFFD76D00)
val color_accent = color_primary
val pressed_item_foreground = Color(0x08000000)
val activated_item_foreground = Color(0x44888888)
val divider_grey = Color(0x55808080)
val gradient_grey_start = Color(0xCC000000)
val dark_grey = Color(0xFF333333)
val bottom_tabs_light_background = Color(0xFFF1F1F1)
val disabled_text_color_highlight = Color(0x00FFFFFF)
val hint_white = Color(0x99FFFFFF)
val hint_black = Color(0x66000000)
val light_grey_stroke = Color(0x40FFFFFF)
val thumb_deactivated = Color(0xFFECECEC)
val track_deactivated = Color(0xFFB2B2B2)
val radiobutton_disabled = Color(0xFF757575)
val md_amber = Color(0xFFFFC107)
val md_blue = Color(0xFF2196F3)
val md_blue_grey = Color(0xFF607D8B)
val md_brown = Color(0xFF795548)
val md_cyan = Color(0xFF00BCD4)
val md_deep_orange = Color(0xFFFF5722)
val md_deep_purple = Color(0xFF673AB7)
val md_green = Color(0xFF4CAF50)
val md_grey = Color(0xFF9E9E9E)
val md_indigo = Color(0xFF3F51B5)
val md_light_blue = Color(0xFF03A9F4)
val md_light_green = Color(0xFF8BC34A)
val md_lime = Color(0xFFCDDC39)
val md_orange = Color(0xFFFF9800)
val md_pink = Color(0xFFE91E63)
val md_purple = Color(0xFF9C27B0)
val md_red = Color(0xFFF44336)
val md_teal = Color(0xFF009688)
val md_yellow = Color(0xFFFFEB3B)
val md_amber_100 = Color(0xFFFFECB3)
val md_amber_200 = Color(0xFFFFE082)
val md_amber_300 = Color(0xFFFFD54F)
val md_amber_400 = Color(0xFFFFCA28)
val md_amber_500 = Color(0xFFFFC107)
val md_amber_600 = Color(0xFFFFB300)
val md_amber_700 = Color(0xFFFFA000)
val md_amber_800 = Color(0xFFFF8F00)
val md_amber_900 = Color(0xFFFF6F00)
val md_amber_100_dark = Color(0xFFFFE28A)
val md_amber_200_dark = Color(0xFFFFD659)
val md_amber_300_dark = Color(0xFFFFCC26)
val md_amber_400_dark = Color(0xFFFFC100)
val md_amber_500_dark = Color(0xFFDEA700)
val md_amber_600_dark = Color(0xFFD79700)
val md_amber_700_dark = Color(0xFFD78700)
val md_amber_800_dark = Color(0xFFD77800)
val md_amber_900_dark = Color(0xFFD75D00)
val md_blue_100 = Color(0xFFBBDEFB)
val md_blue_200 = Color(0xFF90CAF9)
val md_blue_300 = Color(0xFF64B5F6)
val md_blue_400 = Color(0xFF42A5F5)
val md_blue_500 = Color(0xFF2196F3)
val md_blue_600 = Color(0xFF1E88E5)
val md_blue_700 = Color(0xFF1976D2)
val md_blue_800 = Color(0xFF1565C0)
val md_blue_900 = Color(0xFF0D47A1)
val md_blue_100_dark = Color(0xFF94CCF9)
val md_blue_200_dark = Color(0xFF69B8F7)
val md_blue_300_dark = Color(0xFF3DA2F4)
val md_blue_400_dark = Color(0xFF1A92F3)
val md_blue_500_dark = Color(0xFF0B82E0)
val md_blue_600_dark = Color(0xFF1673C4)
val md_blue_700_dark = Color(0xFF1462AE)
val md_blue_800_dark = Color(0xFF11529B)
val md_blue_900_dark = Color(0xFF09367B)
val md_blue_grey_100 = Color(0xFFCFD8DC)
val md_blue_grey_200 = Color(0xFFB0BBC5)
val md_blue_grey_300 = Color(0xFF90A4AE)
val md_blue_grey_400 = Color(0xFF78909C)
val md_blue_grey_500 = Color(0xFF607D8B)
val md_blue_grey_600 = Color(0xFF546E7A)
val md_blue_grey_700 = Color(0xFF455A64)
val md_blue_grey_800 = Color(0xFF37474F)
val md_blue_grey_900 = Color(0xFF263238)
val md_blue_grey_100_dark = Color(0xFFB8C5CB)
val md_blue_grey_200_dark = Color(0xFF99A7B4)
val md_blue_grey_300_dark = Color(0xFF78919D)
val md_blue_grey_400_dark = Color(0xFF647C88)
val md_blue_grey_500_dark = Color(0xFF4F6873)
val md_blue_grey_600_dark = Color(0xFF445962)
val md_blue_grey_700_dark = Color(0xFF34454C)
val md_blue_grey_800_dark = Color(0xFF263237)
val md_blue_grey_900_dark = Color(0xFF151C1F)
val md_brown_100 = Color(0xFFD7CCC8)
val md_brown_200 = Color(0xFFBCAAA4)
val md_brown_300 = Color(0xFFA1887F)
val md_brown_400 = Color(0xFF8D6E63)
val md_brown_500 = Color(0xFF795548)
val md_brown_600 = Color(0xFF6D4C41)
val md_brown_700 = Color(0xFF5D4037)
val md_brown_800 = Color(0xFF4E342E)
val md_brown_900 = Color(0xFF3E2723)
val md_brown_100_dark = Color(0xFFC6B7B1)
val md_brown_200_dark = Color(0xFFAB958D)
val md_brown_300_dark = Color(0xFF8F7369)
val md_brown_400_dark = Color(0xFF755B52)
val md_brown_500_dark = Color(0xFF5F4339)
val md_brown_600_dark = Color(0xFF533A31)
val md_brown_700_dark = Color(0xFF432E28)
val md_brown_800_dark = Color(0xFF34231F)
val md_brown_900_dark = Color(0xFF241714)
val md_cyan_100 = Color(0xFFB2EBF2)
val md_cyan_200 = Color(0xFF80DEEA)
val md_cyan_300 = Color(0xFF4DD0E1)
val md_cyan_400 = Color(0xFF26C6DA)
val md_cyan_500 = Color(0xFF00BCD4)
val md_cyan_600 = Color(0xFF00ACC1)
val md_cyan_700 = Color(0xFF0097A7)
val md_cyan_800 = Color(0xFF00838F)
val md_cyan_900 = Color(0xFF006064)
val md_cyan_100_dark = Color(0xFF90E3ED)
val md_cyan_200_dark = Color(0xFF5DD5E5)
val md_cyan_300_dark = Color(0xFF2AC7DB)
val md_cyan_400_dark = Color(0xFF1FA7B8)
val md_cyan_500_dark = Color(0xFF0098AB)
val md_cyan_600_dark = Color(0xFF008898)
val md_cyan_700_dark = Color(0xFF00727E)
val md_cyan_800_dark = Color(0xFF005E66)
val md_cyan_900_dark = Color(0xFF00393B)
val md_deep_orange_100 = Color(0xFFFFCCBC)
val md_deep_orange_200 = Color(0xFFFFAB91)
val md_deep_orange_300 = Color(0xFFFF8A65)
val md_deep_orange_400 = Color(0xFFFF7043)
val md_deep_orange_500 = Color(0xFFFF5722)
val md_deep_orange_600 = Color(0xFFF4511E)
val md_deep_orange_700 = Color(0xFFE64A19)
val md_deep_orange_800 = Color(0xFFD84315)
val md_deep_orange_900 = Color(0xFFBF360C)
val md_deep_orange_100_dark = Color(0xFFFFAD93)
val md_deep_orange_200_dark = Color(0xFFFF8C68)
val md_deep_orange_300_dark = Color(0xFFFF6B3C)
val md_deep_orange_400_dark = Color(0xFFFF511A)
val md_deep_orange_500_dark = Color(0xFFF93C00)
val md_deep_orange_600_dark = Color(0xFFDF3D0A)
val md_deep_orange_700_dark = Color(0xFFC13E14)
val md_deep_orange_800_dark = Color(0xFFB33710)
val md_deep_orange_900_dark = Color(0xFF992B09)
val md_deep_purple_100 = Color(0xFFD1C4E9)
val md_deep_purple_200 = Color(0xFFB39DDB)
val md_deep_purple_300 = Color(0xFF9575CD)
val md_deep_purple_400 = Color(0xFF7E57C2)
val md_deep_purple_500 = Color(0xFF673AB7)
val md_deep_purple_600 = Color(0xFF5E35B1)
val md_deep_purple_700 = Color(0xFF512DA8)
val md_deep_purple_800 = Color(0xFF4527A0)
val md_deep_purple_900 = Color(0xFF311B92)
val md_deep_purple_100_dark = Color(0xFFBAA6DE)
val md_deep_purple_200_dark = Color(0xFF9C7FD0)
val md_deep_purple_300_dark = Color(0xFF7E56C2)
val md_deep_purple_400_dark = Color(0xFF693FB0)
val md_deep_purple_500_dark = Color(0xFF563098)
val md_deep_purple_600_dark = Color(0xFF4E2B92)
val md_deep_purple_700_dark = Color(0xFF412488)
val md_deep_purple_800_dark = Color(0xFF371F7F)
val md_deep_purple_900_dark = Color(0xFF251470)
val md_green_100 = Color(0xFFC8E6C9)
val md_green_200 = Color(0xFFA5D6A7)
val md_green_300 = Color(0xFF81C784)
val md_green_400 = Color(0xFF66BB6A)
val md_green_500 = Color(0xFF4CAF50)
val md_green_600 = Color(0xFF43A047)
val md_green_700 = Color(0xFF388E3C)
val md_green_800 = Color(0xFF2E7D32)
val md_green_900 = Color(0xFF1B5E20)
val md_green_100_dark = Color(0xFFACDAAE)
val md_green_200_dark = Color(0xFF89CA8D)
val md_green_300_dark = Color(0xFF65BB69)
val md_green_400_dark = Color(0xFF4CAC51)
val md_green_500_dark = Color(0xFF409343)
val md_green_600_dark = Color(0xFF37833A)
val md_green_700_dark = Color(0xFF2C7130)
val md_green_800_dark = Color(0xFF235F26)
val md_green_900_dark = Color(0xFF113E15)
val md_grey_white = Color(0xFFFFFFFF)
val md_grey_200 = Color(0xFFEEEEEE)
val md_grey_300 = Color(0xFFE0E0E0)
val md_grey_400 = Color(0xFFBDBDBD)
val md_grey_500 = Color(0xFF9E9E9E)
val md_grey_600 = Color(0xFF757575)
val md_grey_700 = Color(0xFF616161)
val md_grey_800 = Color(0xFF424242)
val md_grey_black = Color(0xFF000000)
val md_grey_white_dark = Color(0xFFDFDFDF)
val md_grey_200_dark = Color(0xFFDADADA)
val md_grey_300_dark = Color(0xFFCCCCCC)
val md_grey_400_dark = Color(0xFFA9A9A9)
val md_grey_500_dark = Color(0xFF8A8A8A)
val md_grey_600_dark = Color(0xFF606060)
val md_grey_700_dark = Color(0xFF4C4C4C)
val md_grey_800_dark = Color(0xFF2D2D2D)
val md_grey_black_dark = Color(0xFF000000)
val md_indigo_100 = Color(0xFFC5CAE9)
val md_indigo_200 = Color(0xFF9FA8DA)
val md_indigo_300 = Color(0xFF7986CB)
val md_indigo_400 = Color(0xFF5C6BC0)
val md_indigo_500 = Color(0xFF3F51B5)
val md_indigo_600 = Color(0xFF3949AB)
val md_indigo_700 = Color(0xFF303F9F)
val md_indigo_800 = Color(0xFF283593)
val md_indigo_900 = Color(0xFF1A237E)
val md_indigo_100_dark = Color(0xFFA8AFDE)
val md_indigo_200_dark = Color(0xFF828ECF)
val md_indigo_300_dark = Color(0xFF5B6CC0)
val md_indigo_400_dark = Color(0xFF4354B0)
val md_indigo_500_dark = Color(0xFF344497)
val md_indigo_600_dark = Color(0xFF2E3C8C)
val md_indigo_700_dark = Color(0xFF263380)
val md_indigo_800_dark = Color(0xFF1F2973)
val md_indigo_900_dark = Color(0xFF12195C)
val md_light_blue_100 = Color(0xFFB3E5FC)
val md_light_blue_200 = Color(0xFF81D4fA)
val md_light_blue_300 = Color(0xFF4fC3F7)
val md_light_blue_400 = Color(0xFF29B6FC)
val md_light_blue_500 = Color(0xFF03A9F4)
val md_light_blue_600 = Color(0xFF039BE5)
val md_light_blue_700 = Color(0xFF0288D1)
val md_light_blue_800 = Color(0xFF0277BD)
val md_light_blue_900 = Color(0xFF01579B)
val md_light_blue_100_dark = Color(0xFF8BD8FB)
val md_light_blue_200_dark = Color(0xFF59C7F9)
val md_light_blue_300_dark = Color(0xFF27B6F6)
val md_light_blue_400_dark = Color(0xFF02A7F9)
val md_light_blue_500_dark = Color(0xFF028DCC)
val md_light_blue_600_dark = Color(0xFF0280BD)
val md_light_blue_700_dark = Color(0xFF016EA9)
val md_light_blue_800_dark = Color(0xFF015E95)
val md_light_blue_900_dark = Color(0xFF004072)
val md_light_green_100 = Color(0xFFDCEDC8)
val md_light_green_200 = Color(0xFFC5E1A5)
val md_light_green_300 = Color(0xFFAED581)
val md_light_green_400 = Color(0xFF9CCC65)
val md_light_green_500 = Color(0xFF8BC34A)
val md_light_green_600 = Color(0xFF7CB342)
val md_light_green_700 = Color(0xFF689F38)
val md_light_green_800 = Color(0xFF558B2F)
val md_light_green_900 = Color(0xFF33691E)
val md_light_green_100_dark = Color(0xFFC9E3A9)
val md_light_green_200_dark = Color(0xFFB2D787)
val md_light_green_300_dark = Color(0xFF9BCB62)
val md_light_green_400_dark = Color(0xFF89C246)
val md_light_green_500_dark = Color(0xFF76AC38)
val md_light_green_600_dark = Color(0xFF679537)
val md_light_green_700_dark = Color(0xFF54812D)
val md_light_green_800_dark = Color(0xFF426C24)
val md_light_green_900_dark = Color(0xFF234915)
val md_lime_100 = Color(0xFFF0F4C3)
val md_lime_200 = Color(0xFFE6EE9C)
val md_lime_300 = Color(0xFFDCE775)
val md_lime_400 = Color(0xFFD4E157)
val md_lime_500 = Color(0xFFCDDC39)
val md_lime_600 = Color(0xFFC0CA33)
val md_lime_700 = Color(0xFFA4B42B)
val md_lime_800 = Color(0xFF9E9D24)
val md_lime_900 = Color(0xFF827717)
val md_lime_100_dark = Color(0xFFE8EEA0)
val md_lime_200_dark = Color(0xFFDEE879)
val md_lime_300_dark = Color(0xFFD3E152)
val md_lime_400_dark = Color(0xFFCBDB34)
val md_lime_500_dark = Color(0xFFBAC923)
val md_lime_600_dark = Color(0xFFA2AA2A)
val md_lime_700_dark = Color(0xFF869323)
val md_lime_800_dark = Color(0xFF7D7D1C)
val md_lime_900_dark = Color(0xFF5F5710)
val md_orange_100 = Color(0xFFFFE0B2)
val md_orange_200 = Color(0xFFFFCC80)
val md_orange_300 = Color(0xFFFFB74D)
val md_orange_400 = Color(0xFFFFA726)
val md_orange_500 = Color(0xFFFF9800)
val md_orange_600 = Color(0xFFFB8C00)
val md_orange_700 = Color(0xFFF57C00)
val md_orange_800 = Color(0xFFEF6C00)
val md_orange_900 = Color(0xFFE65100)
val md_orange_100_dark = Color(0xFFFFD089)
val md_orange_200_dark = Color(0xFFFFBC57)
val md_orange_300_dark = Color(0xFFFFA724)
val md_orange_400_dark = Color(0xFFFD9600)
val md_orange_500_dark = Color(0xFFD78000)
val md_orange_600_dark = Color(0xFFD37600)
val md_orange_700_dark = Color(0xFFCD6800)
val md_orange_800_dark = Color(0xFFC65A00)
val md_orange_900_dark = Color(0xFFBD4200)
val md_pink_100 = Color(0xFFF8BBD0)
val md_pink_200 = Color(0xFFF48FB1)
val md_pink_300 = Color(0xFFF06292)
val md_pink_400 = Color(0xFFEC407A)
val md_pink_500 = Color(0xFFE91E63)
val md_pink_600 = Color(0xFFD81B60)
val md_pink_700 = Color(0xFFC2185B)
val md_pink_800 = Color(0xFFAD1457)
val md_pink_900 = Color(0xFF880E4F)
val md_pink_100_dark = Color(0xFFF596B7)
val md_pink_200_dark = Color(0xFFF16998)
val md_pink_300_dark = Color(0xFFED3C78)
val md_pink_400_dark = Color(0xFFE91A60)
val md_pink_500_dark = Color(0xFFCB1352)
val md_pink_600_dark = Color(0xFFB4154F)
val md_pink_700_dark = Color(0xFF9E134A)
val md_pink_800_dark = Color(0xFF880F44)
val md_pink_900_dark = Color(0xFF630A3A)
val md_purple_100 = Color(0xFFE1BEE7)
val md_purple_200 = Color(0xFFCE93D8)
val md_purple_300 = Color(0xFFBA68C8)
val md_purple_400 = Color(0xFFAB47BC)
val md_purple_500 = Color(0xFF9C27B0)
val md_purple_600 = Color(0xFF8E24AA)
val md_purple_700 = Color(0xFF7B1FA2)
val md_purple_800 = Color(0xFF6A1B9A)
val md_purple_900 = Color(0xFF4A148C)
val md_purple_100_dark = Color(0xFFD3A0DC)
val md_purple_200_dark = Color(0xFFC175CD)
val md_purple_300_dark = Color(0xFFAC4ABD)
val md_purple_400_dark = Color(0xFF913AA0)
val md_purple_500_dark = Color(0xFF7F1F8F)
val md_purple_600_dark = Color(0xFF711C88)
val md_purple_700_dark = Color(0xFF611880)
val md_purple_800_dark = Color(0xFF521477)
val md_purple_900_dark = Color(0xFF370E68)
val md_red_100 = Color(0xFFFFCDD2)
val md_red_200 = Color(0xFFEF9A9A)
val md_red_300 = Color(0xFFE57373)
val md_red_400 = Color(0xFFEF5350)
val md_red_500 = Color(0xFFF44336)
val md_red_600 = Color(0xFFE53935)
val md_red_700 = Color(0xFFD32F2F)
val md_red_800 = Color(0xFFC62828)
val md_red_900 = Color(0xFFB71C1C)
val md_red_100_dark = Color(0xFFFFA4AE)
val md_red_200_dark = Color(0xFFEA7777)
val md_red_300_dark = Color(0xFFDF5050)
val md_red_400_dark = Color(0xFFEC2E2A)
val md_red_500_dark = Color(0xFFF21F0F)
val md_red_600_dark = Color(0xFFD61F1A)
val md_red_700_dark = Color(0xFFB32525)
val md_red_800_dark = Color(0xFFA42020)
val md_red_900_dark = Color(0xFF941616)
val md_teal_100 = Color(0xFFB2DFDB)
val md_teal_200 = Color(0xFF80CBC4)
val md_teal_300 = Color(0xFF4DB6AC)
val md_teal_400 = Color(0xFF26A69A)
val md_teal_500 = Color(0xFF009688)
val md_teal_600 = Color(0xFF00897B)
val md_teal_700 = Color(0xFF00796B)
val md_teal_800 = Color(0xFF00695C)
val md_teal_900 = Color(0xFF004D40)
val md_teal_100_dark = Color(0xFF95D3CE)
val md_teal_200_dark = Color(0xFF63BFB7)
val md_teal_300_dark = Color(0xFF3F9B92)
val md_teal_400_dark = Color(0xFF1E857C)
val md_teal_500_dark = Color(0xFF006D63)
val md_teal_600_dark = Color(0xFF006056)
val md_teal_700_dark = Color(0xFF005047)
val md_teal_800_dark = Color(0xFF004038)
val md_teal_900_dark = Color(0xFF00241E)
val md_yellow_100 = Color(0xFFFFF9C4)
val md_yellow_200 = Color(0xFFFFF590)
val md_yellow_300 = Color(0xFFFFF176)
val md_yellow_400 = Color(0xFFFFEE58)
val md_yellow_500 = Color(0xFFFFEB3B)
val md_yellow_600 = Color(0xFFFDD835)
val md_yellow_700 = Color(0xFFFBC02D)
val md_yellow_800 = Color(0xFFF9A825)
val md_yellow_900 = Color(0xFFF57F17)
val md_yellow_100_dark = Color(0xFFFFF59B)
val md_yellow_200_dark = Color(0xFFFFF267)
val md_yellow_300_dark = Color(0xFFFFED4D)
val md_yellow_400_dark = Color(0xFFFFEA2F)
val md_yellow_500_dark = Color(0xFFFFE712)
val md_yellow_600_dark = Color(0xFFFDD10B)
val md_yellow_700_dark = Color(0xFFFBB504)
val md_yellow_800_dark = Color(0xFFEF9606)
val md_yellow_900_dark = Color(0xFFDA6B09)
val theme_light_text_color = md_grey_800_dark
val theme_light_background_color = md_grey_white
val theme_dark_text_color = md_grey_200
val theme_dark_background_color = md_grey_800_dark
val theme_solarized_background_color = md_indigo_900_dark
val theme_solarized_text_color = md_amber_700
val theme_solarized_primary_color = md_indigo_900
val theme_dark_red_primary_color = md_red_700
val default_text_color = theme_dark_text_color
val default_background_color = theme_dark_background_color
val default_primary_color = color_primary
val default_app_icon_color = color_primary
val default_accent_color = color_primary
val default_widget_bg_color = Color(0xAA000000)
val default_widget_text_color = color_primary
val ripple_light = Color(0x1f000000)
val ripple_dark = Color(0x33ffffff)

View file

@ -1,34 +0,0 @@
package com.simplemobiletools.calculator.compose.theme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.luminance
@get:ReadOnlyComposable
val disabledTextColor @Composable get() = if (isInDarkThemeAndSurfaceIsNotLitWell()) Color.DarkGray else Color.LightGray
@get:ReadOnlyComposable
val textSubTitleColor
@Composable get() = if (isInDarkThemeAndSurfaceIsNotLitWell()) {
Color.White.copy(0.5f)
} else {
Color.Black.copy(
0.5f,
)
}
@Composable
@ReadOnlyComposable
fun preferenceSummaryColor(isEnabled: Boolean) =
if (isEnabled) textSubTitleColor else disabledTextColor
@Composable
@ReadOnlyComposable
fun preferenceTitleColor(isEnabled: Boolean) = if (isEnabled) MaterialTheme.colorScheme.onSurface else disabledTextColor
fun Color.isLitWell(threshold : Float = LUMINANCE_THRESHOLD) = luminance() > threshold
fun Color.isNotLitWell(threshold: Float = LUMINANCE_THRESHOLD) = luminance() < threshold

View file

@ -1,249 +0,0 @@
package com.simplemobiletools.calculator.compose.theme
import android.content.Context
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import com.simplemobiletools.calculator.compose.theme.model.Theme
import com.simplemobiletools.calculator.extensions.config
import com.simplemobiletools.commons.extensions.isBlackAndWhiteTheme
import com.simplemobiletools.commons.extensions.isWhiteTheme
fun getTheme(context: Context, materialYouTheme: Theme.SystemDefaultMaterialYou): Theme {
val baseConfig = context.config
val primaryColorInt = baseConfig.primaryColor
val isSystemInDarkTheme = context.isDarkMode()
val accentColor = baseConfig.accentColor
val backgroundColorTheme = if (baseConfig.isUsingSystemTheme || baseConfig.isUsingAutoTheme) {
if (isSystemInDarkTheme) theme_dark_background_color else Color.White
} else {
Color(baseConfig.backgroundColor)
}
val backgroundColor = backgroundColorTheme.toArgb()
val appIconColor = baseConfig.appIconColor
val textColor = baseConfig.textColor
val theme = when {
baseConfig.isUsingSystemTheme -> materialYouTheme
context.isBlackAndWhiteTheme() -> Theme.BlackAndWhite(
accentColor = accentColor,
primaryColorInt = primaryColorInt,
backgroundColorInt = backgroundColor,
appIconColorInt = appIconColor,
textColorInt = textColor
)
context.isWhiteTheme() -> Theme.White(
accentColor = accentColor,
primaryColorInt = primaryColorInt,
backgroundColorInt = backgroundColor,
appIconColorInt = appIconColor,
textColorInt = textColor
)
else -> {
val customPrimaryColor = when (primaryColorInt) {
-12846 -> md_red_100
-1074534 -> md_red_200
-1739917 -> md_red_300
-1092784 -> md_red_400
-769226 -> md_red_500
-1754827 -> md_red_600
-2937041 -> md_red_700
-3790808 -> md_red_800
-4776932 -> md_red_900
-476208 -> md_pink_100
-749647 -> md_pink_200
-1023342 -> md_pink_300
-1294214 -> md_pink_400
-1499549 -> md_pink_500
-2614432 -> md_pink_600
-4056997 -> md_pink_700
-5434281 -> md_pink_800
-7860657 -> md_pink_900
-1982745 -> md_purple_100
-3238952 -> md_purple_200
-4560696 -> md_purple_300
-5552196 -> md_purple_400
-6543440 -> md_purple_500
-7461718 -> md_purple_600
-8708190 -> md_purple_700
-9823334 -> md_purple_800
-11922292 -> md_purple_900
-3029783 -> md_deep_purple_100
-5005861 -> md_deep_purple_200
-6982195 -> md_deep_purple_300
-8497214 -> md_deep_purple_400
-10011977 -> md_deep_purple_500
-10603087 -> md_deep_purple_600
-11457112 -> md_deep_purple_700
-12245088 -> md_deep_purple_800
-13558894 -> md_deep_purple_900
-3814679 -> md_indigo_100
-6313766 -> md_indigo_200
-8812853 -> md_indigo_300
-10720320 -> md_indigo_400
-12627531 -> md_indigo_500
-13022805 -> md_indigo_600
-13615201 -> md_indigo_700
-14142061 -> md_indigo_800
-15064194 -> md_indigo_900
-4464901 -> md_blue_100
-7288071 -> md_blue_200
-10177034 -> md_blue_300
-12409355 -> md_blue_400
-14575885 -> md_blue_500
-14776091 -> md_blue_600
-15108398 -> md_blue_700
-15374912 -> md_blue_800
-15906911 -> md_blue_900
-4987396 -> md_light_blue_100
-8268550 -> md_light_blue_200
-11549705 -> md_light_blue_300
-14043396 -> md_light_blue_400
-16537100 -> md_light_blue_500
-16540699 -> md_light_blue_600
-16611119 -> md_light_blue_700
-16615491 -> md_light_blue_800
-16689253 -> md_light_blue_900
-5051406 -> md_cyan_100
-8331542 -> md_cyan_200
-11677471 -> md_cyan_300
-14235942 -> md_cyan_400
-16728876 -> md_cyan_500
-16732991 -> md_cyan_600
-16738393 -> md_cyan_700
-16743537 -> md_cyan_800
-16752540 -> md_cyan_900
-5054501 -> md_teal_100
-8336444 -> md_teal_200
-11684180 -> md_teal_300
-14244198 -> md_teal_400
-16738680 -> md_teal_500
-16742021 -> md_teal_600
-16746133 -> md_teal_700
-16750244 -> md_teal_800
-16757440 -> md_teal_900
-3610935 -> md_green_100
-5908825 -> md_green_200
-8271996 -> md_green_300
-10044566 -> md_green_400
-11751600 -> md_green_500
-12345273 -> md_green_600
-13070788 -> md_green_700
-13730510 -> md_green_800
-14983648 -> md_green_900
-2298424 -> md_light_green_100
-3808859 -> md_light_green_200
-5319295 -> md_light_green_300
-6501275 -> md_light_green_400
-7617718 -> md_light_green_500
-8604862 -> md_light_green_600
-9920712 -> md_light_green_700
-11171025 -> md_light_green_800
-13407970 -> md_light_green_900
-985917 -> md_lime_100
-1642852 -> md_lime_200
-2300043 -> md_lime_300
-2825897 -> md_lime_400
-3285959 -> md_lime_500
-4142541 -> md_lime_600
-5983189 -> md_lime_700
-6382300 -> md_lime_800
-8227049 -> md_lime_900
-1596 -> md_yellow_100
-2672 -> md_yellow_200
-3722 -> md_yellow_300
-4520 -> md_yellow_400
-5317 -> md_yellow_500
-141259 -> md_yellow_600
-278483 -> md_yellow_700
-415707 -> md_yellow_800
-688361 -> md_yellow_900
-4941 -> md_amber_100
-8062 -> md_amber_200
-10929 -> md_amber_300
-13784 -> md_amber_400
-16121 -> md_amber_500
-19712 -> md_amber_600
-24576 -> md_amber_700
-28928 -> md_amber_800
-37120 -> md_amber_900
-8014 -> md_orange_100
-13184 -> md_orange_200
-18611 -> md_orange_300
-22746 -> md_orange_400
-26624 -> md_orange_500
-291840 -> md_orange_600
-689152 -> md_orange_700
-1086464 -> md_orange_800
-1683200 -> md_orange_900
-13124 -> md_deep_orange_100
-21615 -> md_deep_orange_200
-30107 -> md_deep_orange_300
-36797 -> md_deep_orange_400
-43230 -> md_deep_orange_500
-765666 -> md_deep_orange_600
-1684967 -> md_deep_orange_700
-2604267 -> md_deep_orange_800
-4246004 -> md_deep_orange_900
-2634552 -> md_brown_100
-4412764 -> md_brown_200
-6190977 -> md_brown_300
-7508381 -> md_brown_400
-8825528 -> md_brown_500
-9614271 -> md_brown_600
-10665929 -> md_brown_700
-11652050 -> md_brown_800
-12703965 -> md_brown_900
-3155748 -> md_blue_grey_100
-5194811 -> md_blue_grey_200
-7297874 -> md_blue_grey_300
-8875876 -> md_blue_grey_400
-10453621 -> md_blue_grey_500
-11243910 -> md_blue_grey_600
-12232092 -> md_blue_grey_700
-13154481 -> md_blue_grey_800
-14273992 -> md_blue_grey_900
-1 -> md_grey_black_dark
-1118482 -> md_grey_200
-2039584 -> md_grey_300
-4342339 -> md_grey_400
-6381922 -> md_grey_500
-9079435 -> md_grey_600
-10395295 -> md_grey_700
-12434878 -> md_grey_800
-16777216 -> md_grey_black_dark
else -> md_orange_700
}
Theme.Custom(
primaryColorInt = customPrimaryColor.toArgb(),
backgroundColorInt = backgroundColor,
appIconColorInt = appIconColor,
textColorInt = textColor
)
}
}
return theme
}

View file

@ -1,79 +0,0 @@
package com.simplemobiletools.calculator.compose.theme
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalView
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.simplemobiletools.calculator.compose.theme.model.Theme
import com.simplemobiletools.calculator.compose.theme.model.Theme.Companion.systemDefaultMaterialYou
import com.simplemobiletools.calculator.extensions.config
import com.simplemobiletools.commons.helpers.isSPlus
@Composable
internal fun Theme(
theme: Theme = systemDefaultMaterialYou(),
content: @Composable () -> Unit,
) {
val view = LocalView.current
val context = LocalContext.current
val systemUiController = rememberSystemUiController()
val baseConfig = remember { context.config }
val colorScheme = if (!view.isInEditMode) {
val colorScheme = when {
theme is Theme.SystemDefaultMaterialYou && isSPlus() -> {
if (isSystemInDarkTheme()) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
theme is Theme.Custom || theme is Theme.Dark -> darkColorScheme(
primary = theme.primaryColor, surface = theme.backgroundColor,
onSurface = theme.textColor
)
theme is Theme.White -> darkColorScheme(
primary = Color(theme.accentColor),
surface = theme.backgroundColor,
tertiary = theme.primaryColor,
onSurface = theme.textColor
)
theme is Theme.BlackAndWhite -> darkColorScheme(
primary = Color(theme.accentColor),
surface = theme.backgroundColor,
tertiary = theme.primaryColor,
onSurface = theme.textColor
)
else -> darkColorScheme
}
colorScheme
} else {
darkColorScheme
}
SideEffect {
systemUiController.setNavigationBarColor(colorScheme.surface, navigationBarContrastEnforced = false)
}
SideEffect {
updateRecentsAppIcon(baseConfig, context)
}
MaterialTheme(
colorScheme = colorScheme,
content = content,
)
}

View file

@ -1,34 +0,0 @@
package com.simplemobiletools.calculator.compose.theme
import android.content.Context
import android.content.res.Configuration
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.graphics.luminance
import androidx.compose.ui.platform.LocalContext
import com.simplemobiletools.calculator.compose.theme.model.Theme.Companion.systemDefaultMaterialYou
@Composable
fun getCurrentTheme() = getTheme(LocalContext.current, systemDefaultMaterialYou())
@Composable
@ReadOnlyComposable
fun isInDarkThemeAndSurfaceIsNotLitWell() = isSystemInDarkTheme() || isSurfaceNotLitWell()
internal const val LUMINANCE_THRESHOLD = 0.5f
@Composable
@ReadOnlyComposable
fun isSurfaceNotLitWell(threshold: Float = LUMINANCE_THRESHOLD) = MaterialTheme.colorScheme.surface.luminance() < threshold
@Composable
@ReadOnlyComposable
fun isSurfaceLitWell(threshold: Float = LUMINANCE_THRESHOLD) = MaterialTheme.colorScheme.surface.luminance() > threshold
fun Context.isDarkMode(): Boolean {
val darkModeFlag = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
return darkModeFlag == Configuration.UI_MODE_NIGHT_YES
}

View file

@ -1,18 +0,0 @@
package com.simplemobiletools.calculator.compose.theme.model
import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
@Immutable
interface CommonTheme {
val primaryColorInt: Int
val backgroundColorInt: Int
val appIconColorInt: Int
val textColorInt: Int
val primaryColor get() = Color(primaryColorInt)
val backgroundColor get() = Color(backgroundColorInt)
val appIconColor get() = Color(appIconColorInt)
val textColor get() = Color(textColorInt)
}

View file

@ -1,60 +0,0 @@
package com.simplemobiletools.calculator.compose.theme.model
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import com.simplemobiletools.calculator.compose.theme.isInDarkThemeAndSurfaceIsNotLitWell
import com.simplemobiletools.calculator.extensions.config
@Stable
sealed class Theme : CommonTheme {
data class SystemDefaultMaterialYou(
override val primaryColorInt: Int,
override val backgroundColorInt: Int,
override val appIconColorInt: Int,
override val textColorInt: Int
) : Theme()
data class White(
val accentColor: Int,
override val primaryColorInt: Int,
override val backgroundColorInt: Int,
override val appIconColorInt: Int,
override val textColorInt: Int
) : Theme()
data class Dark(
override val primaryColorInt: Int,
override val backgroundColorInt: Int,
override val appIconColorInt: Int,
override val textColorInt: Int
) : Theme()
data class BlackAndWhite(
val accentColor: Int,
override val primaryColorInt: Int,
override val backgroundColorInt: Int,
override val appIconColorInt: Int,
override val textColorInt: Int
) : Theme()
data class Custom(
override val primaryColorInt: Int,
override val backgroundColorInt: Int,
override val appIconColorInt: Int,
override val textColorInt: Int
) : Theme()
companion object {
@Composable
fun systemDefaultMaterialYou() = SystemDefaultMaterialYou(
appIconColorInt = LocalContext.current.config.appIconColor,
primaryColorInt = LocalContext.current.config.primaryColor,
backgroundColorInt = LocalContext.current.config.backgroundColor,
textColorInt = (if (isInDarkThemeAndSurfaceIsNotLitWell()) Color.White else Color.Black).toArgb()
)
}
}

View file

@ -20,7 +20,7 @@ exp4j = "0.4.8"
#Room
room = "2.5.2"
#Simple tools
simple-commons = "4c83ec8740"
simple-commons = "53ad279f5e"
#Gradle
gradlePlugins-agp = "8.0.2"
#build