diff --git a/lib/config/config.dart b/lib/config/config.dart index d7ffabcd..7840b97d 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -12,8 +12,8 @@ const PACKAGES_PRODUCTS = '/api/products'; const PACKAGES_CUSTOMER = '/api/customers'; const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; const PACKAGES_ORDERS = '/api/orders'; -const BASE_URL = 'https://uat.hmgwebservices.com/'; -// const BASE_URL = 'https://hmgwebservices.com/'; +// const BASE_URL = 'https://uat.hmgwebservices.com/'; +const BASE_URL = 'https://hmgwebservices.com/'; // Pharmacy UAT URLs // const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; diff --git a/lib/core/viewModels/medical/labs_view_model.dart b/lib/core/viewModels/medical/labs_view_model.dart index f4ba71ab..8e61e3f3 100644 --- a/lib/core/viewModels/medical/labs_view_model.dart +++ b/lib/core/viewModels/medical/labs_view_model.dart @@ -6,6 +6,8 @@ import 'package:diplomaticquarterapp/core/model/labs/patient_lab_orders.dart'; import 'package:diplomaticquarterapp/core/model/labs/patient_lab_special_result.dart'; import 'package:diplomaticquarterapp/core/service/medical/labs_service.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart'; import '../../../locator.dart'; import '../base_view_model.dart'; @@ -15,6 +17,7 @@ class LabsViewModel extends BaseViewModel { LabsService _labsService = locator(); List get labOrdersResultsList => _labsService.labOrdersResultsList; + List timeSeries = []; List _patientLabOrdersListClinic = List(); List _patientLabOrdersListHospital = List(); @@ -121,6 +124,12 @@ class LabsViewModel extends BaseViewModel { // if (isShouldClear) // // _labsService.labOrdersResultsList.clear(); + + _labsService.labOrdersResultsList.forEach((element) { + try { + timeSeries.add(new TimeSeriesSales2(DateUtil.convertStringToDate(element.verifiedOnDateTime), double.parse(element.resultValue))); + } catch (e) {} + }); setState(ViewState.Idle); } } diff --git a/lib/pages/BookAppointment/Search.dart b/lib/pages/BookAppointment/Search.dart index 20efe489..3c89b2f5 100644 --- a/lib/pages/BookAppointment/Search.dart +++ b/lib/pages/BookAppointment/Search.dart @@ -12,8 +12,9 @@ import 'components/SearchByClinic.dart'; class Search extends StatefulWidget { final int type; final List clnicIds; + Function onBackClick; - Search({this.type = 0, this.clnicIds}); + Search({this.type = 0, this.clnicIds,this.onBackClick}); @override _SearchState createState() => _SearchState(); @@ -36,8 +37,11 @@ class _SearchState extends State with TickerProviderStateMixin { return AppScaffold( isShowAppBar: false, isShowDecPage: false, + showNewAppBarTitle: true, + showNewAppBar: true, appBarTitle: TranslationBase.of(context).bookAppo, backgroundColor: Color(0xFFF7F7F7), + onTap: widget.onBackClick, body: Column( children: [ TabBar( diff --git a/lib/pages/DrawerPages/family/my-family.dart b/lib/pages/DrawerPages/family/my-family.dart index 4c20fa05..1d0478d1 100644 --- a/lib/pages/DrawerPages/family/my-family.dart +++ b/lib/pages/DrawerPages/family/my-family.dart @@ -37,8 +37,9 @@ import 'package:provider/provider.dart'; class MyFamily extends StatefulWidget { final bool isAppbarVisible; + Function onBackClick; - MyFamily({this.isAppbarVisible = true}); + MyFamily({this.isAppbarVisible = true,this.onBackClick}); @override _MyFamily createState() => _MyFamily(); @@ -88,6 +89,7 @@ class _MyFamily extends State with TickerProviderStateMixin { imagesInfo: imagesInfo, showNewAppBar: true, showNewAppBarTitle: true, + onTap: widget.isAppbarVisible == false ? widget.onBackClick : null, icon: "assets/images/new/bottom_nav/family_files.svg", description: TranslationBase.of(context).familyInfo, body: Column( diff --git a/lib/pages/ToDoList/ToDo.dart b/lib/pages/ToDoList/ToDo.dart index b7a257aa..a143fa15 100644 --- a/lib/pages/ToDoList/ToDo.dart +++ b/lib/pages/ToDoList/ToDo.dart @@ -13,6 +13,7 @@ import 'package:diplomaticquarterapp/pages/ToDoList/payment_method_select.dart'; import 'package:diplomaticquarterapp/pages/ToDoList/widgets/paymentDialog.dart'; import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; @@ -37,8 +38,9 @@ class ToDo extends StatefulWidget { MyInAppBrowser browser; bool isShowAppBar = true; + Function onBackClick; - ToDo({@required this.isShowAppBar}); + ToDo({@required this.isShowAppBar,this.onBackClick}); @override _ToDoState createState() => _ToDoState(); @@ -77,8 +79,12 @@ class _ToDoState extends State { imagesInfo: imagesInfo, isShowAppBar: widget.isShowAppBar, isShowDecPage: true, + showNewAppBar: true, + showNewAppBarTitle: true, icon: "assets/images/new/bottom_nav/todo.svg", description: TranslationBase.of(context).infoTodo, + onTap:widget.onBackClick, + backgroundColor: CustomColors.appBackgroudGrey2Color, body: SingleChildScrollView( child: Column( children: [ diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index e5f8e35c..f96cf7f4 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -281,120 +281,103 @@ class _LandingPageState extends State with WidgetsBindingObserver { // // //_firebase Background message handler _firebaseMessaging.configure( - onMessage: (Map message) async { - // showDialog("onMessage: $message"); - print("onMessage: $message"); - print(message); - print(message['name']); - print(message['appointmentdate']); - - if (Platform.isIOS) { - if (message['is_call'] == "true") { - var route = ModalRoute.of(context); - - if (route != null) { - print(route.settings.name); - } + onMessage: (Map message) async { + // showDialog("onMessage: $message"); + print("onMessage: $message"); + print(message); + print(message['name']); + print(message['appointmentdate']); + + if (Platform.isIOS) { + if (message['is_call'] == "true") { + var route = ModalRoute.of(context); + + if (route != null) { + print(route.settings.name); + } - Map myMap = new Map.from(message); - print(myMap); - LandingPage.isOpenCallPage = true; - LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); - if (!isPageNavigated) { - isPageNavigated = true; - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => IncomingCall( - incomingCallData: LandingPage.incomingCallData))) - .then((value) { - isPageNavigated = false; - }); - } - } else { - print("Is Call Not Found iOS"); - } - } else { - print("Is Call Not Found iOS"); + Map myMap = new Map.from(message); + print(myMap); + LandingPage.isOpenCallPage = true; + LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); + if (!isPageNavigated) { + isPageNavigated = true; + Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { + isPageNavigated = false; + }); } + } else { + print("Is Call Not Found iOS"); + } + } else { + print("Is Call Not Found iOS"); + } - if (Platform.isAndroid) { - if (message['data'].containsKey("is_call")) { - var route = ModalRoute.of(context); + if (Platform.isAndroid) { + if (message['data'].containsKey("is_call")) { + var route = ModalRoute.of(context); - if (route != null) { - print(route.settings.name); - } + if (route != null) { + print(route.settings.name); + } - Map myMap = - new Map.from(message['data']); - print(myMap); - LandingPage.isOpenCallPage = true; - LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); - if (!isPageNavigated) { - isPageNavigated = true; - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => IncomingCall( - incomingCallData: LandingPage.incomingCallData))) - .then((value) { - isPageNavigated = false; - }); - } - } else { - print("Is Call Not Found Android"); - LocalNotification.getInstance().showNow(title: message['notification']['title'], subtitle: message['notification']['body']); - } - } else { - print("Is Call Not Found Android"); + Map myMap = new Map.from(message['data']); + print(myMap); + LandingPage.isOpenCallPage = true; + LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); + if (!isPageNavigated) { + isPageNavigated = true; + Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { + isPageNavigated = false; + }); + } + } else { + print("Is Call Not Found Android"); + LocalNotification.getInstance().showNow(title: message['notification']['title'], subtitle: message['notification']['body']); + } + } else { + print("Is Call Not Found Android"); + } + }, + onBackgroundMessage: Platform.isIOS ? null : myBackgroundMessageHandler, + onLaunch: (Map message) async { + print("onLaunch: $message"); + // showDialog("onLaunch: $message"); + }, + onResume: (Map message) async { + print("onResume: $message"); + print(message); + print(message['name']); + print(message['appointmentdate']); + + // showDialog("onResume: $message"); + + if (Platform.isIOS) { + if (message['is_call'] == "true") { + var route = ModalRoute.of(context); + + if (route != null) { + print(route.settings.name); } - }, - onBackgroundMessage: Platform.isIOS ? null : myBackgroundMessageHandler, - onLaunch: (Map message) async { - print("onLaunch: $message"); - // showDialog("onLaunch: $message"); - }, - onResume: (Map message) async { - print("onResume: $message"); - print(message); - print(message['name']); - print(message['appointmentdate']); - - // showDialog("onResume: $message"); - - if (Platform.isIOS) { - if (message['is_call'] == "true") { - var route = ModalRoute.of(context); - - if (route != null) { - print(route.settings.name); - } - Map myMap = - new Map.from(message); - print(myMap); - LandingPage.isOpenCallPage = true; - LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); - if (!isPageNavigated) { - isPageNavigated = true; - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => IncomingCall( - incomingCallData: LandingPage.incomingCallData))) - .then((value) { - isPageNavigated = false; - }); - } - } else { - print("Is Call Not Found iOS"); - } - } else { - print("Is Call Not Found iOS"); + Map myMap = new Map.from(message); + print(myMap); + LandingPage.isOpenCallPage = true; + LandingPage.incomingCallData = IncomingCallData.fromJson(myMap); + if (!isPageNavigated) { + isPageNavigated = true; + Navigator.push(context, MaterialPageRoute(builder: (context) => IncomingCall(incomingCallData: LandingPage.incomingCallData))).then((value) { + isPageNavigated = false; + }); } - }, - ); + } else { + print("Is Call Not Found iOS"); + } + } else { + print("Is Call Not Found iOS"); + } + }, + ); } showDialogs(String message) { @@ -627,10 +610,21 @@ class _LandingPageState extends State with WidgetsBindingObserver { changeCurrentTab(1); }, ), - MedicalProfilePageNew(), - Search(), - MyFamily(isAppbarVisible: false), - ToDo(isShowAppBar: false), + MedicalProfilePageNew(onTap: (){ + changeCurrentTab(0); + },), + Search(onBackClick: (){ + changeCurrentTab(0); + },), + MyFamily( + isAppbarVisible: false, + onBackClick: () { + changeCurrentTab(0); + }, + ), + ToDo(isShowAppBar: true,onBackClick: (){ + changeCurrentTab(0); + },), ], // Please do not remove the BookingOptions from this array ), RobotIcon() @@ -645,7 +639,8 @@ class _LandingPageState extends State with WidgetsBindingObserver { elevation: true, onTap: () { changeCurrentTab(2); - }) + }, + ) : null); } diff --git a/lib/pages/medical/medical_profile_page_new.dart b/lib/pages/medical/medical_profile_page_new.dart index 97e1fe70..8f0bb0fc 100644 --- a/lib/pages/medical/medical_profile_page_new.dart +++ b/lib/pages/medical/medical_profile_page_new.dart @@ -1,4 +1,3 @@ - import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/medical_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; @@ -14,6 +13,9 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; class MedicalProfilePageNew extends StatefulWidget { + Function onTap; + String a; + MedicalProfilePageNew({this.onTap}); @override _MedicalProfilePageState createState() => _MedicalProfilePageState(); } @@ -30,12 +32,15 @@ class _MedicalProfilePageState extends State { List myMedicalList = Utils.myMedicalList(projectViewModel: projectViewModel, context: context, count: appoCountProvider.count, isLogin: projectViewModel.isLogin); return BaseView( onModelReady: (model) => model.getAppointmentHistory(), - builder: (_, model, widget) => AppScaffold( + builder: (_, model, widget1) => AppScaffold( isShowDecPage: false, isShowAppBar: false, baseViewModel: model, - showNewAppBar: false, + showNewAppBar: true, isHelp: true, + showNewAppBarTitle: true, + appBarTitle: TranslationBase.of(context).medicalFile, + onTap:widget.onTap, body: Container( child: SingleChildScrollView( child: Column( diff --git a/lib/pages/medical/my_trackers/Weight/WeightMonthlyPage.dart b/lib/pages/medical/my_trackers/Weight/WeightMonthlyPage.dart index 05485adf..ff5a707d 100644 --- a/lib/pages/medical/my_trackers/Weight/WeightMonthlyPage.dart +++ b/lib/pages/medical/my_trackers/Weight/WeightMonthlyPage.dart @@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart'; +import 'package:diplomaticquarterapp/widgets/charts/show_chart.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; @@ -42,6 +43,7 @@ class WeightMonthlyPage extends StatelessWidget { timeSeries: model.weighMonthTimeSeriesData.isEmpty ? [TimeSeriesSales3(0, 0.0)] : model.weighMonthTimeSeriesData, indexes: model.weighMonthTimeSeriesData.length ~/ 5.5, ), + ), Card( shape: cardRadius(12), diff --git a/lib/pages/medical/my_trackers/Weight/WeightWeeklyPage.dart b/lib/pages/medical/my_trackers/Weight/WeightWeeklyPage.dart index 2f3f7d0a..448d8809 100644 --- a/lib/pages/medical/my_trackers/Weight/WeightWeeklyPage.dart +++ b/lib/pages/medical/my_trackers/Weight/WeightWeeklyPage.dart @@ -7,6 +7,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart'; +import 'package:diplomaticquarterapp/widgets/charts/show_chart.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -44,10 +45,11 @@ class WeightWeeklyPage extends StatelessWidget { shape: cardRadius(12), elevation: 1, margin: EdgeInsets.only(left: 16, top: 16, right: 16, bottom: 8), - child: LineChartCurved( + child: ShowChart( title: TranslationBase.of(context).weight, timeSeries: model.weightWeekTimeSeriesData.isEmpty ? [TimeSeriesSales2(DateTime.now(), 0.0)] : model.weightWeekTimeSeriesData, indexes: model.weightWeekTimeSeriesData.length ~/ 5.5 ?? 0, + horizontalInterval: 2, ), ), Card( diff --git a/lib/pages/medical/my_trackers/Weight/WeightYeaPage.dart b/lib/pages/medical/my_trackers/Weight/WeightYeaPage.dart index 843e438b..efa3393d 100644 --- a/lib/pages/medical/my_trackers/Weight/WeightYeaPage.dart +++ b/lib/pages/medical/my_trackers/Weight/WeightYeaPage.dart @@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart'; +import 'package:diplomaticquarterapp/widgets/charts/show_chart.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; @@ -35,7 +36,7 @@ class WeightYearPage extends StatelessWidget { shape: cardRadius(12), elevation: 1, margin: EdgeInsets.only(left: 16, top: 16, right: 16, bottom: 8), - child: LineChartCurved( + child: ShowChart( horizontalInterval: 2.0, title: TranslationBase.of(context).weight, timeSeries: model.weightYearTimeSeriesData.isEmpty ? [TimeSeriesSales2(DateTime.now(), 0.0)] : model.weightYearTimeSeriesData, diff --git a/lib/pages/medical/vital_sign/LineChartCurved.dart b/lib/pages/medical/vital_sign/LineChartCurved.dart index f28c2801..12cfa026 100644 --- a/lib/pages/medical/vital_sign/LineChartCurved.dart +++ b/lib/pages/medical/vital_sign/LineChartCurved.dart @@ -9,8 +9,9 @@ class LineChartCurved extends StatelessWidget { final String title; final List timeSeries; final int indexes; + final double horizontalInterval; - LineChartCurved({this.title, this.timeSeries, this.indexes}); + LineChartCurved({this.title, this.timeSeries, this.indexes, this.horizontalInterval = 20.0}); List xAxixs = List(); List yAxixs = List(); @@ -166,8 +167,6 @@ class LineChartCurved extends StatelessWidget { ); } - - calculateMaxAndMin() { getMaxY(); getMaxX(); diff --git a/lib/pages/medical/vital_sign/vital_sing_chart_and_detials.dart b/lib/pages/medical/vital_sign/vital_sing_chart_and_detials.dart index 6bec6023..ea29909b 100644 --- a/lib/pages/medical/vital_sign/vital_sing_chart_and_detials.dart +++ b/lib/pages/medical/vital_sign/vital_sing_chart_and_detials.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart'; +import 'package:diplomaticquarterapp/widgets/charts/show_chart.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -52,10 +53,11 @@ class _VitalSingChartAndDetialsState extends State { shape: cardRadius(12), elevation: 1, margin: EdgeInsets.only(left: 16, top: 16, right: 16, bottom: 8), - child: LineChartCurved( + child: ShowChart( title: widget.name, timeSeries: timeSeriesData, indexes: timeSeriesData.length ~/ 5.5, + horizontalInterval: 8, ), ), Card( diff --git a/lib/widgets/charts/show_chart.dart b/lib/widgets/charts/show_chart.dart index ea0a8a9a..15e32a48 100644 --- a/lib/widgets/charts/show_chart.dart +++ b/lib/widgets/charts/show_chart.dart @@ -1,3 +1,4 @@ +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/charts/app_time_series_chart.dart'; import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; @@ -10,15 +11,26 @@ class ShowChart extends StatelessWidget { final int indexes; final double horizontalInterval; - ShowChart({this.title, this.timeSeries, this.indexes, this.horizontalInterval = 20.0}); + ShowChart({this.title, this.timeSeries, this.indexes, this.horizontalInterval = 8.0}); List xAxixs = List(); List yAxixs = List(); + double minY = 0; + double maxY = 0; + double intialY = 0; + double lastY = 0; + + double minX = 0; + double maxX = 0; + double increasingY = 0; + @override Widget build(BuildContext context) { getXaxix(); getYaxix(); + getInitialY(); + calculateMaxAndMin(); return AspectRatio( aspectRatio: 1.0, child: Container( @@ -31,17 +43,20 @@ class ShowChart extends StatelessWidget { Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - const SizedBox( - height: 4, - ), - Text( - title, - style: TextStyle(color: Colors.black, fontSize: 16, letterSpacing: -0.64, fontWeight: FontWeight.w600), - textAlign: TextAlign.center, - ), - SizedBox( - height: 10, + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(16.0), + child: Text( + title, + style: TextStyle(color: Colors.black, fontSize: 16, letterSpacing: -0.64, fontWeight: FontWeight.w600), + textAlign: TextAlign.center, + ), + ), + ], ), + mHeight(10), Expanded( child: Padding( padding: const EdgeInsets.only(right: 18.0, left: 16.0), @@ -72,91 +87,14 @@ class ShowChart extends StatelessWidget { } getYaxix() { - int indexess = (timeSeries.length * 0.30).toInt(); for (int index = 0; index < timeSeries.length; index++) { - int mIndex = indexess * index; + int mIndex = indexes * index; if (mIndex < timeSeries.length) { yAxixs.add(timeSeries[mIndex].sales); } } } - // LineChartData sampleData1(context) { - // return LineChartData( - // lineTouchData: LineTouchData( - // touchTooltipData: LineTouchTooltipData( - // tooltipBgColor: Colors.white, - // ), - // touchCallback: (LineTouchResponse touchResponse) {}, - // handleBuiltInTouches: true, - // ), - // gridData: FlGridData(show: true, drawVerticalLine: true, drawHorizontalLine: true, horizontalInterval: 14, verticalInterval: 14), - // titlesData: FlTitlesData( - // bottomTitles: SideTitles( - // showTitles: true, - // getTextStyles: (value) => const TextStyle( - // color: Colors.black, - // fontSize: 10, - // ), - // // rotateAngle: 90, - // //rotateAngle:-65, - // margin: 22, - // getTitles: (value) { - // if (timeSeries.length < 15) { - // if (timeSeries.length > value.toInt()) { - // return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}'; - // } else - // return ''; - // } else { - // if (value.toInt() == 0) return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}'; - // if (value.toInt() == timeSeries.length - 1) return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}'; - // if (xAxixs.contains(value.toInt())) { - // return '${timeSeries[value.toInt()].time.month}/ ${timeSeries[value.toInt()].time.year}'; - // } - // } - // return ''; - // }, - // ), - // leftTitles: SideTitles( - // showTitles: true, - // // interval:getMaxY() - getMinY() <=500?50:getMaxY() - getMinY() <=1000?100:200, - // interval: 3, - // getTextStyles: (value) => const TextStyle( - // color: Colors.black, - // fontWeight: FontWeight.bold, - // fontSize: 10, - // ), - // - // margin: 12, - // ), - // ), - // borderData: FlBorderData( - // show: true, - // border: const Border( - // bottom: BorderSide( - // color: Colors.black, - // width: 0.5, - // ), - // left: BorderSide( - // color: Colors.black, - // ), - // right: BorderSide( - // color: Colors.black, - // ), - // top: BorderSide( - // color: Colors.transparent, - // ), - // ), - // ), - // minX: 0, - // maxX: (timeSeries.length - 1).toDouble(), - // maxY: getMaxY() + 0.3, - // minY: 0, - // //getMinY(), - // lineBarsData: getData(context), - // ); - // } - LineChartData sampleData1(context) { return LineChartData( lineTouchData: LineTouchData( @@ -166,7 +104,7 @@ class ShowChart extends StatelessWidget { touchCallback: (LineTouchResponse touchResponse) {}, handleBuiltInTouches: true, ), - gridData: FlGridData(show: true, drawVerticalLine: true, drawHorizontalLine: true, horizontalInterval: 14, verticalInterval: 14), + gridData: FlGridData(show: true, drawVerticalLine: true, drawHorizontalLine: true, horizontalInterval: horizontalInterval, verticalInterval: horizontalInterval), titlesData: FlTitlesData( bottomTitles: SideTitles( showTitles: true, @@ -200,15 +138,6 @@ class ShowChart extends StatelessWidget { fontSize: 10, ), interval: 3.0, - // interval: getMaxY() - getMinY() <= 500 - // ? getMaxY() - getMinY() <= 50 - // ? 10 - // : 10 - // : getMaxY() - getMinY() <= 1000 - // ? 100 - // : getMaxY() - getMinY() >= 10000 - // ? 5000 - // : 200, margin: 12, ), ), @@ -230,32 +159,73 @@ class ShowChart extends StatelessWidget { ), ), ), - minX: 0, - maxX: (timeSeries.length - 1).toDouble(), - maxY: getMaxY() + 0.3, - minY: 0, - //getMinY(), + minX: minX, + maxX: maxX, + maxY: lastY + 1, + minY: intialY - 0.5, lineBarsData: getData(context), ); } + calculateMaxAndMin() { + getMaxY(); + getMaxX(); + getMin(); + getMinY(); + increasingY = ((maxY - minY) / timeSeries.length - 1) * 15; + maxY += increasingY.abs(); + minY -= increasingY.abs(); + } + double getMaxY() { - double max = 0; + maxY = 0; + timeSeries.forEach((element) { + double resultValueDouble = element.sales; + if (resultValueDouble > maxY) { + lastY = resultValueDouble; + maxY = resultValueDouble; + } + }); + print("maxY " + lastY.toString()); + return maxY.roundToDouble(); + } + + double getInitialY() { + try { + intialY = timeSeries.first.sales; + timeSeries.forEach((element) { + double resultValueDouble = element.sales; + if (resultValueDouble < intialY) intialY = resultValueDouble; + }); + } catch (e) { + intialY = 0; + } + + print("minY " + intialY.toString()); + return intialY.roundToDouble(); + } + + getMaxX() { + maxX = (timeSeries.length - 1).toDouble(); + } + + double getMin() { + minX = 0; timeSeries.forEach((element) { double resultValueDouble = element.sales; - if (resultValueDouble > max) max = resultValueDouble; + if (resultValueDouble < minX) minX = resultValueDouble; }); - return max.roundToDouble(); + return minX.roundToDouble(); } double getMinY() { - double min = timeSeries.isEmpty ? 0 : timeSeries.first.sales; + minY = 0; timeSeries.forEach((element) { double resultValueDouble = element.sales; - if (resultValueDouble < min) min = resultValueDouble; + if (resultValueDouble < minY) minY = resultValueDouble; }); - int value = min.toInt(); + int value = minY.toInt(); return value.toDouble(); } diff --git a/lib/widgets/data_display/medical/LabResult/FlowChartPage.dart b/lib/widgets/data_display/medical/LabResult/FlowChartPage.dart index 1a29856f..b1991f9f 100644 --- a/lib/widgets/data_display/medical/LabResult/FlowChartPage.dart +++ b/lib/widgets/data_display/medical/LabResult/FlowChartPage.dart @@ -1,6 +1,8 @@ import 'package:diplomaticquarterapp/core/model/labs/patient_lab_orders.dart'; import 'package:diplomaticquarterapp/core/viewModels/medical/labs_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; +import 'package:diplomaticquarterapp/widgets/charts/show_chart.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; @@ -25,7 +27,7 @@ class FlowChartPage extends StatelessWidget { baseViewModel: model, showNewAppBar: true, showNewAppBarTitle: true, - backgroundColor: Color(0xffF8F8F8), + backgroundColor: CustomColors.appBackgroudGrey2Color, body: SingleChildScrollView( child: model.labOrdersResultsList.isNotEmpty ? Column( @@ -51,9 +53,14 @@ class FlowChartPage extends StatelessWidget { ), ], ), - child: LineChartCurved( + // child: LineChartCurved( + // title: filterName, + // labResult: model.labOrdersResultsList, + // ), + child: ShowChart( title: filterName, - labResult: model.labOrdersResultsList, + timeSeries: model.timeSeries, + indexes: model.timeSeries.length ~/ 5.5 ?? 0, ), ), LabResultChartAndDetails( diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index b0316542..5d4e3704 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -55,10 +55,12 @@ class AppScaffold extends StatelessWidget { final int dropdownIndexValue; List dropDownList; final Function(int) dropDownIndexChange; + Function onTap; AuthenticatedUserObject authenticatedUserObject = locator(); AppBarWidget appBar; + AppScaffold({ @required this.body, this.appBarTitle = '', @@ -90,6 +92,7 @@ class AppScaffold extends StatelessWidget { this.dropDownList, this.dropdownIndexValue, this.dropDownIndexChange, + this.onTap, }); AppScaffold setOnAppBarCartClick(VoidCallback onClick) { @@ -114,7 +117,9 @@ class AppScaffold extends StatelessWidget { dropdownIndexValue: dropdownIndexValue, dropDownList: dropDownList ?? [], dropDownIndexChange: dropDownIndexChange, - appBarIcons: appBarIcons) + appBarIcons: appBarIcons, + onTap: onTap, + ) : (isShowAppBar ? appBar = AppBarWidget( appBarTitle: appBarTitle, @@ -167,7 +172,10 @@ class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { List dropDownList; final Function(int) dropDownIndexChange; final List appBarIcons; - NewAppBarWidget({Key key, this.showTitle = false, this.showDropDown = false, this.title = "", this.dropDownList, this.appBarIcons, this.dropdownIndexValue, this.dropDownIndexChange}) + Function onTap; + + NewAppBarWidget( + {Key key, this.showTitle = false, this.showDropDown = false, this.title = "", this.dropDownList, this.appBarIcons, this.dropdownIndexValue, this.dropDownIndexChange, this.onTap}) : super(key: key); @override @@ -180,7 +188,9 @@ class NewAppBarWidget extends StatelessWidget with PreferredSizeWidget { automaticallyImplyLeading: false, title: Row( children: [ - ArrowBack(), + ArrowBack( + onTap: onTap, + ), if (showTitle) Expanded( child: Text( @@ -274,6 +284,7 @@ String _badgeText = "0"; class AppBarWidgetState extends State { String badgeText = "0"; + @override Widget build(BuildContext context) { widget.badgeUpdater = badgeUpdateBlock; @@ -435,10 +446,10 @@ class _RobotIcon extends State { bottom: -15); } - // setAnimation() async { - // /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || - // // var animation = - // // IS_TEXT_COMPLETED == ? true : false; +// setAnimation() async { +// /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || +// // var animation = +// // IS_TEXT_COMPLETED == ? true : false; - // } +// } } diff --git a/lib/widgets/others/arrow_back.dart b/lib/widgets/others/arrow_back.dart index ff45083c..ebdd4877 100644 --- a/lib/widgets/others/arrow_back.dart +++ b/lib/widgets/others/arrow_back.dart @@ -5,7 +5,7 @@ import 'package:provider/provider.dart'; class ArrowBack extends StatelessWidget { final Function onTap; - ArrowBack({Key key, this.onTap}) : super(key: key); + ArrowBack({Key key, this.onTap,}) : super(key: key); @override Widget build(BuildContext context) {