-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopt Ferris Wheel animation colors to different themes
- Loading branch information
Showing
7 changed files
with
159 additions
and
46 deletions.
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
gauguin-app/src/main/kotlin/org/piepmeyer/gauguin/ui/main/FerrisWheelConfigurer.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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package org.piepmeyer.gauguin.ui.main | ||
|
||
import android.content.res.Configuration | ||
import android.graphics.Color | ||
import com.google.android.material.color.MaterialColors | ||
import org.koin.core.component.KoinComponent | ||
import org.koin.core.component.inject | ||
import org.piepmeyer.gauguin.R | ||
import org.piepmeyer.gauguin.Theme | ||
import org.piepmeyer.gauguin.preferences.ApplicationPreferences | ||
import ru.github.igla.ferriswheel.CabinStyle | ||
import ru.github.igla.ferriswheel.CoreStyle | ||
import ru.github.igla.ferriswheel.FerrisWheelView | ||
import ru.github.igla.ferriswheel.StarIcon | ||
|
||
class FerrisWheelConfigurer( | ||
private val ferrisWheel: FerrisWheelView, | ||
) : KoinComponent { | ||
private val applicationPreferences: ApplicationPreferences by inject() | ||
|
||
fun configure() { | ||
ferrisWheel.baseColor = | ||
MaterialColors.getColor(ferrisWheel, com.google.android.material.R.attr.colorOnSurfaceVariant) | ||
ferrisWheel.wheelColor = | ||
MaterialColors.getColor(ferrisWheel, com.google.android.material.R.attr.colorOnSurfaceVariant) | ||
ferrisWheel.outlineAmbientShadowColor = Color.WHITE | ||
ferrisWheel.coreStyle = | ||
CoreStyle( | ||
MaterialColors.getColor(ferrisWheel, com.google.android.material.R.attr.colorSecondary), | ||
MaterialColors.getColor(ferrisWheel, com.google.android.material.R.attr.colorOnSecondary), | ||
StarIcon(MaterialColors.getColor(ferrisWheel, com.google.android.material.R.attr.colorSurfaceVariant)), | ||
) | ||
ferrisWheel.cabinColors = | ||
when (applicationPreferences.theme) { | ||
Theme.DARK -> cabinColorsDark() | ||
Theme.LIGHT -> cabinColorsLight() | ||
Theme.DYNAMIC_COLORS -> cabinColorsDynamic() | ||
Theme.SYSTEM_DEFAULT -> { | ||
when (isNightMode()) { | ||
true -> cabinColorsDark() | ||
false -> cabinColorsLight() | ||
} | ||
} | ||
} | ||
|
||
ferrisWheel.numberOfCabins = 9 | ||
} | ||
|
||
private fun isNightMode(): Boolean { | ||
val mode = | ||
ferrisWheel.context | ||
?.resources | ||
?.configuration | ||
?.uiMode ?: return false | ||
|
||
return (mode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES | ||
} | ||
|
||
private fun cabinColorsDark(): List<CabinStyle> = | ||
listOf( | ||
CabinStyle( | ||
MaterialColors.getColor(ferrisWheel, com.google.android.material.R.attr.colorPrimaryVariant), | ||
Color.TRANSPARENT, | ||
), | ||
CabinStyle( | ||
MaterialColors.getColor(ferrisWheel, com.google.android.material.R.attr.colorSecondaryVariant), | ||
Color.TRANSPARENT, | ||
), | ||
CabinStyle( | ||
ferrisWheel.resources.getColor(R.color.gridSelected, null), | ||
Color.TRANSPARENT, | ||
), | ||
) | ||
|
||
private fun cabinColorsLight(): List<CabinStyle> = | ||
listOf( | ||
CabinStyle( | ||
ferrisWheel.resources.getColor(R.color.md_theme_light_inversePrimary, null), | ||
Color.TRANSPARENT, | ||
), | ||
CabinStyle( | ||
MaterialColors.getColor(ferrisWheel, com.google.android.material.R.attr.colorSecondaryVariant), | ||
Color.TRANSPARENT, | ||
), | ||
CabinStyle( | ||
MaterialColors.getColor(ferrisWheel, R.attr.colorMainTopPanelBackground), | ||
Color.TRANSPARENT, | ||
), | ||
) | ||
|
||
private fun cabinColorsDynamic(): List<CabinStyle> = | ||
listOf( | ||
CabinStyle( | ||
MaterialColors.getColor(ferrisWheel, com.google.android.material.R.attr.colorPrimaryVariant), | ||
Color.TRANSPARENT, | ||
), | ||
CabinStyle( | ||
MaterialColors.getColor(ferrisWheel, com.google.android.material.R.attr.colorSecondaryVariant), | ||
Color.TRANSPARENT, | ||
), | ||
CabinStyle( | ||
MaterialColors.getColor(ferrisWheel, R.attr.colorMainTopPanelBackground), | ||
Color.TRANSPARENT, | ||
), | ||
) | ||
} |
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