You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Redesign is now the new norm
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package com.topjohnwu.magisk.ui.theme
|
||||
|
||||
import com.topjohnwu.magisk.Config
|
||||
import com.topjohnwu.magisk.R
|
||||
|
||||
enum class Theme(
|
||||
val themeName: String,
|
||||
val themeRes: Int
|
||||
) {
|
||||
|
||||
Piplup(
|
||||
themeName = "Piplup",
|
||||
themeRes = R.style.ThemeFoundationMD2_Piplup
|
||||
),
|
||||
PiplupAmoled(
|
||||
themeName = "AMOLED",
|
||||
themeRes = R.style.ThemeFoundationMD2_Amoled
|
||||
),
|
||||
Rayquaza(
|
||||
themeName = "Rayquaza",
|
||||
themeRes = R.style.ThemeFoundationMD2_Rayquaza
|
||||
),
|
||||
Zapdos(
|
||||
themeName = "Zapdos",
|
||||
themeRes = R.style.ThemeFoundationMD2_Zapdos
|
||||
),
|
||||
Charmeleon(
|
||||
themeName = "Charmeleon",
|
||||
themeRes = R.style.ThemeFoundationMD2_Charmeleon
|
||||
),
|
||||
Mew(
|
||||
themeName = "Mew",
|
||||
themeRes = R.style.ThemeFoundationMD2_Mew
|
||||
),
|
||||
Salamence(
|
||||
themeName = "Salamence",
|
||||
themeRes = R.style.ThemeFoundationMD2_Salamence
|
||||
);
|
||||
|
||||
val isSelected get() = Config.themeOrdinal == ordinal
|
||||
|
||||
fun select() {
|
||||
Config.themeOrdinal = ordinal
|
||||
}
|
||||
|
||||
companion object {
|
||||
val selected get() = values().getOrNull(Config.themeOrdinal) ?: Piplup
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.topjohnwu.magisk.ui.theme
|
||||
|
||||
import androidx.core.graphics.Insets
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.databinding.FragmentThemeMd2Binding
|
||||
import com.topjohnwu.magisk.ui.compat.CompatFragment
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
|
||||
class ThemeFragment : CompatFragment<ThemeViewModel, FragmentThemeMd2Binding>() {
|
||||
|
||||
override val layoutRes = R.layout.fragment_theme_md2
|
||||
override val viewModel by viewModel<ThemeViewModel>()
|
||||
|
||||
override fun consumeSystemWindowInsets(insets: Insets) = insets
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
|
||||
activity.title = getString(R.string.section_theme)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.topjohnwu.magisk.ui.theme
|
||||
|
||||
import com.topjohnwu.magisk.model.entity.recycler.TappableHeadlineItem
|
||||
import com.topjohnwu.magisk.model.events.RecreateEvent
|
||||
import com.topjohnwu.magisk.model.events.dialog.DarkThemeDialog
|
||||
import com.topjohnwu.magisk.ui.compat.CompatViewModel
|
||||
|
||||
class ThemeViewModel : CompatViewModel(), TappableHeadlineItem.Listener {
|
||||
|
||||
val themeHeadline = TappableHeadlineItem.ThemeMode
|
||||
|
||||
override fun onItemPressed(item: TappableHeadlineItem) = when (item) {
|
||||
is TappableHeadlineItem.ThemeMode -> darkModePressed()
|
||||
else -> Unit
|
||||
}
|
||||
|
||||
fun saveTheme(theme: Theme) {
|
||||
theme.select()
|
||||
RecreateEvent().publish()
|
||||
}
|
||||
|
||||
private fun darkModePressed() = DarkThemeDialog().publish()
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user