-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mohsen Mirhoseini <[email protected]>
- Loading branch information
Mohsen Mirhoseini
authored
Mar 26, 2024
1 parent
5c0ab53
commit af8c13b
Showing
103 changed files
with
1,094 additions
and
1,064 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
compose/app/src/main/java/com/firework/example/compose/ui/theme/Shape.kt
This file was deleted.
Oops, something went wrong.
74 changes: 52 additions & 22 deletions
74
compose/app/src/main/java/com/firework/example/compose/ui/theme/Theme.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,72 @@ | ||
package com.firework.example.compose.ui.theme | ||
|
||
import android.app.Activity | ||
import android.os.Build | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.darkColors | ||
import androidx.compose.material.lightColors | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.darkColorScheme | ||
import androidx.compose.material3.dynamicDarkColorScheme | ||
import androidx.compose.material3.dynamicLightColorScheme | ||
import androidx.compose.material3.lightColorScheme | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.SideEffect | ||
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 DarkColorPalette = | ||
darkColors( | ||
primary = Purple200, | ||
primaryVariant = Purple700, | ||
secondary = Teal200, | ||
private val DarkColorScheme = | ||
darkColorScheme( | ||
primary = Purple80, | ||
secondary = PurpleGrey80, | ||
tertiary = Pink80, | ||
) | ||
|
||
private val LightColorPalette = | ||
lightColors( | ||
primary = Purple500, | ||
primaryVariant = Purple700, | ||
secondary = Teal200, | ||
background = White, | ||
private val LightColorScheme = | ||
lightColorScheme( | ||
primary = Purple40, | ||
secondary = PurpleGrey40, | ||
tertiary = Pink40, | ||
/* Other default colors to override | ||
background = Color(0xFFFFFBFE), | ||
surface = Color(0xFFFFFBFE), | ||
onPrimary = Color.White, | ||
onSecondary = Color.White, | ||
onTertiary = Color.White, | ||
onBackground = Color(0xFF1C1B1F), | ||
onSurface = Color(0xFF1C1B1F), | ||
*/ | ||
) | ||
|
||
@Composable | ||
fun FireworkComposeTheme( | ||
fun MyApplicationTheme( | ||
darkTheme: Boolean = isSystemInDarkTheme(), | ||
// Dynamic color is available on Android 12+ | ||
dynamicColor: Boolean = true, | ||
content: @Composable () -> Unit, | ||
) { | ||
val colors = | ||
if (darkTheme) { | ||
DarkColorPalette | ||
} else { | ||
LightColorPalette | ||
val colorScheme = | ||
when { | ||
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { | ||
val context = LocalContext.current | ||
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) | ||
} | ||
|
||
darkTheme -> DarkColorScheme | ||
else -> LightColorScheme | ||
} | ||
val view = LocalView.current | ||
if (!view.isInEditMode) { | ||
SideEffect { | ||
val window = (view.context as Activity).window | ||
window.statusBarColor = colorScheme.primary.toArgb() | ||
WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme | ||
} | ||
} | ||
|
||
MaterialTheme( | ||
colors = colors, | ||
colorScheme = colorScheme, | ||
typography = Typography, | ||
shapes = Shapes, | ||
content = content, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
plugins { | ||
id("com.android.application") version "8.2.2" apply false | ||
id("com.android.library") version "8.2.2" apply false | ||
id("com.android.application") version "8.3.1" apply false | ||
id("org.jetbrains.kotlin.android") version "1.9.22" apply false | ||
id("org.jlleitschuh.gradle.ktlint") version "12.0.3" apply false | ||
id("io.gitlab.arturbosch.detekt") version "1.23.4" apply false | ||
} | ||
|
||
task<Delete>("clean") { | ||
delete = setOf(rootProject.buildDir) | ||
delete = setOf(rootProject.layout.buildDirectory) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
plugins { | ||
id("com.android.application") version "8.2.2" apply false | ||
id("com.android.library") version "8.2.2" apply false | ||
id("com.android.application") version "8.3.1" apply false | ||
id("org.jetbrains.kotlin.android") version "1.9.21" apply false | ||
id("org.jlleitschuh.gradle.ktlint") version "12.0.3" apply false | ||
id("io.gitlab.arturbosch.detekt") version "1.23.4" apply false | ||
} | ||
|
||
task<Delete>("clean") { | ||
delete = setOf(rootProject.buildDir) | ||
delete = setOf(rootProject.layout.buildDirectory) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.