@ -1,6 +1,8 @@
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/location_util.dart ' ;
import ' package:diplomaticquarterapp/uitl/translations_delegate_base.dart ' ;
import ' package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart ' ;
@ -19,13 +21,15 @@ class HealthWeatherIndicator extends StatefulWidget {
class _HospitalsPageState extends State < HealthWeatherIndicator > {
var data ;
LocationUtils locationUtils ;
AppSharedPreferences sharedPref = AppSharedPreferences ( ) ;
var weather = ' -- ' ;
@ override
void initState ( ) {
locationUtils =
new LocationUtils ( isShowConfirmDialog: true , context: context ) ;
WidgetsBinding . instance
. addPostFrameCallback ( ( _ ) = > locationUtils . getCurrentLocation ( ) ) ;
getWeather ( ) ;
super . initState ( ) ;
}
@ override
@ -33,14 +37,73 @@ class _HospitalsPageState extends State<HealthWeatherIndicator> {
ProjectViewModel projectViewModel = Provider . of ( context ) ;
return BaseView < WeatherViewModel > (
onModelReady: ( model ) = > model . getWeatherData ( ) ,
allowAny: true ,
builder: ( _ , mode , widget ) = > AppScaffold (
isShowDecPage: false ,
appBarTitle: TranslationBase . of ( context ) . healthWeatherIndicators ,
isShowAppBar: true ,
baseViewModel: mode ,
body: mode . weatherIndicatorData . length > 0 ? SingleChildScrollView (
child: Column ( children: [
Container (
margin: EdgeInsets . all ( 8 ) ,
width: double . infinity ,
height: 150 ,
decoration: BoxDecoration (
image: DecorationImage (
image: ExactAssetImage ( ' assets/images/Weather_img.png ' ) ,
fit: BoxFit . cover ,
) ,
borderRadius: BorderRadius . circular ( 8.0 ) ) ,
child: Padding (
padding: EdgeInsets . symmetric ( horizontal: 10.0 ) ,
child: Row (
children: [
Expanded (
flex: 3 ,
child:
Column (
mainAxisAlignment: MainAxisAlignment . center ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
AppText (
TranslationBase . of ( context )
. healthWeatherIndicators ,
color: Colors . white ,
fontWeight: FontWeight . w600 ,
) ,
AppText (
TranslationBase . of ( context ) . healthTipsBasedOnCurrentWeather ,
color: Colors . white ,
fontSize: 14 ,
) ,
] ,
) ) ,
Expanded (
flex: 2 ,
child: InkWell (
onTap: ( ) {
} ,
child: Column (
mainAxisAlignment: MainAxisAlignment . center ,
children: [
Row (
mainAxisAlignment: MainAxisAlignment . center ,
children: [
Image . asset ( ' assets/images/Weather_ico.png ' , width: 60 , height: 60 , ) ,
AppText ( weather , fontSize: 22 , color: Colors . white )
] , ) ,
] ,
) ) ,
)
] ,
) ,
) ,
) ,
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:
@ -50,7 +113,14 @@ class _HospitalsPageState extends State<HealthWeatherIndicator> {
data ) ;
} ) . toList ( )
) ) ] ) ) : Container ( child: AppText ( ' Loading... ' ) ) ) ,
) ) ] ) ) : Container ( ) ) ,
) ;
}
getWeather ( ) async {
var data = await this . sharedPref . getObject ( WEATHER ) ;
setState ( ( ) {
weather = data [ ' Temperature ' ] . toString ( ) + ' \u2103 ' ? ? ' -- ' ;
} ) ;
}
}