import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/analytics/modules/air_quality/blocs/device_location/device_location_bloc.dart';
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_location.dart';
import 'package:syncrow_web/pages/analytics/modules/air_quality/widgets/aqi_location_info_cell.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/style.dart';

class AqiLocationInfo extends StatelessWidget {
  const AqiLocationInfo({super.key});

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<DeviceLocationBloc, DeviceLocationState>(
      builder: (context, state) {
        final info = state.locationInfo;
        return Container(
          decoration: secondarySection.copyWith(boxShadow: const []),
          padding: const EdgeInsetsDirectional.all(20),
          child: Column(
            spacing: 8,
            children: [
              AqiLocation(
                city: info?.city,
                country: info?.country,
                address: info?.address,
              ),
              Expanded(
                child: Row(
                  spacing: 8,
                  children: [
                    AqiLocationInfoCell(
                      label: 'Temperature',
                      value: ' ${info?.temperature?.roundToDouble() ?? '--'}°',
                      svgPath: Assets.aqiTemperature,
                    ),
                    AqiLocationInfoCell(
                      label: 'Humidity',
                      value: '${info?.humidity?.roundToDouble() ?? '--'}%',
                      svgPath: Assets.aqiHumidity,
                    ),
                    AqiLocationInfoCell(
                      label: 'Air Quality',
                      value: ' ${info?.airQuality?.roundToDouble() ?? '--'}',
                      svgPath: Assets.aqiAirQuality,
                    ),
                  ],
                ),
              ),
            ],
          ),
        );
      },
    );
  }
}
