Add search in Procedure Screen

pull/208/head
Mohammad Aljammal 5 years ago
parent b60b45ab53
commit 45edddb49f

@ -0,0 +1,148 @@
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
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/widgets/shared/Text.dart';
import 'package:doctor_app_flutter/widgets/shared/TextFields.dart';
import 'package:doctor_app_flutter/widgets/shared/app_buttons_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 EntityListCheckboxSearchWidget extends StatefulWidget {
final ProcedureViewModel model;
final Function addSelectedHistories;
final Function(EntityList) removeHistory;
final Function(EntityList) addHistory;
final bool Function(EntityList) isEntityListSelected;
final List<EntityList> masterList;
EntityListCheckboxSearchWidget(
{Key key,
this.model,
this.addSelectedHistories,
this.removeHistory,
this.masterList,
this.addHistory,
this.isEntityListSelected})
: super(key: key);
@override
_EntityListCheckboxSearchWidgetState createState() => _EntityListCheckboxSearchWidgetState();
}
class _EntityListCheckboxSearchWidgetState extends State<EntityListCheckboxSearchWidget> {
List<EntityList> items = List();
@override
void initState() {
items.addAll(widget.masterList);
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: [
NetworkBaseView(
baseViewModel: widget.model,
child: Container(
height: MediaQuery.of(context).size.height * 0.5,
child: Center(
child: Container(
margin: EdgeInsets.only(top: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white),
child: ListView(
children: [
TextFields(
hintText: 'Search ',
suffixIcon: EvaIcons.search,
onChanged: (value) {
filterSearchResults(value);
},
),
SizedBox(height: 15,),
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: Texts(historyInfo.procedureName,
variant: "bodyText",
bold: true,
color: Colors.black),
),
),
],
),
DividerWithSpacesAround(),
],
);
}).toList(),
),
],
),
)),
),
),
SizedBox(
height: 10,
),
if (widget.model.state == ViewState.Idle)
AppButton(//TODO change the button name
title: "Add ".toUpperCase(),
onPressed: () {
widget.addSelectedHistories();
},
),
],
),
);
}
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);
});
}
}
}

