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.
doctor_app_flutter/lib/screens/patients/patients_screen.dart

181 lines
6.6 KiB
Dart

/*
*@author: Amjad Amireh Merge to Elham rababah
*@Date:27/4/2020
*@param:
*@return:PatientsScreen
*@desc:
*/
import 'package:doctor_app_flutter/models/patient/patient_model.dart';
import 'package:doctor_app_flutter/providers/patients_provider.dart';
import 'package:doctor_app_flutter/routes.dart';
import 'package:doctor_app_flutter/screens/patients/TopTenUsersModelResponse.dart';
import 'package:doctor_app_flutter/screens/patients/patiant_info_model.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;
//*******************
List<PatiantInformtion> responseModelList;
//List<PatiantInformtion<dynamic>> litems2;
//*******************
bool _isInit = true;
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;
//PatientModel patient = routeArgs['patientSearchForm'];
patient = routeArgs['patientSearchForm'];
//PatiantInformtion patiantInfo = routeArgs['patientSearchForm'];
print(patient.TokenID + "EEEEEE");
String patientType = routeArgs['selectedType'];
print("**************patiant Type**************");
print(patientType);
print("**************test**************");
if (_isInit) {
// setState(() {});
PatientsProvider patientsProv = Provider.of<PatientsProvider>(context);
patientsProv.getPatientList(patient, patientType).then((res) {
// print('MessageStatus${res['MessageStatus']}');
print('List_MyInPatient${(res['List_MyInPatient'])}');
setState(() {
int val2 = int.parse(patientType);
litems = res[SERVICES_PATIANT2[val2]]; //res['List_MyInPatient'];
//********************
// litems2=res[SERVICES_PATIANT2[val2]];
//PatiantInformtion
//List<PatiantInformtion> responseModelList = new PatiantInformtion.fromJson(litems).;//TopTenUsersModelResponse.fromJson(parsed).list;
final List parsed = litems; //json.decode(response.body);
//List<PatientModel> responseModelList = new TopTenUsersModelResponse.fromJson(parsed).list;
// List<PatiantInformtion> responseModelList = new TopTenUsersModelResponse.fromJson(parsed).list;
responseModelList =
new TopTenUsersModelResponse.fromJson(parsed).list;
//********************
_isLoading = false;
_hasError = res['ErrorEndUserMessage'];
});
print(res);
}).catchError((error) {
print(error);
});
}
_isInit = false;
super.didChangeDependencies();
}
@override
Widget build(BuildContext context) {
PatientsProvider patientsProv = Provider.of<PatientsProvider>(context);
return AppScaffold(
appBarTitle: 'Patients',
//***********Modify by amjad (create List view to insert all new data webservise in scroll )*************
body: Container(
child: ListView(
scrollDirection: Axis.vertical,
children: <Widget>[
Container(
//child:litems == null?Column():Column(children: <Widget>[
child: litems == null
? Column()
: Column(
children: <Widget>[
Container(
width: SizeConfig.screenWidth * 0.80,
child: TextField(
controller: _controller,
onSubmitted: (value) {
// fetch all the news related to the keyword
if (value.isNotEmpty) {
// vm.search(value);
}
},
decoration:
buildInputDecoration(context, 'Search patiant'),
),
),
Column(
children:
responseModelList.map((PatiantInformtion item) {
return InkWell(
child: CardWithBgWidget(
line1Text: item
.nationalityName, //item['FirstName'],//patient.getFirstName(),//item['FirstName'],
line2Text: item
.lastName, //responseModelList['LastName'],//item['LastName'],//'12/04/2020 - 02:00 PM',
// line3Text: item.middleName,
heightPercentage: 0.15,
widthPercentage: 0.80),
onTap: () =>
tapOnPatient(context, item, patientsProv),
);
}).toList())
],
),
),
],
)));
}
void tapOnPatient(BuildContext context, PatiantInformtion patient,
PatientsProvider patientsProv) {
patientsProv.setSelectedPatient(patient);
Navigator.of(context)
.pushNamed(PATIENTS_PROFILE, arguments: {"patient": patient});
}
//***********amjad update*************
InputDecoration buildInputDecoration(BuildContext context, hint) {
return InputDecoration(
prefixIcon: Icon(Icons.search, color: Colors.red),
filled: true,
fillColor: Colors.white,
//Image.asset(asset),
/* icon: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(Icons.search),
),*/
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),
));
}
//*************
}
//***********************