import 'package:equatable/equatable.dart'; class HomeEntity extends Equatable { final String plantName; final double realTimePower; final double todayGeneration; final double equivalentHours; final int pendingWorkOrders; final WeatherInfo weather; final int alarmCount; final WorkOrderStats workOrderStats; final List powerTrendData; final PlantOverview plantOverview; const HomeEntity({ required this.plantName, required this.realTimePower, required this.todayGeneration, required this.equivalentHours, required this.pendingWorkOrders, required this.weather, required this.alarmCount, required this.workOrderStats, required this.powerTrendData, required this.plantOverview, }); @override List get props => [ plantName, realTimePower, todayGeneration, equivalentHours, pendingWorkOrders, weather, alarmCount, workOrderStats, powerTrendData, plantOverview, ]; } class WeatherInfo extends Equatable { final String condition; final int tempMin; final int tempMax; final String windDirection; final String windLevel; const WeatherInfo({ required this.condition, required this.tempMin, required this.tempMax, required this.windDirection, required this.windLevel, }); factory WeatherInfo.fromJson(Map json) { return WeatherInfo( condition: json['condition'] as String, tempMin: json['tempMin'] as int, tempMax: json['tempMax'] as int, windDirection: json['windDirection'] as String, windLevel: json['windLevel'] as String, ); } Map toJson() { return { 'condition': condition, 'tempMin': tempMin, 'tempMax': tempMax, 'windDirection': windDirection, 'windLevel': windLevel, }; } @override List get props => [condition, tempMin, tempMax, windDirection, windLevel]; } class WorkOrderStats extends Equatable { final int pending; final int processing; final int pendingAcceptance; const WorkOrderStats({ required this.pending, required this.processing, required this.pendingAcceptance, }); factory WorkOrderStats.fromJson(Map json) { return WorkOrderStats( pending: json['pending'] as int, processing: json['processing'] as int, pendingAcceptance: json['pendingAcceptance'] as int, ); } Map toJson() { return { 'pending': pending, 'processing': processing, 'pendingAcceptance': pendingAcceptance, }; } @override List get props => [pending, processing, pendingAcceptance]; } class PowerTrendPoint extends Equatable { final String time; final double power; const PowerTrendPoint({ required this.time, required this.power, }); factory PowerTrendPoint.fromJson(Map json) { return PowerTrendPoint( time: json['time'] as String, power: (json['power'] as num).toDouble(), ); } Map toJson() { return { 'time': time, 'power': power, }; } @override List get props => [time, power]; } class PlantOverview extends Equatable { final double installedCapacity; final String commissionDate; final String backgroundImage; const PlantOverview({ required this.installedCapacity, required this.commissionDate, this.backgroundImage = 'assets/images/carousel1.png', }); factory PlantOverview.fromJson(Map json) { return PlantOverview( installedCapacity: (json['installedCapacity'] as num).toDouble(), commissionDate: json['commissionDate'] as String, backgroundImage: json['backgroundImage'] as String? ?? 'assets/images/carousel1.png', ); } Map toJson() { return { 'installedCapacity': installedCapacity, 'commissionDate': commissionDate, 'backgroundImage': backgroundImage, }; } @override List get props => [installedCapacity, commissionDate, backgroundImage]; }