@ -2,21 +2,27 @@ import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart';
import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart';
import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/procedures/entity_list_checkbox_search_widget.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/patient_profile_widget.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_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.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/master_key_checkbox_search_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
@ -249,121 +255,121 @@ class _ProcedureScreenState extends State<ProcedureScreen> {
],
),
),
Container(
height: 120,
width: 325.0,
child: Column(
children: [
Row(
children: [
AppText(
'Code #: ',
fontWeight:
FontWeight
.w700,
fontSize: 15.0,
),
AppText(
model
.procedureList[
0]
.entityList[
index]
.procedureId
.toString(),
fontSize: 13.0,
),
SizedBox(
width: 12.0,
),
AppText(
'Order Type: ',
fontWeight:
FontWeight
.w700,
fontSize: 15.0,
),
AppText(
'Urgent',
fontSize: 13.0,
color:
Colors.red,
),
],
),
Row(
children: [
Container(
child: Expanded(
child:
AppText(
model
.procedureList[
0]
.entityList[
index]
.procedureName,
fontWeight:
FontWeight
.w800,
),
Expanded(
child: Container(
height: 120,
width: 325.0,
child: Column(
children: [
Row(
children: [
AppText(
'Code #: ',
fontWeight:
FontWeight
.w700,
fontSize: 15.0,
),
AppText(
model
.procedureList[
0]
.entityList[
index]
.procedureId
.toString(),
fontSize: 13.0,
),
)
],
),
SizedBox(
width: 12.0,
),
AppText(
'Order Type: ',
fontWeight:
FontWeight
.w700,
fontSize: 15.0,
),
AppText(
'Urgent',
fontSize: 13.0,
color:
Colors.red,
),
],
),
Row(
children: [
Container(
child: Expanded(
child:
AppText(
model
.procedureList[
0]
.entityList[
index]
.procedureName,
fontWeight:
FontWeight
.w800,
),
),
)
],
),
Row(
children: [
AppText(
'Price: ',
fontWeight:
FontWeight
.w700,
),
Expanded(
child: AppText(
model
.procedureList[
0]
.entityList[
index]
.price
.toString(),
fontSize:
13.0),
)
],
),
SizedBox(
height: 10.0,
),
Row(
children: [
AppText(
'Price: ',
fontWeight:
FontWeight
.w700,
),
Expanded(
child: AppText(
model
.procedureList[
0]
.entityList[
index]
.price
.toString(),
fontSize:
13.0),
)
],
),
SizedBox(
height: 10.0,
),
Row(
children: [
AppText(
'Some short remark about the procedure',
fontSize: 13.5,
),
],
),
SizedBox(
height: 10.0,
),
Row(
children: [
AppText(
'Some short remark about the procedure',
fontSize: 13.5,
),
],
),
SizedBox(
height: 10.0,
),
Divider(
height: 5.0,
thickness: 1.0,
color: Colors.grey,
)
// SizedBox(
// height: 40,
// ),
],
Divider(
height: 5.0,
thickness: 1.0,
color: Colors.grey,
)
// SizedBox(
// height: 40,
// ),
],
),
),
),
Container(
width: 30,
height: 120,
child: Column(
children: [
Icon(Icons.edit)
@ -420,6 +426,7 @@ postProcedure({ProcedureViewModel model}) async {
void addSelectedProcedure(context, ProcedureViewModel model) {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext bc) {
return AddSelectedProcedure(
model: model,
@ -437,14 +444,14 @@ class AddSelectedProcedure extends StatefulWidget {
class _AddSelectedProcedureState extends State<AddSelectedProcedure> {
TextEditingController procedureController = TextEditingController();
List<EntityList> entityList= List();
@override
Widget build(BuildContext context) {
return NetworkBaseView(
baseViewModel: widget.model,
child: SingleChildScrollView(
child: Container(
height: 490,
//height: 490,
child: Padding(
padding: EdgeInsets.all(12.0),
child: Column(
@ -455,76 +462,26 @@ class _AddSelectedProcedureState extends State<AddSelectedProcedure> {
fontWeight: FontWeight.w900,
),
if (widget.model.categoriesList.length != 0)
Container(
// child: ListView(
// children: [
// Column(
// children: model.historyFamilyList
// .map((historyInfo) {
// return Column(
// children: [
// Row(
// children: [
// Checkbox(
// value: isServiceSelected(
// historyInfo),
// activeColor:
// Colors.red[800],
// onChanged:
// (bool newValue) {
// setState(() {
// if (isServiceSelected(
// historyInfo
// )) {
// widget
// .removeHistory(
// historyInfo
// );
// }
// else {
// widget
// .myHistoryList
// .add(
// historyInfo);
// }
// });
// }),
// Expanded(
// child: Padding(
// padding:
// const EdgeInsets
// .symmetric(
// horizontal: 10,
// vertical: 0),
// child: Texts(
// historyInfo.nameEn,
// variant: "bodyText",
// bold: true,
// color:
// Colors.black),
// ),
// ),
// ],
// ),
// DividerWithSpacesAround(),
// ],
// );
// }).toList(),
// ),
// ],
// ),
height: 120.0,
child: ListView.builder(
scrollDirection: Axis.vertical,
shrinkWrap: true,
itemCount: widget.model.categoriesList[0].rowcount,
itemBuilder: (BuildContext ctxt, int index) {
return Container(
child: AppText(widget.model.categoriesList[0]
.entityList[index].procedureName),
);
}),
),
EntityListCheckboxSearchWidget(
model: widget.model,
masterList: widget.model.categoriesList[0].entityList,
removeHistory: (item){
setState(() {
entityList.remove(item);
});
},
addHistory: (history){
setState(() {
entityList.add(history);
});
},
addSelectedHistories: (){
//TODO build your fun herr
// widget.addSelectedHistories();
},
isEntityListSelected: (master) => isEntityListSelected(master),
),
SizedBox(
height: 0.0,
),
@ -571,16 +528,17 @@ class _AddSelectedProcedureState extends State<AddSelectedProcedure> {
),
);
}
bool isEntityListSelected(EntityList masterKey) {
Iterable<EntityList> history =
entityList.where((element) => masterKey.procedureId == element.procedureId);
if (history.length > 0) {
return true;
}
return false;
}
}
// isServiceSelected(ProcedureViewModel masterKey) {
// Iterable<MasterKeyModel> history = widget.myHistoryList.where((element) =>
// masterKey.id == element.id && masterKey.typeId == element.typeId);
// if (history.length > 0) {
// return true;
// }
// return false;
// }
void updateProcedureForm(context) {
showModalBottomSheet(

Loading…
Cancel
Save