diff --git a/lib/screens/procedures/add-favourite-procedure.dart b/lib/screens/procedures/add-favourite-procedure.dart index a68336c7..66118508 100644 --- a/lib/screens/procedures/add-favourite-procedure.dart +++ b/lib/screens/procedures/add-favourite-procedure.dart @@ -13,20 +13,19 @@ import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'ProcedureType.dart'; + class AddFavouriteProcedure extends StatefulWidget { final ProcedureViewModel model; final PatiantInformtion patient; - final String categoryID; - final String addButtonTitle; - final String toolbarTitle; + final ProcedureType procedureType; - AddFavouriteProcedure( - {Key key, - this.model, - this.patient, - this.categoryID, - @required this.addButtonTitle, - @required this.toolbarTitle}); + AddFavouriteProcedure({ + Key key, + this.model, + this.patient, + @required this.procedureType, + }); @override _AddFavouriteProcedureState createState() => _AddFavouriteProcedureState(); @@ -43,7 +42,7 @@ class _AddFavouriteProcedureState extends State { Widget build(BuildContext context) { return BaseView( onModelReady: (model) => - model.getProcedureTemplate(categoryID: widget.categoryID), + model.getProcedureTemplate(categoryID: widget.procedureType.getCategoryId()), builder: (BuildContext context, ProcedureViewModel model, Widget child) => AppScaffold( isShowAppBar: false, @@ -55,23 +54,20 @@ class _AddFavouriteProcedureState extends State { ), if (model.templateList.length != 0) Expanded( - child: NetworkBaseView( - baseViewModel: model, - child: EntityListCheckboxSearchFavProceduresWidget( - model: model, - removeFavProcedure: (item) { - setState(() { - entityList.remove(item); - }); - }, - addFavProcedure: (history) { - setState(() { - entityList.add(history); - }); - }, - isEntityFavListSelected: (master) => - isEntityListSelected(master), - ), + child: EntityListCheckboxSearchFavProceduresWidget( + model: model, + removeFavProcedure: (item) { + setState(() { + entityList.remove(item); + }); + }, + addFavProcedure: (history) { + setState(() { + entityList.add(history); + }); + }, + isEntityFavListSelected: (master) => + isEntityListSelected(master), ), ), Container( @@ -80,7 +76,7 @@ class _AddFavouriteProcedureState extends State { alignment: WrapAlignment.center, children: [ AppButton( - title: widget.addButtonTitle ?? + title: widget.procedureType.getAddButtonTitle(context) ?? TranslationBase.of(context).addSelectedProcedures, color: Color(0xff359846), fontWeight: FontWeight.w700, @@ -100,8 +96,8 @@ class _AddFavouriteProcedureState extends State { items: entityList, model: model, patient: widget.patient, - addButtonTitle: widget.addButtonTitle, - toolbarTitle: widget.toolbarTitle, + addButtonTitle: widget.procedureType.getAddButtonTitle(context), + toolbarTitle: widget.procedureType.getToolbarLabel(context), ), ), ); diff --git a/lib/screens/procedures/add-procedure-page.dart b/lib/screens/procedures/add-procedure-page.dart index 3640a8dc..e0b7374f 100644 --- a/lib/screens/procedures/add-procedure-page.dart +++ b/lib/screens/procedures/add-procedure-page.dart @@ -21,7 +21,7 @@ class AddProcedurePage extends StatefulWidget { final ProcedureType procedureType; const AddProcedurePage( - {Key key, this.model, this.patient, this.procedureType}) + {Key key, this.model, this.patient, @required this.procedureType}) : super(key: key); @override @@ -73,7 +73,6 @@ class _AddProcedurePageState extends State { baseViewModel: model, child: SingleChildScrollView( child: Container( - // height: MediaQuery.of(context).size.height * 1.2, child: Padding( padding: EdgeInsets.all(12.0), child: Column( @@ -81,80 +80,70 @@ class _AddProcedurePageState extends State { children: [ if (procedureType == ProcedureType.PROCEDURE) Column( - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - AppText( - TranslationBase.of(context) - .pleaseEnterProcedure, - fontWeight: FontWeight.w700, - fontSize: 20, - ), - ], - ), - SizedBox( - height: - MediaQuery.of(context).size.height * 0.02, - ), - Row( - children: [ - Container( - width: MediaQuery.of(context).size.width * - 0.79, - child: AppTextFieldCustom( - hintText: TranslationBase.of(context) - .searchProcedureHere, - isTextFieldHasSuffix: false, - maxLines: 1, - minLines: 1, - hasBorder: true, - controller: procedureName, - // onClick: () { - // if (procedureName.text.isNotEmpty && - // procedureName.text.length >= 3) - // model.getProcedureCategory( - // patientId: patient.patientId, - // categoryName: - // procedureName.text); - // else - // DrAppToastMsg.showErrorToast( - // TranslationBase.of(context) - // .atLeastThreeCharacters, - // ); - // }, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + AppText( + TranslationBase.of(context) + .pleaseEnterProcedure, + fontWeight: FontWeight.w700, + fontSize: 20, ), - ), - SizedBox( - width: MediaQuery.of(context).size.width * - 0.02, - ), - Expanded( - child: InkWell( - onTap: () { - if (procedureName.text.isNotEmpty && - procedureName.text.length >= 3) - model.getProcedureCategory( - patientId: patient.patientId, - categoryName: procedureName.text); - else - DrAppToastMsg.showErrorToast( - TranslationBase.of(context) - .atLeastThreeCharacters, - ); - }, - child: Icon( - Icons.search, - size: 25.0, + ], + ), + SizedBox( + height: + MediaQuery.of(context).size.height * 0.02, + ), + Row( + children: [ + Container( + width: MediaQuery.of(context).size.width * + 0.79, + child: AppTextFieldCustom( + hintText: TranslationBase.of(context) + .searchProcedureHere, + isTextFieldHasSuffix: false, + maxLines: 1, + minLines: 1, + hasBorder: true, + controller: procedureName, ), ), - ), - ], - ), - ], - ), - if (procedureName.text.isNotEmpty && + SizedBox( + width: MediaQuery.of(context).size.width * + 0.02, + ), + Expanded( + child: InkWell( + onTap: () { + if (procedureName.text.isNotEmpty && + procedureName.text.length >= 3) + model.getProcedureCategory( + patientId: patient.patientId, + categoryName: + procedureName.text); + else + DrAppToastMsg.showErrorToast( + TranslationBase.of(context) + .atLeastThreeCharacters, + ); + }, + child: Icon( + Icons.search, + size: 25.0, + ), + ), + ), + ], + ), + ], + ), + if ((procedureType == ProcedureType.PROCEDURE + ? procedureName.text.isNotEmpty + : true) && model.categoriesList.length != 0) NetworkBaseView( baseViewModel: model, @@ -229,36 +218,4 @@ class _AddProcedurePageState extends State { } return false; } - - InputDecoration textFieldSelectorDecoration( - String hintText, String selectedText, bool isDropDown, - {Icon suffixIcon}) { - return InputDecoration( - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - disabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - hintText: selectedText != null ? selectedText : hintText, - suffixIcon: isDropDown - ? suffixIcon != null - ? suffixIcon - : Icon( - Icons.arrow_drop_down, - color: Colors.black, - ) - : null, - hintStyle: TextStyle( - fontSize: 14, - color: Colors.grey.shade600, - ), - ); - } } diff --git a/lib/screens/procedures/base_add_procedure_tab_page.dart b/lib/screens/procedures/base_add_procedure_tab_page.dart index f4a6c85e..58efaaca 100644 --- a/lib/screens/procedures/base_add_procedure_tab_page.dart +++ b/lib/screens/procedures/base_add_procedure_tab_page.dart @@ -74,7 +74,7 @@ class _BaseAddProcedureTabPageState extends State builder: (BuildContext context, ScrollController scrollController) { return Container( - height: MediaQuery.of(context).size.height * 1.20, + height: MediaQuery.of(context).size.height * 1.25, child: Padding( padding: EdgeInsets.all(12.0), child: Column( @@ -153,14 +153,9 @@ class _BaseAddProcedureTabPageState extends State controller: _tabController, children: [ AddFavouriteProcedure( - patient: patient, model: model, - addButtonTitle: procedureType - .getAddButtonTitle(context), - toolbarTitle: procedureType - .getToolbarLabel(context), - categoryID: - procedureType.getCategoryId(), + patient: patient, + procedureType: procedureType, ), AddProcedurePage( model: model, diff --git a/lib/screens/procedures/entity_list_fav_procedure.dart b/lib/screens/procedures/entity_list_fav_procedure.dart index 822726ce..4b946131 100644 --- a/lib/screens/procedures/entity_list_fav_procedure.dart +++ b/lib/screens/procedures/entity_list_fav_procedure.dart @@ -81,7 +81,7 @@ class _EntityListCheckboxSearchFavProceduresWidgetState NetworkBaseView( baseViewModel: widget.model, child: Container( - height: MediaQuery.of(context).size.height * 0.65, + height: MediaQuery.of(context).size.height * 0.60, child: Center( child: Container( margin: EdgeInsets.only(top: 15), diff --git a/lib/screens/procedures/entity_list_procedure_widget.dart b/lib/screens/procedures/entity_list_procedure_widget.dart deleted file mode 100644 index 125262e4..00000000 --- a/lib/screens/procedures/entity_list_procedure_widget.dart +++ /dev/null @@ -1,168 +0,0 @@ -import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'; -import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; -import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; -import 'package:doctor_app_flutter/widgets/shared/TextFields.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/divider_with_spaces_around.dart'; -import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; -import 'package:eva_icons_flutter/eva_icons_flutter.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - -class ProcedureListWidget extends StatefulWidget { - final ProcedureViewModel model; - final Function addSelectedHistories; - final Function(EntityList) removeHistory; - final Function(EntityList) addHistory; - final Function(EntityList) addRemarks; - - final bool Function(EntityList) isEntityListSelected; - final List masterList; - - ProcedureListWidget( - {Key key, - this.model, - this.addSelectedHistories, - this.removeHistory, - this.masterList, - this.addHistory, - this.isEntityListSelected, - this.addRemarks}) - : super(key: key); - - @override - _ProcedureListWidgetState createState() => _ProcedureListWidgetState(); -} - -class _ProcedureListWidgetState extends State { - int selectedType = 0; - int typeUrgent; - int typeRegular; - - setSelectedType(int val) { - setState(() { - selectedType = val; - }); - } - - List items = List(); - List remarksList = List(); - List typeList = List(); - - @override - void initState() { - items.addAll(widget.masterList); - super.initState(); - } - - TextEditingController remarksController = TextEditingController(); - @override - Widget build(BuildContext context) { - return Container( - child: Column( - children: [ - NetworkBaseView( - baseViewModel: widget.model, - child: Container( - height: MediaQuery.of(context).size.height * 0.75, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: ListView( - children: [ - TextFields( - hintText: TranslationBase.of(context).searchProcedures, - suffixIcon: EvaIcons.search, - onChanged: (value) { - filterSearchResults(value); - }, - ), - SizedBox( - height: 15, - ), - items.length != 0 - ? Column( - children: items.map((historyInfo) { - return Column( - children: [ - Row( - children: [ - Checkbox( - value: widget.isEntityListSelected( - historyInfo), - activeColor: Colors.red[800], - onChanged: (bool newValue) { - setState(() { - if (widget.isEntityListSelected( - historyInfo)) { - widget - .removeHistory(historyInfo); - } else { - widget.addHistory(historyInfo); - } - }); - }), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10, vertical: 0), - child: AppText( - historyInfo.procedureName, - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - ], - ); - }).toList(), - ) - : Center( - child: Container( - child: AppText( - "There's no procedures for this category", - color: Color(0xFFB9382C)), - ), - ) - ], - ), - )), - ), - ), - SizedBox( - height: 10, - ), - ], - ), - ); - } - - void filterSearchResults(String query) { - List dummySearchList = List(); - dummySearchList.addAll(widget.masterList); - if (query.isNotEmpty) { - List dummyListData = List(); - dummySearchList.forEach((item) { - if (item.procedureName.toLowerCase().contains(query.toLowerCase())) { - dummyListData.add(item); - } - }); - setState(() { - items.clear(); - items.addAll(dummyListData); - }); - return; - } else { - setState(() { - items.clear(); - items.addAll(widget.masterList); - }); - } - } -}