@ -10,9 +10,29 @@ import 'package:hmg_patient_app_new/presentation/hmg_services/widgets/weather_wi
import ' package:hmg_patient_app_new/theme/colors.dart ' ;
import ' package:hmg_patient_app_new/theme/colors.dart ' ;
import ' package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart ' ;
import ' package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart ' ;
import ' package:provider/provider.dart ' ;
import ' package:provider/provider.dart ' ;
import ' package:shimmer/shimmer.dart ' ;
class WeatherDetailsPage extends StatelessWidget {
class WeatherDetailsPage extends StatefulWidget {
const WeatherDetailsPage ( { super . key } ) ;
final bool showBackIcon ;
const WeatherDetailsPage ( { super . key , this . showBackIcon = true } ) ;
@ override
State < WeatherDetailsPage > createState ( ) = > _WeatherDetailsPageState ( ) ;
}
class _WeatherDetailsPageState extends State < WeatherDetailsPage > {
@ override
void initState ( ) {
super . initState ( ) ;
/ / Fetch weather data when page loads only if data is not already available
WidgetsBinding . instance . addPostFrameCallback ( ( _ ) {
final weatherVM = Provider . of < WeatherMonitorViewModel > ( context , listen: false ) ;
/ / Only fetch if cityInfoList is empty
if ( weatherVM . cityInfoList . isEmpty & & ! weatherVM . isLoading ) {
weatherVM . initiateFetchWeather ( ) ;
}
} ) ;
}
Color _getColorFromColorName ( ColorName ? colorName ) {
Color _getColorFromColorName ( ColorName ? colorName ) {
if ( colorName = = null ) return AppColors . successColor ;
if ( colorName = = null ) return AppColors . successColor ;
@ -132,13 +152,9 @@ class WeatherDetailsPage extends StatelessWidget {
backgroundColor: AppColors . bgScaffoldColor ,
backgroundColor: AppColors . bgScaffoldColor ,
body: CollapsingListView (
body: CollapsingListView (
title: LocaleKeys . healthWeatherIndicators . tr ( ) ,
title: LocaleKeys . healthWeatherIndicators . tr ( ) ,
isLeading: true ,
isLeading: widget . showBackIcon ,
child: weatherVM . isLoading
child: weatherVM . isLoading
? Center (
? _buildShimmerLoading ( )
child: CircularProgressIndicator (
color: AppColors . primaryRedColor ,
) ,
)
: Column (
: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
@ -251,5 +267,164 @@ class WeatherDetailsPage extends StatelessWidget {
) ,
) ,
) . paddingSymmetrical ( 24. w , 0. w ) ;
) . paddingSymmetrical ( 24. w , 0. w ) ;
}
}
Widget _buildShimmerLoading ( ) {
return Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
/ / Weather Widget Shimmer
Shimmer . fromColors (
baseColor: AppColors . shimmerBaseColor ,
highlightColor: AppColors . shimmerHighlightColor ,
child: Container (
margin: EdgeInsets . symmetric ( horizontal: 24. w ) ,
padding: EdgeInsets . all ( 16. w ) ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor ,
borderRadius: 24. r ,
hasShadow: false ,
) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Row (
children: [
Container (
width: 64. w ,
height: 64. w ,
decoration: BoxDecoration (
color: AppColors . whiteColor ,
borderRadius: BorderRadius . circular ( 12. r ) ,
) ,
) ,
SizedBox ( width: 12. w ) ,
Expanded (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Container (
width: double . infinity ,
height: 12. h ,
decoration: BoxDecoration (
color: AppColors . whiteColor ,
borderRadius: BorderRadius . circular ( 4. r ) ,
) ,
) ,
SizedBox ( height: 8. h ) ,
Container (
width: 120. w ,
height: 16. h ,
decoration: BoxDecoration (
color: AppColors . whiteColor ,
borderRadius: BorderRadius . circular ( 4. r ) ,
) ,
) ,
SizedBox ( height: 8. h ) ,
Container (
width: 160. w ,
height: 12. h ,
decoration: BoxDecoration (
color: AppColors . whiteColor ,
borderRadius: BorderRadius . circular ( 4. r ) ,
) ,
) ,
] ,
) ,
) ,
] ,
) ,
SizedBox ( height: 16. h ) ,
Container (
width: double . infinity ,
height: 40. h ,
decoration: BoxDecoration (
color: AppColors . whiteColor ,
borderRadius: BorderRadius . circular ( 10. r ) ,
) ,
) ,
] ,
) ,
) ,
) ,
SizedBox ( height: 16. h ) ,
/ / Shimmer for category cards
. . . List . generate ( 3 , ( index ) {
return Shimmer . fromColors (
baseColor: AppColors . shimmerBaseColor ,
highlightColor: AppColors . shimmerHighlightColor ,
child: Container (
margin: EdgeInsets . only ( bottom: 16. h , left: 24. w , right: 24. w ) ,
padding: EdgeInsets . all ( 16. w ) ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor ,
borderRadius: 16. r ,
hasShadow: false ,
) ,
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Row (
children: [
Container (
width: 40. w ,
height: 40. w ,
decoration: BoxDecoration (
color: AppColors . whiteColor ,
shape: BoxShape . circle ,
) ,
) ,
SizedBox ( width: 12. w ) ,
Expanded (
child: Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Container (
width: double . infinity ,
height: 14. h ,
decoration: BoxDecoration (
color: AppColors . whiteColor ,
borderRadius: BorderRadius . circular ( 4. r ) ,
) ,
) ,
SizedBox ( height: 8. h ) ,
Container (
width: 100. w ,
height: 12. h ,
decoration: BoxDecoration (
color: AppColors . whiteColor ,
borderRadius: BorderRadius . circular ( 4. r ) ,
) ,
) ,
] ,
) ,
) ,
Container (
width: 60. w ,
height: 24. h ,
decoration: BoxDecoration (
color: AppColors . whiteColor ,
borderRadius: BorderRadius . circular ( 8. r ) ,
) ,
) ,
] ,
) ,
SizedBox ( height: 12. h ) ,
Container (
width: double . infinity ,
height: 8. h ,
decoration: BoxDecoration (
color: AppColors . whiteColor ,
borderRadius: BorderRadius . circular ( 4. r ) ,
) ,
) ,
] ,
) ,
) ,
) ;
} ) ,
] ,
) ;
}
}
}