fix(widget): Week day badge polish from on-device review
Weekday + day number live in one circular badge again (bigger font on both, badge widened to fit), and the per-day task count is always rendered, including zero — an omitted count row was making each day's badge drift up or down relative to its neighbours.
This commit is contained in:
@@ -16,14 +16,19 @@ import androidx.glance.LocalSize
|
||||
import androidx.glance.appwidget.GlanceAppWidget
|
||||
import androidx.glance.appwidget.SizeMode
|
||||
import androidx.glance.appwidget.action.actionStartActivity
|
||||
import androidx.glance.appwidget.cornerRadius
|
||||
import androidx.glance.appwidget.provideContent
|
||||
import androidx.glance.background
|
||||
import androidx.glance.currentState
|
||||
import androidx.glance.layout.Alignment
|
||||
import androidx.glance.layout.Box
|
||||
import androidx.glance.layout.Column
|
||||
import androidx.glance.layout.Row
|
||||
import androidx.glance.layout.Spacer
|
||||
import androidx.glance.layout.fillMaxSize
|
||||
import androidx.glance.layout.height
|
||||
import androidx.glance.layout.padding
|
||||
import androidx.glance.layout.size
|
||||
import androidx.glance.layout.width
|
||||
import androidx.glance.state.PreferencesGlanceStateDefinition
|
||||
import androidx.glance.text.FontWeight
|
||||
@@ -113,29 +118,44 @@ private fun WeekDayCell(day: WeekDay, tall: Boolean, modifier: GlanceModifier) {
|
||||
} else {
|
||||
actionStartActivity(MainActivity.smartListIntent(context, SmartList.UPCOMING))
|
||||
}
|
||||
val badgeBackground = if (today) GlanceTheme.colors.primary else GlanceTheme.colors.surface
|
||||
val onBadgeBackground = if (today) GlanceTheme.colors.onPrimary else GlanceTheme.colors.onSurfaceVariant
|
||||
WidgetTile(color = background, modifier = modifier, onClick = open) {
|
||||
Column(modifier = GlanceModifier.fillMaxSize(), horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
val locale = context.resources.configuration.locales[0] ?: Locale.ROOT
|
||||
Spacer(GlanceModifier.defaultWeight())
|
||||
Box(
|
||||
modifier = GlanceModifier
|
||||
.size(44.dp)
|
||||
.cornerRadius(22.dp)
|
||||
.background(badgeBackground),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
Text(
|
||||
text = day.date.dayOfWeek.getDisplayName(JavaTextStyle.SHORT, locale),
|
||||
maxLines = 1,
|
||||
style = TextStyle(color = onBadgeBackground, fontSize = 11.sp, fontWeight = FontWeight.Medium, textAlign = TextAlign.Center),
|
||||
)
|
||||
Text(
|
||||
text = "${day.date.dayOfMonth}",
|
||||
style = TextStyle(color = onBadgeBackground, fontSize = 15.sp, fontWeight = FontWeight.Bold, textAlign = TextAlign.Center),
|
||||
)
|
||||
}
|
||||
}
|
||||
Spacer(GlanceModifier.height(4.dp))
|
||||
// Always rendered, even at 0 — an omitted count row made every
|
||||
// other day's badge drift up or down relative to its neighbours.
|
||||
Text(
|
||||
text = day.date.dayOfWeek.getDisplayName(JavaTextStyle.NARROW, locale),
|
||||
style = TextStyle(color = onBackground, fontSize = 11.sp, textAlign = TextAlign.Center),
|
||||
)
|
||||
Text(
|
||||
text = "${day.date.dayOfMonth}",
|
||||
style = TextStyle(color = onBackground, fontSize = 13.sp, fontWeight = FontWeight.Medium, textAlign = TextAlign.Center),
|
||||
text = "${day.count}",
|
||||
style = TextStyle(
|
||||
color = if (day.overdueCount > 0) GlanceTheme.colors.error else onBackground,
|
||||
fontSize = 18.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
textAlign = TextAlign.Center,
|
||||
),
|
||||
)
|
||||
Spacer(GlanceModifier.defaultWeight())
|
||||
if (day.count > 0) {
|
||||
Text(
|
||||
text = "${day.count}",
|
||||
style = TextStyle(
|
||||
color = if (day.overdueCount > 0) GlanceTheme.colors.error else onBackground,
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Medium,
|
||||
textAlign = TextAlign.Center,
|
||||
),
|
||||
)
|
||||
}
|
||||
if (tall) {
|
||||
day.first?.let { row ->
|
||||
Text(
|
||||
|
||||
Reference in New Issue
Block a user