|
|
|
|
@ -1,8 +1,6 @@
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_export.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/dependencies.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/weather/models/waether_cities_model.dart';
|
|
|
|
|
@ -21,7 +19,10 @@ class WeatherDetailsPage extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
switch (colorName) {
|
|
|
|
|
case ColorName.GREEN:
|
|
|
|
|
case ColorName.LIGHTGREEN:
|
|
|
|
|
return AppColors.successColor;
|
|
|
|
|
case ColorName.YELLOW:
|
|
|
|
|
return AppColors.warningColorYellow;
|
|
|
|
|
case ColorName.ORANGE:
|
|
|
|
|
return AppColors.warningColor;
|
|
|
|
|
case ColorName.RED:
|
|
|
|
|
@ -34,7 +35,10 @@ class WeatherDetailsPage extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
switch (colorName) {
|
|
|
|
|
case ColorName.GREEN:
|
|
|
|
|
case ColorName.LIGHTGREEN:
|
|
|
|
|
return AppColors.successLightColor.withValues(alpha: 0.1);
|
|
|
|
|
case ColorName.YELLOW:
|
|
|
|
|
return AppColors.warningColorYellow.withValues(alpha: 0.1);
|
|
|
|
|
case ColorName.ORANGE:
|
|
|
|
|
return AppColors.warningLightColor.withValues(alpha: 0.1);
|
|
|
|
|
case ColorName.RED:
|
|
|
|
|
@ -42,8 +46,14 @@ class WeatherDetailsPage extends StatelessWidget {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Get color based on category label
|
|
|
|
|
Color _getColorFromCategory(String? categoryLabel) {
|
|
|
|
|
/// Get color based on colorName from API (language-independent)
|
|
|
|
|
Color _getColorFromColorNameOrCategory(ColorName? colorName, String? categoryLabel) {
|
|
|
|
|
// First priority: Use the colorName from API if available
|
|
|
|
|
if (colorName != null) {
|
|
|
|
|
return _getColorFromColorName(colorName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fallback: Try to parse category label (for English)
|
|
|
|
|
if (categoryLabel == null) return AppColors.successColor;
|
|
|
|
|
|
|
|
|
|
final category = categoryLabel.toLowerCase().trim();
|
|
|
|
|
@ -68,8 +78,14 @@ class WeatherDetailsPage extends StatelessWidget {
|
|
|
|
|
return AppColors.successColor; // Default to green
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Get background color based on category label
|
|
|
|
|
Color _getBackgroundFromCategory(String? categoryLabel) {
|
|
|
|
|
/// Get background color based on colorName from API (language-independent)
|
|
|
|
|
Color _getBackgroundFromColorNameOrCategory(ColorName? colorName, String? categoryLabel) {
|
|
|
|
|
// First priority: Use the colorName from API if available
|
|
|
|
|
if (colorName != null) {
|
|
|
|
|
return _getBackgroundColorFromColorName(colorName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fallback: Try to parse category label (for English)
|
|
|
|
|
if (categoryLabel == null) return AppColors.successLightColor.withValues(alpha: 0.1);
|
|
|
|
|
|
|
|
|
|
final category = categoryLabel.toLowerCase().trim();
|
|
|
|
|
@ -136,8 +152,9 @@ class WeatherDetailsPage extends StatelessWidget {
|
|
|
|
|
return _buildCategoryCard(
|
|
|
|
|
description: cityInfo.name ?? '',
|
|
|
|
|
categoryLabel: cityInfo.category ?? '',
|
|
|
|
|
color: _getColorFromCategory(cityInfo.category),
|
|
|
|
|
backgroundColor: _getBackgroundFromCategory(cityInfo.category),
|
|
|
|
|
colorName: cityInfo.colorName,
|
|
|
|
|
color: _getColorFromColorNameOrCategory(cityInfo.colorName, cityInfo.category),
|
|
|
|
|
backgroundColor: _getBackgroundFromColorNameOrCategory(cityInfo.colorName, cityInfo.category),
|
|
|
|
|
icon: _getIconFromCategory(cityInfo.category),
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
@ -154,6 +171,7 @@ class WeatherDetailsPage extends StatelessWidget {
|
|
|
|
|
Widget _buildCategoryCard({
|
|
|
|
|
required String description,
|
|
|
|
|
required String categoryLabel,
|
|
|
|
|
required ColorName? colorName,
|
|
|
|
|
required Color color,
|
|
|
|
|
required Color backgroundColor,
|
|
|
|
|
required IconData icon,
|
|
|
|
|
|