Skip to content

Commit

Permalink
feat(widgets): add default colors for devices lower than S.
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed May 5, 2024
1 parent fd03d4f commit a1ecc39
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 6 deletions.
1 change: 1 addition & 0 deletions androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ dependencies {
implementation(projects.themeM3.main.mainDi)
implementation(projects.themeM3.navigation)
implementation(projects.widgets.widgetsFeature)
implementation(projects.widgets.widgetsStyle)
implementation(projects.shared.core)
implementation(projects.shared.coreDi)
implementation(projects.shared.resources)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import androidx.datastore.preferences.core.MutablePreferences
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.glance.GlanceId
import androidx.glance.GlanceTheme
import androidx.glance.appwidget.GlanceAppWidget
import androidx.glance.appwidget.SizeMode
import androidx.glance.appwidget.action.actionStartActivity
Expand All @@ -21,6 +20,7 @@ import kotlinx.datetime.toLocalDateTime
import org.gdglille.devfest.android.R
import org.gdglille.devfest.android.theme.m3.navigation.Screen
import org.gdglille.devfest.android.widgets.feature.SessionsWidget
import org.gdglille.devfest.android.widgets.style.Conferences4HallGlanceTheme
import org.gdglille.devfest.repositories.AgendaRepository
import org.gdglille.devfest.repositories.EventRepository
import org.koin.core.component.KoinComponent
Expand All @@ -38,7 +38,7 @@ class AgendaAppWidget : GlanceAppWidget(), KoinComponent {
override suspend fun provideGlance(context: Context, id: GlanceId) {
val date = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()).toString()
provideContent {
GlanceTheme {
Conferences4HallGlanceTheme {
val prefs = currentState<Preferences>()
SessionsWidget(
eventRepository = eventRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import android.content.Context
import android.content.Intent
import androidx.core.net.toUri
import androidx.glance.GlanceId
import androidx.glance.GlanceTheme
import androidx.glance.appwidget.GlanceAppWidget
import androidx.glance.appwidget.action.actionStartActivity
import androidx.glance.appwidget.provideContent
import org.gdglille.devfest.android.R
import org.gdglille.devfest.android.theme.m3.navigation.Screen
import org.gdglille.devfest.android.widgets.feature.NetworkingWidget
import org.gdglille.devfest.android.widgets.style.Conferences4HallGlanceTheme
import org.gdglille.devfest.repositories.UserRepository
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
Expand All @@ -20,7 +20,7 @@ class NetworkingAppWidget : GlanceAppWidget(), KoinComponent {

override suspend fun provideGlance(context: Context, id: GlanceId) {
provideContent {
GlanceTheme {
Conferences4HallGlanceTheme {
NetworkingWidget(
userRepository = userRepository,
iconId = R.drawable.ic_launcher_foreground,
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ include(":theme-m3:style:theme")
include(":ui-camera")
include(":widgets:widgets-feature")
include(":widgets:widgets-screens")
include(":widgets:widgets-style")
include(":widgets:widgets-ui")
include(":baselineprofile")
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ val md_theme_dark_surfaceTintColor = Color(0xFF4AD7F6)

val seed = Color(0xFF03B7D5)

internal val LightColors = lightColorScheme(
val LightColors = lightColorScheme(
primary = md_theme_light_primary,
onPrimary = md_theme_light_onPrimary,
primaryContainer = md_theme_light_primaryContainer,
Expand Down Expand Up @@ -96,7 +96,7 @@ internal val LightColors = lightColorScheme(
surfaceTint = md_theme_light_surfaceTint
)

internal val DarkColors = darkColorScheme(
val DarkColors = darkColorScheme(
primary = md_theme_dark_primary,
onPrimary = md_theme_dark_onPrimary,
primaryContainer = md_theme_dark_primaryContainer,
Expand Down
16 changes: 16 additions & 0 deletions widgets/widgets-style/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
id("conferences4hall.android.library")
id("conferences4hall.android.library.compose")
id("conferences4hall.quality")
}

android {
namespace = "org.gdglille.devfest.android.widgets.style"
}

dependencies {
implementation(projects.themeM3.style.theme)

implementation(compose.material3)
implementation(libs.bundles.androidx.glance)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.gdglille.devfest.android.widgets.style

import androidx.glance.material3.ColorProviders
import org.gdglille.devfest.android.theme.m3.style.DarkColors
import org.gdglille.devfest.android.theme.m3.style.LightColors

object Conferences4HallGlanceColorScheme {
val colors = ColorProviders(
light = LightColors,
dark = DarkColors
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.gdglille.devfest.android.widgets.style

import android.os.Build
import androidx.compose.runtime.Composable
import androidx.glance.GlanceComposable
import androidx.glance.GlanceTheme

@Composable
fun Conferences4HallGlanceTheme(
content: @GlanceComposable
@Composable
() -> Unit
) {
GlanceTheme(
colors = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
GlanceTheme.colors
} else {
Conferences4HallGlanceColorScheme.colors
},
content = content
)
}

0 comments on commit a1ecc39

Please sign in to comment.