Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc6068b759 | ||
|
|
9a75fb25db |
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [1.5.4] - 2026-01-07
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **User display in environment section** - Shows authenticated user in section header for debugging
|
||||||
|
- Displays `user: {username}` next to "Environment" header when data loads
|
||||||
|
- Helps diagnose user resolution issues with OIDC authentication
|
||||||
|
|
||||||
|
## [1.5.3] - 2026-01-07
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **Sun position arc redesign** - Arc now touches horizon at sunrise/sunset points
|
||||||
|
- Arc geometry uses chord-radius calculation for proper horizon intersection
|
||||||
|
- Sunrise/sunset icons integrated at horizon endpoints (no duplicate labels)
|
||||||
|
- Daylight duration centered below arc
|
||||||
|
- Increased card height 20% for better arc visibility (140px → 170px)
|
||||||
|
- **Visual balance improvements** - Sunrise/sunset labels raised 10px, daylight label at bottom
|
||||||
|
|
||||||
## [1.5.2] - 2026-01-07
|
## [1.5.2] - 2026-01-07
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
@@ -129,39 +129,62 @@ class _DashboardContentState extends ConsumerState<DashboardContent> {
|
|||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
// Environment - Sun, Weather, Forecast, Air Quality
|
// Environment - Sun, Weather, Forecast, Air Quality
|
||||||
_SectionHeader(title: 'Environment', icon: Icons.eco),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
environmentAsync.when(
|
environmentAsync.when(
|
||||||
data: (envData) => _EnvironmentSection(
|
data: (envData) => Column(
|
||||||
envData: envData,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
onRefresh: () => ref.invalidate(environmentProvider),
|
children: [
|
||||||
),
|
_SectionHeader(
|
||||||
loading: () => const Card(
|
title: 'Environment',
|
||||||
child: Padding(
|
icon: Icons.eco,
|
||||||
padding: EdgeInsets.all(32),
|
subtitle: envData.user != null ? 'user: ${envData.user}' : null,
|
||||||
child: Center(child: CircularProgressIndicator()),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
error: (error, _) => Card(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
|
||||||
Icon(Icons.error_outline, color: colorScheme.error),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
'Failed to load environment data',
|
|
||||||
style: TextStyle(color: colorScheme.error),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.refresh),
|
|
||||||
onPressed: () => ref.invalidate(environmentProvider),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 8),
|
||||||
|
_EnvironmentSection(
|
||||||
|
envData: envData,
|
||||||
|
onRefresh: () => ref.invalidate(environmentProvider),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
loading: () => Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const _SectionHeader(title: 'Environment', icon: Icons.eco),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
const Card(
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(32),
|
||||||
|
child: Center(child: CircularProgressIndicator()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
error: (error, _) => Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
const _SectionHeader(title: 'Environment', icon: Icons.eco),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Card(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.error_outline, color: colorScheme.error),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
'Failed to load environment data',
|
||||||
|
style: TextStyle(color: colorScheme.error),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.refresh),
|
||||||
|
onPressed: () => ref.invalidate(environmentProvider),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
@@ -185,10 +208,12 @@ class _SectionHeader extends StatelessWidget {
|
|||||||
const _SectionHeader({
|
const _SectionHeader({
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.icon,
|
required this.icon,
|
||||||
|
this.subtitle,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String title;
|
final String title;
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
|
final String? subtitle;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -209,6 +234,15 @@ class _SectionHeader extends StatelessWidget {
|
|||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (subtitle != null) ...[
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
subtitle!,
|
||||||
|
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||||
|
color: colorScheme.outline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,28 +210,30 @@ class AirQualityWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
// Match height of populated card content area
|
const SizedBox(height: 8),
|
||||||
const SizedBox(height: 120),
|
// Match sun position card height (170px content area)
|
||||||
Center(
|
SizedBox(
|
||||||
child: Column(
|
height: 170,
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Center(
|
||||||
children: [
|
child: Column(
|
||||||
Icon(
|
mainAxisSize: MainAxisSize.min,
|
||||||
Icons.air_outlined,
|
children: [
|
||||||
size: 32,
|
Icon(
|
||||||
color: colorScheme.outline,
|
Icons.air_outlined,
|
||||||
),
|
size: 32,
|
||||||
const SizedBox(height: 8),
|
color: colorScheme.outline,
|
||||||
Text(
|
),
|
||||||
'No data available',
|
const SizedBox(height: 8),
|
||||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
Text(
|
||||||
color: colorScheme.outline,
|
'No data available',
|
||||||
),
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
),
|
color: colorScheme.outline,
|
||||||
],
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 40),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -48,28 +48,30 @@ class ForecastWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
// Match height of populated card content area
|
const SizedBox(height: 8),
|
||||||
const SizedBox(height: 120),
|
// Match sun position card height (170px content area)
|
||||||
Center(
|
SizedBox(
|
||||||
child: Column(
|
height: 170,
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Center(
|
||||||
children: [
|
child: Column(
|
||||||
Icon(
|
mainAxisSize: MainAxisSize.min,
|
||||||
Icons.event_busy_outlined,
|
children: [
|
||||||
size: 32,
|
Icon(
|
||||||
color: colorScheme.outline,
|
Icons.event_busy_outlined,
|
||||||
),
|
size: 32,
|
||||||
const SizedBox(height: 8),
|
color: colorScheme.outline,
|
||||||
Text(
|
),
|
||||||
'No data available',
|
const SizedBox(height: 8),
|
||||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
Text(
|
||||||
color: colorScheme.outline,
|
'No data available',
|
||||||
),
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
),
|
color: colorScheme.outline,
|
||||||
],
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 40),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -119,41 +119,63 @@ class _SunPositionWidgetState extends State<SunPositionWidget> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
// Arc visualization
|
// Arc with integrated horizon labels
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 120,
|
height: 170,
|
||||||
child: CustomPaint(
|
child: LayoutBuilder(
|
||||||
size: const Size(double.infinity, 120),
|
builder: (context, constraints) {
|
||||||
painter: _SunArcPainter(
|
return Stack(
|
||||||
sunTimes: widget.sunTimes,
|
clipBehavior: Clip.none,
|
||||||
isDark: colorScheme.brightness == Brightness.dark,
|
children: [
|
||||||
),
|
// Arc painter
|
||||||
|
Positioned.fill(
|
||||||
|
child: CustomPaint(
|
||||||
|
painter: _SunArcPainter(
|
||||||
|
sunTimes: widget.sunTimes,
|
||||||
|
isDark: colorScheme.brightness == Brightness.dark,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Sunrise widget at left horizon (10px up for balance)
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
bottom: 10,
|
||||||
|
child: _HorizonTimeDisplay(
|
||||||
|
icon: Icons.wb_twilight,
|
||||||
|
label: 'Sunrise',
|
||||||
|
time: _sunrise,
|
||||||
|
iconColor: Colors.orange,
|
||||||
|
alignment: CrossAxisAlignment.start,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Daylight display centered (at bottom for balance)
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
child: Center(
|
||||||
|
child: _DaylightDisplay(minutes: _daylightMinutes),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Sunset widget at right horizon (10px up for balance)
|
||||||
|
Positioned(
|
||||||
|
right: 0,
|
||||||
|
bottom: 10,
|
||||||
|
child: _HorizonTimeDisplay(
|
||||||
|
icon: Icons.nights_stay,
|
||||||
|
label: 'Sunset',
|
||||||
|
time: _sunset,
|
||||||
|
iconColor: Colors.deepOrange,
|
||||||
|
alignment: CrossAxisAlignment.end,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
|
|
||||||
// Sunrise/Sunset times
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
_TimeDisplay(
|
|
||||||
icon: Icons.wb_twilight,
|
|
||||||
label: 'Sunrise',
|
|
||||||
time: _sunrise,
|
|
||||||
iconColor: Colors.orange,
|
|
||||||
),
|
|
||||||
_DaylightDisplay(minutes: _daylightMinutes),
|
|
||||||
_TimeDisplay(
|
|
||||||
icon: Icons.nights_stay,
|
|
||||||
label: 'Sunset',
|
|
||||||
time: _sunset,
|
|
||||||
iconColor: Colors.deepOrange,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -198,34 +220,39 @@ class _SunPositionWidgetState extends State<SunPositionWidget> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TimeDisplay extends StatelessWidget {
|
/// Horizon-aligned time display with icon above time and label.
|
||||||
const _TimeDisplay({
|
class _HorizonTimeDisplay extends StatelessWidget {
|
||||||
|
const _HorizonTimeDisplay({
|
||||||
required this.icon,
|
required this.icon,
|
||||||
required this.label,
|
required this.label,
|
||||||
required this.time,
|
required this.time,
|
||||||
this.iconColor,
|
this.iconColor,
|
||||||
|
this.alignment = CrossAxisAlignment.center,
|
||||||
});
|
});
|
||||||
|
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
final String label;
|
final String label;
|
||||||
final DateTime time;
|
final DateTime time;
|
||||||
final Color? iconColor;
|
final Color? iconColor;
|
||||||
|
final CrossAxisAlignment alignment;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final colorScheme = Theme.of(context).colorScheme;
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: alignment,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
icon,
|
icon,
|
||||||
size: 20,
|
size: 18,
|
||||||
color: iconColor ?? colorScheme.primary,
|
color: iconColor ?? colorScheme.primary,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 2),
|
||||||
Text(
|
Text(
|
||||||
'${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}',
|
'${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}',
|
||||||
style: Theme.of(context).textTheme.titleSmall?.copyWith(
|
style: Theme.of(context).textTheme.labelMedium?.copyWith(
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -233,6 +260,7 @@ class _TimeDisplay extends StatelessWidget {
|
|||||||
label,
|
label,
|
||||||
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||||
color: colorScheme.onSurfaceVariant,
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
fontSize: 10,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -280,7 +308,7 @@ class _DaylightDisplay extends StatelessWidget {
|
|||||||
/// The arc is proportional to the day/night duration:
|
/// The arc is proportional to the day/night duration:
|
||||||
/// - During day: shows a day arc spanning (daylight hours / 24) × 360°
|
/// - During day: shows a day arc spanning (daylight hours / 24) × 360°
|
||||||
/// - During night: shows a night arc spanning (night hours / 24) × 360°
|
/// - During night: shows a night arc spanning (night hours / 24) × 360°
|
||||||
/// - Horizon points (left/right) represent sunrise/sunset times
|
/// - Arc endpoints touch the horizon line at sunrise/sunset positions
|
||||||
class _SunArcPainter extends CustomPainter {
|
class _SunArcPainter extends CustomPainter {
|
||||||
_SunArcPainter({
|
_SunArcPainter({
|
||||||
this.sunTimes,
|
this.sunTimes,
|
||||||
@@ -316,59 +344,71 @@ class _SunArcPainter extends CustomPainter {
|
|||||||
final isDaytime = now.isAfter(sunrise) && now.isBefore(sunset);
|
final isDaytime = now.isAfter(sunrise) && now.isBefore(sunset);
|
||||||
|
|
||||||
// Calculate arc angles (proportional to duration)
|
// Calculate arc angles (proportional to duration)
|
||||||
// Day arc sweeps upward (above horizon), night arc sweeps downward
|
|
||||||
final dayArcAngle = (daylightMinutes / 1440) * 2 * math.pi;
|
final dayArcAngle = (daylightMinutes / 1440) * 2 * math.pi;
|
||||||
final nightArcAngle = (nightMinutes / 1440) * 2 * math.pi;
|
final nightArcAngle = (nightMinutes / 1440) * 2 * math.pi;
|
||||||
|
|
||||||
final center = Offset(size.width / 2, size.height - 10);
|
// Layout constants - horizon is 50px from bottom to leave room for labels
|
||||||
final radius = math.min(size.width / 2 - 20, size.height - 30);
|
const horizonY = 50.0;
|
||||||
|
const horizontalPadding = 40.0;
|
||||||
|
final horizonWidth = size.width - (horizontalPadding * 2);
|
||||||
|
final centerX = size.width / 2;
|
||||||
|
|
||||||
// Draw horizon line
|
// Draw horizon line
|
||||||
final horizonPaint = Paint()
|
final horizonPaint = Paint()
|
||||||
..color = isDark ? Colors.white24 : Colors.black12
|
..color = isDark ? Colors.white24 : Colors.black12
|
||||||
..strokeWidth = 1;
|
..strokeWidth = 1;
|
||||||
canvas.drawLine(
|
canvas.drawLine(
|
||||||
Offset(center.dx - radius - 10, center.dy),
|
Offset(horizontalPadding - 5, size.height - horizonY),
|
||||||
Offset(center.dx + radius + 10, center.dy),
|
Offset(size.width - horizontalPadding + 5, size.height - horizonY),
|
||||||
horizonPaint,
|
horizonPaint,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (isDaytime) {
|
||||||
|
_drawDayArc(canvas, size, centerX, horizonWidth, horizonY, dayArcAngle, now, sunrise, sunset);
|
||||||
|
} else {
|
||||||
|
_drawNightArc(canvas, size, centerX, horizonWidth, horizonY, nightArcAngle, now, sunrise, sunset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _drawDayArc(
|
||||||
|
Canvas canvas,
|
||||||
|
Size size,
|
||||||
|
double centerX,
|
||||||
|
double horizonWidth,
|
||||||
|
double horizonY,
|
||||||
|
double arcAngle,
|
||||||
|
DateTime now,
|
||||||
|
DateTime sunrise,
|
||||||
|
DateTime sunset,
|
||||||
|
) {
|
||||||
|
// Clamp arc angle between 30° and 180° for visual sanity
|
||||||
|
final clampedAngle = arcAngle.clamp(math.pi / 6, math.pi);
|
||||||
|
|
||||||
|
// Calculate radius so arc endpoints touch horizon
|
||||||
|
// For a chord of width W and arc angle θ: R = W / (2 * sin(θ/2))
|
||||||
|
final radius = horizonWidth / (2 * math.sin(clampedAngle / 2));
|
||||||
|
|
||||||
|
// Arc center is below the horizon for an upward-bulging arc
|
||||||
|
// Distance from chord to center = R * cos(θ/2)
|
||||||
|
final horizonYPos = size.height - horizonY;
|
||||||
|
final centerY = horizonYPos + radius * math.cos(clampedAngle / 2);
|
||||||
|
final center = Offset(centerX, centerY);
|
||||||
|
|
||||||
|
// The arc starts at the LEFT horizon point
|
||||||
|
// In canvas coords (Y down), angle to left point = 3π/2 - θ/2
|
||||||
|
// The arc sweeps clockwise (positive) through angle θ to reach right point
|
||||||
|
final startAngle = (3 * math.pi / 2) - (clampedAngle / 2);
|
||||||
|
|
||||||
final arcRect = Rect.fromCenter(
|
final arcRect = Rect.fromCenter(
|
||||||
center: center,
|
center: center,
|
||||||
width: radius * 2,
|
width: radius * 2,
|
||||||
height: radius * 2,
|
height: radius * 2,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isDaytime) {
|
|
||||||
_drawDayArc(canvas, arcRect, center, radius, dayArcAngle, now, sunrise, sunset);
|
|
||||||
} else {
|
|
||||||
_drawNightArc(canvas, arcRect, center, radius, nightArcAngle, now, sunrise, sunset);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw sunrise/sunset time labels at horizon points
|
|
||||||
_drawHorizonLabels(canvas, center, radius, sunrise, sunset);
|
|
||||||
}
|
|
||||||
|
|
||||||
void _drawDayArc(
|
|
||||||
Canvas canvas,
|
|
||||||
Rect arcRect,
|
|
||||||
Offset center,
|
|
||||||
double radius,
|
|
||||||
double arcAngle,
|
|
||||||
DateTime now,
|
|
||||||
DateTime sunrise,
|
|
||||||
DateTime sunset,
|
|
||||||
) {
|
|
||||||
// Day arc: starts at left horizon, sweeps upward
|
|
||||||
// Arc starts at π (left) and sweeps toward 0 (right)
|
|
||||||
// But the sweep angle is proportional to daylight duration
|
|
||||||
final startAngle = math.pi;
|
|
||||||
final sweepAngle = arcAngle.clamp(0.0, math.pi); // Cap at semicircle for visual
|
|
||||||
|
|
||||||
// Draw arc background with day gradient
|
// Draw arc background with day gradient
|
||||||
final arcPaint = Paint()
|
final arcPaint = Paint()
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = 8
|
..strokeWidth = 6
|
||||||
..strokeCap = StrokeCap.round
|
..strokeCap = StrokeCap.round
|
||||||
..shader = SweepGradient(
|
..shader = SweepGradient(
|
||||||
center: Alignment.center,
|
center: Alignment.center,
|
||||||
@@ -383,18 +423,19 @@ class _SunArcPainter extends CustomPainter {
|
|||||||
_duskOrange.withValues(alpha: 0.6),
|
_duskOrange.withValues(alpha: 0.6),
|
||||||
],
|
],
|
||||||
stops: const [0.0, 0.15, 0.4, 0.6, 0.85, 1.0],
|
stops: const [0.0, 0.15, 0.4, 0.6, 0.85, 1.0],
|
||||||
transform: const GradientRotation(math.pi),
|
transform: GradientRotation(startAngle),
|
||||||
).createShader(arcRect);
|
).createShader(arcRect);
|
||||||
|
|
||||||
canvas.drawArc(arcRect, startAngle, sweepAngle, false, arcPaint);
|
// Draw the arc (positive sweep = clockwise in canvas coords = visually upward arc)
|
||||||
|
canvas.drawArc(arcRect, startAngle, clampedAngle, false, arcPaint);
|
||||||
|
|
||||||
// Calculate sun position along the arc
|
// Calculate sun position along the arc
|
||||||
final totalDaylight = sunset.difference(sunrise).inMinutes;
|
final totalDaylight = sunset.difference(sunrise).inMinutes;
|
||||||
final minutesSinceSunrise = now.difference(sunrise).inMinutes;
|
final minutesSinceSunrise = now.difference(sunrise).inMinutes;
|
||||||
final progress = (minutesSinceSunrise / totalDaylight).clamp(0.0, 1.0);
|
final progress = (minutesSinceSunrise / totalDaylight).clamp(0.0, 1.0);
|
||||||
|
|
||||||
// Map progress to angle along the arc
|
// Map progress to angle along the arc (0 = sunrise/left, 1 = sunset/right)
|
||||||
final sunAngle = startAngle + (progress * sweepAngle);
|
final sunAngle = startAngle + (progress * clampedAngle);
|
||||||
final sunX = center.dx + radius * math.cos(sunAngle);
|
final sunX = center.dx + radius * math.cos(sunAngle);
|
||||||
final sunY = center.dy + radius * math.sin(sunAngle);
|
final sunY = center.dy + radius * math.sin(sunAngle);
|
||||||
|
|
||||||
@@ -410,14 +451,14 @@ class _SunArcPainter extends CustomPainter {
|
|||||||
glowColor.withValues(alpha: 0.6),
|
glowColor.withValues(alpha: 0.6),
|
||||||
glowColor.withValues(alpha: 0.0),
|
glowColor.withValues(alpha: 0.0),
|
||||||
],
|
],
|
||||||
).createShader(Rect.fromCircle(center: Offset(sunX, sunY), radius: 24));
|
).createShader(Rect.fromCircle(center: Offset(sunX, sunY), radius: 20));
|
||||||
canvas.drawCircle(Offset(sunX, sunY), 24, glowPaint);
|
canvas.drawCircle(Offset(sunX, sunY), 20, glowPaint);
|
||||||
|
|
||||||
// Draw sun
|
// Draw sun
|
||||||
final sunPaint = Paint()
|
final sunPaint = Paint()
|
||||||
..style = PaintingStyle.fill
|
..style = PaintingStyle.fill
|
||||||
..color = sunColor;
|
..color = sunColor;
|
||||||
canvas.drawCircle(Offset(sunX, sunY), 12, sunPaint);
|
canvas.drawCircle(Offset(sunX, sunY), 10, sunPaint);
|
||||||
|
|
||||||
// Draw sun rays
|
// Draw sun rays
|
||||||
final rayPaint = Paint()
|
final rayPaint = Paint()
|
||||||
@@ -428,8 +469,8 @@ class _SunArcPainter extends CustomPainter {
|
|||||||
for (var i = 0; i < 8; i++) {
|
for (var i = 0; i < 8; i++) {
|
||||||
final rayAngle = (i * math.pi / 4);
|
final rayAngle = (i * math.pi / 4);
|
||||||
canvas.drawLine(
|
canvas.drawLine(
|
||||||
Offset(sunX + 14 * math.cos(rayAngle), sunY + 14 * math.sin(rayAngle)),
|
Offset(sunX + 12 * math.cos(rayAngle), sunY + 12 * math.sin(rayAngle)),
|
||||||
Offset(sunX + 18 * math.cos(rayAngle), sunY + 18 * math.sin(rayAngle)),
|
Offset(sunX + 16 * math.cos(rayAngle), sunY + 16 * math.sin(rayAngle)),
|
||||||
rayPaint,
|
rayPaint,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -437,23 +478,40 @@ class _SunArcPainter extends CustomPainter {
|
|||||||
|
|
||||||
void _drawNightArc(
|
void _drawNightArc(
|
||||||
Canvas canvas,
|
Canvas canvas,
|
||||||
Rect arcRect,
|
Size size,
|
||||||
Offset center,
|
double centerX,
|
||||||
double radius,
|
double horizonWidth,
|
||||||
|
double horizonY,
|
||||||
double arcAngle,
|
double arcAngle,
|
||||||
DateTime now,
|
DateTime now,
|
||||||
DateTime sunrise,
|
DateTime sunrise,
|
||||||
DateTime sunset,
|
DateTime sunset,
|
||||||
) {
|
) {
|
||||||
// Night arc: sweeps below the horizon (or shown inverted above)
|
// Clamp arc angle between 30° and 180° for visual sanity
|
||||||
// For visual clarity, we show it as an arc above horizon but with night colors
|
final clampedAngle = arcAngle.clamp(math.pi / 6, math.pi);
|
||||||
final startAngle = math.pi;
|
|
||||||
final sweepAngle = arcAngle.clamp(0.0, math.pi); // Cap at semicircle
|
// Calculate radius so arc endpoints touch horizon
|
||||||
|
final radius = horizonWidth / (2 * math.sin(clampedAngle / 2));
|
||||||
|
|
||||||
|
// Arc center is below the horizon for an upward-bulging arc
|
||||||
|
final horizonYPos = size.height - horizonY;
|
||||||
|
final centerY = horizonYPos + radius * math.cos(clampedAngle / 2);
|
||||||
|
final center = Offset(centerX, centerY);
|
||||||
|
|
||||||
|
// The arc starts at the LEFT horizon point
|
||||||
|
// In canvas coords (Y down), angle to left point = 3π/2 - θ/2
|
||||||
|
final startAngle = (3 * math.pi / 2) - (clampedAngle / 2);
|
||||||
|
|
||||||
|
final arcRect = Rect.fromCenter(
|
||||||
|
center: center,
|
||||||
|
width: radius * 2,
|
||||||
|
height: radius * 2,
|
||||||
|
);
|
||||||
|
|
||||||
// Draw arc background with night gradient
|
// Draw arc background with night gradient
|
||||||
final arcPaint = Paint()
|
final arcPaint = Paint()
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = 8
|
..strokeWidth = 6
|
||||||
..strokeCap = StrokeCap.round
|
..strokeCap = StrokeCap.round
|
||||||
..shader = SweepGradient(
|
..shader = SweepGradient(
|
||||||
center: Alignment.center,
|
center: Alignment.center,
|
||||||
@@ -468,10 +526,11 @@ class _SunArcPainter extends CustomPainter {
|
|||||||
_dawnOrange.withValues(alpha: 0.4),
|
_dawnOrange.withValues(alpha: 0.4),
|
||||||
],
|
],
|
||||||
stops: const [0.0, 0.15, 0.4, 0.6, 0.85, 1.0],
|
stops: const [0.0, 0.15, 0.4, 0.6, 0.85, 1.0],
|
||||||
transform: const GradientRotation(math.pi),
|
transform: GradientRotation(startAngle),
|
||||||
).createShader(arcRect);
|
).createShader(arcRect);
|
||||||
|
|
||||||
canvas.drawArc(arcRect, startAngle, sweepAngle, false, arcPaint);
|
// Draw the arc (positive sweep = clockwise in canvas coords)
|
||||||
|
canvas.drawArc(arcRect, startAngle, clampedAngle, false, arcPaint);
|
||||||
|
|
||||||
// Calculate moon position
|
// Calculate moon position
|
||||||
// Night spans from sunset to next sunrise
|
// Night spans from sunset to next sunrise
|
||||||
@@ -490,8 +549,8 @@ class _SunArcPainter extends CustomPainter {
|
|||||||
progress = (minutesSincePrevSunset / nightDuration).clamp(0.0, 1.0);
|
progress = (minutesSincePrevSunset / nightDuration).clamp(0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map progress to angle along the arc
|
// Map progress to angle along the arc (0 = sunset/left, 1 = sunrise/right)
|
||||||
final moonAngle = startAngle + (progress * sweepAngle);
|
final moonAngle = startAngle + (progress * clampedAngle);
|
||||||
final moonX = center.dx + radius * math.cos(moonAngle);
|
final moonX = center.dx + radius * math.cos(moonAngle);
|
||||||
final moonY = center.dy + radius * math.sin(moonAngle);
|
final moonY = center.dy + radius * math.sin(moonAngle);
|
||||||
|
|
||||||
@@ -502,56 +561,20 @@ class _SunArcPainter extends CustomPainter {
|
|||||||
_moonSilver.withValues(alpha: 0.3),
|
_moonSilver.withValues(alpha: 0.3),
|
||||||
_moonSilver.withValues(alpha: 0.0),
|
_moonSilver.withValues(alpha: 0.0),
|
||||||
],
|
],
|
||||||
).createShader(Rect.fromCircle(center: Offset(moonX, moonY), radius: 20));
|
).createShader(Rect.fromCircle(center: Offset(moonX, moonY), radius: 16));
|
||||||
canvas.drawCircle(Offset(moonX, moonY), 20, glowPaint);
|
canvas.drawCircle(Offset(moonX, moonY), 16, glowPaint);
|
||||||
|
|
||||||
// Draw moon
|
// Draw moon
|
||||||
final moonPaint = Paint()
|
final moonPaint = Paint()
|
||||||
..style = PaintingStyle.fill
|
..style = PaintingStyle.fill
|
||||||
..color = _moonSilver;
|
..color = _moonSilver;
|
||||||
canvas.drawCircle(Offset(moonX, moonY), 10, moonPaint);
|
canvas.drawCircle(Offset(moonX, moonY), 8, moonPaint);
|
||||||
|
|
||||||
// Draw crescent shadow for moon effect
|
// Draw crescent shadow for moon effect
|
||||||
final shadowPaint = Paint()
|
final shadowPaint = Paint()
|
||||||
..style = PaintingStyle.fill
|
..style = PaintingStyle.fill
|
||||||
..color = _nightBlue.withValues(alpha: 0.7);
|
..color = _nightBlue.withValues(alpha: 0.7);
|
||||||
canvas.drawCircle(Offset(moonX + 4, moonY - 2), 8, shadowPaint);
|
canvas.drawCircle(Offset(moonX + 3, moonY - 1), 6, shadowPaint);
|
||||||
}
|
|
||||||
|
|
||||||
void _drawHorizonLabels(
|
|
||||||
Canvas canvas,
|
|
||||||
Offset center,
|
|
||||||
double radius,
|
|
||||||
DateTime sunrise,
|
|
||||||
DateTime sunset,
|
|
||||||
) {
|
|
||||||
final textPainter = TextPainter(
|
|
||||||
textDirection: TextDirection.ltr,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
);
|
|
||||||
|
|
||||||
final labelStyle = TextStyle(
|
|
||||||
fontSize: 10,
|
|
||||||
color: isDark ? Colors.white38 : Colors.black38,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Sunrise label (left horizon point)
|
|
||||||
final sunriseText = '${sunrise.hour.toString().padLeft(2, '0')}:${sunrise.minute.toString().padLeft(2, '0')}';
|
|
||||||
textPainter.text = TextSpan(text: sunriseText, style: labelStyle);
|
|
||||||
textPainter.layout();
|
|
||||||
textPainter.paint(
|
|
||||||
canvas,
|
|
||||||
Offset(center.dx - radius - textPainter.width / 2, center.dy + 5),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Sunset label (right horizon point)
|
|
||||||
final sunsetText = '${sunset.hour.toString().padLeft(2, '0')}:${sunset.minute.toString().padLeft(2, '0')}';
|
|
||||||
textPainter.text = TextSpan(text: sunsetText, style: labelStyle);
|
|
||||||
textPainter.layout();
|
|
||||||
textPainter.paint(
|
|
||||||
canvas,
|
|
||||||
Offset(center.dx + radius - textPainter.width / 2, center.dy + 5),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -212,28 +212,30 @@ class WeatherWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
// Match height of populated card content area
|
const SizedBox(height: 8),
|
||||||
const SizedBox(height: 120),
|
// Match sun position card height (170px content area)
|
||||||
Center(
|
SizedBox(
|
||||||
child: Column(
|
height: 170,
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Center(
|
||||||
children: [
|
child: Column(
|
||||||
Icon(
|
mainAxisSize: MainAxisSize.min,
|
||||||
Icons.cloud_off_outlined,
|
children: [
|
||||||
size: 32,
|
Icon(
|
||||||
color: colorScheme.outline,
|
Icons.cloud_off_outlined,
|
||||||
),
|
size: 32,
|
||||||
const SizedBox(height: 8),
|
color: colorScheme.outline,
|
||||||
Text(
|
),
|
||||||
'No data available',
|
const SizedBox(height: 8),
|
||||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
Text(
|
||||||
color: colorScheme.outline,
|
'No data available',
|
||||||
),
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
),
|
color: colorScheme.outline,
|
||||||
],
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 40),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
|||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.5.2+1
|
version: 1.5.4+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.10.4
|
sdk: ^3.10.4
|
||||||
|
|||||||
Reference in New Issue
Block a user