feat: map almost all color schemes except white and black and white
This commit is contained in:
parent
7f146994ce
commit
9edf16cf19
5 changed files with 868 additions and 135 deletions
|
@ -9,7 +9,6 @@ import androidx.activity.compose.setContent
|
|||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.simplemobiletools.calculator.compose.screens.SettingsScreen
|
||||
import com.simplemobiletools.calculator.compose.theme.AppThemeSurface
|
||||
import com.simplemobiletools.calculator.compose.theme.Theme
|
||||
import com.simplemobiletools.calculator.databinding.ActivitySettingsBinding
|
||||
import com.simplemobiletools.calculator.extensions.calculatorDB
|
||||
import com.simplemobiletools.calculator.extensions.config
|
||||
|
@ -29,71 +28,16 @@ class SettingsActivity : AppCompatActivity() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContent {
|
||||
AppThemeSurface(
|
||||
theme = Theme.systemDefaultMaterialYou()
|
||||
) {
|
||||
AppThemeSurface {
|
||||
SettingsScreen(
|
||||
customizeColors = ::handleCustomizeColorsClick, goBack = ::finish,
|
||||
backgroundColor = getProperBackgroundColor(),
|
||||
)
|
||||
}
|
||||
}
|
||||
val backgroundColor = getProperBackgroundColor()
|
||||
updateStatusbarColor(backgroundColor)
|
||||
updateActionbarColor(backgroundColor)
|
||||
|
||||
//updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||
//setupMaterialScrollListener(binding.settingsNestedScrollview, binding.settingsToolbar)
|
||||
}
|
||||
|
||||
fun updateStatusbarColor(color: Int) {
|
||||
window.statusBarColor = color
|
||||
|
||||
if (color.getContrastColor() == DARK_GREY) {
|
||||
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility.addBit(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
|
||||
} else {
|
||||
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility.removeBit(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)
|
||||
}
|
||||
}
|
||||
|
||||
fun updateActionbarColor(color: Int = getProperStatusBarColor()) {
|
||||
updateStatusbarColor(color)
|
||||
setTaskDescription(ActivityManager.TaskDescription(null, null, color))
|
||||
}
|
||||
|
||||
fun updateNavigationBarColor(color: Int) {
|
||||
window.navigationBarColor = color
|
||||
updateNavigationBarButtons(color)
|
||||
}
|
||||
|
||||
fun updateNavigationBarButtons(color: Int) {
|
||||
if (isOreoPlus()) {
|
||||
if (color.getContrastColor() == DARK_GREY) {
|
||||
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility.addBit(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR)
|
||||
} else {
|
||||
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility.removeBit(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
/*setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow)
|
||||
|
||||
setupPurchaseThankYou()
|
||||
setupCustomizeColors()
|
||||
setupUseEnglish()
|
||||
setupLanguage()
|
||||
setupVibrate()
|
||||
setupPreventPhoneFromSleeping()
|
||||
setupUseCommaAsDecimalMark()
|
||||
setupCustomizeWidgetColors()
|
||||
updateTextColors(binding.settingsNestedScrollview)
|
||||
|
||||
arrayOf(binding.settingsColorCustomizationSectionLabel, binding.settingsGeneralSettingsLabel).forEach {
|
||||
it.setTextColor(getProperPrimaryColor())
|
||||
}*/
|
||||
}
|
||||
|
||||
private fun setupPurchaseThankYou() {
|
||||
binding.settingsPurchaseThankYouHolder.beGoneIf(isOrWasThankYouInstalled())
|
||||
|
|
|
@ -15,14 +15,12 @@ import androidx.compose.ui.graphics.toArgb
|
|||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.graphics.toColor
|
||||
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.primaryColor
|
||||
import com.simplemobiletools.commons.R
|
||||
|
||||
@Composable
|
||||
|
@ -30,7 +28,7 @@ fun SettingsScreen(
|
|||
goBack: () -> Unit,
|
||||
customizeColors: () -> Unit,
|
||||
backgroundColor: Int,
|
||||
topBarsScrolledContainerColor: Color = primaryColor
|
||||
topBarsScrolledContainerColor: Color = MaterialTheme.colorScheme.primary
|
||||
) {
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
Scaffold(
|
||||
|
|
|
@ -0,0 +1,443 @@
|
|||
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
|
|
@ -0,0 +1,285 @@
|
|||
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.extensions.config
|
||||
import com.simplemobiletools.commons.extensions.getContrastColor
|
||||
import com.simplemobiletools.commons.extensions.isBlackAndWhiteTheme
|
||||
import com.simplemobiletools.commons.extensions.isWhiteTheme
|
||||
import com.simplemobiletools.commons.helpers.DARK_GREY
|
||||
|
||||
fun getTheme(showTransparentTop: Boolean = false, context: Context, materialYouTheme: Theme.SystemDefaultMaterialYou): Theme {
|
||||
val baseConfig = context.config
|
||||
val primaryColorInt = baseConfig.primaryColor
|
||||
val isSystemInDarkTheme = context.isDarkMode()
|
||||
|
||||
|
||||
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() -> when {//todo fix
|
||||
showTransparentTop -> Theme.BlackAndWhite(
|
||||
accentColor = md_grey_black.toArgb(),
|
||||
primaryColorInt = primaryColorInt,
|
||||
backgroundColorInt = backgroundColor,
|
||||
appIconColorInt = appIconColor,
|
||||
textColorInt = textColor
|
||||
)
|
||||
|
||||
baseConfig.primaryColor.getContrastColor() == DARK_GREY -> Theme.BlackAndWhite(
|
||||
accentColor = md_grey_black.toArgb(),
|
||||
primaryColorInt = primaryColorInt,
|
||||
backgroundColorInt = backgroundColor,
|
||||
appIconColorInt = appIconColor,
|
||||
textColorInt = theme_dark_background_color.toArgb()
|
||||
)
|
||||
|
||||
else -> Theme.BlackAndWhite(
|
||||
accentColor = md_grey_black.toArgb(),
|
||||
primaryColorInt = primaryColorInt,
|
||||
backgroundColorInt = backgroundColor,
|
||||
appIconColorInt = appIconColor,
|
||||
textColorInt = textColor
|
||||
)
|
||||
}
|
||||
|
||||
context.isWhiteTheme() -> when {//todo fix
|
||||
showTransparentTop -> Theme.White(
|
||||
accentColor = md_grey_white.toArgb(),
|
||||
primaryColorInt = primaryColorInt,
|
||||
backgroundColorInt = backgroundColor,
|
||||
appIconColorInt = appIconColor,
|
||||
textColorInt = theme_dark_background_color.toArgb()
|
||||
)
|
||||
|
||||
baseConfig.primaryColor.getContrastColor() == android.graphics.Color.WHITE -> Theme.White(
|
||||
accentColor = md_grey_white.toArgb(),
|
||||
primaryColorInt = primaryColorInt,
|
||||
backgroundColorInt = backgroundColor,
|
||||
appIconColorInt = appIconColor,
|
||||
textColorInt = theme_light_background_color.toArgb()
|
||||
)
|
||||
|
||||
else -> Theme.White(
|
||||
accentColor = md_grey_white.toArgb(),
|
||||
primaryColorInt = primaryColorInt,
|
||||
backgroundColorInt = backgroundColor,
|
||||
appIconColorInt = appIconColor,
|
||||
textColorInt = theme_dark_background_color.toArgb()
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
val customPrimaryColor = when (primaryColorInt) {
|
||||
-12846 -> if (isSystemInDarkTheme) md_red_100_dark else md_red_100
|
||||
-1074534 -> if (isSystemInDarkTheme) md_red_200_dark else md_red_200
|
||||
-1739917 -> if (isSystemInDarkTheme) md_red_300_dark else md_red_300
|
||||
-1092784 -> if (isSystemInDarkTheme) md_red_400_dark else md_red_400
|
||||
-769226 -> if (isSystemInDarkTheme) md_red_500_dark else md_red_500
|
||||
-1754827 -> if (isSystemInDarkTheme) md_red_600_dark else md_red_600
|
||||
-2937041 -> if (isSystemInDarkTheme) md_red_700_dark else md_red_700
|
||||
-3790808 -> if (isSystemInDarkTheme) md_red_800_dark else md_red_800
|
||||
-4776932 -> if (isSystemInDarkTheme) md_red_900_dark else md_red_900
|
||||
|
||||
-476208 -> if (isSystemInDarkTheme) md_pink_100_dark else md_pink_100
|
||||
-749647 -> if (isSystemInDarkTheme) md_pink_200_dark else md_pink_200
|
||||
-1023342 -> if (isSystemInDarkTheme) md_pink_300_dark else md_pink_300
|
||||
-1294214 -> if (isSystemInDarkTheme) md_pink_400_dark else md_pink_400
|
||||
-1499549 -> if (isSystemInDarkTheme) md_pink_500_dark else md_pink_500
|
||||
-2614432 -> if (isSystemInDarkTheme) md_pink_600_dark else md_pink_600
|
||||
-4056997 -> if (isSystemInDarkTheme) md_pink_700_dark else md_pink_700
|
||||
-5434281 -> if (isSystemInDarkTheme) md_pink_800_dark else md_pink_800
|
||||
-7860657 -> if (isSystemInDarkTheme) md_pink_900_dark else md_pink_900
|
||||
|
||||
-1982745 -> if (isSystemInDarkTheme) md_purple_100_dark else md_purple_100
|
||||
-3238952 -> if (isSystemInDarkTheme) md_purple_200_dark else md_purple_200
|
||||
-4560696 -> if (isSystemInDarkTheme) md_purple_300_dark else md_purple_300
|
||||
-5552196 -> if (isSystemInDarkTheme) md_purple_400_dark else md_purple_400
|
||||
-6543440 -> if (isSystemInDarkTheme) md_purple_500_dark else md_purple_500
|
||||
-7461718 -> if (isSystemInDarkTheme) md_purple_600_dark else md_purple_600
|
||||
-8708190 -> if (isSystemInDarkTheme) md_purple_700_dark else md_purple_700
|
||||
-9823334 -> if (isSystemInDarkTheme) md_purple_800_dark else md_purple_800
|
||||
-11922292 -> if (isSystemInDarkTheme) md_purple_900_dark else md_purple_900
|
||||
|
||||
-3029783 -> if (isSystemInDarkTheme) md_deep_purple_100_dark else md_deep_purple_100
|
||||
-5005861 -> if (isSystemInDarkTheme) md_deep_purple_200_dark else md_deep_purple_200
|
||||
-6982195 -> if (isSystemInDarkTheme) md_deep_purple_300_dark else md_deep_purple_300
|
||||
-8497214 -> if (isSystemInDarkTheme) md_deep_purple_400_dark else md_deep_purple_400
|
||||
-10011977 -> if (isSystemInDarkTheme) md_deep_purple_500_dark else md_deep_purple_500
|
||||
-10603087 -> if (isSystemInDarkTheme) md_deep_purple_600_dark else md_deep_purple_600
|
||||
-11457112 -> if (isSystemInDarkTheme) md_deep_purple_700_dark else md_deep_purple_700
|
||||
-12245088 -> if (isSystemInDarkTheme) md_deep_purple_800_dark else md_deep_purple_800
|
||||
-13558894 -> if (isSystemInDarkTheme) md_deep_purple_900_dark else md_deep_purple_900
|
||||
|
||||
-3814679 -> if (isSystemInDarkTheme) md_indigo_100_dark else md_indigo_100
|
||||
-6313766 -> if (isSystemInDarkTheme) md_indigo_200_dark else md_indigo_200
|
||||
-8812853 -> if (isSystemInDarkTheme) md_indigo_300_dark else md_indigo_300
|
||||
-10720320 -> if (isSystemInDarkTheme) md_indigo_400_dark else md_indigo_400
|
||||
-12627531 -> if (isSystemInDarkTheme) md_indigo_500_dark else md_indigo_500
|
||||
-13022805 -> if (isSystemInDarkTheme) md_indigo_600_dark else md_indigo_600
|
||||
-13615201 -> if (isSystemInDarkTheme) md_indigo_700_dark else md_indigo_700
|
||||
-14142061 -> if (isSystemInDarkTheme) md_indigo_800_dark else md_indigo_800
|
||||
-15064194 -> if (isSystemInDarkTheme) md_indigo_900_dark else md_indigo_900
|
||||
|
||||
-4464901 -> if (isSystemInDarkTheme) md_blue_100_dark else md_blue_100
|
||||
-7288071 -> if (isSystemInDarkTheme) md_blue_200_dark else md_blue_200
|
||||
-10177034 -> if (isSystemInDarkTheme) md_blue_300_dark else md_blue_300
|
||||
-12409355 -> if (isSystemInDarkTheme) md_blue_400_dark else md_blue_400
|
||||
-14575885 -> if (isSystemInDarkTheme) md_blue_500_dark else md_blue_500
|
||||
-14776091 -> if (isSystemInDarkTheme) md_blue_600_dark else md_blue_600
|
||||
-15108398 -> if (isSystemInDarkTheme) md_blue_700_dark else md_blue_700
|
||||
-15374912 -> if (isSystemInDarkTheme) md_blue_800_dark else md_blue_800
|
||||
-15906911 -> if (isSystemInDarkTheme) md_blue_900_dark else md_blue_900
|
||||
|
||||
-4987396 -> if (isSystemInDarkTheme) md_light_blue_100_dark else md_light_blue_100
|
||||
-8268550 -> if (isSystemInDarkTheme) md_light_blue_200_dark else md_light_blue_200
|
||||
-11549705 -> if (isSystemInDarkTheme) md_light_blue_300_dark else md_light_blue_300
|
||||
-14043396 -> if (isSystemInDarkTheme) md_light_blue_400_dark else md_light_blue_400
|
||||
-16537100 -> if (isSystemInDarkTheme) md_light_blue_500_dark else md_light_blue_500
|
||||
-16540699 -> if (isSystemInDarkTheme) md_light_blue_600_dark else md_light_blue_600
|
||||
-16611119 -> if (isSystemInDarkTheme) md_light_blue_700_dark else md_light_blue_700
|
||||
-16615491 -> if (isSystemInDarkTheme) md_light_blue_800_dark else md_light_blue_800
|
||||
-16689253 -> if (isSystemInDarkTheme) md_light_blue_900_dark else md_light_blue_900
|
||||
|
||||
-5051406 -> if (isSystemInDarkTheme) md_cyan_100_dark else md_cyan_100
|
||||
-8331542 -> if (isSystemInDarkTheme) md_cyan_200_dark else md_cyan_200
|
||||
-11677471 -> if (isSystemInDarkTheme) md_cyan_300_dark else md_cyan_300
|
||||
-14235942 -> if (isSystemInDarkTheme) md_cyan_400_dark else md_cyan_400
|
||||
-16728876 -> if (isSystemInDarkTheme) md_cyan_500_dark else md_cyan_500
|
||||
-16732991 -> if (isSystemInDarkTheme) md_cyan_600_dark else md_cyan_600
|
||||
-16738393 -> if (isSystemInDarkTheme) md_cyan_700_dark else md_cyan_700
|
||||
-16743537 -> if (isSystemInDarkTheme) md_cyan_800_dark else md_cyan_800
|
||||
-16752540 -> if (isSystemInDarkTheme) md_cyan_900_dark else md_cyan_900
|
||||
|
||||
-5054501 -> if (isSystemInDarkTheme) md_teal_100_dark else md_teal_100
|
||||
-8336444 -> if (isSystemInDarkTheme) md_teal_200_dark else md_teal_200
|
||||
-11684180 -> if (isSystemInDarkTheme) md_teal_300_dark else md_teal_300
|
||||
-14244198 -> if (isSystemInDarkTheme) md_teal_400_dark else md_teal_400
|
||||
-16738680 -> if (isSystemInDarkTheme) md_teal_500_dark else md_teal_500
|
||||
-16742021 -> if (isSystemInDarkTheme) md_teal_600_dark else md_teal_600
|
||||
-16746133 -> if (isSystemInDarkTheme) md_teal_700_dark else md_teal_700
|
||||
-16750244 -> if (isSystemInDarkTheme) md_teal_800_dark else md_teal_800
|
||||
-16757440 -> if (isSystemInDarkTheme) md_teal_900_dark else md_teal_900
|
||||
|
||||
-3610935 -> if (isSystemInDarkTheme) md_green_100_dark else md_green_100
|
||||
-5908825 -> if (isSystemInDarkTheme) md_green_200_dark else md_green_200
|
||||
-8271996 -> if (isSystemInDarkTheme) md_green_300_dark else md_green_300
|
||||
-10044566 -> if (isSystemInDarkTheme) md_green_400_dark else md_green_400
|
||||
-11751600 -> if (isSystemInDarkTheme) md_green_500_dark else md_green_500
|
||||
-12345273 -> if (isSystemInDarkTheme) md_green_600_dark else md_green_600
|
||||
-13070788 -> if (isSystemInDarkTheme) md_green_700_dark else md_green_700
|
||||
-13730510 -> if (isSystemInDarkTheme) md_green_800_dark else md_green_800
|
||||
-14983648 -> if (isSystemInDarkTheme) md_green_900_dark else md_green_900
|
||||
|
||||
-2298424 -> if (isSystemInDarkTheme) md_light_green_100_dark else md_light_green_100
|
||||
-3808859 -> if (isSystemInDarkTheme) md_light_green_200_dark else md_light_green_200
|
||||
-5319295 -> if (isSystemInDarkTheme) md_light_green_300_dark else md_light_green_300
|
||||
-6501275 -> if (isSystemInDarkTheme) md_light_green_400_dark else md_light_green_400
|
||||
-7617718 -> if (isSystemInDarkTheme) md_light_green_500_dark else md_light_green_500
|
||||
-8604862 -> if (isSystemInDarkTheme) md_light_green_600_dark else md_light_green_600
|
||||
-9920712 -> if (isSystemInDarkTheme) md_light_green_700_dark else md_light_green_700
|
||||
-11171025 -> if (isSystemInDarkTheme) md_light_green_800_dark else md_light_green_800
|
||||
-13407970 -> if (isSystemInDarkTheme) md_light_green_900_dark else md_light_green_900
|
||||
|
||||
-985917 -> if (isSystemInDarkTheme) md_lime_100_dark else md_lime_100
|
||||
-1642852 -> if (isSystemInDarkTheme) md_lime_200_dark else md_lime_200
|
||||
-2300043 -> if (isSystemInDarkTheme) md_lime_300_dark else md_lime_300
|
||||
-2825897 -> if (isSystemInDarkTheme) md_lime_400_dark else md_lime_400
|
||||
-3285959 -> if (isSystemInDarkTheme) md_lime_500_dark else md_lime_500
|
||||
-4142541 -> if (isSystemInDarkTheme) md_lime_600_dark else md_lime_600
|
||||
-5983189 -> if (isSystemInDarkTheme) md_lime_700_dark else md_lime_700
|
||||
-6382300 -> if (isSystemInDarkTheme) md_lime_800_dark else md_lime_800
|
||||
-8227049 -> if (isSystemInDarkTheme) md_lime_900_dark else md_lime_900
|
||||
|
||||
-1596 -> if (isSystemInDarkTheme) md_yellow_100_dark else md_yellow_100
|
||||
-2672 -> if (isSystemInDarkTheme) md_yellow_200_dark else md_yellow_200
|
||||
-3722 -> if (isSystemInDarkTheme) md_yellow_300_dark else md_yellow_300
|
||||
-4520 -> if (isSystemInDarkTheme) md_yellow_400_dark else md_yellow_400
|
||||
-5317 -> if (isSystemInDarkTheme) md_yellow_500_dark else md_yellow_500
|
||||
-141259 -> if (isSystemInDarkTheme) md_yellow_600_dark else md_yellow_600
|
||||
-278483 -> if (isSystemInDarkTheme) md_yellow_700_dark else md_yellow_700
|
||||
-415707 -> if (isSystemInDarkTheme) md_yellow_800_dark else md_yellow_800
|
||||
-688361 -> if (isSystemInDarkTheme) md_yellow_900_dark else md_yellow_900
|
||||
|
||||
-4941 -> if (isSystemInDarkTheme) md_amber_100_dark else md_amber_100
|
||||
-8062 -> if (isSystemInDarkTheme) md_amber_200_dark else md_amber_200
|
||||
-10929 -> if (isSystemInDarkTheme) md_amber_300_dark else md_amber_300
|
||||
-13784 -> if (isSystemInDarkTheme) md_amber_400_dark else md_amber_400
|
||||
-16121 -> if (isSystemInDarkTheme) md_amber_500_dark else md_amber_500
|
||||
-19712 -> if (isSystemInDarkTheme) md_amber_600_dark else md_amber_600
|
||||
-24576 -> if (isSystemInDarkTheme) md_amber_700_dark else md_amber_700
|
||||
-28928 -> if (isSystemInDarkTheme) md_amber_800_dark else md_amber_800
|
||||
-37120 -> if (isSystemInDarkTheme) md_amber_900_dark else md_amber_900
|
||||
|
||||
-8014 -> if (isSystemInDarkTheme) md_orange_100_dark else md_orange_100
|
||||
-13184 -> if (isSystemInDarkTheme) md_orange_200_dark else md_orange_200
|
||||
-18611 -> if (isSystemInDarkTheme) md_orange_300_dark else md_orange_300
|
||||
-22746 -> if (isSystemInDarkTheme) md_orange_400_dark else md_orange_400
|
||||
-26624 -> if (isSystemInDarkTheme) md_orange_500_dark else md_orange_500
|
||||
-291840 -> if (isSystemInDarkTheme) md_orange_600_dark else md_orange_600
|
||||
-689152 -> if (isSystemInDarkTheme) md_orange_700_dark else md_orange_700
|
||||
-1086464 -> if (isSystemInDarkTheme) md_orange_800_dark else md_orange_800
|
||||
-1683200 -> if (isSystemInDarkTheme) md_orange_900_dark else md_orange_900
|
||||
|
||||
-13124 -> if (isSystemInDarkTheme) md_deep_orange_100_dark else md_deep_orange_100
|
||||
-21615 -> if (isSystemInDarkTheme) md_deep_orange_200_dark else md_deep_orange_200
|
||||
-30107 -> if (isSystemInDarkTheme) md_deep_orange_300_dark else md_deep_orange_300
|
||||
-36797 -> if (isSystemInDarkTheme) md_deep_orange_400_dark else md_deep_orange_400
|
||||
-43230 -> if (isSystemInDarkTheme) md_deep_orange_500_dark else md_deep_orange_500
|
||||
-765666 -> if (isSystemInDarkTheme) md_deep_orange_600_dark else md_deep_orange_600
|
||||
-1684967 -> if (isSystemInDarkTheme) md_deep_orange_700_dark else md_deep_orange_700
|
||||
-2604267 -> if (isSystemInDarkTheme) md_deep_orange_800_dark else md_deep_orange_800
|
||||
-4246004 -> if (isSystemInDarkTheme) md_deep_orange_900_dark else md_deep_orange_900
|
||||
|
||||
-2634552 -> if (isSystemInDarkTheme) md_brown_100_dark else md_brown_100
|
||||
-4412764 -> if (isSystemInDarkTheme) md_brown_200_dark else md_brown_200
|
||||
-6190977 -> if (isSystemInDarkTheme) md_brown_300_dark else md_brown_300
|
||||
-7508381 -> if (isSystemInDarkTheme) md_brown_400_dark else md_brown_400
|
||||
-8825528 -> if (isSystemInDarkTheme) md_brown_500_dark else md_brown_500
|
||||
-9614271 -> if (isSystemInDarkTheme) md_brown_600_dark else md_brown_600
|
||||
-10665929 -> if (isSystemInDarkTheme) md_brown_700_dark else md_brown_700
|
||||
-11652050 -> if (isSystemInDarkTheme) md_brown_800_dark else md_brown_800
|
||||
-12703965 -> if (isSystemInDarkTheme) md_brown_900_dark else md_brown_900
|
||||
|
||||
-3155748 -> if (isSystemInDarkTheme) md_blue_grey_100_dark else md_blue_grey_100
|
||||
-5194811 -> if (isSystemInDarkTheme) md_blue_grey_200_dark else md_blue_grey_200
|
||||
-7297874 -> if (isSystemInDarkTheme) md_blue_grey_300_dark else md_blue_grey_300
|
||||
-8875876 -> if (isSystemInDarkTheme) md_blue_grey_400_dark else md_blue_grey_400
|
||||
-10453621 -> if (isSystemInDarkTheme) md_blue_grey_500_dark else md_blue_grey_500
|
||||
-11243910 -> if (isSystemInDarkTheme) md_blue_grey_600_dark else md_blue_grey_600
|
||||
-12232092 -> if (isSystemInDarkTheme) md_blue_grey_700_dark else md_blue_grey_700
|
||||
-13154481 -> if (isSystemInDarkTheme) md_blue_grey_800_dark else md_blue_grey_800
|
||||
-14273992 -> if (isSystemInDarkTheme) md_blue_grey_900_dark else md_blue_grey_900
|
||||
|
||||
-1 -> if (isSystemInDarkTheme) md_grey_white_dark else md_grey_black_dark
|
||||
-1118482 -> if (isSystemInDarkTheme) md_grey_200_dark else md_grey_200
|
||||
-2039584 -> if (isSystemInDarkTheme) md_grey_300_dark else md_grey_300
|
||||
-4342339 -> if (isSystemInDarkTheme) md_grey_400_dark else md_grey_400
|
||||
-6381922 -> if (isSystemInDarkTheme) md_grey_500_dark else md_grey_500
|
||||
-9079435 -> if (isSystemInDarkTheme) md_grey_600_dark else md_grey_600
|
||||
-10395295 -> if (isSystemInDarkTheme) md_grey_700_dark else md_grey_700
|
||||
-12434878 -> if (isSystemInDarkTheme) md_grey_800_dark else md_grey_800
|
||||
-16777216 -> if (isSystemInDarkTheme) md_grey_black else md_grey_black_dark
|
||||
|
||||
else -> if (isSystemInDarkTheme) md_orange_700_dark else md_orange_700
|
||||
}
|
||||
Theme.Custom(
|
||||
primaryColorInt = customPrimaryColor.toArgb(),
|
||||
backgroundColorInt = backgroundColor,
|
||||
appIconColorInt = appIconColor,
|
||||
textColorInt = textColor
|
||||
)
|
||||
}
|
||||
}
|
||||
return theme
|
||||
}
|
|
@ -1,8 +1,12 @@
|
|||
package com.simplemobiletools.calculator.compose.theme
|
||||
|
||||
import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.BitmapFactory
|
||||
import android.os.Build
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.LocalOverscrollConfiguration
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.material3.*
|
||||
|
@ -12,39 +16,35 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.graphics.luminance
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalLifecycleOwner
|
||||
import androidx.core.graphics.toColor
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
import com.simplemobiletools.calculator.compose.extensions.getActivity
|
||||
import com.simplemobiletools.calculator.compose.theme.Theme.Companion.systemDefaultMaterialYou
|
||||
import com.simplemobiletools.calculator.extensions.config
|
||||
import com.simplemobiletools.commons.extensions.adjustAlpha
|
||||
import com.simplemobiletools.commons.extensions.getProperStatusBarColor
|
||||
import com.simplemobiletools.commons.extensions.isUsingGestureNavigation
|
||||
import com.simplemobiletools.commons.extensions.navigationBarHeight
|
||||
import com.simplemobiletools.calculator.helpers.Config
|
||||
import com.simplemobiletools.commons.R
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.APP_ICON_IDS
|
||||
import com.simplemobiletools.commons.helpers.APP_LAUNCHER_NAME
|
||||
import com.simplemobiletools.commons.helpers.DARK_GREY
|
||||
import com.simplemobiletools.commons.helpers.HIGHER_ALPHA
|
||||
|
||||
|
||||
val primaryColor = Color(0xFFF57C00)
|
||||
val secondaryColor = Color(0xFFD76D00)
|
||||
val tertiaryColor = primaryColor
|
||||
|
||||
|
||||
private val DarkColorScheme = darkColorScheme(
|
||||
primary = primaryColor,
|
||||
secondary = secondaryColor,
|
||||
tertiary = tertiaryColor,
|
||||
)
|
||||
|
||||
private val LightColorScheme = lightColorScheme(
|
||||
primary = primaryColor,
|
||||
secondary = secondaryColor,
|
||||
tertiary = tertiaryColor,
|
||||
primary = color_primary,
|
||||
secondary = color_primary_dark,
|
||||
tertiary = color_accent,
|
||||
)
|
||||
|
||||
@get:ReadOnlyComposable
|
||||
val disabledTextColor @Composable get() = if (isSystemInDarkTheme()) Color.DarkGray else Color.LightGray
|
||||
val disabledTextColor @Composable get() = if (isSystemInDarkTheme() || MaterialTheme.colorScheme.background.luminance() < 0.5) Color.DarkGray else Color.LightGray
|
||||
|
||||
@get:ReadOnlyComposable
|
||||
val textSubTitleColor
|
||||
@Composable get() = if (isSystemInDarkTheme()) {
|
||||
@Composable get() = if (isSystemInDarkTheme() || MaterialTheme.colorScheme.background.luminance() < 0.5) {
|
||||
Color.White.copy(0.5f)
|
||||
} else {
|
||||
Color.Black.copy(
|
||||
|
@ -54,19 +54,13 @@ val textSubTitleColor
|
|||
|
||||
|
||||
@Composable
|
||||
@ReadOnlyComposable
|
||||
fun preferenceSummaryColor(isEnabled: Boolean) =
|
||||
if (isEnabled) textSubTitleColor else disabledTextColor
|
||||
|
||||
@Composable
|
||||
fun preferenceTitleColor(isEnabled: Boolean) = if (isEnabled) Color.Unspecified else disabledTextColor
|
||||
|
||||
@Composable
|
||||
fun getTheme(): Theme {
|
||||
val context = LocalContext.current
|
||||
val config = remember { context.config }
|
||||
//todo ask for help to create all of these mappings for the theme
|
||||
return systemDefaultMaterialYou()
|
||||
}
|
||||
@ReadOnlyComposable
|
||||
fun preferenceTitleColor(isEnabled: Boolean) = if (isEnabled) LocalContentColor.current else disabledTextColor
|
||||
|
||||
interface CommonTheme {
|
||||
val primaryColorInt: Int
|
||||
|
@ -78,6 +72,7 @@ interface CommonTheme {
|
|||
val backgroundColor get() = Color(backgroundColorInt)
|
||||
val appIconColor get() = Color(appIconColorInt)
|
||||
val textColor get() = Color(textColorInt)
|
||||
|
||||
}
|
||||
|
||||
@Stable
|
||||
|
@ -89,15 +84,8 @@ sealed class Theme : CommonTheme {
|
|||
override val textColorInt: Int
|
||||
) : Theme()
|
||||
|
||||
data class AutoLightDark(
|
||||
override val primaryColorInt: Int,
|
||||
override val backgroundColorInt: Int,
|
||||
override val appIconColorInt: Int,
|
||||
override val textColorInt: Int
|
||||
) :
|
||||
Theme()
|
||||
|
||||
data class Light(
|
||||
data class White(
|
||||
val accentColor: Int,
|
||||
override val primaryColorInt: Int,
|
||||
override val backgroundColorInt: Int,
|
||||
override val appIconColorInt: Int,
|
||||
|
@ -111,21 +99,6 @@ sealed class Theme : CommonTheme {
|
|||
override val textColorInt: Int
|
||||
) : Theme()
|
||||
|
||||
data class DarkRed(
|
||||
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 BlackAndWhite(
|
||||
val accentColor: Int,
|
||||
override val primaryColorInt: Int,
|
||||
|
@ -145,48 +118,80 @@ sealed class Theme : CommonTheme {
|
|||
@Composable
|
||||
fun systemDefaultMaterialYou() = SystemDefaultMaterialYou(
|
||||
appIconColorInt = LocalContext.current.config.appIconColor,
|
||||
primaryColorInt = MaterialTheme.colorScheme.primary.toArgb(),
|
||||
backgroundColorInt = MaterialTheme.colorScheme.background.toArgb(),
|
||||
primaryColorInt = LocalContext.current.config.primaryColor,
|
||||
backgroundColorInt = LocalContext.current.config.backgroundColor,
|
||||
textColorInt = (if (isSystemInDarkTheme() || MaterialTheme.colorScheme.background.luminance() < 0.5) Color.White else Color.Black).toArgb()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
fun Theme(
|
||||
useTransparentNavigation: Boolean = true,
|
||||
statusBarColor: Int,
|
||||
theme: Theme,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val systemUiController = rememberSystemUiController()
|
||||
val window = context.getActivity().window
|
||||
val baseConfig = remember { context.config }
|
||||
|
||||
val colorScheme = when {
|
||||
theme is Theme.SystemDefaultMaterialYou && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||
if (isSystemInDarkTheme()) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||
}
|
||||
|
||||
theme is Theme.AutoLightDark -> if (isSystemInDarkTheme()) DarkColorScheme else LightColorScheme
|
||||
theme is Theme.Dark || theme is Theme.DarkRed -> darkColorScheme(primary = theme.primaryColor, background = theme.backgroundColor)
|
||||
theme is Theme.Light -> lightColorScheme(primary = theme.primaryColor, background = theme.backgroundColor)
|
||||
theme is Theme.White -> lightColorScheme(primary = theme.primaryColor, background = theme.backgroundColor, tertiary = Color(theme.accentColor))
|
||||
theme is Theme.BlackAndWhite -> darkColorScheme(primary = theme.primaryColor, background = theme.backgroundColor, tertiary = Color(theme.accentColor))
|
||||
theme is Theme.Custom -> darkColorScheme(primary = theme.primaryColor, background = theme.backgroundColor)
|
||||
else -> LightColorScheme
|
||||
theme is Theme.Custom || theme is Theme.Dark -> darkColorScheme(
|
||||
primary = theme.primaryColor, surface = theme.backgroundColor,
|
||||
onSurface = theme.textColor
|
||||
)
|
||||
|
||||
theme is Theme.White -> lightColorScheme(
|
||||
primary = theme.primaryColor,
|
||||
surface = theme.backgroundColor,
|
||||
tertiary = Color(theme.accentColor),
|
||||
onSurface = theme.textColor
|
||||
)
|
||||
|
||||
theme is Theme.BlackAndWhite -> darkColorScheme(
|
||||
primary = theme.primaryColor, surface = theme.backgroundColor, tertiary = Color(theme.accentColor),
|
||||
onSurface = theme.textColor
|
||||
)
|
||||
|
||||
else -> DarkColorScheme
|
||||
}
|
||||
LaunchedEffect(Unit) {
|
||||
if (context.navigationBarHeight > 0 || context.isUsingGestureNavigation() && useTransparentNavigation) {
|
||||
systemUiController.isNavigationBarVisible = false
|
||||
}
|
||||
/* if (context.navigationBarHeight > 0 || context.isUsingGestureNavigation() && useTransparentNavigation) {
|
||||
systemUiController.isNavigationBarVisible = false
|
||||
} else {
|
||||
systemUiController.isNavigationBarVisible = true
|
||||
}*/
|
||||
|
||||
/* if (context.navigationBarHeight > 0 || context.isUsingGestureNavigation()) {
|
||||
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility.addBit(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
|
||||
*//* updateTopBottomInsets(statusBarHeight, navigationBarHeight)
|
||||
// Don't touch this. Window Inset API often has a domino effect and things will most likely break.
|
||||
onApplyWindowInsets {
|
||||
val insets = it.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.ime())
|
||||
updateTopBottomInsets(insets.top, insets.bottom)
|
||||
}*//*
|
||||
} else {
|
||||
window.decorView.systemUiVisibility = window.decorView.systemUiVisibility.removeBit(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
|
||||
//updateTopBottomInsets(0, 0)
|
||||
}*/
|
||||
systemUiController.setStatusBarColor(
|
||||
color = Color(statusBarColor)
|
||||
color = colorScheme.surface
|
||||
)
|
||||
systemUiController.setNavigationBarColor(Color(theme.backgroundColorInt.adjustAlpha(HIGHER_ALPHA)))
|
||||
context.getActivity().setTaskDescription(ActivityManager.TaskDescription(null, null, colorScheme.surface.toArgb()))
|
||||
systemUiController.setNavigationBarColor(Color(theme.backgroundColor.toArgb().adjustAlpha(HIGHER_ALPHA)))
|
||||
}
|
||||
|
||||
SideEffect {
|
||||
updateRecentsAppIcon(baseConfig, context)
|
||||
}
|
||||
|
||||
CompositionLocalProvider(
|
||||
LocalContentColor provides theme.textColor,
|
||||
LocalOverscrollConfiguration provides null,
|
||||
) {
|
||||
MaterialTheme(
|
||||
|
@ -196,23 +201,81 @@ fun Theme(
|
|||
}
|
||||
}
|
||||
|
||||
private fun Context.getAppIconIds(): List<Int> = getActivity().intent.getIntegerArrayListExtra(APP_ICON_IDS).orEmpty()
|
||||
private fun Context.getAppLauncherName(): String = getActivity().intent.getStringExtra(APP_LAUNCHER_NAME).orEmpty()
|
||||
private 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())
|
||||
|
||||
@Composable
|
||||
fun AppThemeSurface(
|
||||
modifier: Modifier = Modifier,
|
||||
theme: Theme = systemDefaultMaterialYou(),
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val statusBarColor = remember { context.getProperStatusBarColor() }
|
||||
Theme(statusBarColor = statusBarColor, theme = theme) {
|
||||
val materialYouTheme = systemDefaultMaterialYou()
|
||||
var currentTheme by remember { mutableStateOf(getTheme(context = context, materialYouTheme = materialYouTheme)) }
|
||||
Log.d("Current theme", currentTheme.toString())
|
||||
OnLifecycleEvent {
|
||||
if (it == Lifecycle.Event.ON_RESUME) {
|
||||
currentTheme = getTheme(context = context, materialYouTheme = materialYouTheme)
|
||||
}
|
||||
}
|
||||
Theme(theme = currentTheme) {
|
||||
Surface(
|
||||
modifier = modifier
|
||||
.fillMaxSize()
|
||||
.background(theme.backgroundColor)
|
||||
) {
|
||||
content()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.isDarkMode(): Boolean {
|
||||
val darkModeFlag = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
||||
return darkModeFlag == Configuration.UI_MODE_NIGHT_YES
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun OnLifecycleEvent(
|
||||
lifecycleOwner: LifecycleOwner = LocalLifecycleOwner.current,
|
||||
onEvent: (event: Lifecycle.Event) -> Unit
|
||||
) {
|
||||
val currentOnEvent by rememberUpdatedState(onEvent)
|
||||
DisposableEffect(lifecycleOwner) {
|
||||
val observer = LifecycleEventObserver { _, event ->
|
||||
currentOnEvent(event)
|
||||
}
|
||||
lifecycleOwner.lifecycle.addObserver(observer)
|
||||
onDispose {
|
||||
lifecycleOwner.lifecycle.removeObserver(observer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue