You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
278 lines
9.5 KiB
Dart
278 lines
9.5 KiB
Dart
/*
|
|
*@author: Amjad Amireh Merge to Elham rababah
|
|
*@Date:27/4/2020
|
|
*@param:
|
|
*@return:PatientsScreen
|
|
|
|
*@desc:
|
|
*/
|
|
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
|
|
import 'package:doctor_app_flutter/models/patient/patient_model.dart';
|
|
import 'package:doctor_app_flutter/models/patient/topten_users_res_model.dart';
|
|
import 'package:doctor_app_flutter/providers/patients_provider.dart';
|
|
import 'package:doctor_app_flutter/routes.dart';
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
//*************
|
|
import '../../config/size_config.dart';
|
|
import 'package:hexcolor/hexcolor.dart';
|
|
|
|
//********
|
|
import '../../widgets/shared/app_scaffold_widget.dart';
|
|
import '../../widgets/shared/card_with_bg_widget.dart';
|
|
|
|
import 'package:doctor_app_flutter/config/config.dart';
|
|
|
|
class PatientsScreen extends StatefulWidget {
|
|
@override
|
|
_PatientsScreenState createState() => _PatientsScreenState();
|
|
}
|
|
|
|
class _PatientsScreenState extends State<PatientsScreen> {
|
|
List<dynamic> litems;
|
|
// final List parsed;
|
|
List parsed;
|
|
//**********
|
|
List date;
|
|
List unfilterDate;
|
|
//***********
|
|
|
|
List<PatiantInformtion> responseModelList;
|
|
List<PatiantInformtion> responseModelList2;
|
|
|
|
|
|
|
|
|
|
List<String> _locations = ['Today', 'Tomorrow', 'Next Week'];
|
|
int _activeLocation = 0;
|
|
|
|
bool _isInit = true;
|
|
String patientType;
|
|
String patientTypetitle;
|
|
var _isLoading = true;
|
|
|
|
var _hasError;
|
|
//*******Amjad add to search box******
|
|
final _controller = TextEditingController();
|
|
//**************
|
|
PatientModel patient;
|
|
|
|
@override
|
|
void didChangeDependencies() {
|
|
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
|
|
|
|
patient = routeArgs['patientSearchForm'];
|
|
|
|
print(patient.TokenID + "EEEEEE");
|
|
|
|
patientType = routeArgs['selectedType'];
|
|
patientTypetitle = SERVICES_PATIANT_HEADER[int.parse(patientType)];
|
|
|
|
|
|
print(patientType);
|
|
|
|
if (_isInit) {
|
|
PatientsProvider patientsProv = Provider.of<PatientsProvider>(context);
|
|
patientsProv.getPatientList(patient, patientType).then((res) {
|
|
print('List_MyInPatient${(res['List_MyInPatient'])}');
|
|
setState(() {
|
|
int val2 = int.parse(patientType);
|
|
litems = res[SERVICES_PATIANT2[val2]];
|
|
|
|
parsed = litems;
|
|
|
|
responseModelList = new ModelResponse.fromJson(parsed).list;
|
|
responseModelList2=responseModelList;
|
|
//********************
|
|
_isLoading = false;
|
|
_hasError = res['ErrorEndUserMessage'];
|
|
});
|
|
print(res);
|
|
}).catchError((error) {
|
|
print(error);
|
|
});
|
|
}
|
|
_isInit = false;
|
|
super.didChangeDependencies();
|
|
}
|
|
/*
|
|
*@author: Amjad Amireh
|
|
*@Date:2/5/2020
|
|
*@param:
|
|
*@return:PatientsScreen Search textbox
|
|
|
|
*@desc:
|
|
*/
|
|
searchData(String str) {
|
|
var strExist = str.length > 0 ? true : false;
|
|
if (strExist) {
|
|
List<PatiantInformtion> filterData=[] ;
|
|
for (var i = 0; i < responseModelList2.length; i++) {
|
|
|
|
String firstName = responseModelList[i].firstName.toUpperCase();
|
|
String lastName = responseModelList[i].lastName.toUpperCase();
|
|
if (firstName.contains(str.toUpperCase())||lastName.contains(str.toUpperCase())) {
|
|
print("==========data done===========");
|
|
filterData.add(responseModelList[i]);
|
|
}
|
|
}
|
|
setState(() {
|
|
print("==========data good===========");
|
|
this.responseModelList = filterData;
|
|
});
|
|
} else {
|
|
setState(() {
|
|
print("==========no data===========");
|
|
|
|
this.responseModelList =this.responseModelList2;
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
PatientsProvider patientsProv = Provider.of<PatientsProvider>(context);
|
|
|
|
return AppScaffold(
|
|
appBarTitle: patientTypetitle,
|
|
//***********Modify by amjad (create List view to insert all new data webservise in scroll )*************
|
|
body: Container(
|
|
// margin: EdgeInsets.all(20),
|
|
child: ListView(scrollDirection: Axis.vertical, children: <Widget>[
|
|
Container(
|
|
child: litems == null
|
|
? Column()
|
|
:
|
|
Column(
|
|
children: <Widget>[
|
|
Padding(
|
|
padding: EdgeInsets.only(
|
|
top: MediaQuery.of(context).size.height * 0.03),
|
|
child: _locationBar(context),
|
|
),
|
|
SizedBox(height: 10.0),
|
|
Container(
|
|
width: SizeConfig.screenWidth * 0.80,
|
|
child: TextField(
|
|
controller: _controller,
|
|
|
|
onChanged: (String str){
|
|
// print(str);
|
|
this.searchData(str);
|
|
|
|
},
|
|
decoration:
|
|
buildInputDecoration(context, 'Search patiant'),
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.fromLTRB(15, 0, 15, 0),
|
|
child: Column(
|
|
|
|
children:
|
|
responseModelList.map((PatiantInformtion item) {
|
|
return InkWell(
|
|
child: CardWithBgWidget(
|
|
|
|
widget: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
AppText(
|
|
item.firstName,
|
|
fontSize: 2.5 * SizeConfig.textMultiplier,
|
|
),
|
|
SizedBox(
|
|
height: 8,
|
|
),
|
|
AppText(item.lastName,
|
|
fontSize:
|
|
2.5 * SizeConfig.textMultiplier),
|
|
SizedBox(
|
|
height: 8,
|
|
),
|
|
AppText(item.middleName,
|
|
fontSize:
|
|
2.5 * SizeConfig.textMultiplier),
|
|
],
|
|
),
|
|
),
|
|
onTap: () {
|
|
Navigator.of(context).pushNamed(
|
|
PATIENTS_PROFILE,
|
|
arguments: {"patient": item});
|
|
},
|
|
);
|
|
}).toList(),
|
|
),
|
|
),
|
|
],
|
|
))
|
|
])));
|
|
}
|
|
|
|
//***********amjad update**buildInputDecoration ***to search box********
|
|
InputDecoration buildInputDecoration(BuildContext context, hint) {
|
|
return InputDecoration(
|
|
prefixIcon: Icon(Icons.search, color: Colors.red),
|
|
filled: true,
|
|
fillColor: Colors.white,
|
|
hintText: hint,
|
|
hintStyle: TextStyle(fontSize: 2 * SizeConfig.textMultiplier),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(20)),
|
|
borderSide: BorderSide(color: Hexcolor('#CCCCCC')),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
|
borderSide: BorderSide(color: Theme.of(context).primaryColor),
|
|
));
|
|
}
|
|
|
|
Widget _locationBar(BuildContext _context) {
|
|
return Container(
|
|
height: MediaQuery.of(context).size.height * 0.065,
|
|
width: SizeConfig.screenWidth * 0.80,
|
|
decoration: BoxDecoration(
|
|
color: Color(0Xff59434f), borderRadius: BorderRadius.circular(20)),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
mainAxisSize: MainAxisSize.max,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: _locations.map((l) {
|
|
bool _isActive = _locations[_activeLocation] == l ? true : false;
|
|
return Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
|
|
InkWell(
|
|
child: Text(
|
|
l,
|
|
style: TextStyle(
|
|
fontSize: 15,
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold),
|
|
),
|
|
onTap: () {
|
|
print(l);
|
|
print(_locations.indexOf(l));
|
|
setState(() {
|
|
_activeLocation = _locations.indexOf(l);
|
|
});
|
|
}),
|
|
_isActive
|
|
? Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(10),
|
|
color: Colors.white),
|
|
height: 3,
|
|
width: 80,
|
|
)
|
|
: Container()
|
|
]);
|
|
}).toList(),
|
|
));
|
|
}
|
|
}
|