From 7d3bfddd68f01936e9cfd29d2a2a90c15014ed8e Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Wed, 27 May 2020 13:15:25 +0300 Subject: [PATCH 01/12] update design my schedule and doctor replay --- ...list_doctor_working_hours_table_model.dart | 13 +- .../list_gt_my_pationents_question_model.dart | 6 +- lib/models/request_doctor_reply.dart | 6 +- lib/providers/doctor_reply_provider.dart | 8 +- lib/screens/QR_reader_screen.dart | 32 +--- lib/screens/doctor/doctor_reply_screen.dart | 81 +------- lib/screens/doctor/my_schedule_screen.dart | 42 +---- lib/util/helpers.dart | 148 +++++++++++++-- lib/widgets/doctor/doctor_reply_widget.dart | 177 ++++++++++++++++++ lib/widgets/doctor/my_schedule_widget.dart | 79 ++++++++ .../patients/profile/avatar_gradients.dart | 42 +++++ .../patients/profile/large_avatar.dart | 74 ++++++++ .../shared/card_with_bgNew_widget.dart | 26 +-- 13 files changed, 552 insertions(+), 182 deletions(-) create mode 100644 lib/widgets/doctor/doctor_reply_widget.dart create mode 100644 lib/widgets/doctor/my_schedule_widget.dart create mode 100644 lib/widgets/patients/profile/avatar_gradients.dart create mode 100644 lib/widgets/patients/profile/large_avatar.dart diff --git a/lib/models/list_doctor_working_hours_table_model.dart b/lib/models/list_doctor_working_hours_table_model.dart index d8ca8a04..cb103c8a 100644 --- a/lib/models/list_doctor_working_hours_table_model.dart +++ b/lib/models/list_doctor_working_hours_table_model.dart @@ -1,12 +1,14 @@ +import 'package:doctor_app_flutter/util/helpers.dart'; + class ListDoctorWorkingHoursTable { - String date; + DateTime date; String dayName; String workingHours; ListDoctorWorkingHoursTable({this.date, this.dayName, this.workingHours}); ListDoctorWorkingHoursTable.fromJson(Map json) { - date = json['Date'] ; + date = Helpers.convertStringToDate(json['Date']) ; dayName = json['DayName']; workingHours = json['WorkingHours']; } @@ -19,3 +21,10 @@ class ListDoctorWorkingHoursTable { return data; } } + +class WorkingHours { + String from; + String to; + WorkingHours({this.from,this.to}); + +} diff --git a/lib/models/list_gt_my_pationents_question_model.dart b/lib/models/list_gt_my_pationents_question_model.dart index 8e7eac9c..b743ade6 100644 --- a/lib/models/list_gt_my_pationents_question_model.dart +++ b/lib/models/list_gt_my_pationents_question_model.dart @@ -1,3 +1,5 @@ +import 'package:doctor_app_flutter/util/helpers.dart'; + class ListGtMyPatientsQuestions { String setupID; int projectID; @@ -6,7 +8,7 @@ class ListGtMyPatientsQuestions { int patientID; int doctorID; int requestType; - String requestDate; + DateTime requestDate; String requestTime; String remarks; int status; @@ -58,7 +60,7 @@ class ListGtMyPatientsQuestions { patientID = json['PatientID']; doctorID = json['DoctorID']; requestType = json['RequestType']; - requestDate = json['RequestDate']; + requestDate = Helpers.convertStringToDate(json['RequestDate']) ; requestTime = json['RequestTime']; remarks = json['Remarks']; status = json['Status']; diff --git a/lib/models/request_doctor_reply.dart b/lib/models/request_doctor_reply.dart index e93850a2..fbbe4697 100644 --- a/lib/models/request_doctor_reply.dart +++ b/lib/models/request_doctor_reply.dart @@ -15,15 +15,15 @@ class RequestDoctorReply { bool patientOutSA; RequestDoctorReply( - {this.projectID , - this.doctorID , + {this.projectID =15 , + this.doctorID =70907 , this.transactionNo = TRANSACTION_NO, this.languageID = LANGUAGE_ID, this.stamp = STAMP, this.iPAdress = IP_ADDRESS, this.versionID = VERSION_ID, this.channel = CHANNEL, - this.tokenID , + this.tokenID ='@dm!n' , this.sessionID = SESSION_ID, this.isLoginForDoctorApp = IS_LOGIN_FOR_DOCTOR_APP, this.patientOutSA = PATIENT_OUT_SA}); diff --git a/lib/providers/doctor_reply_provider.dart b/lib/providers/doctor_reply_provider.dart index d28d12cd..1d2add69 100644 --- a/lib/providers/doctor_reply_provider.dart +++ b/lib/providers/doctor_reply_provider.dart @@ -27,13 +27,13 @@ class DoctorReplyProvider with ChangeNotifier { } getDoctorReply() async { - const url = BASE_URL + 'DoctorApplication.svc/REST/GtMyPatientsQuestions'; + const url = 'https://hmgwebservices.com/Services/DoctorApplication.svc/REST/GtMyPatientsQuestions'; Map profile = await sharedPref.getObj(DOCTOR_PROFILE); String token = await sharedPref.getString(TOKEN); DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); - _requestDoctorReply.doctorID = doctorProfile.doctorID; - _requestDoctorReply.projectID = doctorProfile.projectID; - _requestDoctorReply.tokenID = token; +// _requestDoctorReply.doctorID = doctorProfile.doctorID; +// _requestDoctorReply.projectID = doctorProfile.projectID; +// _requestDoctorReply.tokenID = token; try { if (await Helpers.checkConnection()) { final response = await client.post(url, diff --git a/lib/screens/QR_reader_screen.dart b/lib/screens/QR_reader_screen.dart index 4750b38e..bbbe327a 100644 --- a/lib/screens/QR_reader_screen.dart +++ b/lib/screens/QR_reader_screen.dart @@ -108,28 +108,6 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); ], ), ):Container(), - Column( - children: patientList.map((item) { - return InkWell( - onTap: (){ - Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: { - "patient": item, - }); - }, - child: AnimatedContainer( - duration: Duration(milliseconds: 200), - child: CardWithBgWidget( - widget: Container( - child: AppText( - '${item.firstName} ${item.lastName}', - fontSize: 2.5 * SizeConfig.textMultiplier, - ), - ), - ), - ), - ); - }).toList() - ), ], ), @@ -172,11 +150,12 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); case "0": if (response['List_MyOutPatient'] != null) { setState(() { - patientList = ModelResponse - .fromJson(response['List_MyOutPatient']) - .list; + patientList = ModelResponse.fromJson(response['List_MyOutPatient']).list; isLoading = false; }); + Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: { + "patient": patientList[0], + }); } else { setState(() { isError = true; @@ -192,6 +171,9 @@ DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); isLoading = false; error = ""; }); + Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: { + "patient": patientList[0], + }); } else { setState(() { error = 'No patient'; diff --git a/lib/screens/doctor/doctor_reply_screen.dart b/lib/screens/doctor/doctor_reply_screen.dart index 9f73feea..73585593 100644 --- a/lib/screens/doctor/doctor_reply_screen.dart +++ b/lib/screens/doctor/doctor_reply_screen.dart @@ -1,11 +1,16 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/providers/doctor_reply_provider.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/doctor/doctor_reply_widget.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/large_avatar.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/card_with_bg_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; import 'package:provider/provider.dart'; @@ -40,81 +45,9 @@ class DoctorReplyScreen extends StatelessWidget { children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: _doctorReplyProvider.listDoctorWorkingHoursTable.map((reply) { - return CardWithBgWidget( - widget: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - reply.patientName, - fontSize: 2.5 * SizeConfig.textMultiplier, - ), - SizedBox( - height: 8, - ), - AppText( - reply.remarks, - fontSize: 2.5 * SizeConfig.textMultiplier, - ), - SizedBox( - height: 5, - ), - Row( - children: [ - AppText( - TranslationBase.of(context).time, - fontSize: 2.5 * SizeConfig.textMultiplier, - ), - Container( - margin: EdgeInsets.only(left: 10), - child: AppText( - reply.requestTime, - fontSize: 2.5 * SizeConfig.textMultiplier, - ), - ), - ], - ), - SizedBox( - height: 5, - ), - Row( - children: [ - AppText( - TranslationBase.of(context).fileNo, - fontSize: 2.5 * SizeConfig.textMultiplier, - ), - Container( - margin: EdgeInsets.only(left: 10), - child: AppText( - '${reply.patientID}', - fontSize: 2.5 * SizeConfig.textMultiplier, - ), - ), - ], - ), - SizedBox( - height: 5, - ), - Row( - children: [ - AppText( - TranslationBase.of(context).mobileNo, - fontSize: 2.5 * SizeConfig.textMultiplier, - ), - Container( - margin: EdgeInsets.only(left: 10), - child: AppText( - reply.mobileNumber, - fontSize: 2.5 * SizeConfig.textMultiplier, - ), - ), - ], - ), - ], - ), - ), - ); + return DoctorReplyWidget( reply: reply); }).toList(), ) ], diff --git a/lib/screens/doctor/my_schedule_screen.dart b/lib/screens/doctor/my_schedule_screen.dart index b9f60889..711e2642 100644 --- a/lib/screens/doctor/my_schedule_screen.dart +++ b/lib/screens/doctor/my_schedule_screen.dart @@ -1,6 +1,9 @@ import 'package:doctor_app_flutter/providers/schedule_provider.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/doctor/my_schedule_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -49,9 +52,7 @@ class MyScheduleScreen extends StatelessWidget { SizedBox( height: 20, ), - AppText(TranslationBase.of(context).mySchedule, - fontSize: - 2.5 * SizeConfig.textMultiplier), + scheduleListByDate(), // scheduleListByDate('Wednesday, 8 April '), ], @@ -74,40 +75,7 @@ class MyScheduleScreen extends StatelessWidget { Container( child: Column( children: scheduleProvider.listDoctorWorkingHoursTable.map((item) { - return CardWithBgWidget( - widget: Container( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText(item.dayName, - fontSize: 2.5 * SizeConfig.textMultiplier), - SizedBox( - height: 8, - ), - !item.workingHours.contains('and') - ? AppText(item.workingHours, - fontSize: 2.5 * SizeConfig.textMultiplier) - : Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - AppText( - item.workingHours.substring( - 0, item.workingHours.indexOf('a')), - fontSize: 2.5 * SizeConfig.textMultiplier), - AppText( - item.workingHours.substring( - item.workingHours.indexOf('d') + 2, - ), - fontSize: 2.5 * SizeConfig.textMultiplier), - ], - ), - SizedBox( - width: 8, - ) - ], - ), - ), - ); + return MyScheduleWidget(workingHoursTable: item,); }).toList(), ), ), diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index de75f0ec..45ad043d 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -1,3 +1,4 @@ +import 'package:doctor_app_flutter/models/list_doctor_working_hours_table_model.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -17,7 +18,8 @@ DrAppToastMsg toastMsg = DrAppToastMsg(); */ class Helpers { int cupertinoPickerIndex = 0; -/* + +/* *@author: Elham Rababah *@Date:12/4/2020 *@param: context, items, decKey, onSelectFun @@ -42,7 +44,8 @@ class Helpers { mainAxisAlignment: MainAxisAlignment.end, children: [ CupertinoButton( - child: Text('Cancel'.toUpperCase(), style: textStyle(context)), + child: Text('Cancel'.toUpperCase(), + style: textStyle(context)), onPressed: () { Navigator.pop(context); }, @@ -78,9 +81,9 @@ class Helpers { TextStyle textStyle(context) => TextStyle(color: Theme.of(context).primaryColor); -/* - *@author: Elham Rababah - *@Date:12/4/2020 +/* + *@author: Elham Rababah + *@Date:12/4/2020 *@param: context, List items, decKey, onSelectFun *@return: Container widget *@desc: buildPickerIterm this function will build the items of the cupertino @@ -88,7 +91,8 @@ class Helpers { buildPickerItems(context, List items, decKey, onSelectFun) { return CupertinoPicker( magnification: 1.5, - scrollController: FixedExtentScrollController(initialItem: cupertinoPickerIndex), + scrollController: + FixedExtentScrollController(initialItem: cupertinoPickerIndex), // backgroundColor: Colors.black87, children: items.map((item) { @@ -98,7 +102,8 @@ class Helpers { ); }).toList(), - itemExtent: 25, //height of each item + itemExtent: 25, + //height of each item looping: true, onSelectedItemChanged: (int index) { // selectitem =index; @@ -107,11 +112,11 @@ class Helpers { ); } -/* - *@author: Elham Rababah - *@Date:12/4/2020 +/* + *@author: Elham Rababah + *@Date:12/4/2020 *@param: msg - *@return: + *@return: *@desc: showErrorToast */ showErrorToast([msg = null]) { @@ -142,6 +147,127 @@ class Helpers { } } + /* + *@author: Mohammad Aljammal + *@Date:26/5/2020 + *@param: date in String formatted + *@return: DateTime + *@desc: convert String to DateTime + */ + static DateTime convertStringToDate(String date) { + const start = "/Date("; + const end = "+0300)"; + final startIndex = date.indexOf(start); + final endIndex = date.indexOf(end, startIndex + start.length); + return DateTime.fromMillisecondsSinceEpoch( + int.parse( + date.substring(startIndex + start.length, endIndex), + ), + ); + } + + /* + *@author: Mohammad Aljammal + *@Date:26/5/2020 + *@param: month in int formatted + *@return: DateTime + *@desc: convert month in int to month name + */ + static getMonth(int month) { + switch (month) { + case 1: + return "Jan"; + case 2: + return "Feb"; + case 3: + return "Mar"; + case 4: + return "Apr"; + case 5: + return "May"; + case 6: + return "Jun"; + case 7: + return "Jul"; + case 8: + return "Aug"; + case 9: + return "Sep"; + case 10: + return "Oct"; + case 11: + return "Nov"; + case 12: + return "Dec"; + } + } + + /* + *@author: Mohammad Aljammal + *@Date:26/5/2020 + *@param: week day in int formatted + *@return: DateTime + *@desc: convert week day in int to week day name + */ + static getWeekDay(int weekDay) { + switch (weekDay) { + case 1: + return "Monday"; + case 2: + return "Tuesday"; + case 3: + return "Wednesday"; + case 4: + return "Thursday"; + case 5: + return "Friday"; + case 6: + return "Saturday "; + case 7: + return "Sunday"; + } + } + /* + *@author: Mohammad Aljammal + *@Date:26/5/2020 + *@param: DateTime + *@return: data formatted like Apr 26,2020 + *@desc: convert DateTime to data formatted + */ + static String getDate(DateTime dateTime) { + print(dateTime); + if (dateTime != null) + return getMonth(dateTime.month) + + " " + + dateTime.day.toString() + + "," + + dateTime.year.toString(); + else + return ""; + } + + /* + *@author: Mohammad Aljammal + *@Date:26/5/2020 + *@param: String workingHours + *@return: List + *@desc: convert workingHours string to List + */ + static List getWorkingHours(String workingHours ){ + List myWorkingHours =[]; + List listOfHours = workingHours.split('a'); + + listOfHours.forEach((element) { + WorkingHours workingHours = WorkingHours(); + var from = element.substring(element.indexOf('m ') + 2 , element.indexOf('To')-2); + workingHours.from = from.trim(); + var to = element.substring(element.indexOf('To') + 2); + workingHours.to = to.trim(); + myWorkingHours.add(workingHours); + }); + return myWorkingHours; + } + /* *@author: Elham Rababah *@Date:12/5/2020 diff --git a/lib/widgets/doctor/doctor_reply_widget.dart b/lib/widgets/doctor/doctor_reply_widget.dart new file mode 100644 index 00000000..5ec30858 --- /dev/null +++ b/lib/widgets/doctor/doctor_reply_widget.dart @@ -0,0 +1,177 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/models/list_gt_my_pationents_question_model.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/large_avatar.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +class DoctorReplyWidget extends StatefulWidget { + final ListGtMyPatientsQuestions reply; + bool isShowMore = false; + + DoctorReplyWidget({Key key, this.reply}); + + @override + _DoctorReplyWidgetState createState() => _DoctorReplyWidgetState(); +} + +class _DoctorReplyWidgetState extends State { + @override + Widget build(BuildContext context) { + return Stack( + children: [ + Container( + margin: EdgeInsets.symmetric(vertical: 10.0), + width: double.infinity, + decoration: BoxDecoration( + color: Hexcolor('#FFFFFF'), + borderRadius: BorderRadius.all( + Radius.circular(20.0), + ), + ), + child: Container( + margin: EdgeInsets.all(5), + child: Column( + children: [ + SizedBox(height: 18,), + Container( + margin: EdgeInsets.only(right: 15), + child: Row( + children: [ + SizedBox(width: 5,), + LargeAvatar(name: widget.reply.patientName,url: '',), + SizedBox(width: 15,), + Expanded( + child: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + widget.reply.patientName, + fontSize: 1.5 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + SizedBox( + height: 5, + ), + + Row( + children: [ + AppText( + TranslationBase.of(context).fileNo, + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + Container( + margin: EdgeInsets.only(left: 5), + child: AppText( + '${widget.reply.patientID}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + SizedBox( + height: 5, + ), + Row( + children: [ + AppText( + TranslationBase.of(context).mobileNo, + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + Container( + margin: EdgeInsets.only(left: 5), + child: AppText( + widget.reply.mobileNumber, + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + SizedBox( + height: 5, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Container( + width: 70, + height: 20, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(60.0)), + color: Colors.green[600] + ), + child: Center( + child: AppText( + widget.reply.requestTime, + fontSize: 1.5 * SizeConfig.textMultiplier, + color: Colors.white, + ), + ), + ), + Container( + + child: AppText( + '${Helpers.getDate(widget.reply.requestDate)}', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ], + ), + + ], + ), + ), + ) + + ], + ), + ), + + !widget.isShowMore ? SizedBox(height: 18,) : + AnimatedContainer( + duration: Duration(milliseconds: 200), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Divider(color: Colors.grey), + SizedBox(height: 5,), + AppText( + widget.reply.remarks, + fontSize: 2.5 * SizeConfig.textMultiplier, + //fontWeight: FontWeight.bold, + ), + SizedBox(height: 10,) + ], + ), + ), + + ], + ), + ), + ), + Positioned( + right: 5, + top: 20, + child: InkWell( + onTap: (){ + setState(() { + widget.isShowMore = !widget.isShowMore; + }); + }, + child: Icon(widget.isShowMore? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down)), + ) + ], + + ); + } +} diff --git a/lib/widgets/doctor/my_schedule_widget.dart b/lib/widgets/doctor/my_schedule_widget.dart new file mode 100644 index 00000000..c37d09ad --- /dev/null +++ b/lib/widgets/doctor/my_schedule_widget.dart @@ -0,0 +1,79 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/models/list_doctor_working_hours_table_model.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class MyScheduleWidget extends StatelessWidget { + final ListDoctorWorkingHoursTable workingHoursTable; + + MyScheduleWidget({Key key, this.workingHoursTable}); + + @override + Widget build(BuildContext context) { + List workingHours = Helpers.getWorkingHours(workingHoursTable.workingHours); + return CardWithBgWidgetNew( + widget: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + AppText(workingHoursTable.dayName, + fontSize: 2.5 * SizeConfig.textMultiplier), + AppText( + ' ${workingHoursTable.date.day}/${workingHoursTable.date.month}/${workingHoursTable.date.year}', + fontSize: 2.2 * SizeConfig.textMultiplier,fontWeight: FontWeight.w300,), + ], + ), + SizedBox( + height: 8, + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: workingHours.map((work) { + return Container( + child: Column( + children: [ + Divider(color: Colors.grey), + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText('From',fontSize: 2.2 * SizeConfig.textMultiplier,fontWeight: FontWeight.bold,), + AppText(work.from,fontSize: 2.2 * SizeConfig.textMultiplier,fontWeight: FontWeight.w300,) + ], + ), + ), + Container(height: SizeConfig.realScreenWidth * 0.1 ,width: 0.8,color: Colors.grey, + margin: EdgeInsets.only(left: 15,right: 15),), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText('To',fontSize: 2.2 * SizeConfig.textMultiplier,fontWeight: FontWeight.bold,), + AppText(work.to,fontSize: 2.2 * SizeConfig.textMultiplier,fontWeight: FontWeight.w300,) + ], + ), + ), + ], + ) + + ], + ), + ); + }).toList(), + ), + SizedBox( + width: 8, + ) + ], + ), + ), + ); + } +} diff --git a/lib/widgets/patients/profile/avatar_gradients.dart b/lib/widgets/patients/profile/avatar_gradients.dart new file mode 100644 index 00000000..a6cce98d --- /dev/null +++ b/lib/widgets/patients/profile/avatar_gradients.dart @@ -0,0 +1,42 @@ +import 'package:flutter/material.dart'; + +class AvatarGradients{ + static List getGradients (String name) { + + int code = (name?.length ?? 0) > 0 ? name.toUpperCase()[0].codeUnits[0] : 1; + code += (name?.length ?? 0) > 1 ? name.toUpperCase()[1].codeUnits[0] : 0; + + List> colors = [ + [ + Color.fromRGBO(150, 222, 218, 1.0), + Color.fromRGBO(80, 201, 195, 1.0), + ], + [ + Color.fromRGBO(102, 126, 254, 1.0), + Color.fromRGBO(148, 75, 192, 1.0), + ], + [ + Color.fromRGBO(255, 177, 153, 1.0), + Color.fromRGBO(255, 8, 68, 1.0), + ], + [ + Color.fromRGBO(100, 210, 255, 1.0), + Color.fromRGBO(10, 60, 255, 1.0), + ], + [ + Color.fromRGBO(83, 120, 149, 1.0), + Color.fromRGBO(9, 32, 63, 1.0), + ], + [ + Color.fromRGBO(48, 210, 190, 1.0), + Color.fromRGBO(53, 132, 167, 1.0), + ], + [ + Color.fromRGBO(255, 179, 169, 1.0), + Color.fromRGBO(245, 103, 144, 1.0), + ] + ]; + + return colors[code % colors.length]; + } +} \ No newline at end of file diff --git a/lib/widgets/patients/profile/large_avatar.dart b/lib/widgets/patients/profile/large_avatar.dart new file mode 100644 index 00000000..ab28b9fe --- /dev/null +++ b/lib/widgets/patients/profile/large_avatar.dart @@ -0,0 +1,74 @@ +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import 'avatar_gradients.dart'; + +class LargeAvatar extends StatelessWidget { + LargeAvatar({Key key, this.name, this.url, this.disableProfileView: false}) + : super(key: key); + + final String name; + final String url; + final bool disableProfileView; + + Widget _getAvatar() { + if (url != null && url.isNotEmpty && Uri.parse(url).isAbsolute) { + return Center( + child: ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(60.0)), + child: Image.network( + url.trim(), + fit: BoxFit.cover, + width: 90.0, + height: 90.0, + ), + ), + ); + } else if (name == null || name.isEmpty) { + return Center( + child: AppText( + 'DR', + color: Colors.white, + )); + } else { + return Center( + child: AppText( + name[0].toUpperCase(), + color: Colors.white,fontSize: 18,fontWeight: FontWeight.bold, + )); + } + } + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: disableProfileView + ? null + : () { + //TODO when we need that + }, + child: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment(-1, -1), + end: Alignment(1, 1), + colors: [ + Colors.grey[100], + Colors.grey[800], + ] + ), + boxShadow: [ + BoxShadow( + color: Color.fromRGBO(0, 0, 0, 0.08), + offset: Offset(0.0, 5.0), + blurRadius: 16.0) + ], + borderRadius: BorderRadius.all(Radius.circular(50.0)), + ), + width: 90.0, + height: 90.0, + child: _getAvatar()), + ); + } +} diff --git a/lib/widgets/shared/card_with_bgNew_widget.dart b/lib/widgets/shared/card_with_bgNew_widget.dart index b4991736..de8c3e82 100644 --- a/lib/widgets/shared/card_with_bgNew_widget.dart +++ b/lib/widgets/shared/card_with_bgNew_widget.dart @@ -26,36 +26,14 @@ class CardWithBgWidgetNew extends StatelessWidget { width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.all( - Radius.circular(10.0), + Radius.circular(20.0), ), - // border: Border.all(color: Hexcolor('#707070'), width: 2.0), ), child: Material( - borderRadius: BorderRadius.all(Radius.circular(10.0)), + borderRadius: BorderRadius.all(Radius.circular(20.0)), color: Hexcolor('#FFFFFF'), child: Stack( children: [ - if (projectProvider.isArabic) - Positioned( - child: Container( - width: 10, - color: Hexcolor('#FFFFFF'), - - ), - bottom: 0, - top: 0, - right: 0, - ) - else - Positioned( - child: Container( - width: 10, - color: Hexcolor('#FFFFFF'), - ), - bottom: 0, - top: 0, - left: 0, - ), Container( padding: EdgeInsets.all(15.0), margin: EdgeInsets.only(left: 10), From 9aae4b8650d1b2900d2f2234f0eea73b506098a7 Mon Sep 17 00:00:00 2001 From: Amjad Amireh Date: Wed, 27 May 2020 13:16:55 +0300 Subject: [PATCH 02/12] amjad modified to expand list --- lib/routes.dart | 5 ++ .../patients/patient_search_screen.dart | 18 ++++ .../patients/patients_referred_screen.dart | 20 +++++ lib/screens/patients/patients_screen.dart | 8 +- lib/widgets/patients/list_item.dart | 87 +++++++++++++++++++ 5 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 lib/screens/patients/patients_referred_screen.dart create mode 100644 lib/widgets/patients/list_item.dart diff --git a/lib/routes.dart b/lib/routes.dart index f2f5f6bb..cb194c5b 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -1,3 +1,5 @@ + + import './screens/patients/profile/vital_sign/body_measurements_screen.dart'; import './screens/QR_reader_screen.dart'; @@ -13,6 +15,7 @@ import './screens/doctor/services_screen.dart'; import './screens/medicine/medicine_search_screen.dart'; import './screens/medicine/pharmacies_list_screen.dart'; import './screens/patients/patient_search_screen.dart'; +import './screens/patients/patients_referred_screen.dart'; import './screens/patients/patients_screen.dart'; import './screens/patients/profile/lab_result/lab_orders_screen.dart'; import './screens/patients/profile/patient_profile_screen.dart'; @@ -36,6 +39,7 @@ const String QR_READER = 'qr-reader'; const String PATIENT_SEARCH = 'patients/patient-search'; const String PATIENTS = 'patients/patients'; const String PATIENTS_PROFILE = 'patients/patients-profile'; +const String PATIENTS_REFERRED = 'patients/patients-referred'; const String BLOOD_BANK = 'blood-bank'; const String DOCTOR_REPLY = 'doctor-reply'; const String MEDICINE_SEARCH = 'medicine/medicine-search'; @@ -56,6 +60,7 @@ var routes = { PROFILE: (_) => ProfileScreen(), MY_SCHEDULE: (_) => MyScheduleScreen(), PATIENT_SEARCH: (_) => PatientSearchScreen(), + PATIENTS_REFERRED:(_)=>PatientReferredScreen(), PATIENTS: (_) => PatientsScreen(), QR_READER: (_) => QrReaderScreen(), BLOOD_BANK: (_) => BloodBankScreen(), diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index d5bfd7be..2eab35c1 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -58,7 +58,16 @@ class _PatientSearchScreenState extends State { PatientOutSA: false); void _validateInputs() async { + + if(_selectedType=='2') + { try { + + //==================== + //_selectedType=='3'? + //===================== + + Map profile = await sharedPref.getObj(DOCTOR_PROFILE); DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile); @@ -93,6 +102,15 @@ class _PatientSearchScreenState extends State { } catch (err) { handelCatchErrorCase(err); } + } + else + { + Navigator.of(context).pushNamed(PATIENTS_REFERRED, arguments: { + "patientSearchForm": _patientSearchFormValues, + "selectedType": _selectedType + }); + + } } handelCatchErrorCase(err) { diff --git a/lib/screens/patients/patients_referred_screen.dart b/lib/screens/patients/patients_referred_screen.dart new file mode 100644 index 00000000..c0ba5dfe --- /dev/null +++ b/lib/screens/patients/patients_referred_screen.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +class PatientReferredScreen extends StatefulWidget { + PatientReferredScreen({Key key}) : super(key: key); + + @override + _PatientReferredScreenState createState() => _PatientReferredScreenState(); +} + +class _PatientReferredScreenState extends State { + + String patientType; + String patientTypetitle; + @override + Widget build(BuildContext context) { + return Container( + child: Text("Refferrd Patiant"),//child, + ); + } +} \ No newline at end of file diff --git a/lib/screens/patients/patients_screen.dart b/lib/screens/patients/patients_screen.dart index 68f01fd8..d945e38d 100644 --- a/lib/screens/patients/patients_screen.dart +++ b/lib/screens/patients/patients_screen.dart @@ -374,8 +374,7 @@ class _PatientsScreenState extends State { .start, children: [ Image.network( - "https://p.kindpng.com/picc/s/404-4042774_profile-photo-circle-circle-profile-picture-png-transparent.png", - + "https://p.kindpng.com/picc/s/404-4042774_profile-photo-circle-circle-profile-picture-png-transparent.png", height: 100, width: 100), ], @@ -472,8 +471,9 @@ class _PatientsScreenState extends State { ), ), SizedBox( - width:60, - ), + width: + 60, + ), Container( child: AppText( diff --git a/lib/widgets/patients/list_item.dart b/lib/widgets/patients/list_item.dart new file mode 100644 index 00000000..d400d3c4 --- /dev/null +++ b/lib/widgets/patients/list_item.dart @@ -0,0 +1,87 @@ +/* + *@author: Amjad Amireh + *@Date:27/5/2020 + *@param: + *@return:Create Expand list with snakebar notification + + *@desc: + */ + + +import 'package:flutter/material.dart'; + +class ListItem extends StatefulWidget{ + + ListlistItems; + String headerTitle; + + ListItem(this.headerTitle,this.listItems); + + @override + StatecreateState() + { + return ListItemState(); + } +} +class ListItemState extends State +{ + bool isExpand=false; + @override + void initState() { + // TODO: implement initState + super.initState(); + isExpand=false; + } + @override + Widget build(BuildContext context) { + ListlistItem=this.widget.listItems; + return Padding( + padding: (isExpand==true)?const EdgeInsets.all(8.0):const EdgeInsets.all(12.0), + child: Container( + decoration:BoxDecoration( + color: Colors.white, + borderRadius: (isExpand!=true)?BorderRadius.all(Radius.circular(8)):BorderRadius.all(Radius.circular(22)), + border: Border.all(color: Colors.white) + ), + child: ExpansionTile( + key: PageStorageKey(this.widget.headerTitle), + title: Container( + width: double.infinity, + + child: Text(this.widget.headerTitle,style: TextStyle(fontSize: (isExpand!=true)?18:22),)), + trailing: (isExpand==true)?Icon(Icons.keyboard_arrow_up,size: 32,color: Colors.black,):Icon(Icons.keyboard_arrow_down,size: 32,color: Colors.black), + onExpansionChanged: (value){ + setState(() { + isExpand=value; + }); + }, + children: [ + for(final item in listItem) + Padding( + padding: const EdgeInsets.all(8.0), + child: InkWell( + onTap: (){ + Scaffold.of(context).showSnackBar(SnackBar(backgroundColor: Colors.black,duration:Duration(microseconds: 500),content: Text("Selected Item $item "+this.widget.headerTitle ))); + }, + child: Container( + width: double.infinity, + decoration:BoxDecoration( + color: Colors.grey, + borderRadius: BorderRadius.all(Radius.circular(4)), + border: Border.all(color: Colors.grey) + ), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text(item,style: TextStyle(color: Colors.white),), + )), + ), + ) + + + ], + + ), + ), + ); + } +} \ No newline at end of file From f41da183fb2c880e234d3163171b3d81a63065fc Mon Sep 17 00:00:00 2001 From: Amjad Amireh Date: Wed, 27 May 2020 14:47:39 +0300 Subject: [PATCH 03/12] fix --- lib/routes.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/routes.dart b/lib/routes.dart index 048f9ecd..9c87ff2f 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -1,11 +1,8 @@ -<<<<<<< HEAD -======= import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/screens/patients/profile/insurance_approvals_screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/patient_orders_screen.dart'; import 'package:doctor_app_flutter/screens/patients/profile/progress_note_screen.dart'; ->>>>>>> 7f5831335b1fac9625ba368a5bca916aaa9b9d74 import './screens/patients/profile/vital_sign/body_measurements_screen.dart'; From 64f13bf8a7e584c79588557806a0ad128d37fafd Mon Sep 17 00:00:00 2001 From: Amjad Amireh Date: Wed, 27 May 2020 16:16:25 +0300 Subject: [PATCH 04/12] checkDate (today tommorow ,next week) --- lib/util/helpers.dart | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index 45ad043d..b8e86e16 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -165,6 +165,37 @@ class Helpers { ), ); } + /* + *@author: Amjad Amireh + *@Date:5/5/2020 + *@param: checkDate + *@return: DateTime + *@desc: convert String to DateTime + */ +static String checkDate(String dateString) { + DateTime checkedTime = DateTime.parse(dateString); + DateTime currentTime = DateTime.now(); + + if ((currentTime.year == checkedTime.year) && + (currentTime.month == checkedTime.month) && + (currentTime.day == checkedTime.day)) { + return "Today"; + } else if ((currentTime.year == checkedTime.year) && + (currentTime.month == checkedTime.month)) { + if ((currentTime.day - checkedTime.day) == 1) { + return "YESTERDAY"; + } else if ((currentTime.day - checkedTime.day) == -1) { + return "Tomorrow"; + } + + if ((currentTime.day - checkedTime.day) <= -2) { + return "Next Week"; + } else { + return "Old Date"; + } + } + return "Old Date"; + } /* *@author: Mohammad Aljammal @@ -268,6 +299,9 @@ class Helpers { return myWorkingHours; } + + + /* *@author: Elham Rababah *@Date:12/5/2020 From be603839168f0d88b7c00189ef66ce854a92eabd Mon Sep 17 00:00:00 2001 From: Amjad Amireh Date: Thu, 28 May 2020 11:19:17 +0300 Subject: [PATCH 05/12] ListItem Expand --- .../patients/patient_search_screen.dart | 6 +- .../patients/patients_referred_screen.dart | 85 ++++++++++++++++++- lib/widgets/patients/list_item.dart | 34 ++++---- 3 files changed, 105 insertions(+), 20 deletions(-) diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index 8b6467b1..2c0963cd 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -58,8 +58,8 @@ class _PatientSearchScreenState extends State { PatientOutSA: false); void _validateInputs() async { - - if(_selectedType=='2') +print("============== _selectedType============"+ _selectedType); + if(_selectedType!='3') { try { @@ -102,7 +102,7 @@ class _PatientSearchScreenState extends State { } catch (err) { handelCatchErrorCase(err); } - } + } else { Navigator.of(context).pushNamed(PATIENTS_REFERRED, arguments: { diff --git a/lib/screens/patients/patients_referred_screen.dart b/lib/screens/patients/patients_referred_screen.dart index c0ba5dfe..9b03adcb 100644 --- a/lib/screens/patients/patients_referred_screen.dart +++ b/lib/screens/patients/patients_referred_screen.dart @@ -1,3 +1,12 @@ +/* + *@author: Amjad Amireh Modified Referred Patients + *@Date:27/5/2020 + + + *@desc: + */ +import 'package:doctor_app_flutter/widgets/patients/list_item.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; class PatientReferredScreen extends StatefulWidget { @@ -11,10 +20,82 @@ class _PatientReferredScreenState extends State { String patientType; String patientTypetitle; + + List>list_product; + @override + void initState() { + super.initState(); + list_product=new List(); + for(var k=1;k<=5;k++) + { + Map map=Map(); + map.putIfAbsent(getName(k), ()=>getContent()); + list_product.add(map); + + } + list_product.map((s){ + + }).map((list)=>list).toList();} + + + @override Widget build(BuildContext context) { - return Container( - child: Text("Refferrd Patiant"),//child, + + Listlist=List(); + + return AppScaffold( + appBarTitle: "My Referred Patients",//patientTypetitle, + body: Center( + + child: ListView( + children: [ + for(final map in list_product) + for(final keys in map.keys) + ListItem(keys,map[keys].toList()) + , + ], + ) + ), + ); } + + + String getName(int month) + { + switch(month) + { + case 1: + return "Mahmoud Shrouf"; + case 2: + return "Mahmoud Shrouf"; + case 3: + return "Mahmoud Shrouf"; + case 4: + return "Mahmoud Shrouf"; + case 5: + return "Mahmoud Shrouf"; + case 6: + return "Mahmoud Shrouf"; + case 7: + return "Mahmoud Shrouf"; + case 8: + return "Mahmoud Shrouf"; + case 9: + return "Mahmoud Shrouf"; + case 10: + return "Mahmoud Shrouf"; + case 11: + return "Mahmoud Shrouf"; + case 12: + return "Mahmoud Shrouf"; + } + } + + List getContent() + { + + return ["1","2","3","4","5","6"].toList(); + } } \ No newline at end of file diff --git a/lib/widgets/patients/list_item.dart b/lib/widgets/patients/list_item.dart index d400d3c4..069e2fa5 100644 --- a/lib/widgets/patients/list_item.dart +++ b/lib/widgets/patients/list_item.dart @@ -1,13 +1,11 @@ /* *@author: Amjad Amireh *@Date:27/5/2020 - *@param: - *@return:Create Expand list with snakebar notification + *@param:listItems , headerTitle + *@return:ListItem Expand *@desc: */ - - import 'package:flutter/material.dart'; class ListItem extends StatefulWidget{ @@ -28,7 +26,6 @@ class ListItemState extends State bool isExpand=false; @override void initState() { - // TODO: implement initState super.initState(); isExpand=false; } @@ -40,16 +37,21 @@ class ListItemState extends State child: Container( decoration:BoxDecoration( color: Colors.white, - borderRadius: (isExpand!=true)?BorderRadius.all(Radius.circular(8)):BorderRadius.all(Radius.circular(22)), - border: Border.all(color: Colors.white) + borderRadius: (isExpand!=true)?BorderRadius.all(Radius.circular(50)):BorderRadius.all(Radius.circular(25)), + + + + + ), child: ExpansionTile( key: PageStorageKey(this.widget.headerTitle), title: Container( width: double.infinity, - - child: Text(this.widget.headerTitle,style: TextStyle(fontSize: (isExpand!=true)?18:22),)), - trailing: (isExpand==true)?Icon(Icons.keyboard_arrow_up,size: 32,color: Colors.black,):Icon(Icons.keyboard_arrow_down,size: 32,color: Colors.black), + + child: Text(this.widget.headerTitle,style: TextStyle(fontSize: (isExpand!=true)?18:22,color: Colors.black,fontWeight: FontWeight.bold),)), + + trailing: (isExpand==true)?Icon(Icons.keyboard_arrow_up,color: Colors.black,):Icon(Icons.keyboard_arrow_down,color: Colors.black), onExpansionChanged: (value){ setState(() { isExpand=value; @@ -61,18 +63,20 @@ class ListItemState extends State padding: const EdgeInsets.all(8.0), child: InkWell( onTap: (){ - Scaffold.of(context).showSnackBar(SnackBar(backgroundColor: Colors.black,duration:Duration(microseconds: 500),content: Text("Selected Item $item "+this.widget.headerTitle ))); + print(Text("Selected Item $item "+this.widget.headerTitle )); + //========Stop Snak bar=========== Scaffold.of(context).showSnackBar(SnackBar(backgroundColor: Colors.black,duration:Duration(microseconds: 500),content: Text("Selected Item $item "+this.widget.headerTitle ))); }, child: Container( width: double.infinity, decoration:BoxDecoration( - color: Colors.grey, - borderRadius: BorderRadius.all(Radius.circular(4)), - border: Border.all(color: Colors.grey) + color: Colors.white, + + border: Border(top: BorderSide(color: Theme.of(context).dividerColor)) ), child: Padding( padding: const EdgeInsets.all(8.0), - child: Text(item,style: TextStyle(color: Colors.white),), + child: Text(item,style: TextStyle(color: Colors.black),), + )), ), ) From fff2b32deec48c0269843f79e8fa8511b9d0822b Mon Sep 17 00:00:00 2001 From: Amjad Amireh Date: Thu, 28 May 2020 12:31:09 +0300 Subject: [PATCH 06/12] ExpandableItem widget --- .../patients/patients_referred_screen.dart | 5 +- .../shared/expandable_item_widget.dart | 91 +++++++++++++++++++ 2 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 lib/widgets/shared/expandable_item_widget.dart diff --git a/lib/screens/patients/patients_referred_screen.dart b/lib/screens/patients/patients_referred_screen.dart index 9b03adcb..70a84f03 100644 --- a/lib/screens/patients/patients_referred_screen.dart +++ b/lib/screens/patients/patients_referred_screen.dart @@ -5,8 +5,9 @@ *@desc: */ -import 'package:doctor_app_flutter/widgets/patients/list_item.dart'; + import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/expandable_item_widget.dart'; import 'package:flutter/material.dart'; class PatientReferredScreen extends StatefulWidget { @@ -52,7 +53,7 @@ class _PatientReferredScreenState extends State { children: [ for(final map in list_product) for(final keys in map.keys) - ListItem(keys,map[keys].toList()) + ExpandableItem(keys,map[keys].toList()) , ], ) diff --git a/lib/widgets/shared/expandable_item_widget.dart b/lib/widgets/shared/expandable_item_widget.dart new file mode 100644 index 00000000..d369e72a --- /dev/null +++ b/lib/widgets/shared/expandable_item_widget.dart @@ -0,0 +1,91 @@ +/* + *@author: Amjad Amireh + *@Date:27/5/2020 + *@param:listItems , headerTitle + *@return:ListItem Expand + + *@desc: + */ +import 'package:flutter/material.dart'; + +class ExpandableItem extends StatefulWidget{ + + final ListlistItems; + final String headerTitle; + + ExpandableItem(this.headerTitle,this.listItems); + + @override + _ExpandableItemState createState() => _ExpandableItemState(); + +} +class _ExpandableItemState extends State +{ + bool isExpand=false; + @override + void initState() { + super.initState(); + isExpand=false; + } + @override + Widget build(BuildContext context) { + ListlistItem=this.widget.listItems; + return Container( + child: Padding( + padding: (isExpand==true)?const EdgeInsets.all(6.0):const EdgeInsets.all(8.0), + child: Container( + decoration:BoxDecoration( + color: Colors.white, + borderRadius: (isExpand!=true)?BorderRadius.all(Radius.circular(50)):BorderRadius.all(Radius.circular(25)), + + + + + + ), + child: ExpansionTile( + key: PageStorageKey(this.widget.headerTitle), + title: Container( + width: double.infinity, + + child: Text(this.widget.headerTitle,style: TextStyle(fontSize: (isExpand!=true)?18:22,color: Colors.black,fontWeight: FontWeight.bold),)), + + trailing: (isExpand==true)?Icon(Icons.keyboard_arrow_up,color: Colors.black,):Icon(Icons.keyboard_arrow_down,color: Colors.black), + onExpansionChanged: (value){ + setState(() { + isExpand=value; + }); + }, + children: [ + for(final item in listItem) + Padding( + padding: const EdgeInsets.all(8.0), + child: InkWell( + onTap: (){ + print(Text("Selected Item $item "+this.widget.headerTitle )); + //========Stop Snak bar=========== Scaffold.of(context).showSnackBar(SnackBar(backgroundColor: Colors.black,duration:Duration(microseconds: 500),content: Text("Selected Item $item "+this.widget.headerTitle ))); + }, + child: Container( + width: double.infinity, + decoration:BoxDecoration( + color: Colors.white, + + border: Border(top: BorderSide(color: Theme.of(context).dividerColor)) + ), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Text(item,style: TextStyle(color: Colors.black),), + + )), + ), + ) + + + ], + + ), + ), + ), + ); + } +} \ No newline at end of file From 903eaba132fab844ec8bdd4ee0e60f288293fc0a Mon Sep 17 00:00:00 2001 From: Amjad Amireh Date: Thu, 28 May 2020 12:34:10 +0300 Subject: [PATCH 07/12] deete --- lib/widgets/patients/list_item.dart | 91 ----------------------------- 1 file changed, 91 deletions(-) delete mode 100644 lib/widgets/patients/list_item.dart diff --git a/lib/widgets/patients/list_item.dart b/lib/widgets/patients/list_item.dart deleted file mode 100644 index 069e2fa5..00000000 --- a/lib/widgets/patients/list_item.dart +++ /dev/null @@ -1,91 +0,0 @@ -/* - *@author: Amjad Amireh - *@Date:27/5/2020 - *@param:listItems , headerTitle - *@return:ListItem Expand - - *@desc: - */ -import 'package:flutter/material.dart'; - -class ListItem extends StatefulWidget{ - - ListlistItems; - String headerTitle; - - ListItem(this.headerTitle,this.listItems); - - @override - StatecreateState() - { - return ListItemState(); - } -} -class ListItemState extends State -{ - bool isExpand=false; - @override - void initState() { - super.initState(); - isExpand=false; - } - @override - Widget build(BuildContext context) { - ListlistItem=this.widget.listItems; - return Padding( - padding: (isExpand==true)?const EdgeInsets.all(8.0):const EdgeInsets.all(12.0), - child: Container( - decoration:BoxDecoration( - color: Colors.white, - borderRadius: (isExpand!=true)?BorderRadius.all(Radius.circular(50)):BorderRadius.all(Radius.circular(25)), - - - - - - ), - child: ExpansionTile( - key: PageStorageKey(this.widget.headerTitle), - title: Container( - width: double.infinity, - - child: Text(this.widget.headerTitle,style: TextStyle(fontSize: (isExpand!=true)?18:22,color: Colors.black,fontWeight: FontWeight.bold),)), - - trailing: (isExpand==true)?Icon(Icons.keyboard_arrow_up,color: Colors.black,):Icon(Icons.keyboard_arrow_down,color: Colors.black), - onExpansionChanged: (value){ - setState(() { - isExpand=value; - }); - }, - children: [ - for(final item in listItem) - Padding( - padding: const EdgeInsets.all(8.0), - child: InkWell( - onTap: (){ - print(Text("Selected Item $item "+this.widget.headerTitle )); - //========Stop Snak bar=========== Scaffold.of(context).showSnackBar(SnackBar(backgroundColor: Colors.black,duration:Duration(microseconds: 500),content: Text("Selected Item $item "+this.widget.headerTitle ))); - }, - child: Container( - width: double.infinity, - decoration:BoxDecoration( - color: Colors.white, - - border: Border(top: BorderSide(color: Theme.of(context).dividerColor)) - ), - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Text(item,style: TextStyle(color: Colors.black),), - - )), - ), - ) - - - ], - - ), - ), - ); - } -} \ No newline at end of file From 9572e166274de2137720fadf621db19bc45b1e49 Mon Sep 17 00:00:00 2001 From: Mohammad ALjammal Date: Thu, 28 May 2020 13:50:53 +0300 Subject: [PATCH 08/12] done My Referral Patient and create Base App Client --- lib/client/base_app_client.dart | 61 ++++ lib/config/config.dart | 2 +- lib/main.dart | 4 +- lib/models/my_referral_patient_model.dart | 210 +++++++++++ .../request_add_referred_doctor_remarks.dart | 78 ++++ lib/models/request_doctor_reply.dart | 24 +- .../request_my_referral_patient_model.dart | 94 +++++ lib/models/request_schedule.dart | 30 +- lib/providers/doctor_reply_provider.dart | 59 +-- lib/providers/referral_patient_provider.dart | 74 ++++ lib/providers/schedule_provider.dart | 61 +--- lib/screens/dashboard_screen.dart | 27 +- .../doctor/my_referral_patient_screen.dart | 65 ++++ lib/screens/doctor/my_schedule_screen.dart | 7 - lib/util/helpers.dart | 18 + .../doctor/my_referral_patient_widget.dart | 342 ++++++++++++++++++ lib/widgets/shared/Text.dart | 239 ++++++++++++ lib/widgets/shared/TextFields.dart | 185 ++++++++++ lib/widgets/shared/app_button.dart | 7 +- pubspec.lock | 7 + pubspec.yaml | 1 + 21 files changed, 1461 insertions(+), 134 deletions(-) create mode 100644 lib/client/base_app_client.dart create mode 100644 lib/models/my_referral_patient_model.dart create mode 100644 lib/models/request_add_referred_doctor_remarks.dart create mode 100644 lib/models/request_my_referral_patient_model.dart create mode 100644 lib/providers/referral_patient_provider.dart create mode 100644 lib/screens/doctor/my_referral_patient_screen.dart create mode 100644 lib/widgets/doctor/my_referral_patient_widget.dart create mode 100644 lib/widgets/shared/Text.dart create mode 100644 lib/widgets/shared/TextFields.dart diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart new file mode 100644 index 00000000..fa377b90 --- /dev/null +++ b/lib/client/base_app_client.dart @@ -0,0 +1,61 @@ +import 'dart:convert'; + +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; +import 'package:doctor_app_flutter/interceptor/http_interceptor.dart'; +import 'package:doctor_app_flutter/models/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:http/http.dart'; + +class BaseAppClient { + static Client client = HttpInterceptor().getClient(); + + static post( + String endPoint, { + Map body, + Function(dynamic response, int statusCode) onSuccess, + Function(String error, int statusCode) onFailure, + }) async { + String url = BASE_URL + endPoint; + try { + Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + String token = await sharedPref.getString(TOKEN); + DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); + body.containsKey(''); + body['DoctorID'] = doctorProfile.doctorID; + body['EditedBy'] = doctorProfile.doctorID; + body['ProjectID'] = doctorProfile.projectID; + body['ClinicID'] = doctorProfile.clinicID; + body['TokenID'] = token; + body['LanguageID'] = LANGUAGE_ID; + body['stamp'] = STAMP; + body['IPAdress'] = IP_ADDRESS; + body['VersionID'] = VERSION_ID; + body['Channel'] = CHANNEL; + body['SessionID'] = SESSION_ID; + body['IsLoginForDoctorApp'] = IS_LOGIN_FOR_DOCTOR_APP; + body['PatientOutSA'] = PATIENT_OUT_SA; + + if (await Helpers.checkConnection()) { + final response = await client.post(url, body: json.encode(body)); + final int statusCode = response.statusCode; + if (statusCode < 200 || statusCode >= 400 || json == null) { + onFailure('Error While Fetching data', statusCode); + } else { + var parsed = json.decode(response.body.toString()); + if (parsed['MessageStatus'] == 1) { + onSuccess(parsed, statusCode); + } else { + onFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], + statusCode); + } + } + } else { + onFailure('Please Check The Internet Connection', -1); + } + } catch (e) { + print(e); + onFailure(e.toString(), -1); + } + } +} diff --git a/lib/config/config.dart b/lib/config/config.dart index 8ebef939..24c2586a 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -58,6 +58,6 @@ const STAMP = '2020-04-27T12:17:17.721Z'; const IP_ADDRESS = '11.11.11.11'; const VERSION_ID = 1.2; const CHANNEL = 9; -const SESSION_ID = '2Z7FX4Lokp'; +const SESSION_ID = 'BlUSkYymTt'; const IS_LOGIN_FOR_DOCTOR_APP = true; const PATIENT_OUT_SA = false; diff --git a/lib/main.dart b/lib/main.dart index 869d0b88..98331b4a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -43,10 +43,12 @@ class MyApp extends StatelessWidget { const Locale('en', ''), // English ], theme: ThemeData( - primarySwatch: Colors.blue, + primarySwatch: Colors.grey, primaryColor: Hexcolor('#B8382C'), buttonColor: Hexcolor('#B8382C'), fontFamily: 'WorkSans', + dividerColor: Colors.grey[200], + backgroundColor: Color.fromRGBO(255,255,255, 1) ), initialRoute: INIT_ROUTE, routes: routes, diff --git a/lib/models/my_referral_patient_model.dart b/lib/models/my_referral_patient_model.dart new file mode 100644 index 00000000..e18dd546 --- /dev/null +++ b/lib/models/my_referral_patient_model.dart @@ -0,0 +1,210 @@ +import 'package:doctor_app_flutter/util/helpers.dart'; + +class MyReferralPatientModel { + int projectID; + int lineItemNo; + int doctorID; + int patientID; + String doctorName; + String doctorNameN; + String firstName; + String middleName; + String lastName; + String firstNameN; + String middleNameN; + String lastNameN; + int gender; + String dateofBirth; + String mobileNumber; + String emailAddress; + String patientIdentificationNo; + int patientType; + String admissionNo; + String admissionDate; + String roomID; + String bedID; + String nursingStationID; + String description; + String nationalityName; + String nationalityNameN; + String clinicDescription; + String clinicDescriptionN; + int referralDoctor; + int referringDoctor; + int referralClinic; + int referringClinic; + int referralStatus; + String referralDate; + String referringDoctorRemarks; + String referredDoctorRemarks; + String referralResponseOn; + int priority; + int frequency; + DateTime mAXResponseTime; + String age; + String frequencyDescription; + String genderDescription; + bool isDoctorLate; + bool isDoctorResponse; + String nursingStationName; + String priorityDescription; + String referringClinicDescription; + String referringDoctorName; + + MyReferralPatientModel( + {this.projectID, + this.lineItemNo, + this.doctorID, + this.patientID, + this.doctorName, + this.doctorNameN, + this.firstName, + this.middleName, + this.lastName, + this.firstNameN, + this.middleNameN, + this.lastNameN, + this.gender, + this.dateofBirth, + this.mobileNumber, + this.emailAddress, + this.patientIdentificationNo, + this.patientType, + this.admissionNo, + this.admissionDate, + this.roomID, + this.bedID, + this.nursingStationID, + this.description, + this.nationalityName, + this.nationalityNameN, + this.clinicDescription, + this.clinicDescriptionN, + this.referralDoctor, + this.referringDoctor, + this.referralClinic, + this.referringClinic, + this.referralStatus, + this.referralDate, + this.referringDoctorRemarks, + this.referredDoctorRemarks, + this.referralResponseOn, + this.priority, + this.frequency, + this.mAXResponseTime, + this.age, + this.frequencyDescription, + this.genderDescription, + this.isDoctorLate, + this.isDoctorResponse, + this.nursingStationName, + this.priorityDescription, + this.referringClinicDescription, + this.referringDoctorName}); + + MyReferralPatientModel.fromJson(Map json) { + projectID = json['ProjectID']; + lineItemNo = json['LineItemNo']; + doctorID = json['DoctorID']; + patientID = json['PatientID']; + doctorName = json['DoctorName']; + doctorNameN = json['DoctorNameN']; + firstName = json['FirstName']; + middleName = json['MiddleName']; + lastName = json['LastName']; + firstNameN = json['FirstNameN']; + middleNameN = json['MiddleNameN']; + lastNameN = json['LastNameN']; + gender = json['Gender']; + dateofBirth = json['DateofBirth']; + mobileNumber = json['MobileNumber']; + emailAddress = json['EmailAddress']; + patientIdentificationNo = json['PatientIdentificationNo']; + patientType = json['PatientType']; + admissionNo = json['AdmissionNo']; + admissionDate = json['AdmissionDate']; + roomID = json['RoomID']; + bedID = json['BedID']; + nursingStationID = json['NursingStationID']; + description = json['Description']; + nationalityName = json['NationalityName']; + nationalityNameN = json['NationalityNameN']; + clinicDescription = json['ClinicDescription']; + clinicDescriptionN = json['ClinicDescriptionN']; + referralDoctor = json['ReferralDoctor']; + referringDoctor = json['ReferringDoctor']; + referralClinic = json['ReferralClinic']; + referringClinic = json['ReferringClinic']; + referralStatus = json['ReferralStatus']; + referralDate = json['ReferralDate']; + referringDoctorRemarks = json['ReferringDoctorRemarks']; + referredDoctorRemarks = json['ReferredDoctorRemarks']; + referralResponseOn = json['ReferralResponseOn']; + priority = json['Priority']; + frequency = json['Frequency']; + mAXResponseTime = Helpers.convertStringToDate(json['MAXResponseTime']); + age = json['Age']; + frequencyDescription = json['FrequencyDescription']; + genderDescription = json['GenderDescription']; + isDoctorLate = json['IsDoctorLate']; + isDoctorResponse = json['IsDoctorResponse']; + nursingStationName = json['NursingStationName']; + priorityDescription = json['PriorityDescription']; + referringClinicDescription = json['ReferringClinicDescription']; + referringDoctorName = json['ReferringDoctorName']; + } + + Map toJson() { + final Map data = new Map(); + data['ProjectID'] = this.projectID; + data['LineItemNo'] = this.lineItemNo; + data['DoctorID'] = this.doctorID; + data['PatientID'] = this.patientID; + data['DoctorName'] = this.doctorName; + data['DoctorNameN'] = this.doctorNameN; + data['FirstName'] = this.firstName; + data['MiddleName'] = this.middleName; + data['LastName'] = this.lastName; + data['FirstNameN'] = this.firstNameN; + data['MiddleNameN'] = this.middleNameN; + data['LastNameN'] = this.lastNameN; + data['Gender'] = this.gender; + data['DateofBirth'] = this.dateofBirth; + data['MobileNumber'] = this.mobileNumber; + data['EmailAddress'] = this.emailAddress; + data['PatientIdentificationNo'] = this.patientIdentificationNo; + data['PatientType'] = this.patientType; + data['AdmissionNo'] = this.admissionNo; + data['AdmissionDate'] = this.admissionDate; + data['RoomID'] = this.roomID; + data['BedID'] = this.bedID; + data['NursingStationID'] = this.nursingStationID; + data['Description'] = this.description; + data['NationalityName'] = this.nationalityName; + data['NationalityNameN'] = this.nationalityNameN; + data['ClinicDescription'] = this.clinicDescription; + data['ClinicDescriptionN'] = this.clinicDescriptionN; + data['ReferralDoctor'] = this.referralDoctor; + data['ReferringDoctor'] = this.referringDoctor; + data['ReferralClinic'] = this.referralClinic; + data['ReferringClinic'] = this.referringClinic; + data['ReferralStatus'] = this.referralStatus; + data['ReferralDate'] = this.referralDate; + data['ReferringDoctorRemarks'] = this.referringDoctorRemarks; + data['ReferredDoctorRemarks'] = this.referredDoctorRemarks; + data['ReferralResponseOn'] = this.referralResponseOn; + data['Priority'] = this.priority; + data['Frequency'] = this.frequency; + data['MAXResponseTime'] = this.mAXResponseTime; + data['Age'] = this.age; + data['FrequencyDescription'] = this.frequencyDescription; + data['GenderDescription'] = this.genderDescription; + data['IsDoctorLate'] = this.isDoctorLate; + data['IsDoctorResponse'] = this.isDoctorResponse; + data['NursingStationName'] = this.nursingStationName; + data['PriorityDescription'] = this.priorityDescription; + data['ReferringClinicDescription'] = this.referringClinicDescription; + data['ReferringDoctorName'] = this.referringDoctorName; + return data; + } +} diff --git a/lib/models/request_add_referred_doctor_remarks.dart b/lib/models/request_add_referred_doctor_remarks.dart new file mode 100644 index 00000000..0799c7ba --- /dev/null +++ b/lib/models/request_add_referred_doctor_remarks.dart @@ -0,0 +1,78 @@ +import 'package:doctor_app_flutter/config/config.dart'; + +class RequestAddReferredDoctorRemarks { + int projectID; + String admissionNo; + int lineItemNo; + String referredDoctorRemarks; + int editedBy; + int patientID; + int referringDoctor; + int languageID; + String stamp; + String iPAdress; + double versionID; + int channel; + String tokenID; + String sessionID; + bool isLoginForDoctorApp; + bool patientOutSA; + + RequestAddReferredDoctorRemarks( + {this.projectID, + this.admissionNo, + this.lineItemNo, + this.referredDoctorRemarks, + this.editedBy, + this.patientID, + this.referringDoctor, + this.languageID = LANGUAGE_ID, + this.stamp = STAMP, + this.iPAdress = IP_ADDRESS, + this.versionID = VERSION_ID, + this.channel= CHANNEL, + this.tokenID, + this.sessionID = SESSION_ID, + this.isLoginForDoctorApp = IS_LOGIN_FOR_DOCTOR_APP, + this.patientOutSA = PATIENT_OUT_SA}); + + RequestAddReferredDoctorRemarks.fromJson(Map json) { + projectID = json['ProjectID']; + admissionNo = json['AdmissionNo']; + lineItemNo = json['LineItemNo']; + referredDoctorRemarks = json['ReferredDoctorRemarks']; + editedBy = json['EditedBy']; + patientID = json['PatientID']; + referringDoctor = json['ReferringDoctor']; + languageID = json['LanguageID']; + stamp = json['stamp']; + iPAdress = json['IPAdress']; + versionID = json['VersionID']; + channel = json['Channel']; + tokenID = json['TokenID']; + sessionID = json['SessionID']; + isLoginForDoctorApp = json['IsLoginForDoctorApp']; + patientOutSA = json['PatientOutSA']; + } + + Map toJson() { + final Map data = new Map(); + data['ProjectID'] = this.projectID; + data['AdmissionNo'] = this.admissionNo; + data['LineItemNo'] = this.lineItemNo; + data['ReferredDoctorRemarks'] = this.referredDoctorRemarks; + data['EditedBy'] = this.editedBy; + data['PatientID'] = this.patientID; + data['ReferringDoctor'] = this.referringDoctor; + data['LanguageID'] = this.languageID; + data['stamp'] = this.stamp; + data['IPAdress'] = this.iPAdress; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['TokenID'] = this.tokenID; + data['SessionID'] = this.sessionID; + data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; + data['PatientOutSA'] = this.patientOutSA; + return data; + } +} diff --git a/lib/models/request_doctor_reply.dart b/lib/models/request_doctor_reply.dart index fbbe4697..707336d6 100644 --- a/lib/models/request_doctor_reply.dart +++ b/lib/models/request_doctor_reply.dart @@ -15,18 +15,18 @@ class RequestDoctorReply { bool patientOutSA; RequestDoctorReply( - {this.projectID =15 , - this.doctorID =70907 , - this.transactionNo = TRANSACTION_NO, - this.languageID = LANGUAGE_ID, - this.stamp = STAMP, - this.iPAdress = IP_ADDRESS, - this.versionID = VERSION_ID, - this.channel = CHANNEL, - this.tokenID ='@dm!n' , - this.sessionID = SESSION_ID, - this.isLoginForDoctorApp = IS_LOGIN_FOR_DOCTOR_APP, - this.patientOutSA = PATIENT_OUT_SA}); + {this.projectID , + this.doctorID , + this.transactionNo = TRANSACTION_NO , + this.languageID , + this.stamp , + this.iPAdress, + this.versionID , + this.channel, + this.tokenID , + this.sessionID, + this.isLoginForDoctorApp , + this.patientOutSA }); RequestDoctorReply.fromJson(Map json) { projectID = json['ProjectID']; diff --git a/lib/models/request_my_referral_patient_model.dart b/lib/models/request_my_referral_patient_model.dart new file mode 100644 index 00000000..adaf9e5c --- /dev/null +++ b/lib/models/request_my_referral_patient_model.dart @@ -0,0 +1,94 @@ +import 'package:doctor_app_flutter/config/config.dart'; + +class RequestMyReferralPatientModel { + int projectID; + int clinicID; + int doctorID; + String firstName; + String middleName; + String lastName; + String patientMobileNumber; + String patientIdentificationID; + int patientID; + String from; + String to; + int languageID; + String stamp; + String iPAdress; + double versionID; + int channel; + String tokenID; + String sessionID; + bool isLoginForDoctorApp; + bool patientOutSA; + + RequestMyReferralPatientModel( + {this.projectID, + this.clinicID, + this.doctorID, + this.firstName = "0", + this.middleName = "0", + this.lastName = "0", + this.patientMobileNumber = "0", + this.patientIdentificationID = "0", + this.patientID = 0, + this.from = "0", + this.to = "0", + this.languageID , + this.stamp , + this.iPAdress , + this.versionID , + this.channel , + this.tokenID, + this.sessionID , + this.isLoginForDoctorApp , + this.patientOutSA }); + + RequestMyReferralPatientModel.fromJson(Map json) { + projectID = json['ProjectID']; + clinicID = json['ClinicID']; + doctorID = json['DoctorID']; + firstName = json['FirstName']; + middleName = json['MiddleName']; + lastName = json['LastName']; + patientMobileNumber = json['PatientMobileNumber']; + patientIdentificationID = json['PatientIdentificationID']; + patientID = json['PatientID']; + from = json['From']; + to = json['To']; + languageID = json['LanguageID']; + stamp = json['stamp']; + iPAdress = json['IPAdress']; + versionID = json['VersionID']; + channel = json['Channel']; + tokenID = json['TokenID']; + sessionID = json['SessionID']; + isLoginForDoctorApp = json['IsLoginForDoctorApp']; + patientOutSA = json['PatientOutSA']; + } + + Map toJson() { + final Map data = new Map(); + data['ProjectID'] = this.projectID; + data['ClinicID'] = this.clinicID; + data['DoctorID'] = this.doctorID; + data['FirstName'] = this.firstName; + data['MiddleName'] = this.middleName; + data['LastName'] = this.lastName; + data['PatientMobileNumber'] = this.patientMobileNumber; + data['PatientIdentificationID'] = this.patientIdentificationID; + data['PatientID'] = this.patientID; + data['From'] = this.from; + data['To'] = this.to; + data['LanguageID'] = this.languageID; + data['stamp'] = this.stamp; + data['IPAdress'] = this.iPAdress; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['TokenID'] = this.tokenID; + data['SessionID'] = this.sessionID; + data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; + data['PatientOutSA'] = this.patientOutSA; + return data; + } +} diff --git a/lib/models/request_schedule.dart b/lib/models/request_schedule.dart index d704e9bb..949f07eb 100644 --- a/lib/models/request_schedule.dart +++ b/lib/models/request_schedule.dart @@ -16,21 +16,21 @@ class RequestSchedule { bool patientOutSA; int patientTypeID; - RequestSchedule({ - this.projectID, - this.clinicID, - this.doctorID, - this.doctorWorkingHoursDays = 7, - this.languageID = LANGUAGE_ID, - this.stamp = STAMP, - this.iPAdress = IP_ADDRESS, - this.versionID = VERSION_ID, - this.channel = CHANNEL, - this.tokenID, - this.sessionID = SESSION_ID, - this.isLoginForDoctorApp = IS_LOGIN_FOR_DOCTOR_APP, - this.patientOutSA = PATIENT_OUT_SA, - this.patientTypeID = 1}); + RequestSchedule( + {this.projectID, + this.clinicID, + this.doctorID, + this.doctorWorkingHoursDays = 7, + this.languageID, + this.stamp, + this.iPAdress, + this.versionID, + this.channel, + this.tokenID, + this.sessionID, + this.isLoginForDoctorApp, + this.patientOutSA, + this.patientTypeID = 1}); RequestSchedule.fromJson(Map json) { projectID = json['ProjectID']; diff --git a/lib/providers/doctor_reply_provider.dart b/lib/providers/doctor_reply_provider.dart index 1d2add69..c7e48afa 100644 --- a/lib/providers/doctor_reply_provider.dart +++ b/lib/providers/doctor_reply_provider.dart @@ -1,22 +1,12 @@ -import 'dart:convert'; - -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; -import 'package:doctor_app_flutter/models/doctor_profile_model.dart'; +import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/models/request_doctor_reply.dart'; import 'package:doctor_app_flutter/models/list_gt_my_pationents_question_model.dart'; -import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/cupertino.dart'; -import 'package:http/http.dart'; -import 'package:http_interceptor/http_client_with_interceptor.dart'; -import '../interceptor/http_interceptor.dart'; class DoctorReplyProvider with ChangeNotifier { - Client client = - HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); - List listDoctorWorkingHoursTable = []; + bool isLoading = true; bool isError = false; String error = ''; @@ -27,41 +17,22 @@ class DoctorReplyProvider with ChangeNotifier { } getDoctorReply() async { - const url = 'https://hmgwebservices.com/Services/DoctorApplication.svc/REST/GtMyPatientsQuestions'; - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - String token = await sharedPref.getString(TOKEN); - DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); -// _requestDoctorReply.doctorID = doctorProfile.doctorID; -// _requestDoctorReply.projectID = doctorProfile.projectID; -// _requestDoctorReply.tokenID = token; try { - if (await Helpers.checkConnection()) { - final response = await client.post(url, - body: json.encode(_requestDoctorReply.toJson())); - final int statusCode = response.statusCode; - if (statusCode < 200 || statusCode >= 400 || json == null) { - isLoading = false; - isError = true; - error = 'Error While Fetching data'; - } else { - var parsed = json.decode(response.body.toString()); - if (parsed['MessageStatus'] == 1) { - parsed['List_GtMyPatientsQuestions'].forEach((v) { - listDoctorWorkingHoursTable.add( ListGtMyPatientsQuestions.fromJson(v)); - }); + await BaseAppClient.post('DoctorApplication.svc/REST/GtMyPatientsQuestions', + body: _requestDoctorReply.toJson(), + onSuccess: (dynamic response, int statusCode) { + response['List_GtMyPatientsQuestions'].forEach((v) { + listDoctorWorkingHoursTable.add(ListGtMyPatientsQuestions.fromJson(v)); isError = false; isLoading = false; - } else { - isError = true; - isLoading = false; - error = parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'] ; - } - } - } else { - isLoading = false; - isError = true; - error = 'Please Check The Internet Connection'; - } + }); + }, + onFailure: (String error, int statusCode) { + isError = true; + isLoading = false; + this.error= error; + }); + notifyListeners(); } catch (error) { throw error; diff --git a/lib/providers/referral_patient_provider.dart b/lib/providers/referral_patient_provider.dart new file mode 100644 index 00000000..782bced7 --- /dev/null +++ b/lib/providers/referral_patient_provider.dart @@ -0,0 +1,74 @@ +import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/models/my_referral_patient_model.dart'; +import 'package:doctor_app_flutter/models/request_add_referred_doctor_remarks.dart'; +import 'package:doctor_app_flutter/models/request_my_referral_patient_model.dart'; +import 'package:flutter/cupertino.dart'; + + +class MyReferralPatientProvider with ChangeNotifier { + List listMyReferralPatientModel = []; + + bool isLoading = true; + bool isError = false; + String error = ''; + + RequestMyReferralPatientModel _requestMyReferralPatient = RequestMyReferralPatientModel(); + RequestAddReferredDoctorRemarks _requestAddReferredDoctorRemarks = RequestAddReferredDoctorRemarks(); + + MyReferralPatientProvider() { + getMyReferralPatient(); + } + + getMyReferralPatient() async { + try { + await BaseAppClient.post( + 'DoctorApplication.svc/REST/GtMyReferralPatient', + body: _requestMyReferralPatient.toJson(), + onSuccess: (dynamic response, int statusCode) { + response['List_MyReferralPatient'].forEach((v) { + listMyReferralPatientModel.add(MyReferralPatientModel.fromJson(v)); + }); + isError = false; + isLoading = false; + }, + onFailure: (String error, int statusCode) { + isError = true; + isLoading = false; + this.error = error; + }, + ); + notifyListeners(); + } catch (error) { + isLoading = false; + isError = true; + this.error = 'Something wrong happened, please contact the admin'; + notifyListeners(); + } + } + + Future replay( + String referredDoctorRemarks, MyReferralPatientModel model) async { + try { + _requestAddReferredDoctorRemarks.admissionNo = model.admissionNo; + _requestAddReferredDoctorRemarks.patientID = model.patientID; + _requestAddReferredDoctorRemarks.referredDoctorRemarks = referredDoctorRemarks; + _requestAddReferredDoctorRemarks.lineItemNo = model.lineItemNo; + _requestAddReferredDoctorRemarks.referringDoctor = model.referringDoctor; + await BaseAppClient.post( + 'DoctorApplication.svc/REST/AddReferredDoctorRemarks', + body: _requestAddReferredDoctorRemarks.toJson(), + onSuccess: (dynamic body, int statusCode) { + model.referredDoctorRemarks = referredDoctorRemarks; + listMyReferralPatientModel[ + listMyReferralPatientModel.indexOf(model)] = model; + notifyListeners(); + }, + onFailure: (String error, int statusCode) { + throw (error); + }, + ); + } catch (error) { + throw error; + } + } +} diff --git a/lib/providers/schedule_provider.dart b/lib/providers/schedule_provider.dart index 65945f52..057219a1 100644 --- a/lib/providers/schedule_provider.dart +++ b/lib/providers/schedule_provider.dart @@ -1,21 +1,9 @@ -import 'dart:convert'; - -import 'package:doctor_app_flutter/config/config.dart'; -import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; -import 'package:doctor_app_flutter/models/doctor_profile_model.dart'; -import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:flutter/cupertino.dart'; -import 'package:http/http.dart'; -import 'package:http_interceptor/http_client_with_interceptor.dart'; - -import '../interceptor/http_interceptor.dart'; import '../models/list_doctor_working_hours_table_model.dart'; import '../models/request_schedule.dart'; class ScheduleProvider with ChangeNotifier { - - Client client = HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); - List listDoctorWorkingHoursTable = []; bool isLoading = true; bool isError = false; @@ -27,41 +15,26 @@ class ScheduleProvider with ChangeNotifier { } getDoctorSchedule() async { - const url = BASE_URL + 'Doctors.svc/REST/GetDoctorWorkingHoursTable'; - Map profile = await sharedPref.getObj(DOCTOR_PROFILE); - String token = await sharedPref.getString(TOKEN); - DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); - requestSchedule.doctorID = doctorProfile.doctorID; - requestSchedule.projectID = doctorProfile.projectID; - requestSchedule.clinicID = doctorProfile.clinicID; - requestSchedule.tokenID = token; try { - - if (await Helpers.checkConnection()) { - final response = await client.post(url, body: json.encode(requestSchedule.toJson())); - final int statusCode = response.statusCode; - if (statusCode < 200 || statusCode >= 400 || json == null) { - isLoading = false; - isError = true; - error = 'Error While Fetching data'; - } else { - var parsed = json.decode(response.body.toString()); - parsed['List_DoctorWorkingHoursTable'].forEach((v) { - listDoctorWorkingHoursTable - .add(new ListDoctorWorkingHoursTable.fromJson(v)); - }); - isError = false; - isLoading = false; - } - } else { + await BaseAppClient.post('Doctors.svc/REST/GetDoctorWorkingHoursTable', + body: requestSchedule.toJson(), + onSuccess: (dynamic response, int statusCode) { + response['List_DoctorWorkingHoursTable'].forEach((v) { + listDoctorWorkingHoursTable.add(new ListDoctorWorkingHoursTable.fromJson(v)); + }); + isError = false; + isLoading = false; + }, onFailure: (String error, int statusCode) { isLoading = false; isError = true; - error = 'Please Check The Internet Connection'; - } - + this.error = error; + }); + notifyListeners(); + } catch (e) { + isLoading = false; + isError = true; + error = 'Something wrong happened, please contact the admin'; notifyListeners(); - } catch (error) { - throw error; } } } diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index 2146e547..d2a777f1 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/providers/doctor_reply_provider.dart'; import 'package:doctor_app_flutter/providers/medicine_provider.dart'; import 'package:doctor_app_flutter/providers/hospital_provider.dart'; +import 'package:doctor_app_flutter/providers/referral_patient_provider.dart'; import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; @@ -16,6 +17,7 @@ import '../widgets/dashboard/dashboard_item_icons_texts.dart'; import '../widgets/dashboard/dashboard_item_texts_widget.dart'; import '../widgets/shared/rounded_container_widget.dart'; import 'doctor/doctor_reply_screen.dart'; +import 'doctor/my_referral_patient_screen.dart'; class DashboardScreen extends StatefulWidget { DashboardScreen({Key key, this.title}) : super(key: key); @@ -271,12 +273,25 @@ class _DashboardScreenState extends State { ), Expanded( flex: 2, - child: new DashboardItemIconText( - DoctorApp.home_icon, - "", - "Discharge Patient", - showBorder: false, - backgroundColor: Colors.brown[400], + child: InkWell( + onTap: (){ + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => ChangeNotifierProvider( + create: (_) => MyReferralPatientProvider(), + child: MyReferralPatient(), + ), + ), + ); + }, + child: DashboardItemIconText( + DoctorApp.home_icon, + "", + "My Referral Patient", + showBorder: false, + backgroundColor: Colors.brown[400], + ), ), ), ], diff --git a/lib/screens/doctor/my_referral_patient_screen.dart b/lib/screens/doctor/my_referral_patient_screen.dart new file mode 100644 index 00000000..e2e10e82 --- /dev/null +++ b/lib/screens/doctor/my_referral_patient_screen.dart @@ -0,0 +1,65 @@ +import 'package:doctor_app_flutter/providers/referral_patient_provider.dart'; +import 'package:doctor_app_flutter/providers/schedule_provider.dart'; +import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/doctor/my_referral_patient_widget.dart'; +import 'package:doctor_app_flutter/widgets/doctor/my_schedule_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../widgets/shared/app_scaffold_widget.dart'; + +class MyReferralPatient extends StatelessWidget { + MyReferralPatientProvider referralPatientProvider; + + @override + Widget build(BuildContext context) { + referralPatientProvider = Provider.of(context); + return AppScaffold( + showBottomBar: false, + showAppDrawer: false, + appBarTitle: TranslationBase.of(context).mySchedule, + body: referralPatientProvider.isLoading + ? DrAppCircularProgressIndeicator() + : referralPatientProvider.isError + ? Center( + child: AppText( + referralPatientProvider.error, + color: Theme.of(context).errorColor, + ), + ) + : referralPatientProvider.listMyReferralPatientModel.length == 0 + ? Center( + child: AppText( + TranslationBase.of(context).errorNoSchedule, + color: Theme.of(context).errorColor, + ), + ) + : Container( + padding: EdgeInsetsDirectional.fromSTEB(20, 0, 20, 0), + child: ListView( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 10, + ), + Container( + child: Column( + children: referralPatientProvider.listMyReferralPatientModel.map((item) { + return MyReferralPatientWidget( + myReferralPatientModel: item, + ); + }).toList(), + ), + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/screens/doctor/my_schedule_screen.dart b/lib/screens/doctor/my_schedule_screen.dart index 711e2642..dd40dada 100644 --- a/lib/screens/doctor/my_schedule_screen.dart +++ b/lib/screens/doctor/my_schedule_screen.dart @@ -1,16 +1,13 @@ import 'package:doctor_app_flutter/providers/schedule_provider.dart'; -import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/doctor/my_schedule_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../../config/size_config.dart'; import '../../widgets/shared/app_scaffold_widget.dart'; -import '../../widgets/shared/card_with_bg_widget.dart'; class MyScheduleScreen extends StatelessWidget { ScheduleProvider scheduleProvider; @@ -83,8 +80,4 @@ class MyScheduleScreen extends StatelessWidget { ); } - TextStyle textStyle(size, [FontWeight weight]) { - return TextStyle( - fontSize: size * SizeConfig.textMultiplier, fontWeight: weight); - } } diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index 45ad043d..2ca362b5 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -245,6 +245,24 @@ class Helpers { else return ""; } + /* + *@author: Mohammad Aljammal + *@Date:26/5/2020 + *@param: DateTime + *@return: data formatted like 26/4/2020 + *@desc: convert DateTime to data formatted + */ + static String getDateFormatted(DateTime dateTime) { + print(dateTime); + if (dateTime != null) + return dateTime.day.toString() + + "/" + + dateTime.month.toString() + + "/" + + dateTime.year.toString(); + else + return ""; + } /* *@author: Mohammad Aljammal diff --git a/lib/widgets/doctor/my_referral_patient_widget.dart b/lib/widgets/doctor/my_referral_patient_widget.dart new file mode 100644 index 00000000..27517758 --- /dev/null +++ b/lib/widgets/doctor/my_referral_patient_widget.dart @@ -0,0 +1,342 @@ +import 'package:doctor_app_flutter/config/size_config.dart'; +import 'package:doctor_app_flutter/models/my_referral_patient_model.dart'; +import 'package:doctor_app_flutter/providers/referral_patient_provider.dart'; +import 'package:doctor_app_flutter/util/helpers.dart'; +import 'package:doctor_app_flutter/widgets/shared/Text.dart'; +import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_button.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; +import 'package:doctor_app_flutter/widgets/shared/card_with_bgNew_widget.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class MyReferralPatientWidget extends StatefulWidget { + final MyReferralPatientModel myReferralPatientModel; + + MyReferralPatientWidget({Key key, this.myReferralPatientModel}); + + @override + _MyReferralPatientWidgetState createState() => + _MyReferralPatientWidgetState(); +} + +class _MyReferralPatientWidgetState extends State { + bool _showDetails = false; + bool _isLoading = false; + final _formKey = GlobalKey(); + String _referredDoctorRemarks; + String error; + TextEditingController answerController; + + @override + void initState() { + answerController = new TextEditingController(text: widget.myReferralPatientModel.referredDoctorRemarks ?? ''); + super.initState(); + } + + @override + Widget build(BuildContext context) { + return CardWithBgWidgetNew( + widget: Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + AppText( + '${widget.myReferralPatientModel.firstName} ${widget.myReferralPatientModel.lastName}', + fontSize: 2.5 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + InkWell( + onTap: () { + setState(() { + _showDetails = !_showDetails; + }); + }, + child: Icon(_showDetails + ? Icons.keyboard_arrow_up + : Icons.keyboard_arrow_down)), + ], + ), + !_showDetails + ? Container() + : AnimatedContainer( + duration: Duration(milliseconds: 200), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Divider(color: Colors.grey), + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + 'File No', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + '${widget.myReferralPatientModel.referringDoctor}', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + + ), + Container( + height: SizeConfig.realScreenWidth * 0.1, + width: 0.8, + color: Colors.grey, + margin: EdgeInsets.only(left: 15, right: 15), + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + 'Referring Doctor', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + widget.myReferralPatientModel + .referringClinicDescription, + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + ], + ), + + Divider(color: Colors.grey), + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + 'Referring Clinic', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + '${widget.myReferralPatientModel.referringClinicDescription}', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + Container( + height: SizeConfig.realScreenWidth * 0.1, + width: 0.8, + color: Colors.grey, + margin: EdgeInsets.only(left: 15, right: 15), + ), + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + 'Frequency', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + widget.myReferralPatientModel + .frequencyDescription, + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + ], + ), + Divider(color: Colors.grey), + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + 'Priority', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + '${widget.myReferralPatientModel.priorityDescription}', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + Container( + height: SizeConfig.realScreenWidth * 0.1, + width: 0.8, + color: Colors.grey, + margin: EdgeInsets.only(left: 15, right: 15), + ), + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + 'Max Response Time', + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + ), + AppText( + Helpers.getDateFormatted(widget + .myReferralPatientModel + .mAXResponseTime), + fontSize: + 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.w300, + ) + ], + ), + ), + ], + ), + Divider(color: Colors.grey), + AppText( + 'Clinic Details and Remarks', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + ), + SizedBox( + height: 5, + ), + Texts( + '73 years old female known case of HTN and dm on regular medication one day prior the patient had rt sided weakness suddenly and reduced level of conscoiusness no vomting no headache no bluriing of vision no other relevant symptoms.\r\nPMH:No history of similar condition no history of surgey or blood transfusions\r\nCT brain was done apparently effaced left insular cortex', + style: "bodyText1", + readMore: true, + textAlign: TextAlign.start, + maxLength: 100), + SizedBox( + height: 5, + ), + AppText( + 'Answer/Suggestions', + fontSize: 1.7 * SizeConfig.textMultiplier, + fontWeight: FontWeight.bold, + textAlign: TextAlign.start, + ), + SizedBox( + height: 5, + ), + Form( + key: _formKey, + child: TextFields( + maxLines: 2, + minLines: 2, + hintText: 'Answer the patient', + initialValue: widget.myReferralPatientModel.referredDoctorRemarks ?? '', + readOnly: _isLoading, + validator: (value) { + if (value.isEmpty) + return "please enter answer"; + else + return null; + }, + onSubmit: (value) { + _referredDoctorRemarks = value; + }, + ), + ), + SizedBox(height: 10.0), + if (error != null && error.isNotEmpty) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6.0), + color: Theme.of(context) + .errorColor + .withOpacity(0.06), + ), + padding: EdgeInsets.symmetric( + vertical: 8.0, horizontal: 12.0), + child: Row( + children: [ + Expanded( + child: Texts(error ?? "", + style: "bodyText1", + color: Theme.of(context) + .errorColor)), + ], + ), + ), + SizedBox(height: 10.0), + ], + ), + SizedBox(height: 10.0), + Container( + width: double.infinity, + child: Button( + onTap: () async { + final form = _formKey.currentState; + if (form.validate()) { + setState(() { + _isLoading = true; + }); + try { + await Provider.of(context, listen: false).replay(answerController.text.toString(), widget.myReferralPatientModel); + setState(() { + _isLoading = false; + }); + } catch (e) { + setState(() { + error = e.toString(); + _isLoading = false; + }); + } + } + }, + title: 'Reply', + loading: _isLoading, + ), + ) + ], + ) + ], + ), + ) + ], + ), + ), + ); + } +} diff --git a/lib/widgets/shared/Text.dart b/lib/widgets/shared/Text.dart new file mode 100644 index 00000000..76402617 --- /dev/null +++ b/lib/widgets/shared/Text.dart @@ -0,0 +1,239 @@ +import 'package:flutter/material.dart'; +import 'package:hexcolor/hexcolor.dart'; + +class Texts extends StatefulWidget { + + final String text; + final String variant; + final Color color; + final bool bold; + final bool regular; + final bool medium; + final int maxLength; + final bool italic; + final TextAlign textAlign; + final int maxLines; + final bool readMore; + final String style; + final bool allowExpand; + + Texts(this.text, {Key key, this.variant, this.color, + this.bold, this.regular, this.medium, this.allowExpand = true, + this.italic:false, this.textAlign, this.maxLength=60, + this.maxLines, this.readMore=false, this.style + }) : super(key: key); + + @override + _TextsState createState() => _TextsState(); +} + +class _TextsState extends State { + bool hidden = false; + String text = ""; + + @override + void didUpdateWidget(Texts oldWidget) { + setState(() { + if (widget.style=="overline") + text = widget.text.toUpperCase(); + else { + text = widget.text; + } + }); + super.didUpdateWidget(oldWidget); + } + + @override + void initState() { + hidden = widget.readMore; + if (widget.style=="overline") + text = widget.text.toUpperCase(); + else { + text = widget.text; + } + super.initState(); + } + + double _getFontSize () { + switch (widget.variant) { + case "heading0": + return 40.0; + case "heading": + return 32.0; + case "heading2": + return 28.0; + case "heading3": + return 18.0; + case "body1": + return 18.0; + case "body2": + return 20.0; + case "body2Link": + return 16.0; + case "caption": + return 16.0; + case "caption2": + return 14.0; + case "bodyText": + return 15.0; + case "bodyText2": + return 17.0; + case "caption3": + return 12.0; + case "caption4": + return 9.0; + case "overline": + return 11.0; + case "date": + return 24.0; + default: + return 16.0; + } + } + + FontWeight _getFontWeight () { + if (widget.bold ?? false) { + return FontWeight.w900; + } else if (widget.regular ?? false) { + return FontWeight.w500; + } else if (widget.medium ?? false) { + return FontWeight.w800; + } + else { + if (widget.style==null) { + switch (widget.variant) { + case "heading": + return FontWeight.w900; + case "heading2": + return FontWeight.w900; + case "heading3": + return FontWeight.w900; + case "body1": + return FontWeight.w800; + case "body2": + return FontWeight.w900; + case "body2Link": + return FontWeight.w800; + case "caption": + return FontWeight.w700; + case "caption2": + return FontWeight.w700; + case "bodyText": + return FontWeight.w500; + case "bodyText2": + return FontWeight.w500; + case "caption3": + return FontWeight.w600; + case "caption4": + return FontWeight.w600; + case "overline": + return FontWeight.w800; + case "date": + return FontWeight.w900; + default: + return FontWeight.w500; + } + } else { + return null; + } + + } + } + + @override + Widget build(BuildContext context) { + + TextStyle _getFontStyle () { + switch (widget.style) { + case "headline2": + return Theme.of(context).textTheme.headline2; + case "headline3": + return Theme.of(context).textTheme.headline3; + case "headline4": + return Theme.of(context).textTheme.headline4; + case "headline5": + return Theme.of(context).textTheme.headline5; + case "headline6": + return Theme.of(context).textTheme.headline6; + case "bodyText2": + return Theme.of(context).textTheme.bodyText2; + case "bodyText_15": + return Theme.of(context).textTheme.bodyText2.copyWith(fontSize: 15.0); + case "bodyText1": + return Theme.of(context).textTheme.bodyText1; + case "caption": + return Theme.of(context).textTheme.caption; + case "overline": + return Theme.of(context).textTheme.overline; + case "button": + return Theme.of(context).textTheme.button; + default : + return TextStyle(); + } + } + + return Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + Text(!hidden ? text : (text.substring(0, text.length > widget.maxLength ? widget.maxLength : text.length)), + textAlign: widget.textAlign, + overflow: widget.maxLines!=null ? ((widget.maxLines > 1) ? TextOverflow.fade : TextOverflow.ellipsis) : null, + maxLines: widget.maxLines ?? null, + style: widget.style != null ? _getFontStyle().copyWith( + fontStyle: widget.italic ? FontStyle.italic : null, + color: widget.color!=null ? widget.color : null, + fontWeight: _getFontWeight(), + ) : TextStyle( + fontStyle: widget.italic ? FontStyle.italic : null, + color: widget.color!=null ? widget.color : Colors.black, + fontSize: _getFontSize(), + letterSpacing: widget.variant=="overline" ? 1.5 : null, + fontWeight: _getFontWeight(), + ) + ), + if (widget.readMore && text.length > widget.maxLength && hidden) + Positioned( + bottom: 0, + left: 0, + right: 0, + child: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + Theme.of(context).backgroundColor, + Theme.of(context).backgroundColor.withOpacity(0), + ], + begin: Alignment.bottomCenter, + end: Alignment.topCenter + ) + ), + height: 30, + ), + ) + ], + ), + if (widget.allowExpand && widget.readMore && text.length > widget.maxLength) + Padding( + padding: EdgeInsets.only(top: 8.0, right: 8.0, bottom: 8.0), + child: InkWell( + onTap: () { + setState(() { + hidden=!hidden; + }); + }, + child: Text(hidden ? "Read More" : "Read less", + style: _getFontStyle().copyWith( + color: Hexcolor('#515b5d'), + fontWeight: FontWeight.w800, + fontFamily: "WorkSans" + ) + ), + ), + ), + ], + ); + } +} diff --git a/lib/widgets/shared/TextFields.dart b/lib/widgets/shared/TextFields.dart new file mode 100644 index 00000000..269ad660 --- /dev/null +++ b/lib/widgets/shared/TextFields.dart @@ -0,0 +1,185 @@ +import 'package:eva_icons_flutter/eva_icons_flutter.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + + + +class TextFields extends StatefulWidget { + + TextFields({Key key, this.type, this.hintText, this.suffixIcon, this.autoFocus, this.onChanged, this.initialValue, this.minLines, this.maxLines, this.inputFormatters, this.padding, this.focus=false, this.maxLengthEnforced=true, + this.suffixIconColor, this.inputAction, this.onSubmit, this.keepPadding=true, this.textCapitalization = TextCapitalization.none, this.onTap, this.controller, this.keyboardType, this.validator, this.borderOnlyError=false, + this.onSaved, this.onSuffixTap, this.readOnly: false, this.maxLength, this.prefixIcon, this.bare=false, this.fontSize=16.0, this.fontWeight=FontWeight.w700, this.autoValidate=false}) : super(key: key); + + final String hintText; + final String initialValue; + final String type; + final bool autoFocus; + final IconData suffixIcon; + final Color suffixIconColor; + final IconData prefixIcon; + final VoidCallback onTap; + final TextEditingController controller; + final TextInputType keyboardType; + final FormFieldValidator validator; + final Function onSaved; + final Function onSuffixTap; + final Function onChanged; + final Function onSubmit; + final bool readOnly; + final int maxLength; + final int minLines; + final int maxLines; + final bool maxLengthEnforced; + final bool bare; + final TextInputAction inputAction; + final double fontSize; + final FontWeight fontWeight; + final bool keepPadding; + final TextCapitalization textCapitalization; + final List inputFormatters; + final bool autoValidate; + final EdgeInsets padding; + final bool focus; + final bool borderOnlyError; + + @override + _TextFieldsState createState() => _TextFieldsState(); +} + +class _TextFieldsState extends State { + final FocusNode _focusNode = FocusNode(); + bool focus = false; + bool view = false; + + @override + void initState() { + super.initState(); + _focusNode.addListener(() { + setState(() { + focus = _focusNode.hasFocus; + }); + }); + } + + @override + void didUpdateWidget(TextFields oldWidget) { + if (widget.focus) + _focusNode.requestFocus(); + super.didUpdateWidget(oldWidget); + } + + @override + void dispose() { + _focusNode.dispose(); + super.dispose(); + } + + Widget _buildSuffixIcon() { + switch (widget.type) { + case "password": + { return Padding( + padding: const EdgeInsets.only(right: 8.0), + child: view ? + InkWell(onTap: () {this.setState(() { view= false; });}, child: Icon(EvaIcons.eye, size: 24.0, color: Color.fromRGBO(78, 62, 253, 1.0))) + : + InkWell(onTap: () {this.setState(() { view= true; });}, child: Icon(EvaIcons.eyeOff, size: 24.0, color: Colors.grey[500])) + );} + + break; + default: + if (widget.suffixIcon!=null) + return InkWell(onTap: widget.onSuffixTap, child: Icon(widget.suffixIcon, size: 22.0, color: widget.suffixIconColor!=null ? widget.suffixIconColor : Colors.grey[500])); + else + return null; + } + } + + bool _determineReadOnly() { + if (widget.readOnly!=null && widget.readOnly) { + _focusNode.unfocus(); + return true; + } else { + return false; + } + } + + @override + Widget build(BuildContext context) { + return ( + AnimatedContainer( + duration: Duration(milliseconds: 300), + decoration: widget.bare ? null :BoxDecoration( + boxShadow: [BoxShadow(color: Color.fromRGBO(70, 68, 167, focus ? 0.20 : 0), offset: Offset(0.0, 13.0), blurRadius: focus ? 34.0 : 12.0)] + ), + child: TextFormField( + keyboardAppearance: Theme.of(context).brightness, + scrollPhysics: BouncingScrollPhysics(), + autovalidate: widget.autoValidate, + textCapitalization: widget.textCapitalization, + onFieldSubmitted: widget.inputAction==TextInputAction.next ? (widget.onSubmit!=null ? widget.onSubmit : (val) { _focusNode.nextFocus(); }) : widget.onSubmit, + textInputAction: widget.inputAction, + minLines: widget.minLines ?? 1, + maxLines: widget.maxLines ?? 1, + maxLengthEnforced: widget.maxLengthEnforced, + initialValue: widget.initialValue, + onChanged: widget.onChanged, + focusNode: _focusNode, + maxLength: widget.maxLength ?? null, + controller: widget.controller, + keyboardType: widget.keyboardType, + readOnly: _determineReadOnly(), + obscureText: widget.type=="password" && !view ? true : false, + autofocus: widget.autoFocus ?? false, + validator: widget.validator, + onSaved: widget.onSaved, + style: Theme.of(context).textTheme.body2.copyWith( fontSize: widget.fontSize, fontWeight: widget.fontWeight ), + inputFormatters: widget.inputFormatters, + decoration: InputDecoration( + counterText: "", + hintText: widget.hintText, + hintStyle: TextStyle(fontSize: widget.fontSize, fontWeight: widget.fontWeight, color: Theme.of(context).hintColor), + + contentPadding: widget.padding!=null ? widget.padding : EdgeInsets.symmetric(vertical: (widget.bare && !widget.keepPadding) ? 0.0 : 10.0, horizontal: 16.0), + filled: true, + fillColor: widget.bare ? Colors.transparent : Theme.of(context).backgroundColor, + + suffixIcon: _buildSuffixIcon(), + prefixIcon: widget.type!="search" ? + widget.prefixIcon!=null ? + Padding( + padding: EdgeInsets.only(left: 28.0, top: 14.0, bottom: 14.0, right: 0), + child: Text("\$", style: TextStyle( fontSize: 14, fontWeight: FontWeight.w800),), + ) + : + null + : + Icon(EvaIcons.search, size: 20.0, color: Colors.grey[500]), + + errorStyle: TextStyle(fontSize: 14.0, fontWeight: widget.fontWeight, height: widget.borderOnlyError ? 0.0 : null), + errorBorder: OutlineInputBorder( + borderSide: BorderSide(color: Theme.of(context).errorColor.withOpacity(widget.bare ? 0.0 : 0.5 ), width: 2.0), + borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0) + ), + focusedErrorBorder: OutlineInputBorder( + borderSide: BorderSide(color: Theme.of(context).errorColor.withOpacity(widget.bare ? 0.0 : 0.5 ), width: 2.0), + borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0) + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: Theme.of(context).dividerColor.withOpacity(widget.bare ? 0.0 : 1.0 ), width: 2.0), + borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0) + ), + disabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Theme.of(context).dividerColor.withOpacity(widget.bare ? 0.0 : 1.0 ), width: 2.0), + borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0) + ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: Theme.of(context).dividerColor.withOpacity(widget.bare ? 0.0 : 1.0 ), width: 2.0), + borderRadius: BorderRadius.circular(widget.bare ? 0.0 : 8.0) + ) + + ), + ), + ) + ); + } +} diff --git a/lib/widgets/shared/app_button.dart b/lib/widgets/shared/app_button.dart index 522255df..32f5b139 100644 --- a/lib/widgets/shared/app_button.dart +++ b/lib/widgets/shared/app_button.dart @@ -86,8 +86,7 @@ class _ButtonState extends State