Files
tatlock-ui/lib/features/front_hall/data/datasources/environment_datasource.dart
T
Jeroen SchweitzerandClaude Opus 4.5 fffc3d5baf
Build and Push / release (push) Successful in 3s
Build and Push / build (push) Successful in 3m12s
chore: release v1.5.0
feat: add dynamic environment widgets

Add live weather, sun position, and forecast widgets to Front Hall dashboard,
powered by data from the Qdrant volatile collection via core-api.

New widgets:
- SunPositionWidget: Animated arc showing sun/moon position with gradient colors
- ForecastWidget: Multi-day weather outlook
- Updated WeatherWidget and AirQualityWidget to accept API data

Infrastructure:
- Environment datasource calling GET /tools/environment
- Environment provider with 5-minute auto-refresh
- Freezed models for environment data

Tests:
- 12 widget tests for environment section
- Updated existing tests with givenEnvironment() harness method

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-06 23:05:24 +01:00

39 lines
1.1 KiB
Dart

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/environment_model.dart';
part 'environment_datasource.g.dart';
/// Data source for environment data operations.
///
/// Fetches weather, forecast, sun times, and air quality from Core API.
class EnvironmentDatasource {
EnvironmentDatasource(this._dio);
final Dio _dio;
static const _basePath = '/tools/environment';
/// Gets current environment data.
///
/// Returns weather, forecast, sun times, and optionally air quality.
Future<EnvironmentData> getEnvironment() async {
final response = await _dio.get<Map<String, dynamic>>(_basePath);
final data = response.data;
if (data == null) {
throw Exception('Failed to fetch environment data');
}
return EnvironmentData.fromJson(data);
}
}
/// Provides the environment datasource.
@riverpod
EnvironmentDatasource environmentDatasource(Ref ref) {
final dio = ref.watch(coreApiClientProvider);
return EnvironmentDatasource(dio);
}