refactoring

merge-requests/711/head
mosazaid 5 years ago
parent 3107950f5c
commit 91cd7f2b88

@ -13,20 +13,19 @@ import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'ProcedureType.dart';
class AddFavouriteProcedure extends StatefulWidget { class AddFavouriteProcedure extends StatefulWidget {
final ProcedureViewModel model; final ProcedureViewModel model;
final PatiantInformtion patient; final PatiantInformtion patient;
final String categoryID; final ProcedureType procedureType;
final String addButtonTitle;
final String toolbarTitle;
AddFavouriteProcedure( AddFavouriteProcedure({
{Key key, Key key,
this.model, this.model,
this.patient, this.patient,
this.categoryID, @required this.procedureType,
@required this.addButtonTitle, });
@required this.toolbarTitle});
@override @override
_AddFavouriteProcedureState createState() => _AddFavouriteProcedureState(); _AddFavouriteProcedureState createState() => _AddFavouriteProcedureState();
@ -43,7 +42,7 @@ class _AddFavouriteProcedureState extends State<AddFavouriteProcedure> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<ProcedureViewModel>( return BaseView<ProcedureViewModel>(
onModelReady: (model) => onModelReady: (model) =>
model.getProcedureTemplate(categoryID: widget.categoryID), model.getProcedureTemplate(categoryID: widget.procedureType.getCategoryId()),
builder: (BuildContext context, ProcedureViewModel model, Widget child) => builder: (BuildContext context, ProcedureViewModel model, Widget child) =>
AppScaffold( AppScaffold(
isShowAppBar: false, isShowAppBar: false,
@ -55,23 +54,20 @@ class _AddFavouriteProcedureState extends State<AddFavouriteProcedure> {
), ),
if (model.templateList.length != 0) if (model.templateList.length != 0)
Expanded( Expanded(
child: NetworkBaseView( child: EntityListCheckboxSearchFavProceduresWidget(
baseViewModel: model, model: model,
child: EntityListCheckboxSearchFavProceduresWidget( removeFavProcedure: (item) {
model: model, setState(() {
removeFavProcedure: (item) { entityList.remove(item);
setState(() { });
entityList.remove(item); },
}); addFavProcedure: (history) {
}, setState(() {
addFavProcedure: (history) { entityList.add(history);
setState(() { });
entityList.add(history); },
}); isEntityFavListSelected: (master) =>
}, isEntityListSelected(master),
isEntityFavListSelected: (master) =>
isEntityListSelected(master),
),
), ),
), ),
Container( Container(
@ -80,7 +76,7 @@ class _AddFavouriteProcedureState extends State<AddFavouriteProcedure> {
alignment: WrapAlignment.center, alignment: WrapAlignment.center,
children: <Widget>[ children: <Widget>[
AppButton( AppButton(
title: widget.addButtonTitle ?? title: widget.procedureType.getAddButtonTitle(context) ??
TranslationBase.of(context).addSelectedProcedures, TranslationBase.of(context).addSelectedProcedures,
color: Color(0xff359846), color: Color(0xff359846),
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
@ -100,8 +96,8 @@ class _AddFavouriteProcedureState extends State<AddFavouriteProcedure> {
items: entityList, items: entityList,
model: model, model: model,
patient: widget.patient, patient: widget.patient,
addButtonTitle: widget.addButtonTitle, addButtonTitle: widget.procedureType.getAddButtonTitle(context),
toolbarTitle: widget.toolbarTitle, toolbarTitle: widget.procedureType.getToolbarLabel(context),
), ),
), ),
); );

@ -21,7 +21,7 @@ class AddProcedurePage extends StatefulWidget {
final ProcedureType procedureType; final ProcedureType procedureType;
const AddProcedurePage( const AddProcedurePage(
{Key key, this.model, this.patient, this.procedureType}) {Key key, this.model, this.patient, @required this.procedureType})
: super(key: key); : super(key: key);
@override @override
@ -73,7 +73,6 @@ class _AddProcedurePageState extends State<AddProcedurePage> {
baseViewModel: model, baseViewModel: model,
child: SingleChildScrollView( child: SingleChildScrollView(
child: Container( child: Container(
// height: MediaQuery.of(context).size.height * 1.2,
child: Padding( child: Padding(
padding: EdgeInsets.all(12.0), padding: EdgeInsets.all(12.0),
child: Column( child: Column(
@ -81,80 +80,70 @@ class _AddProcedurePageState extends State<AddProcedurePage> {
children: [ children: [
if (procedureType == ProcedureType.PROCEDURE) if (procedureType == ProcedureType.PROCEDURE)
Column( Column(
children: [ children: [
Row( Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment.spaceBetween, MainAxisAlignment.spaceBetween,
children: [ children: [
AppText( AppText(
TranslationBase.of(context) TranslationBase.of(context)
.pleaseEnterProcedure, .pleaseEnterProcedure,
fontWeight: FontWeight.w700, fontWeight: FontWeight.w700,
fontSize: 20, 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,
// );
// },
), ),
), ],
SizedBox( ),
width: MediaQuery.of(context).size.width * SizedBox(
0.02, height:
), MediaQuery.of(context).size.height * 0.02,
Expanded( ),
child: InkWell( Row(
onTap: () { children: [
if (procedureName.text.isNotEmpty && Container(
procedureName.text.length >= 3) width: MediaQuery.of(context).size.width *
model.getProcedureCategory( 0.79,
patientId: patient.patientId, child: AppTextFieldCustom(
categoryName: procedureName.text); hintText: TranslationBase.of(context)
else .searchProcedureHere,
DrAppToastMsg.showErrorToast( isTextFieldHasSuffix: false,
TranslationBase.of(context) maxLines: 1,
.atLeastThreeCharacters, minLines: 1,
); hasBorder: true,
}, controller: procedureName,
child: Icon(
Icons.search,
size: 25.0,
), ),
), ),
), SizedBox(
], width: MediaQuery.of(context).size.width *
), 0.02,
], ),
), Expanded(
if (procedureName.text.isNotEmpty && 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) model.categoriesList.length != 0)
NetworkBaseView( NetworkBaseView(
baseViewModel: model, baseViewModel: model,
@ -229,36 +218,4 @@ class _AddProcedurePageState extends State<AddProcedurePage> {
} }
return false; 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,
),
);
}
} }

@ -74,7 +74,7 @@ class _BaseAddProcedureTabPageState extends State<BaseAddProcedureTabPage>
builder: builder:
(BuildContext context, ScrollController scrollController) { (BuildContext context, ScrollController scrollController) {
return Container( return Container(
height: MediaQuery.of(context).size.height * 1.20, height: MediaQuery.of(context).size.height * 1.25,
child: Padding( child: Padding(
padding: EdgeInsets.all(12.0), padding: EdgeInsets.all(12.0),
child: Column( child: Column(
@ -153,14 +153,9 @@ class _BaseAddProcedureTabPageState extends State<BaseAddProcedureTabPage>
controller: _tabController, controller: _tabController,
children: [ children: [
AddFavouriteProcedure( AddFavouriteProcedure(
patient: patient,
model: model, model: model,
addButtonTitle: procedureType patient: patient,
.getAddButtonTitle(context), procedureType: procedureType,
toolbarTitle: procedureType
.getToolbarLabel(context),
categoryID:
procedureType.getCategoryId(),
), ),
AddProcedurePage( AddProcedurePage(
model: model, model: model,

@ -81,7 +81,7 @@ class _EntityListCheckboxSearchFavProceduresWidgetState
NetworkBaseView( NetworkBaseView(
baseViewModel: widget.model, baseViewModel: widget.model,
child: Container( child: Container(
height: MediaQuery.of(context).size.height * 0.65, height: MediaQuery.of(context).size.height * 0.60,
child: Center( child: Center(
child: Container( child: Container(
margin: EdgeInsets.only(top: 15), margin: EdgeInsets.only(top: 15),

@ -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<EntityList> 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<ProcedureListWidget> {
int selectedType = 0;
int typeUrgent;
int typeRegular;
setSelectedType(int val) {
setState(() {
selectedType = val;
});
}
List<EntityList> items = List();
List<String> remarksList = List();
List<int> 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<EntityList> dummySearchList = List();
dummySearchList.addAll(widget.masterList);
if (query.isNotEmpty) {
List<EntityList> 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);
});
}
}
}
Loading…
Cancel
Save