diff options
author | Allan Wang <me@allanwang.ca> | 2017-07-30 15:57:27 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-30 15:57:27 -0700 |
commit | 14185936f46160997ef9eaae92cb3c8eacae93c5 (patch) | |
tree | 616d132c4191cd025788e9d7faa9654cf20fa9fd /app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt | |
parent | d94bc858c8a0c273d87d705eb06d35cfd9cf9e08 (diff) | |
download | frost-14185936f46160997ef9eaae92cb3c8eacae93c5.tar.gz frost-14185936f46160997ef9eaae92cb3c8eacae93c5.tar.bz2 frost-14185936f46160997ef9eaae92cb3c8eacae93c5.zip |
Intro (#100)v1.4.1
* Create base activity
* Created some testers
* Update theme and fix mess up
* Update theme and replace paint
* WIP intro drawables
* Create intro screens
* Clear unnecessary dependencies
* Finalize intro panels
* Clean up intro
* Attack intro to settings
* Fix lint
* Finalize intro
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt new file mode 100644 index 00000000..d1d64712 --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroFragmentTheme.kt @@ -0,0 +1,51 @@ +package com.pitchedapps.frost.intro + +import android.os.Bundle +import android.view.View +import ca.allanwang.kau.utils.bindViewResettable +import ca.allanwang.kau.utils.scaleXY +import com.pitchedapps.frost.R +import com.pitchedapps.frost.activities.IntroActivity +import com.pitchedapps.frost.utils.Prefs +import com.pitchedapps.frost.utils.Theme + +/** + * Created by Allan Wang on 2017-07-28. + */ +class IntroFragmentTheme : BaseIntroFragment(R.layout.intro_theme) { + + val light: View by bindViewResettable(R.id.intro_theme_light) + val dark: View by bindViewResettable(R.id.intro_theme_dark) + val amoled: View by bindViewResettable(R.id.intro_theme_amoled) + val glass: View by bindViewResettable(R.id.intro_theme_glass) + + val themeList + get() = listOf(light, dark, amoled, glass) + + override fun viewArray(): Array<Array<out View>> + = arrayOf(arrayOf(title), arrayOf(light, dark), arrayOf(amoled, glass)) + + override fun onViewCreated(view: View?, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + light.setThemeClick(Theme.LIGHT) + dark.setThemeClick(Theme.DARK) + amoled.setThemeClick(Theme.AMOLED) + glass.setThemeClick(Theme.GLASS) + val currentTheme = Prefs.theme - 1 + if (currentTheme in 0..3) + themeList.forEachIndexed { index, v -> v.scaleXY = if (index == currentTheme) 1.6f else 0.8f } + } + + private fun View.setThemeClick(theme: Theme) { + setOnClickListener { + v -> + Prefs.theme = theme.ordinal + (activity as IntroActivity).apply { + ripple.ripple(Prefs.bgColor, v.x + v.pivotX, v.y + v.pivotY) + theme() + } + themeList.forEach { it.animate().scaleXY(if (it == this) 1.6f else 0.8f).start() } + } + } + +}
\ No newline at end of file |