pull/32/head
parent
90c98f2012
commit
d64a7cafb8
@ -1,32 +1,30 @@ |
|||||||
package io.legado.app.utils |
package io.legado.app.utils |
||||||
|
|
||||||
|
import android.content.Context |
||||||
import android.view.Menu |
import android.view.Menu |
||||||
import androidx.appcompat.view.menu.MenuBuilder |
import androidx.appcompat.view.menu.MenuBuilder |
||||||
import androidx.appcompat.view.menu.MenuItemImpl |
import androidx.appcompat.view.menu.MenuItemImpl |
||||||
import androidx.core.view.forEach |
import androidx.core.view.forEach |
||||||
import io.legado.app.App |
|
||||||
import io.legado.app.R |
import io.legado.app.R |
||||||
import io.legado.app.lib.theme.ColorUtils |
import io.legado.app.lib.theme.ColorUtils |
||||||
import io.legado.app.lib.theme.DrawableUtils |
import io.legado.app.lib.theme.DrawableUtils |
||||||
import io.legado.app.lib.theme.ThemeStore |
import io.legado.app.lib.theme.ThemeStore |
||||||
import io.legado.app.lib.theme.getPrimaryTextColor |
import io.legado.app.lib.theme.getPrimaryTextColor |
||||||
|
|
||||||
val Menu.initIconColor: Menu |
fun Menu.setIconColor(context: Context): Menu = this.let { menu -> |
||||||
get() = this.let { menu -> |
if (menu is MenuBuilder) { |
||||||
if (menu is MenuBuilder) { |
menu.setOptionalIconsVisible(true) |
||||||
menu.setOptionalIconsVisible(true) |
} |
||||||
} |
val primaryTextColor = context.getPrimaryTextColor(ColorUtils.isColorLight(ThemeStore.primaryColor(context))) |
||||||
val primaryTextColor = |
val defaultTextColor = context.getCompatColor(R.color.tv_text_default) |
||||||
App.INSTANCE.getPrimaryTextColor(ColorUtils.isColorLight(ThemeStore.primaryColor(App.INSTANCE))) |
menu.forEach { item -> |
||||||
val defaultTextColor = App.INSTANCE.getCompatColor(R.color.tv_text_default) |
(item as MenuItemImpl).let { impl -> |
||||||
menu.forEach { item -> |
//overflow:展开的item |
||||||
(item as MenuItemImpl).let { impl -> |
DrawableUtils.setTint( |
||||||
//overflow:展开的item |
impl.icon, |
||||||
DrawableUtils.setTint( |
if (impl.requiresOverflow()) defaultTextColor else primaryTextColor |
||||||
impl.icon, |
) |
||||||
if (impl.requiresOverflow()) defaultTextColor else primaryTextColor |
|
||||||
) |
|
||||||
} |
|
||||||
} |
} |
||||||
return menu |
|
||||||
} |
} |
||||||
|
return menu |
||||||
|
} |
Loading…
Reference in new issue