import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/weather/weather_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/location_util.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/weather_slider/weather_slider.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; class HealthWeatherIndicator extends StatefulWidget { @override _HospitalsPageState createState() => _HospitalsPageState(); } class _HospitalsPageState extends State { var data; AppSharedPreferences sharedPref = AppSharedPreferences(); LocationUtils locationUtils; var weather = '--'; ProjectViewModel projectViewModel; @override void initState() { locationUtils = new LocationUtils(isShowConfirmDialog: true, context: context); WidgetsBinding.instance.addPostFrameCallback((_) => locationUtils.getCurrentLocation()); getWeather(); super.initState(); } @override Widget build(BuildContext context) { projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getWeatherData(), allowAny: true, builder: (_, mode, widget) => AppScaffold( isShowDecPage: false, showNewAppBar: true, showNewAppBarTitle: true, appBarTitle: TranslationBase.of(context).healthWeatherIndicators, isShowAppBar: true, body: mode.weatherIndicatorData.length > 0 ? SingleChildScrollView( child: Column(children: [ Container( width: double.infinity, decoration: containerRadiusWithGradient(0, color1: timeCalculator(6, 0, 10, 59) ? Color(0xFFB3E3FE) : timeCalculator(11, 0, 15, 59) ? Color(0xFFFF9E7E) : Color(0xFF2E6686), color2: timeCalculator(6, 0, 10, 59) ? Color(0xFF9AC7FF) : timeCalculator(11, 0, 15, 59) ? Color(0xFFFECB50) : Color(0xFF122F48)), child: Padding( padding: const EdgeInsets.all(20.0), child: Row( children: [ Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Directionality( textDirection: TextDirection.ltr, child: Text( weather, style: TextStyle( fontSize: 24, letterSpacing: -0.83, fontWeight: FontWeight.bold, color: Colors.white, ), ), ), Text( DateUtil.getMonthDayYearDateFormatted(new DateTime.now()), style: TextStyle( fontSize: 12, letterSpacing: -0.60, fontWeight: FontWeight.w600, color: Colors.white, ), ), Text( TranslationBase.of(context).healthWeatherIndicators, style: TextStyle( fontSize: 12, letterSpacing: -0.96, fontWeight: FontWeight.bold, color: Colors.white, ), ), Text( TranslationBase.of(context).healthTipsBasedOnCurrentWeather, style: TextStyle( fontSize: 10, letterSpacing: -0.72, fontWeight: FontWeight.w600, color: Colors.white, ), ), ], ), ), SvgPicture.asset( "assets/images/new/cloudy.svg", ), ], ), ), ), Padding( padding: EdgeInsets.all(15), child: AppText( projectViewModel.isArabic ? mode.weatherIndicatorData[0].cityNameN : mode.weatherIndicatorData[0].cityName, fontSize: 24, fontWeight: FontWeight.bold, )), Padding( padding: EdgeInsets.all(15), child: Column( children: mode.weatherIndicatorData.map((data) { return WeatherSlider(data, projectViewModel); }).toList())) ])) : Center(child: AppCircularProgressIndicator())), ); } getWeather() async { var data = await this.sharedPref.getObject(WEATHER); setState(() { weather = data['Temperature'].toString() + '\u2103' ?? '--'; }); } }