diff --git a/lib/pages/BookAppointment/SearchResults.dart b/lib/pages/BookAppointment/SearchResults.dart index 57a88991..3ab31dec 100644 --- a/lib/pages/BookAppointment/SearchResults.dart +++ b/lib/pages/BookAppointment/SearchResults.dart @@ -37,6 +37,7 @@ class _SearchResultsState extends State { itemCount: widget.doctorsList.length, itemBuilder: (context, index) { return DoctorView( + //AJ note doctor: widget.doctorsList[index], ); }, diff --git a/lib/pages/BookAppointment/components/SearchByClinic.dart b/lib/pages/BookAppointment/components/SearchByClinic.dart index edfa9cd1..03370d82 100644 --- a/lib/pages/BookAppointment/components/SearchByClinic.dart +++ b/lib/pages/BookAppointment/components/SearchByClinic.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/models/Clinics/ClinicListResponse.dart'; +import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/BranchView.dart'; import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; @@ -8,6 +9,7 @@ import 'package:flutter/material.dart'; import 'package:smart_progress_bar/smart_progress_bar.dart'; import '../SearchResults.dart'; +import "dart:collection"; class SearchByClinic extends StatefulWidget { @override @@ -21,8 +23,7 @@ class _SearchByClinicState extends State { @override void initState() { - WidgetsBinding.instance - .addPostFrameCallback((_) => getClinicsList()); + WidgetsBinding.instance.addPostFrameCallback((_) => getClinicsList()); super.initState(); } @@ -97,11 +98,19 @@ class _SearchByClinicState extends State { } else {} }).catchError((err) { print(err); - }).showProgressBar(text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); + }).showProgressBar( + text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); } getDoctorsList(BuildContext context) { List doctorsList = []; + //======================== + + List arr = []; + var distinctIds; + List result; + int numAll; + //========================= DoctorsListService service = new DoctorsListService(); service.getDoctorsList(int.parse(dropdownValue), 0, context).then((res) { if (res['MessageStatus'] == 1) { @@ -110,22 +119,38 @@ class _SearchByClinicState extends State { doctorsList.clear(); res['DoctorList'].forEach((v) { doctorsList.add(new DoctorList.fromJson(v)); + + arr.add(new DoctorList.fromJson(v).projectName); + // print(DoctorList.fromJson(v).projectName); + // print(DoctorList.fromJson(v).projectDistanceInKiloMeters); + // distinctIds = result.toSet().toList(); }); } else {} }); - navigateToSearchResults(context, doctorsList); + + result = LinkedHashSet.from(arr).toList(); + numAll = result.length; + // print(result); + print("numAll=" + numAll.toString()); + + navigateToSearchResults(context, doctorsList, result, numAll); } else { AppToast.showErrorToast(message: res['ErrorEndUserMessage']); } }).catchError((err) { print(err); - }).showProgressBar(text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); + }).showProgressBar( + text: "Loading", backgroundColor: Colors.blue.withOpacity(0.6)); } - Future navigateToSearchResults(context, docList) async { + Future navigateToSearchResults(context, docList, result, numAll) async { Navigator.push( - context, - MaterialPageRoute( - builder: (context) => SearchResults(doctorsList: docList))); + context, + MaterialPageRoute( + builder: (context) => + BranchView(doctorsList: docList, result: result, num: numAll), + ), + ); + //builder: (context) => SearchResults(doctorsList: docList))); } } diff --git a/lib/pages/BookAppointment/widgets/BranchView.dart b/lib/pages/BookAppointment/widgets/BranchView.dart new file mode 100644 index 00000000..82c38cb2 --- /dev/null +++ b/lib/pages/BookAppointment/widgets/BranchView.dart @@ -0,0 +1,173 @@ +import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/material.dart'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +import 'DoctorView.dart'; + +class BranchView extends StatefulWidget { + final List doctorsList; + + final List result; + final int num; + + const BranchView({Key key, this.doctorsList, this.result, this.num}) + : super(key: key); + + @override + _BranchViewState createState() => _BranchViewState(); +} + +class _BranchViewState extends State { + @override + Widget build(BuildContext context) { + return AppScaffold( + appBarTitle: TranslationBase.of(context).bookAppo, + isShowAppBar: true, + body: new ListView.builder( + itemBuilder: (BuildContext context, int index) { + return new ExpandableListView( + + result2: widget.result, + val: index, + doctorsList2: widget.doctorsList); + }, + itemCount: widget.num, //5, + ), + ); + } +} + +class ExpandableListView extends StatefulWidget { + + final List result2; + final List doctorsList2; + final val; + + const ExpandableListView( + {Key key, this.result2, this.val, this.doctorsList2}) + : super(key: key); + + @override + _ExpandableListViewState createState() => new _ExpandableListViewState(); +} + +class _ExpandableListViewState extends State { + bool expandFlag = false; + + @override + Widget build(BuildContext context) { + return new Container( + // margin: new EdgeInsets.symmetric(vertical: 1.0), + width: MediaQuery.of(context).size.width * 0.6, + margin: EdgeInsets.fromLTRB(20.0, 10.0, 10.0, 0.0), + child: Card( + // margin: EdgeInsets.fromLTRB(20.0, 16.0, 20.0, 8.0), + color: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + child: Container( + decoration: BoxDecoration(), + padding: EdgeInsets.all(5.0), + width: MediaQuery.of(context).size.width, + child: new Column( + children: [ + new Container( + color: Colors.white, + // padding: new EdgeInsets.symmetric(horizontal: 5.0), + child: new Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + new Text( + widget.result2[widget.val].toString()+" "+ "22 كم", + style: new TextStyle( + fontWeight: FontWeight.bold, color: Colors.black), + ), + new IconButton( + icon: new Container( + height: 30.0, + width: 30.0, + decoration: new BoxDecoration( + color: Colors.red, + shape: BoxShape.circle, + ), + child: new Center( + child: new Icon( + expandFlag + ? Icons.keyboard_arrow_up + : Icons.keyboard_arrow_down, + color: Colors.white, + size: 30.0, + ), + ), + ), + onPressed: () { + setState(() { + expandFlag = !expandFlag; + }); + }), + ], + ), + ), + // SizedBox(height: 15), + new ExpandableContainer( + expanded: expandFlag, + child: ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: ScrollPhysics(), + padding: EdgeInsets.all(0.0), + itemCount: widget.doctorsList2.length, + itemBuilder: (context, index) { + return widget.result2[widget.val].toString() == + widget.doctorsList2[index].projectName.toString()? DoctorView( + //AJ note + doctor: + widget.doctorsList2[index] + + // widget.doctorsList2[index] + ):Container(); + }, + ), + ) + ], + ), + ), + ), + ); + } +} + +class ExpandableContainer extends StatelessWidget { + final bool expanded; + final double collapsedHeight; + final double expandedHeight; + final Widget child; + + ExpandableContainer({ + @required this.child, + this.collapsedHeight = 0.0, + this.expandedHeight = 300.0, + this.expanded = true, + }); + + @override + Widget build(BuildContext context) { + double screenWidth = MediaQuery.of(context).size.width; + return new AnimatedContainer( + duration: new Duration(milliseconds: 500), + curve: Curves.easeInOut, + width: screenWidth, + height: expanded ? expandedHeight : collapsedHeight, + child: new Container( + child: child, + decoration: new BoxDecoration( + border: new Border.all(width: 1.0, color: Colors.white)), + ), + ); + } +} diff --git a/lib/pages/BookAppointment/widgets/DoctorView.dart b/lib/pages/BookAppointment/widgets/DoctorView.dart index 38838917..35068bd7 100644 --- a/lib/pages/BookAppointment/widgets/DoctorView.dart +++ b/lib/pages/BookAppointment/widgets/DoctorView.dart @@ -11,6 +11,7 @@ import '../DoctorProfile.dart'; class DoctorView extends StatelessWidget { DoctorList doctor; + DoctorView({@required this.doctor}); @override @@ -139,6 +140,8 @@ class DoctorView extends StatelessWidget { context, MaterialPageRoute( builder: (context) => - DoctorProfile(doctor: docObject, docProfileList: docProfile))); + DoctorProfile(doctor: docObject, docProfileList: docProfile) + + )); } }