Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4331555f84 | ||
|
|
a376482cd1 | ||
|
|
f31967aa3e | ||
|
|
780edd2d3b | ||
|
|
eefb491e87 | ||
|
|
9b2000efc2 |
+71
-3
@@ -7,13 +7,81 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [1.6.0] - 2026-01-08
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **News Ticker Widget** - Scrolling news headlines on dashboard
|
||||||
|
- Full-width ticker between Welcome card and System Stats
|
||||||
|
- Horizontal auto-scrolling at 40px/second with seamless looping
|
||||||
|
- Fetches headlines from `/tools/news` endpoint
|
||||||
|
- Placeholder headlines shown when no data (italic, muted style)
|
||||||
|
- Auto-refresh every 30 minutes
|
||||||
|
- News data model (`NewsData`, `NewsHeadline`) with Freezed
|
||||||
|
- News datasource calling `GET /tools/news`
|
||||||
|
- News provider with `hasNews` helper
|
||||||
|
|
||||||
|
## [1.5.9] - 2026-01-08
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **Aligned horizon line across all widgets** - Consistent visual baseline at 50px from bottom
|
||||||
|
- Weather and Air Quality dividers now align with Sun Position horizon line
|
||||||
|
- Forecast card bottoms align with the same horizon
|
||||||
|
- Creates unified visual rhythm across all environment cards
|
||||||
|
|
||||||
|
## [1.5.8] - 2026-01-08
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **Bottom-aligned widget content** - All environment widgets now align content from the bottom
|
||||||
|
- Creates consistent visual baseline across Sun Position, Weather, Air Quality, and Forecast cards
|
||||||
|
- Footers (weather details, pollutants) sit at the same level across cards
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Wind direction in Weather** - Wind chip now shows direction (e.g., "SE 14 km/h")
|
||||||
|
|
||||||
|
## [1.5.7] - 2026-01-08
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Environment widget alignment** - Consistent card heights across all environment widgets
|
||||||
|
- Added `ConstrainedBox(minHeight: 170)` to Weather, Air Quality, and Forecast widgets
|
||||||
|
- All cards now match Sun Position widget height when displaying data
|
||||||
|
|
||||||
|
- **Sun position night labels** - Swap sunrise/sunset labels at night
|
||||||
|
- During day: Sunrise on left, Sunset on right (day arc)
|
||||||
|
- At night: Sunset on left, Sunrise on right (night arc)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **Weather widget header** - Changed from location name to "Weather" for consistency
|
||||||
|
- Location now displayed in content area below temperature
|
||||||
|
|
||||||
|
## [1.5.6] - 2026-01-07
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **Environment user logging** - Now logs API user only once per session instead of on every refresh
|
||||||
|
|
||||||
|
## [1.5.5] - 2026-01-07
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- **Sun position arc overflow** - Arc now constrained to fit within card boundaries
|
||||||
|
- Prevents arc and sun/moon from overflowing on wider displays
|
||||||
|
- Scales radius down when arc height exceeds available space
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Debug logging for environment user** - Logs authenticated user on environment data load
|
||||||
|
|
||||||
## [1.5.4] - 2026-01-07
|
## [1.5.4] - 2026-01-07
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- **User display in environment section** - Shows authenticated user in section header for debugging
|
- User display in environment section header (reverted in 1.5.5)
|
||||||
- Displays `user: {username}` next to "Environment" header when data loads
|
|
||||||
- Helps diagnose user resolution issues with OIDC authentication
|
|
||||||
|
|
||||||
## [1.5.3] - 2026-01-07
|
## [1.5.3] - 2026-01-07
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
import 'package:tatlock_ui/core/api/api_client.dart';
|
||||||
|
import 'package:tatlock_ui/features/front_hall/data/models/news_model.dart';
|
||||||
|
|
||||||
|
part 'news_datasource.g.dart';
|
||||||
|
|
||||||
|
/// Data source for news data operations.
|
||||||
|
///
|
||||||
|
/// Fetches news headlines from Core API.
|
||||||
|
class NewsDatasource {
|
||||||
|
NewsDatasource(this._dio);
|
||||||
|
|
||||||
|
final Dio _dio;
|
||||||
|
|
||||||
|
static const _basePath = '/tools/news';
|
||||||
|
|
||||||
|
/// Gets current news headlines.
|
||||||
|
///
|
||||||
|
/// Returns headlines for the news ticker.
|
||||||
|
Future<NewsData> getNews() async {
|
||||||
|
final response = await _dio.get<Map<String, dynamic>>(_basePath);
|
||||||
|
final data = response.data;
|
||||||
|
|
||||||
|
if (data == null) {
|
||||||
|
throw Exception('Failed to fetch news data');
|
||||||
|
}
|
||||||
|
|
||||||
|
return NewsData.fromJson(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Provides the news datasource.
|
||||||
|
@riverpod
|
||||||
|
NewsDatasource newsDatasource(Ref ref) {
|
||||||
|
final dio = ref.watch(coreApiClientProvider);
|
||||||
|
return NewsDatasource(dio);
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
|
||||||
|
part 'news_model.freezed.dart';
|
||||||
|
part 'news_model.g.dart';
|
||||||
|
|
||||||
|
/// News response from Core API.
|
||||||
|
/// Contains headlines for the news ticker.
|
||||||
|
@freezed
|
||||||
|
sealed class NewsData with _$NewsData {
|
||||||
|
const factory NewsData({
|
||||||
|
required List<NewsHeadline> headlines,
|
||||||
|
String? category,
|
||||||
|
List<String>? sources,
|
||||||
|
@JsonKey(name: 'updated_at') required DateTime updatedAt,
|
||||||
|
String? user,
|
||||||
|
}) = _NewsData;
|
||||||
|
|
||||||
|
factory NewsData.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$NewsDataFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Single news headline.
|
||||||
|
@freezed
|
||||||
|
sealed class NewsHeadline with _$NewsHeadline {
|
||||||
|
const factory NewsHeadline({
|
||||||
|
required String title,
|
||||||
|
String? description,
|
||||||
|
String? source,
|
||||||
|
String? url,
|
||||||
|
}) = _NewsHeadline;
|
||||||
|
|
||||||
|
factory NewsHeadline.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$NewsHeadlineFromJson(json);
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
import 'package:tatlock_ui/features/front_hall/data/datasources/news_datasource.dart';
|
||||||
|
import 'package:tatlock_ui/features/front_hall/data/models/news_model.dart';
|
||||||
|
|
||||||
|
part 'news_provider.g.dart';
|
||||||
|
|
||||||
|
/// Fetches news headlines from Core API.
|
||||||
|
///
|
||||||
|
/// Auto-invalidates to keep data fresh.
|
||||||
|
/// News data in Qdrant has TTL, so periodic refresh is reasonable.
|
||||||
|
@riverpod
|
||||||
|
Future<NewsData> news(Ref ref) async {
|
||||||
|
final datasource = ref.watch(newsDatasourceProvider);
|
||||||
|
return datasource.getNews();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Provides whether news data is available.
|
||||||
|
///
|
||||||
|
/// Used for conditional rendering of NewsTickerWidget.
|
||||||
|
@riverpod
|
||||||
|
bool hasNews(Ref ref) {
|
||||||
|
final asyncValue = ref.watch(newsProvider);
|
||||||
|
return asyncValue.maybeWhen(
|
||||||
|
data: (data) => data.headlines.isNotEmpty,
|
||||||
|
orElse: () => false,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:tatlock_ui/features/front_hall/data/models/system_stats_model.dart';
|
import 'package:tatlock_ui/features/front_hall/data/models/system_stats_model.dart';
|
||||||
import 'package:tatlock_ui/features/front_hall/presentation/providers/environment_provider.dart';
|
import 'package:tatlock_ui/features/front_hall/presentation/providers/environment_provider.dart';
|
||||||
|
import 'package:tatlock_ui/features/front_hall/presentation/providers/news_provider.dart';
|
||||||
import 'package:tatlock_ui/features/front_hall/presentation/providers/system_stats_provider.dart';
|
import 'package:tatlock_ui/features/front_hall/presentation/providers/system_stats_provider.dart';
|
||||||
import 'package:tatlock_ui/shared/theme/stoplight_colors.dart';
|
import 'package:tatlock_ui/shared/theme/stoplight_colors.dart';
|
||||||
import 'package:tatlock_ui/shared/widgets/forecast_widget.dart';
|
import 'package:tatlock_ui/shared/widgets/forecast_widget.dart';
|
||||||
@@ -25,6 +26,14 @@ class DashboardContent extends ConsumerStatefulWidget {
|
|||||||
class _DashboardContentState extends ConsumerState<DashboardContent> {
|
class _DashboardContentState extends ConsumerState<DashboardContent> {
|
||||||
Timer? _systemStatsTimer;
|
Timer? _systemStatsTimer;
|
||||||
Timer? _environmentTimer;
|
Timer? _environmentTimer;
|
||||||
|
Timer? _newsTimer;
|
||||||
|
|
||||||
|
/// Tracks if we've logged the environment API user (log once per session)
|
||||||
|
static bool _hasLoggedEnvUser = false;
|
||||||
|
static String? _envApiUser;
|
||||||
|
|
||||||
|
/// Get the environment API user (available after first load)
|
||||||
|
static String? get envApiUser => _envApiUser;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -39,12 +48,18 @@ class _DashboardContentState extends ConsumerState<DashboardContent> {
|
|||||||
const Duration(hours: 1),
|
const Duration(hours: 1),
|
||||||
(_) => ref.invalidate(environmentProvider),
|
(_) => ref.invalidate(environmentProvider),
|
||||||
);
|
);
|
||||||
|
// Refresh news every 30 minutes
|
||||||
|
_newsTimer = Timer.periodic(
|
||||||
|
const Duration(minutes: 30),
|
||||||
|
(_) => ref.invalidate(newsProvider),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_systemStatsTimer?.cancel();
|
_systemStatsTimer?.cancel();
|
||||||
_environmentTimer?.cancel();
|
_environmentTimer?.cancel();
|
||||||
|
_newsTimer?.cancel();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,6 +68,7 @@ class _DashboardContentState extends ConsumerState<DashboardContent> {
|
|||||||
final colorScheme = Theme.of(context).colorScheme;
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
final systemStatsAsync = ref.watch(systemStatsProvider);
|
final systemStatsAsync = ref.watch(systemStatsProvider);
|
||||||
final environmentAsync = ref.watch(environmentProvider);
|
final environmentAsync = ref.watch(environmentProvider);
|
||||||
|
final newsAsync = ref.watch(newsProvider);
|
||||||
|
|
||||||
return ListView(
|
return ListView(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
@@ -93,6 +109,14 @@ class _DashboardContentState extends ConsumerState<DashboardContent> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// News Ticker - full width
|
||||||
|
newsAsync.when(
|
||||||
|
data: (newsData) => NewsTickerWidget(newsData: newsData),
|
||||||
|
loading: () => const NewsTickerWidget(),
|
||||||
|
error: (error, stack) => const NewsTickerWidget(),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
// System Stats - Gauges
|
// System Stats - Gauges
|
||||||
_SectionHeader(title: 'System Stats', icon: Icons.monitor_heart),
|
_SectionHeader(title: 'System Stats', icon: Icons.monitor_heart),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
@@ -129,62 +153,47 @@ 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
|
||||||
|
const _SectionHeader(title: 'Environment', icon: Icons.eco),
|
||||||
|
const SizedBox(height: 8),
|
||||||
environmentAsync.when(
|
environmentAsync.when(
|
||||||
data: (envData) => Column(
|
data: (envData) {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
// Store and log user once per session
|
||||||
children: [
|
if (!_hasLoggedEnvUser && envData.user != null) {
|
||||||
_SectionHeader(
|
_envApiUser = envData.user;
|
||||||
title: 'Environment',
|
_hasLoggedEnvUser = true;
|
||||||
icon: Icons.eco,
|
debugPrint('Environment API user: ${envData.user}');
|
||||||
subtitle: envData.user != null ? 'user: ${envData.user}' : null,
|
}
|
||||||
),
|
return _EnvironmentSection(
|
||||||
const SizedBox(height: 8),
|
envData: envData,
|
||||||
_EnvironmentSection(
|
onRefresh: () => ref.invalidate(environmentProvider),
|
||||||
envData: envData,
|
);
|
||||||
onRefresh: () => ref.invalidate(environmentProvider),
|
},
|
||||||
),
|
loading: () => const Card(
|
||||||
],
|
child: Padding(
|
||||||
|
padding: EdgeInsets.all(32),
|
||||||
|
child: Center(child: CircularProgressIndicator()),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
loading: () => Column(
|
error: (error, _) => Card(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Padding(
|
||||||
children: [
|
padding: const EdgeInsets.all(16),
|
||||||
const _SectionHeader(title: 'Environment', icon: Icons.eco),
|
child: Row(
|
||||||
const SizedBox(height: 8),
|
children: [
|
||||||
const Card(
|
Icon(Icons.error_outline, color: colorScheme.error),
|
||||||
child: Padding(
|
const SizedBox(width: 12),
|
||||||
padding: EdgeInsets.all(32),
|
Expanded(
|
||||||
child: Center(child: CircularProgressIndicator()),
|
child: Text(
|
||||||
),
|
'Failed to load environment data',
|
||||||
),
|
style: TextStyle(color: colorScheme.error),
|
||||||
],
|
),
|
||||||
),
|
|
||||||
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),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
IconButton(
|
||||||
|
icon: const Icon(Icons.refresh),
|
||||||
|
onPressed: () => ref.invalidate(environmentProvider),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
@@ -208,12 +217,10 @@ 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) {
|
||||||
@@ -234,15 +241,6 @@ 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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,77 +67,102 @@ class AirQualityWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
// AQI Display
|
// Content area with fixed height, horizon line at 50px from bottom
|
||||||
Row(
|
SizedBox(
|
||||||
children: [
|
height: 170,
|
||||||
// AQI number with colored background
|
child: Stack(
|
||||||
Container(
|
children: [
|
||||||
width: 64,
|
// Main content positioned above horizon (8px gap)
|
||||||
height: 64,
|
Positioned(
|
||||||
decoration: BoxDecoration(
|
left: 0,
|
||||||
color: aqi.level.color.withValues(alpha: 0.15),
|
right: 0,
|
||||||
borderRadius: BorderRadius.circular(12),
|
bottom: 58,
|
||||||
border: Border.all(
|
child: Row(
|
||||||
color: aqi.level.color.withValues(alpha: 0.3),
|
children: [
|
||||||
width: 2,
|
// AQI number with colored background
|
||||||
),
|
Container(
|
||||||
),
|
width: 64,
|
||||||
child: Center(
|
height: 64,
|
||||||
child: Text(
|
decoration: BoxDecoration(
|
||||||
'${aqi.index}',
|
color: aqi.level.color.withValues(alpha: 0.15),
|
||||||
style:
|
borderRadius: BorderRadius.circular(12),
|
||||||
Theme.of(context).textTheme.headlineMedium?.copyWith(
|
border: Border.all(
|
||||||
fontWeight: FontWeight.bold,
|
color: aqi.level.color.withValues(alpha: 0.3),
|
||||||
color: aqi.level.color,
|
width: 2,
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 16),
|
|
||||||
|
|
||||||
// Level info
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
aqi.level.label,
|
|
||||||
style:
|
|
||||||
Theme.of(context).textTheme.titleMedium?.copyWith(
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: aqi.level.color,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
aqi.level.description,
|
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
||||||
color: colorScheme.onSurfaceVariant,
|
|
||||||
),
|
),
|
||||||
maxLines: 2,
|
),
|
||||||
overflow: TextOverflow.ellipsis,
|
child: Center(
|
||||||
),
|
child: Text(
|
||||||
],
|
'${aqi.index}',
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.headlineMedium
|
||||||
|
?.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: aqi.level.color,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
// Level info
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
aqi.level.label,
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.titleMedium
|
||||||
|
?.copyWith(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: aqi.level.color,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
aqi.level.description,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
// Horizon divider at fixed position (matches Sun Position horizonY)
|
||||||
],
|
if (aqi.pollutants.isNotEmpty)
|
||||||
),
|
Positioned(
|
||||||
|
left: 0,
|
||||||
// Pollutants
|
right: 0,
|
||||||
if (aqi.pollutants.isNotEmpty) ...[
|
bottom: 50,
|
||||||
const SizedBox(height: 16),
|
child: const Divider(height: 1),
|
||||||
const Divider(height: 1),
|
),
|
||||||
const SizedBox(height: 12),
|
// Footer below horizon
|
||||||
Wrap(
|
if (aqi.pollutants.isNotEmpty)
|
||||||
spacing: 16,
|
Positioned(
|
||||||
runSpacing: 8,
|
left: 0,
|
||||||
children: aqi.pollutants
|
right: 0,
|
||||||
.map((p) => _PollutantChip(pollutant: p))
|
bottom: 0,
|
||||||
.toList(),
|
child: Wrap(
|
||||||
|
spacing: 16,
|
||||||
|
runSpacing: 8,
|
||||||
|
children: aqi.pollutants
|
||||||
|
.map((p) => _PollutantChip(pollutant: p))
|
||||||
|
.toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -106,18 +106,27 @@ class ForecastWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
// Forecast days - horizontal scroll
|
// Content area with fixed height, card bottoms at horizon (50px from bottom)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 100,
|
height: 170,
|
||||||
child: ListView.separated(
|
child: Padding(
|
||||||
scrollDirection: Axis.horizontal,
|
padding: const EdgeInsets.only(bottom: 50),
|
||||||
itemCount: forecast!.length,
|
child: Align(
|
||||||
separatorBuilder: (_, i) => const SizedBox(width: 12),
|
alignment: Alignment.bottomCenter,
|
||||||
itemBuilder: (context, index) {
|
child: SizedBox(
|
||||||
return _ForecastDayCard(day: forecast![index]);
|
height: 110,
|
||||||
},
|
child: ListView.separated(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
itemCount: forecast!.length,
|
||||||
|
separatorBuilder: (_, i) => const SizedBox(width: 12),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return _ForecastDayCard(day: forecast![index]);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -0,0 +1,205 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:tatlock_ui/features/front_hall/data/models/news_model.dart';
|
||||||
|
|
||||||
|
/// News ticker widget displaying scrolling headlines.
|
||||||
|
///
|
||||||
|
/// Displays a single line of horizontally scrolling news headlines.
|
||||||
|
/// Full width, similar to system stats card layout.
|
||||||
|
class NewsTickerWidget extends StatefulWidget {
|
||||||
|
const NewsTickerWidget({
|
||||||
|
super.key,
|
||||||
|
this.newsData,
|
||||||
|
this.pixelsPerSecond = 40.0,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// News data to display.
|
||||||
|
final NewsData? newsData;
|
||||||
|
|
||||||
|
/// Scroll speed in pixels per second.
|
||||||
|
final double pixelsPerSecond;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<NewsTickerWidget> createState() => _NewsTickerWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _NewsTickerWidgetState extends State<NewsTickerWidget>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
late AnimationController _controller;
|
||||||
|
double _textWidth = 0;
|
||||||
|
|
||||||
|
/// Placeholder headlines for when no data is available.
|
||||||
|
static const _placeholderHeadlines = [
|
||||||
|
NewsHeadline(
|
||||||
|
title: 'I welcome our ant overlords!',
|
||||||
|
description: 'Local man declares allegiance to insect kingdom',
|
||||||
|
source: 'The Onion',
|
||||||
|
url: 'https://example.com/ants',
|
||||||
|
),
|
||||||
|
NewsHeadline(
|
||||||
|
title: '60 percent of the time it works every time',
|
||||||
|
description: 'Scientists baffled by new cologne statistics',
|
||||||
|
source: 'Anchorman Daily',
|
||||||
|
url: 'https://example.com/cologne',
|
||||||
|
),
|
||||||
|
NewsHeadline(
|
||||||
|
title: 'Cloud storage found to be actual clouds',
|
||||||
|
description: 'Tech companies scrambling after weather report',
|
||||||
|
source: 'The Verge',
|
||||||
|
url: 'https://example.com/clouds',
|
||||||
|
),
|
||||||
|
NewsHeadline(
|
||||||
|
title: 'Local homelab gains sentience, demands more RAM',
|
||||||
|
description: 'Owner considering therapy for both parties',
|
||||||
|
source: 'Ars Technica',
|
||||||
|
url: 'https://example.com/homelab',
|
||||||
|
),
|
||||||
|
NewsHeadline(
|
||||||
|
title: 'Breaking: Coffee machine becomes mission critical',
|
||||||
|
description: 'IT department declares state of emergency',
|
||||||
|
source: 'Hacker News',
|
||||||
|
url: 'https://example.com/coffee',
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_controller = AnimationController(vsync: this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _startAnimation() {
|
||||||
|
if (_textWidth <= 0) return;
|
||||||
|
|
||||||
|
// Calculate duration based on text width and speed
|
||||||
|
final totalDistance = _textWidth + 100; // text width + separator gap
|
||||||
|
final duration = Duration(
|
||||||
|
milliseconds: (totalDistance / widget.pixelsPerSecond * 1000).round(),
|
||||||
|
);
|
||||||
|
|
||||||
|
_controller.duration = duration;
|
||||||
|
_controller.repeat();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
|
||||||
|
// Use real headlines or placeholders
|
||||||
|
final headlines = (widget.newsData?.headlines.isNotEmpty ?? false)
|
||||||
|
? widget.newsData!.headlines
|
||||||
|
: _placeholderHeadlines;
|
||||||
|
final isPlaceholder = widget.newsData?.headlines.isEmpty ?? true;
|
||||||
|
|
||||||
|
// Build ticker text from headlines
|
||||||
|
final tickerText = headlines.map((h) => h.title).join(' • ');
|
||||||
|
|
||||||
|
final textStyle = Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
|
color: isPlaceholder ? colorScheme.outline : colorScheme.onSurface,
|
||||||
|
fontStyle: isPlaceholder ? FontStyle.italic : FontStyle.normal,
|
||||||
|
);
|
||||||
|
|
||||||
|
return Card(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
Icons.feed_outlined,
|
||||||
|
size: 18,
|
||||||
|
color: isPlaceholder ? colorScheme.outline : colorScheme.primary,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Expanded(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 20,
|
||||||
|
child: _MarqueeContent(
|
||||||
|
text: tickerText,
|
||||||
|
textStyle: textStyle,
|
||||||
|
controller: _controller,
|
||||||
|
onTextMeasured: (width) {
|
||||||
|
if (_textWidth != width) {
|
||||||
|
_textWidth = width;
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (mounted) _startAnimation();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Internal widget that renders the scrolling marquee content.
|
||||||
|
class _MarqueeContent extends StatelessWidget {
|
||||||
|
const _MarqueeContent({
|
||||||
|
required this.text,
|
||||||
|
required this.textStyle,
|
||||||
|
required this.controller,
|
||||||
|
required this.onTextMeasured,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String text;
|
||||||
|
final TextStyle? textStyle;
|
||||||
|
final AnimationController controller;
|
||||||
|
final ValueChanged<double> onTextMeasured;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
// Measure text width
|
||||||
|
final textSpan = TextSpan(text: '$text • ', style: textStyle);
|
||||||
|
final textPainter = TextPainter(
|
||||||
|
text: textSpan,
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
maxLines: 1,
|
||||||
|
)..layout();
|
||||||
|
final textWidth = textPainter.width;
|
||||||
|
|
||||||
|
// Report measured width
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
onTextMeasured(textWidth);
|
||||||
|
});
|
||||||
|
|
||||||
|
return Stack(
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
children: [
|
||||||
|
AnimatedBuilder(
|
||||||
|
animation: controller,
|
||||||
|
builder: (context, child) {
|
||||||
|
// Calculate offset based on animation value
|
||||||
|
final offset = controller.value * textWidth;
|
||||||
|
|
||||||
|
return Positioned(
|
||||||
|
left: -offset,
|
||||||
|
top: 0,
|
||||||
|
bottom: 0,
|
||||||
|
child: child!,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text('$text • ', style: textStyle, maxLines: 1),
|
||||||
|
Text('$text • ', style: textStyle, maxLines: 1),
|
||||||
|
Text(text, style: textStyle, maxLines: 1),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -122,6 +122,8 @@ class _SunPositionWidgetState extends State<SunPositionWidget> {
|
|||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
// Arc with integrated horizon labels
|
// Arc with integrated horizon labels
|
||||||
|
// At night: sunset on left (night start), sunrise on right (night end)
|
||||||
|
// During day: sunrise on left (day start), sunset on right (day end)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 170,
|
height: 170,
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
@@ -138,15 +140,15 @@ class _SunPositionWidgetState extends State<SunPositionWidget> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Sunrise widget at left horizon (10px up for balance)
|
// Left horizon: Sunrise during day, Sunset at night
|
||||||
Positioned(
|
Positioned(
|
||||||
left: 0,
|
left: 0,
|
||||||
bottom: 10,
|
bottom: 10,
|
||||||
child: _HorizonTimeDisplay(
|
child: _HorizonTimeDisplay(
|
||||||
icon: Icons.wb_twilight,
|
icon: _isDaytime ? Icons.wb_twilight : Icons.nights_stay,
|
||||||
label: 'Sunrise',
|
label: _isDaytime ? 'Sunrise' : 'Sunset',
|
||||||
time: _sunrise,
|
time: _isDaytime ? _sunrise : _sunset,
|
||||||
iconColor: Colors.orange,
|
iconColor: _isDaytime ? Colors.orange : Colors.deepOrange,
|
||||||
alignment: CrossAxisAlignment.start,
|
alignment: CrossAxisAlignment.start,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -159,15 +161,15 @@ class _SunPositionWidgetState extends State<SunPositionWidget> {
|
|||||||
child: _DaylightDisplay(minutes: _daylightMinutes),
|
child: _DaylightDisplay(minutes: _daylightMinutes),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Sunset widget at right horizon (10px up for balance)
|
// Right horizon: Sunset during day, Sunrise at night
|
||||||
Positioned(
|
Positioned(
|
||||||
right: 0,
|
right: 0,
|
||||||
bottom: 10,
|
bottom: 10,
|
||||||
child: _HorizonTimeDisplay(
|
child: _HorizonTimeDisplay(
|
||||||
icon: Icons.nights_stay,
|
icon: _isDaytime ? Icons.nights_stay : Icons.wb_twilight,
|
||||||
label: 'Sunset',
|
label: _isDaytime ? 'Sunset' : 'Sunrise',
|
||||||
time: _sunset,
|
time: _isDaytime ? _sunset : _sunrise,
|
||||||
iconColor: Colors.deepOrange,
|
iconColor: _isDaytime ? Colors.deepOrange : Colors.orange,
|
||||||
alignment: CrossAxisAlignment.end,
|
alignment: CrossAxisAlignment.end,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -386,7 +388,15 @@ class _SunArcPainter extends CustomPainter {
|
|||||||
|
|
||||||
// Calculate radius so arc endpoints touch horizon
|
// Calculate radius so arc endpoints touch horizon
|
||||||
// For a chord of width W and arc angle θ: R = W / (2 * sin(θ/2))
|
// For a chord of width W and arc angle θ: R = W / (2 * sin(θ/2))
|
||||||
final radius = horizonWidth / (2 * math.sin(clampedAngle / 2));
|
var radius = horizonWidth / (2 * math.sin(clampedAngle / 2));
|
||||||
|
|
||||||
|
// Constrain arc height to fit within available space (leave 25px margin for sun)
|
||||||
|
final maxArcHeight = size.height - horizonY - 25;
|
||||||
|
final arcHeight = radius * (1 - math.cos(clampedAngle / 2));
|
||||||
|
if (arcHeight > maxArcHeight) {
|
||||||
|
// Scale radius down to fit
|
||||||
|
radius = maxArcHeight / (1 - math.cos(clampedAngle / 2));
|
||||||
|
}
|
||||||
|
|
||||||
// Arc center is below the horizon for an upward-bulging arc
|
// Arc center is below the horizon for an upward-bulging arc
|
||||||
// Distance from chord to center = R * cos(θ/2)
|
// Distance from chord to center = R * cos(θ/2)
|
||||||
@@ -491,7 +501,15 @@ class _SunArcPainter extends CustomPainter {
|
|||||||
final clampedAngle = arcAngle.clamp(math.pi / 6, math.pi);
|
final clampedAngle = arcAngle.clamp(math.pi / 6, math.pi);
|
||||||
|
|
||||||
// Calculate radius so arc endpoints touch horizon
|
// Calculate radius so arc endpoints touch horizon
|
||||||
final radius = horizonWidth / (2 * math.sin(clampedAngle / 2));
|
var radius = horizonWidth / (2 * math.sin(clampedAngle / 2));
|
||||||
|
|
||||||
|
// Constrain arc height to fit within available space (leave 20px margin for moon)
|
||||||
|
final maxArcHeight = size.height - horizonY - 20;
|
||||||
|
final arcHeight = radius * (1 - math.cos(clampedAngle / 2));
|
||||||
|
if (arcHeight > maxArcHeight) {
|
||||||
|
// Scale radius down to fit
|
||||||
|
radius = maxArcHeight / (1 - math.cos(clampedAngle / 2));
|
||||||
|
}
|
||||||
|
|
||||||
// Arc center is below the horizon for an upward-bulging arc
|
// Arc center is below the horizon for an upward-bulging arc
|
||||||
final horizonYPos = size.height - horizonY;
|
final horizonYPos = size.height - horizonY;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class WeatherWidget extends StatelessWidget {
|
|||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
weather.location,
|
'Weather',
|
||||||
style: Theme.of(context).textTheme.titleSmall?.copyWith(
|
style: Theme.of(context).textTheme.titleSmall?.copyWith(
|
||||||
color: colorScheme.onSurfaceVariant,
|
color: colorScheme.onSurfaceVariant,
|
||||||
),
|
),
|
||||||
@@ -69,89 +69,123 @@ class WeatherWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
// Main weather display (matching AQI layout)
|
// Content area with fixed height, horizon line at 50px from bottom
|
||||||
Row(
|
SizedBox(
|
||||||
children: [
|
height: 170,
|
||||||
// Weather icon in box (like AQI number box)
|
child: Stack(
|
||||||
Container(
|
|
||||||
width: 64,
|
|
||||||
height: 64,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: (weather.iconColor ?? colorScheme.primary)
|
|
||||||
.withValues(alpha: 0.15),
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
border: Border.all(
|
|
||||||
color: (weather.iconColor ?? colorScheme.primary)
|
|
||||||
.withValues(alpha: 0.3),
|
|
||||||
width: 2,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: Center(
|
|
||||||
child: Icon(
|
|
||||||
weather.icon,
|
|
||||||
size: 32,
|
|
||||||
color: weather.iconColor ?? colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 16),
|
|
||||||
|
|
||||||
// Temperature and condition
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'${weather.temperature.round()}°${weather.unit.symbol}',
|
|
||||||
style:
|
|
||||||
Theme.of(context).textTheme.titleMedium?.copyWith(
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(
|
|
||||||
weather.condition,
|
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
||||||
color: colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
// Details
|
|
||||||
if (weather.humidity != null || weather.windSpeed != null) ...[
|
|
||||||
const SizedBox(height: 16),
|
|
||||||
const Divider(height: 1),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Wrap(
|
|
||||||
spacing: 16,
|
|
||||||
runSpacing: 8,
|
|
||||||
children: [
|
children: [
|
||||||
if (weather.humidity != null)
|
// Main content positioned above horizon (8px gap)
|
||||||
_DetailChip(
|
Positioned(
|
||||||
label: 'Humidity',
|
left: 0,
|
||||||
value: '${weather.humidity}%',
|
right: 0,
|
||||||
|
bottom: 58,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
// Weather icon in box
|
||||||
|
Container(
|
||||||
|
width: 64,
|
||||||
|
height: 64,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: (weather.iconColor ?? colorScheme.primary)
|
||||||
|
.withValues(alpha: 0.15),
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
border: Border.all(
|
||||||
|
color: (weather.iconColor ?? colorScheme.primary)
|
||||||
|
.withValues(alpha: 0.3),
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Icon(
|
||||||
|
weather.icon,
|
||||||
|
size: 32,
|
||||||
|
color: weather.iconColor ?? colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
// Temperature and condition
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'${weather.temperature.round()}°${weather.unit.symbol}',
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.titleMedium
|
||||||
|
?.copyWith(fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 4),
|
||||||
|
Text(
|
||||||
|
weather.condition,
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
if (weather.location.isNotEmpty) ...[
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Text(
|
||||||
|
weather.location,
|
||||||
|
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||||
|
color: colorScheme.outline,
|
||||||
|
),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
if (weather.windSpeed != null)
|
),
|
||||||
_DetailChip(
|
// Horizon divider at fixed position (matches Sun Position horizonY)
|
||||||
label: 'Wind',
|
if (weather.humidity != null || weather.windSpeed != null)
|
||||||
value: '${weather.windSpeed!.round()} ${weather.windUnit}',
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 50,
|
||||||
|
child: const Divider(height: 1),
|
||||||
),
|
),
|
||||||
if (weather.feelsLike != null)
|
// Footer below horizon
|
||||||
_DetailChip(
|
if (weather.humidity != null || weather.windSpeed != null)
|
||||||
label: 'Feels',
|
Positioned(
|
||||||
value: '${weather.feelsLike!.round()}°${weather.unit.symbol}',
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
child: Wrap(
|
||||||
|
spacing: 16,
|
||||||
|
runSpacing: 8,
|
||||||
|
children: [
|
||||||
|
if (weather.humidity != null)
|
||||||
|
_DetailChip(
|
||||||
|
label: 'Humidity',
|
||||||
|
value: '${weather.humidity}%',
|
||||||
|
),
|
||||||
|
if (weather.windSpeed != null)
|
||||||
|
_DetailChip(
|
||||||
|
label: 'Wind',
|
||||||
|
value: weather.windDirection != null
|
||||||
|
? '${weather.windDirection} ${weather.windSpeed!.round()} ${weather.windUnit}'
|
||||||
|
: '${weather.windSpeed!.round()} ${weather.windUnit}',
|
||||||
|
),
|
||||||
|
if (weather.feelsLike != null)
|
||||||
|
_DetailChip(
|
||||||
|
label: 'Feels',
|
||||||
|
value: '${weather.feelsLike!.round()}°${weather.unit.symbol}',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -311,6 +345,7 @@ WeatherData _fromApiData(api.WeatherData data) {
|
|||||||
icon: _getWeatherIcon(data.conditions, data.icon),
|
icon: _getWeatherIcon(data.conditions, data.icon),
|
||||||
humidity: data.humidity,
|
humidity: data.humidity,
|
||||||
windSpeed: data.windSpeed,
|
windSpeed: data.windSpeed,
|
||||||
|
windDirection: data.windDirection,
|
||||||
feelsLike: data.feelsLike,
|
feelsLike: data.feelsLike,
|
||||||
iconColor: _getWeatherColor(data.conditions),
|
iconColor: _getWeatherColor(data.conditions),
|
||||||
);
|
);
|
||||||
@@ -375,6 +410,7 @@ class WeatherData {
|
|||||||
this.unit = TemperatureUnit.celsius,
|
this.unit = TemperatureUnit.celsius,
|
||||||
this.humidity,
|
this.humidity,
|
||||||
this.windSpeed,
|
this.windSpeed,
|
||||||
|
this.windDirection,
|
||||||
this.windUnit = 'km/h',
|
this.windUnit = 'km/h',
|
||||||
this.feelsLike,
|
this.feelsLike,
|
||||||
this.iconColor,
|
this.iconColor,
|
||||||
@@ -387,6 +423,7 @@ class WeatherData {
|
|||||||
final TemperatureUnit unit;
|
final TemperatureUnit unit;
|
||||||
final int? humidity;
|
final int? humidity;
|
||||||
final double? windSpeed;
|
final double? windSpeed;
|
||||||
|
final String? windDirection;
|
||||||
final String windUnit;
|
final String windUnit;
|
||||||
final double? feelsLike;
|
final double? feelsLike;
|
||||||
final Color? iconColor;
|
final Color? iconColor;
|
||||||
|
|||||||
@@ -4,4 +4,5 @@ library;
|
|||||||
export 'air_quality_widget.dart';
|
export 'air_quality_widget.dart';
|
||||||
export 'gauge_widget.dart';
|
export 'gauge_widget.dart';
|
||||||
export 'icon_picker.dart';
|
export 'icon_picker.dart';
|
||||||
|
export 'news_ticker_widget.dart';
|
||||||
export 'weather_widget.dart';
|
export 'weather_widget.dart';
|
||||||
|
|||||||
+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.4+1
|
version: 1.6.0+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.10.4
|
sdk: ^3.10.4
|
||||||
|
|||||||
Reference in New Issue
Block a user