diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3f600982..b6fd5ac3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -117,6 +117,7 @@ diff --git a/app/src/main/java/com/google/android/samples/socialite/MainActivity.kt b/app/src/main/java/com/google/android/samples/socialite/MainActivity.kt index 028c58e9..d5158f6f 100644 --- a/app/src/main/java/com/google/android/samples/socialite/MainActivity.kt +++ b/app/src/main/java/com/google/android/samples/socialite/MainActivity.kt @@ -20,7 +20,6 @@ import android.content.Intent import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent -import androidx.activity.enableEdgeToEdge import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import com.google.android.samples.socialite.ui.Main diff --git a/app/src/main/java/com/google/android/samples/socialite/widget/SociaLiteAppWidgetConfigActivity.kt b/app/src/main/java/com/google/android/samples/socialite/widget/SociaLiteAppWidgetConfigActivity.kt index e5ea9a19..654869d8 100644 --- a/app/src/main/java/com/google/android/samples/socialite/widget/SociaLiteAppWidgetConfigActivity.kt +++ b/app/src/main/java/com/google/android/samples/socialite/widget/SociaLiteAppWidgetConfigActivity.kt @@ -95,7 +95,7 @@ class SociaLiteAppWidgetConfigActivity : ComponentActivity() { ContactRow( contact = contact, - onClick = TODO("Replace with code from codelab"), + onClick = { TODO("Replace with code from codelab") }, ) } } diff --git a/app/src/main/java/com/google/android/samples/socialite/widget/ui/FavoriteContact.kt b/app/src/main/java/com/google/android/samples/socialite/widget/ui/FavoriteContact.kt index 9c69e378..754dca67 100644 --- a/app/src/main/java/com/google/android/samples/socialite/widget/ui/FavoriteContact.kt +++ b/app/src/main/java/com/google/android/samples/socialite/widget/ui/FavoriteContact.kt @@ -17,19 +17,19 @@ package com.google.android.samples.socialite.widget.ui import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.core.net.toUri import androidx.glance.GlanceModifier +import androidx.glance.GlanceTheme import androidx.glance.Image -import androidx.glance.ImageProvider import androidx.glance.action.Action import androidx.glance.action.clickable import androidx.glance.appwidget.ImageProvider +import androidx.glance.appwidget.appWidgetBackground import androidx.glance.appwidget.cornerRadius +import androidx.glance.background import androidx.glance.layout.Alignment -import androidx.glance.layout.Box import androidx.glance.layout.Column import androidx.glance.layout.ContentScale import androidx.glance.layout.fillMaxSize @@ -39,25 +39,27 @@ import androidx.glance.layout.wrapContentHeight import androidx.glance.text.FontWeight import androidx.glance.text.Text import androidx.glance.text.TextStyle -import androidx.glance.unit.ColorProvider import com.google.android.samples.socialite.widget.model.WidgetModel @Composable -fun FavoriteContact(model: WidgetModel, onClick: Action) { - Box( - modifier = GlanceModifier.fillMaxSize().clickable(onClick) - .cornerRadius(8.dp).padding(bottom = 8.dp), - contentAlignment = Alignment.TopCenter, +fun FavoriteContact(modifier: GlanceModifier = GlanceModifier, model: WidgetModel, onClick: Action) { + Column( + modifier = modifier.fillMaxSize().clickable(onClick) + .background(GlanceTheme.colors.widgetBackground).appWidgetBackground() + .padding(bottom = 8.dp), + verticalAlignment = Alignment.Vertical.Bottom, + horizontalAlignment = Alignment.Horizontal.CenterHorizontally, ) { Image( - modifier = GlanceModifier.fillMaxSize().cornerRadius(8.dp), + modifier = GlanceModifier.fillMaxWidth().wrapContentHeight().defaultWeight() + .cornerRadius(16.dp), provider = ImageProvider(model.photo.toUri()), contentScale = ContentScale.Crop, contentDescription = model.displayName, ) Column( - modifier = GlanceModifier.fillMaxWidth().wrapContentHeight(), - verticalAlignment = Alignment.Vertical.Top, + modifier = GlanceModifier.fillMaxWidth().wrapContentHeight().padding(top = 4.dp), + verticalAlignment = Alignment.Vertical.Bottom, horizontalAlignment = Alignment.Horizontal.CenterHorizontally, ) { Text( @@ -65,7 +67,7 @@ fun FavoriteContact(model: WidgetModel, onClick: Action) { style = TextStyle( fontWeight = FontWeight.Bold, fontSize = 24.sp, - color = ColorProvider(Color.White), + color = (GlanceTheme.colors.onSurface), ), ) @@ -74,7 +76,7 @@ fun FavoriteContact(model: WidgetModel, onClick: Action) { style = TextStyle( fontWeight = FontWeight.Bold, fontSize = 16.sp, - color = ColorProvider(Color.White), + color = (GlanceTheme.colors.onSurface), ), ) } diff --git a/app/src/main/res/drawable/widget_preview.png b/app/src/main/res/drawable/widget_preview.png index 9bd895d3..8f7ac887 100644 Binary files a/app/src/main/res/drawable/widget_preview.png and b/app/src/main/res/drawable/widget_preview.png differ