import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/constants/assets.dart';
import 'package:syncrow_web/utils/extension/build_context_x.dart';

class AqiHumidityAndTemperature extends StatelessWidget {
  const AqiHumidityAndTemperature({
    required this.temperature,
    required this.humidity,
    super.key,
  });

  final int temperature;
  final int humidity;

  static const iconSize = 12.0;
  static const colorFilter = ColorFilter.mode(
    ColorsManager.textPrimaryColor,
    BlendMode.srcIn,
  );

  @override
  Widget build(BuildContext context) {
    return FittedBox(
      fit: BoxFit.scaleDown,
      alignment: AlignmentDirectional.centerStart,
      child: DefaultTextStyle(
        style: context.textTheme.bodySmall!.copyWith(
          color: ColorsManager.textPrimaryColor,
          fontWeight: FontWeight.w400,
          fontSize: 16,
        ),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            _buildIconAndValue(Assets.temperatureAqiSidebar, '$temperature°C'),
            const SizedBox(height: 10),
            _buildIconAndValue(Assets.humidityAqiSidebar, '$humidity%'),
          ],
        ),
      ),
    );
  }

  Widget _buildIconAndValue(String icon, String value) {
    return Row(
      children: [
        SvgPicture.asset(
          icon,
          height: iconSize,
          width: iconSize,
          colorFilter: colorFilter,
        ),
        const SizedBox(width: 4),
        Text(value),
      ],
    );
  }
}
