diff --git a/android/app/src/main/java/com/chronomind/app/widget/TimerWidget.kt b/android/app/src/main/java/com/chronomind/app/widget/TimerWidget.kt new file mode 100644 index 0000000..7b22e3c --- /dev/null +++ b/android/app/src/main/java/com/chronomind/app/widget/TimerWidget.kt @@ -0,0 +1,181 @@ +package com.chronomind.app.widget + +import android.content.Context +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.glance.* +import androidx.glance.action.actionStartActivity +import androidx.glance.appwidget.GlanceAppWidget +import androidx.glance.appwidget.GlanceAppWidgetReceiver +import androidx.glance.appwidget.provideContent +import androidx.glance.layout.* +import androidx.glance.text.FontWeight +import androidx.glance.text.Text +import androidx.glance.text.TextStyle +import com.chronomind.app.MainActivity + +// ── Small Widget: Next Timer Countdown ──────────────────────── + +class TimerWidgetSmall : GlanceAppWidget() { + override suspend fun provideGlance(context: Context, id: GlanceId) { + provideContent { + SmallTimerContent() + } + } +} + +class TimerWidgetSmallReceiver : GlanceAppWidgetReceiver() { + override val glanceAppWidget: GlanceAppWidget = TimerWidgetSmall() +} + +@Composable +private fun SmallTimerContent() { + Box( + modifier = GlanceModifier + .fillMaxSize() + .background(Color(0xFF14141F)) + .padding(12.dp) + .clickable(actionStartActivity()), + contentAlignment = Alignment.Center + ) { + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalAlignment = Alignment.CenterVertically + ) { + Text( + text = "⏱", + style = TextStyle(fontSize = 24.sp) + ) + Spacer(modifier = GlanceModifier.height(4.dp)) + Text( + text = "No active timers", + style = TextStyle( + color = ColorProvider(Color(0xFFAAAACC)), + fontSize = 12.sp + ) + ) + } + } +} + +// ── Medium Widget: Next 3 Timers ────────────────────────────── + +class TimerWidgetMedium : GlanceAppWidget() { + override suspend fun provideGlance(context: Context, id: GlanceId) { + provideContent { + MediumTimerContent() + } + } +} + +class TimerWidgetMediumReceiver : GlanceAppWidgetReceiver() { + override val glanceAppWidget: GlanceAppWidget = TimerWidgetMedium() +} + +@Composable +private fun MediumTimerContent() { + Column( + modifier = GlanceModifier + .fillMaxSize() + .background(Color(0xFF14141F)) + .padding(12.dp) + .clickable(actionStartActivity()) + ) { + Text( + text = "ChronoMind", + style = TextStyle( + color = ColorProvider(Color(0xFFEEEEFF)), + fontSize = 14.sp, + fontWeight = FontWeight.Bold + ) + ) + Spacer(modifier = GlanceModifier.height(8.dp)) + Text( + text = "No active timers", + style = TextStyle( + color = ColorProvider(Color(0xFF666688)), + fontSize = 12.sp + ) + ) + Spacer(modifier = GlanceModifier.height(4.dp)) + Text( + text = "Tap to create one", + style = TextStyle( + color = ColorProvider(Color(0xFF6C5CE7)), + fontSize = 11.sp + ) + ) + } +} + +// ── Large Widget: Mini Timeline ─────────────────────────────── + +class TimerWidgetLarge : GlanceAppWidget() { + override suspend fun provideGlance(context: Context, id: GlanceId) { + provideContent { + LargeTimerContent() + } + } +} + +class TimerWidgetLargeReceiver : GlanceAppWidgetReceiver() { + override val glanceAppWidget: GlanceAppWidget = TimerWidgetLarge() +} + +@Composable +private fun LargeTimerContent() { + Column( + modifier = GlanceModifier + .fillMaxSize() + .background(Color(0xFF14141F)) + .padding(16.dp) + .clickable(actionStartActivity()) + ) { + Row(verticalAlignment = Alignment.CenterVertically) { + Text( + text = "ChronoMind", + style = TextStyle( + color = ColorProvider(Color(0xFFEEEEFF)), + fontSize = 16.sp, + fontWeight = FontWeight.Bold + ) + ) + Spacer(modifier = GlanceModifier.defaultWeight()) + Text( + text = "Timeline", + style = TextStyle( + color = ColorProvider(Color(0xFF6C5CE7)), + fontSize = 12.sp + ) + ) + } + + Spacer(modifier = GlanceModifier.height(12.dp)) + + // Empty state + Box( + modifier = GlanceModifier.fillMaxSize(), + contentAlignment = Alignment.Center + ) { + Column(horizontalAlignment = Alignment.CenterHorizontally) { + Text( + text = "No active timers", + style = TextStyle( + color = ColorProvider(Color(0xFF666688)), + fontSize = 14.sp + ) + ) + Spacer(modifier = GlanceModifier.height(4.dp)) + Text( + text = "Tap to open ChronoMind", + style = TextStyle( + color = ColorProvider(Color(0xFF6C5CE7)), + fontSize = 12.sp + ) + ) + } + } + } +}