Fix launcher bottom sheet scrim color
This commit is contained in:
1 parent
82adc1db28
commit
abaf63de6d
7 files changed
+27
-9
No files matched your search
@@ -2,6 +2,7 @@ package app.lawnchair.theme.color
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import app.lawnchair.theme.ResourceToken
|
||||
import app.lawnchair.theme.ThemeProvider
|
||||
import app.lawnchair.theme.UiColorMode
|
||||
@@ -78,6 +79,17 @@ data class DarkTextColorToken(
|
||||
}
|
||||
}
|
||||
|
||||
data class SetAlphaColorToken(
|
||||
private val token: ColorToken,
|
||||
private val alpha: Float
|
||||
) : ColorToken {
|
||||
|
||||
override fun resolve(context: Context, scheme: ColorScheme, uiColorMode: UiColorMode): Color {
|
||||
val color = token.resolveColor(context, scheme, uiColorMode)
|
||||
return AndroidColor(ColorUtils.setAlphaComponent(color, (alpha * 255).toInt()))
|
||||
}
|
||||
}
|
||||
|
||||
data class SetLStarColorToken(
|
||||
private val token: ColorToken,
|
||||
private val lStar: Double
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
package app.lawnchair.theme.color
|
||||
|
||||
fun ColorToken.setAlpha(alpha: Float) = SetAlphaColorToken(this, alpha)
|
||||
fun ColorToken.setLStar(lStar: Double) = SetLStarColorToken(this, lStar)
|
||||
@@ -5,6 +5,7 @@ object ColorTokens {
|
||||
val Neutral1_0 = SwatchColorToken(Swatch.Neutral1, Shade.S0)
|
||||
val Neutral1_50 = SwatchColorToken(Swatch.Neutral1, Shade.S50)
|
||||
val Neutral1_100 = SwatchColorToken(Swatch.Neutral1, Shade.S100)
|
||||
val Neutral1_200 = SwatchColorToken(Swatch.Neutral1, Shade.S200)
|
||||
val Neutral1_500 = SwatchColorToken(Swatch.Neutral1, Shade.S500)
|
||||
val Neutral1_700 = SwatchColorToken(Swatch.Neutral1, Shade.S700)
|
||||
val Neutral1_800 = SwatchColorToken(Swatch.Neutral1, Shade.S800)
|
||||
@@ -54,5 +55,7 @@ object ColorTokens {
|
||||
@JvmField val PopupShadeThird = DayNightColorToken(PopupColorPrimary.setLStar(90.0), PopupColorPrimary.setLStar(10.0))
|
||||
@JvmField val WallpaperPopupScrim = Neutral1_900
|
||||
|
||||
@JvmField val WidgetsPickerScrim = DayNightColorToken(Neutral1_200, Neutral1_900).setAlpha(0.8f)
|
||||
|
||||
@JvmField val WorkspaceAccentColor = DarkTextColorToken(Accent1_100, Accent2_600)
|
||||
}
|
||||
@@ -13,9 +13,9 @@ import androidx.compose.runtime.SideEffect
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.core.content.ContextCompat
|
||||
import app.lawnchair.LawnchairLauncher
|
||||
import app.lawnchair.launcher
|
||||
import app.lawnchair.theme.color.ColorTokens
|
||||
import app.lawnchair.ui.preferences.components.BottomSheet
|
||||
import app.lawnchair.ui.preferences.components.BottomSheetState
|
||||
import app.lawnchair.ui.preferences.components.rememberBottomSheetState
|
||||
@@ -25,7 +25,6 @@ import app.lawnchair.ui.util.portal.PortalNodeView
|
||||
import app.lawnchair.util.ProvideLifecycleState
|
||||
import com.android.launcher3.AbstractFloatingView
|
||||
import com.android.launcher3.Insettable
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.util.SystemUiController
|
||||
import com.google.accompanist.insets.ProvideWindowInsets
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -101,7 +100,7 @@ class ComposeFloatingView(context: Context) :
|
||||
@Composable
|
||||
fun scrimColor(): Color {
|
||||
val context = LocalContext.current
|
||||
val intColor = ContextCompat.getColor(context, R.color.widgets_picker_scrim)
|
||||
val intColor = ColorTokens.WidgetsPickerScrim.resolveColor(context)
|
||||
return Color(intColor)
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ import com.android.launcher3.Insettable;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
|
||||
import app.lawnchair.theme.color.ColorTokens;
|
||||
|
||||
/**
|
||||
* Education view about widgets.
|
||||
*/
|
||||
@@ -78,7 +80,7 @@ public class WidgetsEduView extends AbstractSlideInView<Launcher> implements Ins
|
||||
|
||||
@Override
|
||||
protected int getScrimColor(Context context) {
|
||||
return context.getResources().getColor(R.color.widgets_picker_scrim);
|
||||
return ColorTokens.WidgetsPickerScrim.resolveColor(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,6 +35,8 @@ import com.android.launcher3.R;
|
||||
import com.android.launcher3.dragndrop.AddItemActivity;
|
||||
import com.android.launcher3.views.AbstractSlideInView;
|
||||
|
||||
import app.lawnchair.theme.color.ColorTokens;
|
||||
|
||||
/**
|
||||
* Bottom sheet for the pin widget.
|
||||
*/
|
||||
@@ -129,7 +131,7 @@ public class AddItemWidgetsBottomSheet extends AbstractSlideInView<AddItemActivi
|
||||
|
||||
@Override
|
||||
protected int getScrimColor(Context context) {
|
||||
return context.getResources().getColor(R.color.widgets_picker_scrim);
|
||||
return ColorTokens.WidgetsPickerScrim.resolveColor(context);
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi") // Already added API check.
|
||||
|
||||
@@ -45,6 +45,8 @@ import com.android.launcher3.util.Themes;
|
||||
import com.android.launcher3.views.AbstractSlideInView;
|
||||
import com.android.launcher3.views.ArrowTipView;
|
||||
|
||||
import app.lawnchair.theme.color.ColorTokens;
|
||||
|
||||
/**
|
||||
* Base class for various widgets popup
|
||||
*/
|
||||
@@ -64,10 +66,7 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView<Launcher>
|
||||
}
|
||||
|
||||
protected int getScrimColor(Context context) {
|
||||
boolean isMainColorDark = Themes.getAttrBoolean(context, R.attr.isMainColorDark);
|
||||
return context.getResources().getColor(isMainColorDark
|
||||
? R.color.widgets_picker_scrim_dark
|
||||
: R.color.widgets_picker_scrim);
|
||||
return ColorTokens.WidgetsPickerScrim.resolveColor(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user