import 'package:hmg_qline/constants/app_constants.dart';

class WeathersWidgetModel {
  int? id;
  String? headline;
  double? maxTemp;
  double? minTemp;
  String? iconPhrase;
  String? forecastDate;
  int? cityID;
  String? forecastDay;
  String? createDateTime;
  double? windSpeed;
  String? windDirection;
  double? windDegrees;
  String? weatherIconPath;

  WeathersWidgetModel({
    this.id,
    this.headline,
    this.maxTemp,
    this.minTemp,
    this.iconPhrase,
    this.forecastDate,
    this.cityID,
    this.forecastDay,
    this.createDateTime,
    this.windSpeed,
    this.windDirection,
    this.windDegrees,
    this.weatherIconPath,
  });

  WeathersWidgetModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    headline = json['headline'];
    maxTemp = json['maxTemp'];
    minTemp = json['minTemp'];
    iconPhrase = json['iconPhrase'];
    forecastDate = json['forecastDate'];
    cityID = json['cityID'];
    forecastDay = json['forecastDay'];
    createDateTime = json['createDateTime'];
    windSpeed = json['windSpeed'];
    windDirection = json['windDirection'];
    windDegrees = json['windDegrees'];
    weatherIconPath = getWeatherIconPath(json['iconPhrase']);
  }

  String getWeatherIconPath(String iconPhrase) {
    if (iconPhrase == "Rain" || iconPhrase == "Showers" || iconPhrase == "ThunderStorms") {
      return AppAssets.rainIcon;
    } else if (iconPhrase == "Hot") {
      return AppAssets.hotIcon;
    } else if (iconPhrase == "Windy") {
      return AppAssets.windIcon;
    } else if (iconPhrase == "Cloudy" || iconPhrase == "Mostly cloudy" || iconPhrase == "Intermittent clouds") {
      return AppAssets.cloudIcon;
    } else if (iconPhrase == "Sunny" || iconPhrase == "Mostly sunny" || iconPhrase == "Partly sunny" || iconPhrase == "Hazy sunshine") {
      return AppAssets.sunnyIcon;
    } else {
      return AppAssets.weatherIcon;
    }
  }
}
