From 7d3c1ac852f5acd530ad1ab763c862c2b24cf4dc Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Tue, 1 Dec 2020 15:30:38 +0300 Subject: [PATCH] weather indicator updated --- lib/config/config.dart | 9 +- lib/config/shared_pref_kay.dart | 3 +- lib/core/service/weather_service.dart | 23 +- .../weather/weather_view_model.dart | 28 +-- lib/locator.dart | 6 +- .../all_habib_medical_service_page.dart | 100 ++++---- .../health-weather-indicator.dart | 126 +++------- lib/routes.dart | 1 + .../weather_slider/weather_slider.dart | 224 ++++++++++++++---- 9 files changed, 314 insertions(+), 206 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 37da28b4..2cd553fa 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -6,11 +6,13 @@ import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart'; const MAX_SMALL_SCREEN = 660; - - const BASE_URL = 'https://uat.hmgwebservices.com/'; +const BASE_URL = 'https://uat.hmgwebservices.com/'; // const BASE_URL = 'https://hmgwebservices.com/'; const GET_PROJECT = 'Services/Lists.svc/REST/GetProject'; +//weather +const WEATHER_INDICATOR = 'Services/Weather.svc/REST/GetCityInfo'; + ///Doctor const GET_MY_DOCTOR = 'Services/Doctors.svc/REST/GetPatientDoctorAppointmentResult'; @@ -256,8 +258,7 @@ const GET_PAtIENTS_INSURANCE = const GET_PAtIENTS_INSURANCE_UPDATED = "Services/Patients.svc/REST/PatientER_GetPatientInsuranceCardUpdateHistory"; -const INSURANCE_DETAILS = - "Services/Patients.svc/REST/Get_InsuranceCheckList"; +const INSURANCE_DETAILS = "Services/Patients.svc/REST/Get_InsuranceCheckList"; const GET_VACCINES = "Services/Patients.svc/REST/GetDoneVaccinesByPatientID"; const GET_VACCINES_EMAIL = "Services/Notifications.svc/REST/SendVaccinesEmail"; diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index ac611c71..bcd7195b 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -18,4 +18,5 @@ const IS_SEARCH_APPO = 'is-search-appo'; const IS_LIVECARE_APPOINTMENT = 'is_livecare_appointment'; const IS_VIBRATION = 'is_vibration'; const THEME_VALUE = 'is_vibration'; -const MAIN_USER = 'main-user'; \ No newline at end of file +const MAIN_USER = 'main-user'; +const WEATHER = 'weather'; \ No newline at end of file diff --git a/lib/core/service/weather_service.dart b/lib/core/service/weather_service.dart index 828a665b..b2dcf0ef 100644 --- a/lib/core/service/weather_service.dart +++ b/lib/core/service/weather_service.dart @@ -1,17 +1,17 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; -import 'package:diplomaticquarterapp/core/model/er/projectavgerwaitingtime.dart'; +import 'package:diplomaticquarterapp/core/model/weahter/weather_model.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; class WeatherService extends BaseService { - List projectAvgERWaitingTimeModelList = List(); + List weatherIndicatorData = List(); Map body = Map(); String Latitude = ""; String Longitude = ""; String PhoneNumber = ""; - Future getProjectAvgERWaitingTimeOrders() async { + Future getWeatherData() async { hasError = false; var lat = await sharedPref.getDouble(USER_LAT); @@ -19,20 +19,19 @@ class WeatherService extends BaseService { body['Latitude'] = lat ?? 0; body['Longitude'] = long ?? 0; - await baseAppClient.post(GET_NEAREST_HOSPITAL, + await baseAppClient.post(WEATHER_INDICATOR, onSuccess: (dynamic response, int statusCode) { - response['List_ProjectAvgERWaitingTime'].forEach((vital) { - projectAvgERWaitingTimeModelList - .add(ProjectAvgERWaitingTime.fromJson(vital)); - }); - projectAvgERWaitingTimeModelList.forEach((element) { - Latitude = '${element.latitude}'; - Longitude = '${element.longitude}'; - PhoneNumber = '${element.phoneNumber}'; + + + response['GetCityInfo_List'].forEach((data) { + weatherIndicatorData.add(GetCityInfoList.fromJson(data)); }); + print(weatherIndicatorData); + }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); + await this.sharedPref.setObject(WEATHER,weatherIndicatorData[0]); } } diff --git a/lib/core/viewModels/weather/weather_view_model.dart b/lib/core/viewModels/weather/weather_view_model.dart index eb00db9b..85b019e4 100644 --- a/lib/core/viewModels/weather/weather_view_model.dart +++ b/lib/core/viewModels/weather/weather_view_model.dart @@ -1,29 +1,29 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/er/projectavgerwaitingtime.dart'; +import 'package:diplomaticquarterapp/core/model/weahter/weather_model.dart'; import 'package:diplomaticquarterapp/core/service/er/er_service.dart'; +import 'package:diplomaticquarterapp/core/service/weather_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/BranchView.dart'; import '../../../locator.dart'; class WeatherViewModel extends BaseViewModel { - ErService _erService = locator(); - - List get ProjectAvgERWaitingTimeModeList => - _erService.projectAvgERWaitingTimeModelList; - - getProjectAvgERWaitingTimeOrders({int id, int projectID}) async { + WeatherService _weatherService = locator(); + List get weatherIndicatorData => + _weatherService.weatherIndicatorData; + getWeatherData({int id, int projectID}) async { setState(ViewState.Busy); - if (id != null && projectID != null) { - await _erService.getProjectAvgERWaitingTimeOrders( - id: id, projectID: projectID); - } else { - await _erService.getProjectAvgERWaitingTimeOrders(); - } - if (_erService.hasError) { - error = _erService.error; + // if (id != null && projectID != null) { + // await _erService.getProjectAvgERWaitingTimeOrders( + // id: id, projectID: projectID); + // } else { + await _weatherService.getWeatherData(); + // } + if (_weatherService.hasError) { + error = _weatherService.error; setState(ViewState.Error); } else setState(ViewState.Idle); diff --git a/lib/locator.dart b/lib/locator.dart index d13d4057..310558f2 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -1,9 +1,11 @@ import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/H2O_service.dart'; import 'package:diplomaticquarterapp/core/service/qr_service.dart'; +import 'package:diplomaticquarterapp/core/service/weather_service.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/H2O_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/child_vaccines/user_information_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/home_health_care_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/weather/weather_view_model.dart'; import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:get_it/get_it.dart'; @@ -132,7 +134,7 @@ void setupLocator() { locator.registerLazySingleton(() => DeleteBabyService()); locator.registerLazySingleton(() => VaccinationTableService()); locator.registerLazySingleton(() => NotificationService()); - + locator.registerLazySingleton(() => WeatherService()); /// View Model locator.registerFactory(() => HospitalViewModel()); @@ -152,6 +154,7 @@ void setupLocator() { locator.registerFactory(() => QrViewModel()); locator.registerFactory(() => ReportsMonthlyViewModel()); locator.registerFactory(() => NearHospitalViewModel()); + locator.registerFactory(() => WeatherViewModel()); locator.registerFactory(() => AmRequestViewModel()); locator.registerFactory(() => PatientSickLeaveViewMode()); locator.registerFactory(() => MyBalanceViewModel()); @@ -175,5 +178,4 @@ void setupLocator() { locator.registerFactory(() => HomeHealthCareViewModel()); locator.registerFactory(() => CMCViewModel()); locator.registerFactory(() => NotificationViewModel()); - } diff --git a/lib/pages/AlHabibMedicalService/all_habib_medical_service_page.dart b/lib/pages/AlHabibMedicalService/all_habib_medical_service_page.dart index d46a357c..5deac2f2 100644 --- a/lib/pages/AlHabibMedicalService/all_habib_medical_service_page.dart +++ b/lib/pages/AlHabibMedicalService/all_habib_medical_service_page.dart @@ -22,10 +22,12 @@ import 'package:diplomaticquarterapp/pages/paymentService/payment_service.dart'; import 'package:diplomaticquarterapp/pages/symptom-checker/info.dart'; import 'package:diplomaticquarterapp/routes.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/data_display/services)contaniner.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -44,11 +46,13 @@ class AllHabibMedicalService extends StatefulWidget { class _AllHabibMedicalServiceState extends State { AppSharedPreferences sharedPref = AppSharedPreferences(); AuthenticatedUser authUser = new AuthenticatedUser(); - + LocationUtils locationUtils; + var weather ='--'; @override void initState() { WidgetsBinding.instance.addPostFrameCallback((timeStamp) { getAuthUser(); + locationUtils.getCurrentLocation(); }); super.initState(); } @@ -77,28 +81,33 @@ class _AllHabibMedicalServiceState extends State { fit: BoxFit.cover, ), borderRadius: BorderRadius.circular(8.0)), + child: Padding( padding: EdgeInsets.symmetric(horizontal: 10.0), child: Row( children: [ - Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - TranslationBase.of(context) - .healthWeatherIndicators, - color: Colors.white, - fontWeight: FontWeight.w600, - ), - Texts( - TranslationBase.of(context).healthTipsBasedOnCurrentWeather, - color: Colors.white, - fontSize: 14, - ), - ], - ), Expanded( + flex:3, + child: + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + TranslationBase.of(context) + .healthWeatherIndicators, + color: Colors.white, + fontWeight: FontWeight.w600, + ), + Texts( + TranslationBase.of(context).healthTipsBasedOnCurrentWeather, + color: Colors.white, + fontSize: 14, + ), + ], + )), + Expanded( + flex: 2, child:InkWell( onTap: (){ Navigator.push( @@ -109,16 +118,22 @@ class _AllHabibMedicalServiceState extends State { ); }, child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Image.asset('assets/images/Weather_ico.png',width: 80,height: 80,), - Texts( - TranslationBase.of(context).moreDetails, - color: Colors.white, - decoration: TextDecoration.underline, - ), - ], - )), + 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) + ],), + + Texts( + TranslationBase.of(context).moreDetails, + color: Colors.white, + decoration: TextDecoration.underline, + ), + ], + )), ) ], ), @@ -130,7 +145,7 @@ class _AllHabibMedicalServiceState extends State { widget.goToMyProfile(); }, imageLocation: - 'assets/images/new-design/my_file_bottom_bar.png', + 'assets/images/new-design/my_file_bottom_bar.png', title: TranslationBase.of(context).myMedicalFile, ), @@ -144,7 +159,7 @@ class _AllHabibMedicalServiceState extends State { ), ), imageLocation: - 'assets/images/new-design/booking_icon_active.png', + 'assets/images/new-design/booking_icon_active.png', title: TranslationBase.of(context).bookAppo, ), ServicesContainer( @@ -155,7 +170,7 @@ class _AllHabibMedicalServiceState extends State { ), ), imageLocation: - 'assets/images/al-habib_online_payment_service_icon.png', + 'assets/images/al-habib_online_payment_service_icon.png', title: TranslationBase.of(context).onlinePaymentService, ), @@ -182,7 +197,7 @@ class _AllHabibMedicalServiceState extends State { ), ), imageLocation: - 'assets/images/new-design/family_menu_icon_red.png', + 'assets/images/new-design/family_menu_icon_red.png', title: 'My Family', ), @@ -194,7 +209,7 @@ class _AllHabibMedicalServiceState extends State { ), ), imageLocation: - 'assets/images/new-design/upcoming_icon_bottom_bar.png', + 'assets/images/new-design/upcoming_icon_bottom_bar.png', title: TranslationBase.of(context).todoList, ), @@ -206,27 +221,27 @@ class _AllHabibMedicalServiceState extends State { ), ), imageLocation: - 'assets/images/new-design/parking_system_icon.png', + 'assets/images/new-design/parking_system_icon.png', title: TranslationBase.of(context).parking, ), ServicesContainer( onTap: () => launch( "https://hmgwebservices.com/vt_mobile/html/index.html"), imageLocation: - 'assets/images/new-design/virtual_tour_icon.png', + 'assets/images/new-design/virtual_tour_icon.png', title: 'Virtual Tour', ), ServicesContainer( onTap: () { Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) => MyWebView( - title: "HMG News", - selectedUrl: - "https://twitter.com/hashtag/مجموعة_د_سليمان_الحبيب_الطبية?src=hashtag_click&f=live", - ))); + title: "HMG News", + selectedUrl: + "https://twitter.com/hashtag/مجموعة_د_سليمان_الحبيب_الطبية?src=hashtag_click&f=live", + ))); }, imageLocation: - 'assets/images/new-design/twitter_dashboard_icon.png', + 'assets/images/new-design/twitter_dashboard_icon.png', title: 'Latest News', ), ServicesContainer( @@ -248,13 +263,16 @@ class _AllHabibMedicalServiceState extends State { } getAuthUser() async { + if (await this.sharedPref.getObject(USER_PROFILE) != null) { var data = AuthenticatedUser.fromJson( await this.sharedPref.getObject(USER_PROFILE)); setState(() { authUser = data; }); - print(authUser.patientID); } + var data = await this.sharedPref.getObject(WEATHER); + weather = data['Temperature'].toString() + '\u2103' ?? '--'; + print(data); } } diff --git a/lib/pages/AlHabibMedicalService/health-weather/health-weather-indicator.dart b/lib/pages/AlHabibMedicalService/health-weather/health-weather-indicator.dart index aa384a66..98aba205 100644 --- a/lib/pages/AlHabibMedicalService/health-weather/health-weather-indicator.dart +++ b/lib/pages/AlHabibMedicalService/health-weather/health-weather-indicator.dart @@ -1,106 +1,56 @@ -import 'package:diplomaticquarterapp/core/model/contactus/get_hmg_locations.dart'; -import 'package:diplomaticquarterapp/core/viewModels/contactus/findus_view_model.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/location_util.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/slider/slider.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_xlider/flutter_xlider.dart'; -import 'package:giffy_dialog/giffy_dialog.dart'; -import 'package:url_launcher/url_launcher.dart'; -import 'package:maps_launcher/maps_launcher.dart'; +import 'package:provider/provider.dart'; class HealthWeatherIndicator extends StatefulWidget { - - @override _HospitalsPageState createState() => _HospitalsPageState(); } + class _HospitalsPageState extends State { - LinearGradient gradient = LinearGradient( - colors: [ - Colors.red, - Colors.orange, - Colors.yellow, - Colors.green, - Colors.blue, - Colors.blue[900], - Colors.purple - ] - ); + var data; + LocationUtils locationUtils; + @override + void initState() { + locationUtils = + new LocationUtils(isShowConfirmDialog: true, context: context); + WidgetsBinding.instance + .addPostFrameCallback((_) => locationUtils.getCurrentLocation()); + + super.initState(); + } @override Widget build(BuildContext context) { - return AppScaffold( - isShowDecPage: false, - appBarTitle: TranslationBase.of(context).healthWeatherIndicators, - isShowAppBar: true, - body: SingleChildScrollView( - child: Column(children: [ - WeatherSlider(.4, LinearGradient(colors: [Colors.redAccent[100],Colors.redAccent ])), - WeatherSlider(.6, LinearGradient(colors: [Colors.greenAccent[100],Colors.greenAccent ])), - WeatherSlider(.8, LinearGradient(colors: [Colors.yellowAccent[100],Colors.yellowAccent ])), - ]) - ), + ProjectViewModel projectViewModel = Provider.of(context); + return BaseView( + onModelReady: (model) => model.getWeatherData(), + builder: (_, mode, widget) => AppScaffold( + isShowDecPage: false, + appBarTitle: TranslationBase.of(context).healthWeatherIndicators, + isShowAppBar: true, + baseViewModel: mode, + body: mode.weatherIndicatorData.length>0 ? SingleChildScrollView( + child: Column(children: [ + 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); + }).toList() + + ))])) : Container(child:AppText('Loading...'))), ); } } - - -class WeatherSlider extends StatelessWidget{ - final width; - final LinearGradient color; - WeatherSlider(this.width, this.color); - - @override - Widget build(BuildContext context) { - // TODO: implement build - return Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - AppText('Low', fontSize: 24,), - - Padding( - padding: EdgeInsets.all(10), - child: - Stack( - children: [ - Container( - decoration: BoxDecoration(gradient: LinearGradient(colors: [Colors.grey[100],Colors.grey[400] ]), - borderRadius: BorderRadius.circular(10) - ), - height: 15, width: MediaQuery.of(context).size.width, - child:SizedBox(), - ), - Positioned( - top:0, - child: Container( - decoration: BoxDecoration(gradient: color, - borderRadius: BorderRadius.circular(10) - ), - height: 15, - width: MediaQuery.of(context).size.width * width, - padding: EdgeInsets.all(10), - child:SizedBox(), - - )), - - ], - )), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AppText('Low', fontSize: 12,), - AppText('Moderate', fontSize: 12,), - AppText('High', fontSize: 12,), - AppText('Very High', fontSize: 12,), - AppText('Extreme', fontSize: 12,), - ],) - ],); - - } -} \ No newline at end of file diff --git a/lib/routes.dart b/lib/routes.dart index 74a6a189..dc49ce18 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -36,6 +36,7 @@ const String SYMPTOM_CHECKER = 'symptom-checker'; const String SYMPTOM_CHECKER_INFO = 'symptom-checker-info'; const String SELECT_GENDER = 'select-gender'; const String SETTINGS = 'settings'; +const String HEALTH_WEATHER = 'health-weather'; var routes = { SPLASH: (_) => SplashScreen(), HOME: (_) => LandingPage(), diff --git a/lib/widgets/weather_slider/weather_slider.dart b/lib/widgets/weather_slider/weather_slider.dart index 8eafab4c..61d5c1d5 100644 --- a/lib/widgets/weather_slider/weather_slider.dart +++ b/lib/widgets/weather_slider/weather_slider.dart @@ -1,55 +1,191 @@ +import 'package:diplomaticquarterapp/core/model/weahter/weather_model.dart'; +import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; - -class WeatherSlider extends StatelessWidget{ - final width; - final LinearGradient color; - WeatherSlider(this.width, this.color); - +class WeatherSlider extends StatelessWidget { + // final width; + // final LinearGradient color; + final GetCityInfoList data; + WeatherSlider(this.data); + LinearGradient red = LinearGradient( + colors: [ + Colors.redAccent[100], + Colors.redAccent + ]); + LinearGradient green = LinearGradient( + colors: [ + Colors.greenAccent[100], + Colors.greenAccent + ]); + LinearGradient grey = LinearGradient( + colors: [ + Colors.grey[100], + Colors.grey + ]); + LinearGradient orange = LinearGradient( + colors: [ + Colors.orangeAccent[100], + Colors.orange + ]); + LinearGradient yellow = LinearGradient( + colors: [ + Colors.yellow[100], + Colors.yellow[600] + ]); @override Widget build(BuildContext context) { // TODO: implement build return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - AppText('Low', fontSize: 24,), - - Padding( - padding: EdgeInsets.all(10), - child: - Stack( - children: [ - Container( - decoration: BoxDecoration(gradient: LinearGradient(colors: [Colors.grey[100],Colors.grey[400] ]), - borderRadius: BorderRadius.circular(10) + Padding( + padding: EdgeInsets.only(top:10), + child: AppText(data.name)), + AppText( + data.category, + fontSize: 24, + ), + Padding( + padding: EdgeInsets.all(10), + child: Stack( + children: [ + Container( + margin: EdgeInsets.only(bottom:10), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [Colors.grey[100], Colors.grey[400]]), + borderRadius: BorderRadius.circular(10)), + height: 15, + width: MediaQuery.of(context).size.width, + child: SizedBox(), + ), + Positioned( + top: 0, + child: Container( + decoration: BoxDecoration( + gradient: data.colorName =='red' ? red : data.colorName =='orange' ? orange : data.colorName =='green' ? green : data.colorName == 'yellow' ? yellow : grey, + borderRadius: BorderRadius.circular(10)), + height: 15, + width: (MediaQuery.of(context).size.width * (double.parse(data.value) / 10)), + padding: EdgeInsets.all(15), + child: SizedBox(), + )), + Positioned(child: Container( + height: 0, + width:0, + decoration: ShapeDecoration( + color:data.colorName =='red' ? Colors.redAccent : data.colorName =='orange' ? Colors.orangeAccent : data.colorName =='green' ? Colors.greenAccent : data.colorName == 'yellow' ? Colors.yellowAccent : Colors.grey, + shape: MessageBorder(), + + )),top:25, left: (MediaQuery.of(context).size.width * (double.parse(data.value) / 10)),) + + ], + ), + + ), + Padding( + padding: EdgeInsets.only(top:10), + child: data.isValuesReversed == false ? Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppText( + data.categoriesNames.category1, + fontSize: 12, + color: data.categoriesNames.category1== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category1== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category1== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category1== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black + ), + AppText( + data.categoriesNames.category2, + fontSize: 12, + color: data.categoriesNames.category2== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category2== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category2== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category2== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black + + ), + AppText( + data.categoriesNames.category3, + fontSize: 12, + color: data.categoriesNames.category3== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category3== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category3== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category3== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black + + ), + AppText( + data.categoriesNames.category4, + fontSize: 12, + color: data.categoriesNames.category4== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category4== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category4== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category4== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black + + ), + AppText( + data.categoriesNames.category5, + fontSize: 12, + color: data.categoriesNames.category5== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category5== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category5== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category5== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black + + ), + ], + ) : Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppText( + data.categoriesNames.category5, + fontSize: 12, + color: data.categoriesNames.category5== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category5== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category5== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category5== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black + ), + AppText( + data.categoriesNames.category4, + fontSize: 12, + color: data.categoriesNames.category4== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category4== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category4== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category4== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black + + ), + AppText( + data.categoriesNames.category3, + fontSize: 12, + color: data.categoriesNames.category3== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category3== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category3== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category3== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black + + ), + AppText( + data.categoriesNames.category2, + fontSize: 12, + color: data.categoriesNames.category2== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category2== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category2== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category2== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black + + ), + AppText( + data.categoriesNames.category1, + fontSize: 12, + color: data.categoriesNames.category1== data.category && data.colorName=='red' ? Colors.redAccent : data.categoriesNames.category1== data.category && data.colorName=='orange' ? Colors.orangeAccent : data.categoriesNames.category1== data.category && data.colorName=='green' ? Colors.greenAccent : data.categoriesNames.category1== data.category && data.colorName=='yellow' ? Colors.yellow[900] : Colors.black + ), - height: 15, width: MediaQuery.of(context).size.width, - child:SizedBox(), - ), - Positioned( - top:0, - child: Container( - decoration: BoxDecoration(gradient: color, - borderRadius: BorderRadius.circular(10) - ), - height: 15, - width: MediaQuery.of(context).size.width * width, - padding: EdgeInsets.all(10), - child:SizedBox(), - - )), - - ], - )), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AppText('Low', fontSize: 12,), - AppText('Moderate', fontSize: 12,), - AppText('High', fontSize: 12,), - AppText('Very High', fontSize: 12,), - AppText('Extreme', fontSize: 12,), - ],) - ],); + ], + )), + Padding( + padding: EdgeInsets.all(15), + child:Divider()) + ], + ); } +} +class MessageBorder extends ShapeBorder { + final bool usePadding; + + MessageBorder({this.usePadding = true}); + + @override + EdgeInsetsGeometry get dimensions => EdgeInsets.only(bottom: usePadding? 0 : 0); + + @override + Path getInnerPath(Rect rect, {TextDirection textDirection}) => null; + + @override + Path getOuterPath(Rect rect, {TextDirection textDirection}) { + rect = Rect.fromPoints(rect.bottomRight, rect.bottomLeft - Offset(0, 0)); + return Path() + ..addRRect(RRect.fromRectAndRadius(rect, Radius.circular(rect.height / 2))) + ..moveTo(rect.topCenter.dx - 10, rect.topCenter.dy) + ..relativeLineTo(10, -10) + ..relativeLineTo(10,10) + ..close(); + } + + @override + void paint(Canvas canvas, Rect rect, {TextDirection textDirection}) {} + + @override + ShapeBorder scale(double t) => this; } \ No newline at end of file