buildPastWeatherView function

Widget buildPastWeatherView({
  1. required BuildContext context,
  2. required bool isLoading,
  3. required HourlyWeatherData? pastWeatherData,
  4. required double latitude,
  5. required double longitude,
  6. String? address,
  7. required String selectedDataType,
  8. required void onDataTypeChanged(
    1. String
    ),
})

Build past weather view.

Implementation

Widget buildPastWeatherView({
  required BuildContext context,
  required bool isLoading,
  required HourlyWeatherData? pastWeatherData,
  required double latitude,
  required double longitude,
  String? address,
  required String selectedDataType,
  required void Function(String) onDataTypeChanged,
}) {
  if (isLoading) {
    return const Center(child: CircularProgressIndicator());
  }

  if (pastWeatherData == null) {
    return const Center(child: Text('Tap to load past 10 days weather data'));
  }

  return SingleChildScrollView(
    padding: const EdgeInsets.all(16),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text(
          'Past 10 Days Weather',
          style: Theme.of(context).textTheme.titleLarge,
        ),
        const SizedBox(height: 8),
        if (address != null && address.isNotEmpty) ...[
          Text(address, style: Theme.of(context).textTheme.bodySmall),
          const SizedBox(height: 4),
        ],
        Text(
          'Coordinates: ${latitude.toStringAsFixed(4)}, ${longitude.toStringAsFixed(4)}',
          style: Theme.of(context).textTheme.bodySmall?.copyWith(
            color: Theme.of(
              context,
            ).textTheme.bodySmall?.color?.withValues(alpha: 0.7),
          ),
        ),
        const SizedBox(height: 16),
        buildDataTypeSelector(
          selectedDataType: selectedDataType,
          onSelectionChanged: onDataTypeChanged,
        ),
        const SizedBox(height: 16),
        HourlyWeatherChart(
          data: pastWeatherData,
          dataType: selectedDataType,
          sortAscending: true, // Past: oldest to newest
          latitude: latitude,
          longitude: longitude,
          address: address,
          dataSource: 'Past 10 Days',
        ),
      ],
    ),
  );
}