merge-update-with-lab-changes
Sultan Khan 6 years ago
parent badb4e52df
commit 3a4c016f4e

@ -7,7 +7,8 @@ import 'package:flutter/material.dart';
class Search extends StatefulWidget { class Search extends StatefulWidget {
final int type; final int type;
Search({this.type = 0}); final List clnicIds;
Search({this.type = 0, this.clnicIds});
@override @override
_SearchState createState() => _SearchState(); _SearchState createState() => _SearchState();
} }
@ -41,7 +42,12 @@ class _SearchState extends State<Search> with TickerProviderStateMixin {
), ),
body: TabBarView( body: TabBarView(
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
children: [SearchByClinic(), SearchByDoctor()], children: [
SearchByClinic(
clnicIds: widget.clnicIds,
),
SearchByDoctor()
],
controller: _tabController), controller: _tabController),
bottomNavigationBar: BottomBarSearch()); bottomNavigationBar: BottomBarSearch());
} }

@ -17,6 +17,8 @@ import '../SearchResults.dart';
import "dart:collection"; import "dart:collection";
class SearchByClinic extends StatefulWidget { class SearchByClinic extends StatefulWidget {
final List clnicIds;
SearchByClinic({this.clnicIds});
@override @override
_SearchByClinicState createState() => _SearchByClinicState(); _SearchByClinicState createState() => _SearchByClinicState();
} }
@ -30,14 +32,7 @@ class _SearchByClinicState extends State<SearchByClinic> {
@override @override
void initState() { void initState() {
WidgetsBinding.instance.addPostFrameCallback((_) => getClinicsList()); WidgetsBinding.instance.addPostFrameCallback((_) => getClinicsList());
// event.controller.stream.listen((p) {
// if (p['clinic_id'] != null) {
// // setState(() {
// dropdownValue = p['clinic_id'].toString();
// //});
// getDoctorsList(context);
// }
// });
super.initState(); super.initState();
} }
@ -109,6 +104,7 @@ class _SearchByClinicState extends State<SearchByClinic> {
clinicsList.add(new ListClinicCentralized.fromJson(v)); clinicsList.add(new ListClinicCentralized.fromJson(v));
}); });
}); });
filterClinic();
} else {} } else {}
}).catchError((err) { }).catchError((err) {
print(err); print(err);
@ -167,4 +163,13 @@ class _SearchByClinicState extends State<SearchByClinic> {
); );
//builder: (context) => SearchResults(doctorsList: docList))); //builder: (context) => SearchResults(doctorsList: docList)));
} }
filterClinic() {
setState(() {
clinicsList = clinicsList
.where((i) => widget.clnicIds.indexOf(i.clinicID) > -1)
.toList();
print(clinicsList);
});
}
} }

@ -54,7 +54,9 @@ class DoctorsListService extends BaseService {
"IsGetNearAppointment": false, "IsGetNearAppointment": false,
"Latitude": 0, "Latitude": 0,
"Longitude": 0, "Longitude": 0,
"License": true "License": true,
// "IsVoiceCommand": doctorId != null && doctorId.length > 0 ? true : false,
// "DoctorIDsList": doctorId
}; };
dynamic localRes; dynamic localRes;

@ -194,62 +194,70 @@ class _SearchBot extends State<BottomBarSearch> {
searchProvider searchProvider
.getBotPages(request) .getBotPages(request)
.then((value) => {getCommands(value['Understand'])}); .then((value) => {getCommands(value['Understand'])});
//getDoctorsList(12, 17, 40036, context);
} }
getCommands(result) async { getCommands(result) async {
//RoboSearch.closeAlertDialog(context);
print(result); print(result);
results = result; results = result;
//getDoctorsList(12, 17, 40036, context); List clnicID = unique(result['ClinicId']);
switch (result["CommandNumber"]) { switch (result["CommandNumber"]) {
case 100: case 100:
if (result['ProjectId'] != 0 && if (result['ProjectId'] != 0 &&
result['ClinicId'] != 0 && clnicID.length > 0 &&
result['DoctorId'] != 0) { result['DoctorId'].length > 0) {
var name = result['DoctorName'].replaceAll('دكتور', ''); var name = result['DoctorName'].replaceAll('دكتور', '');
getDoctorsList( if (clnicID.length == 1) {
result['ProjectId'], getDoctorsList(
result['ClinicId'], result['ProjectId'],
context, clnicID[0],
doctorId: result['DoctorId'], context,
doctorName: name.trim(), doctorId: result['DoctorId'],
); doctorName: name.trim(),
);
} else {
goToClinic(clnicID);
}
} else if (result['ProjectId'] != 0 && } else if (result['ProjectId'] != 0 &&
result['ClinicId'] != 0 && clnicID.length > 0 &&
result['DoctorId'] == 0) { result['DoctorId'].length == 0) {
getDoctorsList( if (clnicID.length == 1) {
result['ProjectId'], getDoctorsList(
result['ClinicId'], result['ProjectId'],
context, clnicID[0],
); context,
);
} else {
goToClinic(clnicID);
}
} else if (result['ProjectId'] == 0 && } else if (result['ProjectId'] == 0 &&
result['ClinicId'] != 0 && clnicID.length > 0 &&
result['DoctorId'] == 0) { result['DoctorId'].length == 0) {
getDoctorsList( if (clnicID.length == 1) {
result['ProjectId'], getDoctorsList(
result['ClinicId'], result['ProjectId'],
context, clnicID[0],
); context,
);
} else {
goToClinic(clnicID);
}
} else if (result['ProjectId'] == 0 && } else if (result['ProjectId'] == 0 &&
result['ClinicId'] != 0 && clnicID.length > 0 &&
result['DoctorId'] != 0) { result['DoctorId'].length > 0) {
var name = result['DoctorName'].replaceAll('دكتور', ''); var name = result['DoctorName'].replaceAll('دكتور', '');
getDoctorsList( if (clnicID.length == 1) {
result['ProjectId'], getDoctorsList(
result['ClinicId'], result['ProjectId'],
context, clnicID[0],
doctorId: result['DoctorId'], context,
doctorName: name.trim(), doctorId: result['DoctorId'],
); doctorName: name.trim(),
);
} else {
goToClinic(clnicID);
}
} else { } else {
Navigator.push( goToClinic(clnicID);
AppGlobal.context,
MaterialPageRoute(
builder: (context) => Search(
type: 0,
)));
} }
speak(); speak();
break; break;
@ -327,9 +335,9 @@ class _SearchBot extends State<BottomBarSearch> {
doctorsList.add(new DoctorList.fromJson(v)); doctorsList.add(new DoctorList.fromJson(v));
arr.add(new DoctorList.fromJson(v).projectName); arr.add(new DoctorList.fromJson(v).projectName);
}); });
if (res['DoctorList'].length == 1 && doctorId != null) { if (res['DoctorList'].length == 1) {
getDoctorProfile( getDoctorProfile(
projectId, clinicId, doctorId, context, doctorsList); projectId, clinicId, doctorId[0], context, doctorsList);
//speak(); //speak();
} else { } else {
@ -384,4 +392,19 @@ class _SearchBot extends State<BottomBarSearch> {
// initSpeechState().then((value) => startVoiceSearch()); // initSpeechState().then((value) => startVoiceSearch());
// }); // });
} }
goToClinic(List ids) {
Navigator.push(
AppGlobal.context,
MaterialPageRoute(
builder: (context) => Search(
type: 0,
clnicIds: ids,
)));
// eventProvider.setValue({"clinic_id": ids});
}
List unique(List list) {
return list.toSet().toList();
}
} }

Loading…
Cancel
Save