mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-24 03:16:00 +00:00
63
app/src/main/java/com/bintianqi/owndroid/ui/theme/Color.kt
Normal file
63
app/src/main/java/com/bintianqi/owndroid/ui/theme/Color.kt
Normal file
@@ -0,0 +1,63 @@
|
||||
package com.bintianqi.owndroid.ui.theme
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
val md_theme_light_primary = Color(0xFF006A65)
|
||||
val md_theme_light_onPrimary = Color(0xFFFFFFFF)
|
||||
val md_theme_light_primaryContainer = Color(0xFF70F7EE)
|
||||
val md_theme_light_onPrimaryContainer = Color(0xFF00201E)
|
||||
val md_theme_light_secondary = Color(0xFF4A6361)
|
||||
val md_theme_light_onSecondary = Color(0xFFFFFFFF)
|
||||
val md_theme_light_secondaryContainer = Color(0xFFCCE8E5)
|
||||
val md_theme_light_onSecondaryContainer = Color(0xFF051F1E)
|
||||
val md_theme_light_tertiary = Color(0xFF48607B)
|
||||
val md_theme_light_onTertiary = Color(0xFFFFFFFF)
|
||||
val md_theme_light_tertiaryContainer = Color(0xFFD0E4FF)
|
||||
val md_theme_light_onTertiaryContainer = Color(0xFF001D34)
|
||||
val md_theme_light_error = Color(0xFFBA1A1A)
|
||||
val md_theme_light_errorContainer = Color(0xFFFFDAD6)
|
||||
val md_theme_light_onError = Color(0xFFFFFFFF)
|
||||
val md_theme_light_onErrorContainer = Color(0xFF410002)
|
||||
val md_theme_light_background = Color(0xFFFAFDFB)
|
||||
val md_theme_light_onBackground = Color(0xFF191C1C)
|
||||
val md_theme_light_surface = Color(0xFFFAFDFB)
|
||||
val md_theme_light_onSurface = Color(0xFF191C1C)
|
||||
val md_theme_light_surfaceVariant = Color(0xFFDAE5E3)
|
||||
val md_theme_light_onSurfaceVariant = Color(0xFF3F4947)
|
||||
val md_theme_light_outline = Color(0xFF6F7978)
|
||||
val md_theme_light_inverseOnSurface = Color(0xFFEFF1F0)
|
||||
val md_theme_light_inverseSurface = Color(0xFF2D3130)
|
||||
val md_theme_light_inversePrimary = Color(0xFF4FDAD1)
|
||||
val md_theme_light_surfaceTint = Color(0xFF006A65)
|
||||
val md_theme_light_outlineVariant = Color(0xFFBEC9C7)
|
||||
val md_theme_light_scrim = Color(0xFF000000)
|
||||
|
||||
val md_theme_dark_primary = Color(0xFF4FDAD1)
|
||||
val md_theme_dark_onPrimary = Color(0xFF003734)
|
||||
val md_theme_dark_primaryContainer = Color(0xFF00504C)
|
||||
val md_theme_dark_onPrimaryContainer = Color(0xFF70F7EE)
|
||||
val md_theme_dark_secondary = Color(0xFFB0CCC9)
|
||||
val md_theme_dark_onSecondary = Color(0xFF1C3533)
|
||||
val md_theme_dark_secondaryContainer = Color(0xFF324B49)
|
||||
val md_theme_dark_onSecondaryContainer = Color(0xFFCCE8E5)
|
||||
val md_theme_dark_tertiary = Color(0xFFB0C9E7)
|
||||
val md_theme_dark_onTertiary = Color(0xFF18324A)
|
||||
val md_theme_dark_tertiaryContainer = Color(0xFF304962)
|
||||
val md_theme_dark_onTertiaryContainer = Color(0xFFD0E4FF)
|
||||
val md_theme_dark_error = Color(0xFFFFB4AB)
|
||||
val md_theme_dark_errorContainer = Color(0xFF93000A)
|
||||
val md_theme_dark_onError = Color(0xFF690005)
|
||||
val md_theme_dark_onErrorContainer = Color(0xFFFFDAD6)
|
||||
val md_theme_dark_background = Color(0xFF000000)
|
||||
val md_theme_dark_onBackground = Color(0xFFE0E3E2)
|
||||
val md_theme_dark_surface = Color(0xFF191C1C)
|
||||
val md_theme_dark_onSurface = Color(0xFFE0E3E2)
|
||||
val md_theme_dark_surfaceVariant = Color(0xFF3F4947)
|
||||
val md_theme_dark_onSurfaceVariant = Color(0xFFBEC9C7)
|
||||
val md_theme_dark_outline = Color(0xFF889391)
|
||||
val md_theme_dark_inverseOnSurface = Color(0xFF191C1C)
|
||||
val md_theme_dark_inverseSurface = Color(0xFFE0E3E2)
|
||||
val md_theme_dark_inversePrimary = Color(0xFF006A65)
|
||||
val md_theme_dark_surfaceTint = Color(0xFF4FDAD1)
|
||||
val md_theme_dark_outlineVariant = Color(0xFF3F4947)
|
||||
val md_theme_dark_scrim = Color(0xFF000000)
|
||||
129
app/src/main/java/com/bintianqi/owndroid/ui/theme/Theme.kt
Normal file
129
app/src/main/java/com/bintianqi/owndroid/ui/theme/Theme.kt
Normal file
@@ -0,0 +1,129 @@
|
||||
package com.bintianqi.owndroid.ui.theme
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.Build.VERSION
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.material3.MaterialTheme.colorScheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.core.view.WindowCompat
|
||||
|
||||
private val DarkColorScheme = darkColorScheme(
|
||||
primary = md_theme_dark_primary,
|
||||
onPrimary = md_theme_dark_onPrimary,
|
||||
primaryContainer = md_theme_dark_primaryContainer,
|
||||
onPrimaryContainer = md_theme_dark_onPrimaryContainer,
|
||||
secondary = md_theme_dark_secondary,
|
||||
onSecondary = md_theme_dark_onSecondary,
|
||||
secondaryContainer = md_theme_dark_secondaryContainer,
|
||||
onSecondaryContainer = md_theme_dark_onSecondaryContainer,
|
||||
tertiary = md_theme_dark_tertiary,
|
||||
onTertiary = md_theme_dark_onTertiary,
|
||||
tertiaryContainer = md_theme_dark_tertiaryContainer,
|
||||
onTertiaryContainer = md_theme_dark_onTertiaryContainer,
|
||||
error = md_theme_dark_error,
|
||||
errorContainer = md_theme_dark_errorContainer,
|
||||
onError = md_theme_dark_onError,
|
||||
onErrorContainer = md_theme_dark_onErrorContainer,
|
||||
background = md_theme_dark_background,
|
||||
onBackground = md_theme_dark_onBackground,
|
||||
surface = md_theme_dark_surface,
|
||||
onSurface = md_theme_dark_onSurface,
|
||||
surfaceVariant = md_theme_dark_surfaceVariant,
|
||||
onSurfaceVariant = md_theme_dark_onSurfaceVariant,
|
||||
outline = md_theme_dark_outline,
|
||||
inverseOnSurface = md_theme_dark_inverseOnSurface,
|
||||
inverseSurface = md_theme_dark_inverseSurface,
|
||||
inversePrimary = md_theme_dark_inversePrimary,
|
||||
surfaceTint = md_theme_dark_surfaceTint,
|
||||
outlineVariant = md_theme_dark_outlineVariant,
|
||||
scrim = md_theme_dark_scrim
|
||||
)
|
||||
|
||||
private val LightColorScheme = lightColorScheme(
|
||||
primary = md_theme_light_primary,
|
||||
onPrimary = md_theme_light_onPrimary,
|
||||
primaryContainer = md_theme_light_primaryContainer,
|
||||
onPrimaryContainer = md_theme_light_onPrimaryContainer,
|
||||
secondary = md_theme_light_secondary,
|
||||
onSecondary = md_theme_light_onSecondary,
|
||||
secondaryContainer = md_theme_light_secondaryContainer,
|
||||
onSecondaryContainer = md_theme_light_onSecondaryContainer,
|
||||
tertiary = md_theme_light_tertiary,
|
||||
onTertiary = md_theme_light_onTertiary,
|
||||
tertiaryContainer = md_theme_light_tertiaryContainer,
|
||||
onTertiaryContainer = md_theme_light_onTertiaryContainer,
|
||||
error = md_theme_light_error,
|
||||
errorContainer = md_theme_light_errorContainer,
|
||||
onError = md_theme_light_onError,
|
||||
onErrorContainer = md_theme_light_onErrorContainer,
|
||||
background = md_theme_light_background,
|
||||
onBackground = md_theme_light_onBackground,
|
||||
surface = md_theme_light_surface,
|
||||
onSurface = md_theme_light_onSurface,
|
||||
surfaceVariant = md_theme_light_surfaceVariant,
|
||||
onSurfaceVariant = md_theme_light_onSurfaceVariant,
|
||||
outline = md_theme_light_outline,
|
||||
inverseOnSurface = md_theme_light_inverseOnSurface,
|
||||
inverseSurface = md_theme_light_inverseSurface,
|
||||
inversePrimary = md_theme_light_inversePrimary,
|
||||
surfaceTint = md_theme_light_surfaceTint,
|
||||
outlineVariant = md_theme_light_outlineVariant,
|
||||
scrim = md_theme_light_scrim
|
||||
)
|
||||
|
||||
var bgColor = Color(0xFF000000)
|
||||
|
||||
@Composable
|
||||
fun SetDarkTheme(){
|
||||
val dark = isSystemInDarkTheme()
|
||||
val sharedPref = LocalContext.current.getSharedPreferences("data", Context.MODE_PRIVATE)
|
||||
val bg = colorScheme.background
|
||||
val lightBg = colorScheme.primary.copy(alpha = 0.05F)
|
||||
bgColor = if(dark){
|
||||
if(sharedPref.getBoolean("blackTheme",true)){ Color(0xFF000000) }else{ bg }
|
||||
}else{
|
||||
lightBg
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun OwnDroidTheme(
|
||||
darkTheme: Boolean = isSystemInDarkTheme(),
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
SetDarkTheme()
|
||||
val context = LocalContext.current
|
||||
val sharedPref = context.getSharedPreferences("data", Context.MODE_PRIVATE)
|
||||
if(!sharedPref.contains("dynamicColor")&&VERSION.SDK_INT>=32){
|
||||
sharedPref.edit().putBoolean("dynamicColor",true).apply()
|
||||
}
|
||||
val dynamicColor = sharedPref.getBoolean("dynamicColor",false)
|
||||
val colorScheme = when {
|
||||
dynamicColor && VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
|
||||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
|
||||
}
|
||||
|
||||
darkTheme -> DarkColorScheme
|
||||
else -> LightColorScheme
|
||||
}
|
||||
val view = LocalView.current
|
||||
SideEffect {
|
||||
val window = (view.context as Activity).window
|
||||
window.statusBarColor = Color.Transparent.toArgb()
|
||||
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = !darkTheme
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
colorScheme = colorScheme,
|
||||
typography = Typography,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
34
app/src/main/java/com/bintianqi/owndroid/ui/theme/Type.kt
Normal file
34
app/src/main/java/com/bintianqi/owndroid/ui/theme/Type.kt
Normal file
@@ -0,0 +1,34 @@
|
||||
package com.bintianqi.owndroid.ui.theme
|
||||
|
||||
import androidx.compose.material3.Typography
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
// Set of Material typography styles to start with
|
||||
val Typography = Typography(
|
||||
bodyLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 16.sp,
|
||||
lineHeight = 24.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
)
|
||||
/* Other default text styles to override
|
||||
titleLarge = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 22.sp,
|
||||
lineHeight = 28.sp,
|
||||
letterSpacing = 0.sp
|
||||
),
|
||||
labelSmall = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Medium,
|
||||
fontSize = 11.sp,
|
||||
lineHeight = 16.sp,
|
||||
letterSpacing = 0.5.sp
|
||||
)
|
||||
*/
|
||||
)
|
||||
Reference in New Issue
Block a user