|
|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
import 'package:doctor_app_flutter/config/config.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/pharmacies_items_request_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/providers/medicine_provider.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/screens/medicine/pharmacies_list_screen.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
|
|
|
|
|
@ -13,7 +12,6 @@ import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import '../../routes.dart';
|
|
|
|
|
import '../../util/extenstions.dart';
|
|
|
|
|
|
|
|
|
|
DrAppSharedPreferances sharedPref = DrAppSharedPreferances();
|
|
|
|
|
@ -31,101 +29,89 @@ class _MedicineSearchState extends State<MedicineSearchScreen> {
|
|
|
|
|
final myController = TextEditingController();
|
|
|
|
|
Helpers helpers = new Helpers();
|
|
|
|
|
|
|
|
|
|
var _medicineModel = PharmaciesItemsRequestModel(
|
|
|
|
|
IsLoginForDoctorApp: true,
|
|
|
|
|
PatientOutSA: false,
|
|
|
|
|
PatientTypeID: 1,
|
|
|
|
|
LanguageID: 2,
|
|
|
|
|
IPAdress: "11.11.11.11",
|
|
|
|
|
VersionID: 1.2,
|
|
|
|
|
TokenID: "2Fi7HoIHB0eDyekVa6tCJg==",
|
|
|
|
|
stamp: "2020-04-23T21:01:21.492Z",
|
|
|
|
|
SessionID: "e29zoooEJ4");
|
|
|
|
|
MedicineProvider _medicineProvider;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return ChangeNotifierProvider(
|
|
|
|
|
create: (context) => MedicineProvider(), //change builder to create
|
|
|
|
|
child: Consumer<MedicineProvider>(
|
|
|
|
|
builder: (context, provider, child) => AppScaffold(
|
|
|
|
|
appBarTitle: "Search Medicine",
|
|
|
|
|
body: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
RoundedContainer(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Icon(
|
|
|
|
|
Icons.search,
|
|
|
|
|
size: SizeConfig.imageSizeMultiplier * 15,
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
bottom: SizeConfig.heightMultiplier * 5,
|
|
|
|
|
right: SizeConfig.heightMultiplier * 3,
|
|
|
|
|
left: SizeConfig.heightMultiplier * 3,
|
|
|
|
|
top: SizeConfig.heightMultiplier * 3),
|
|
|
|
|
child: AppTextFormField(
|
|
|
|
|
hintText: 'Type Medicine Name Here..',
|
|
|
|
|
controller: myController,
|
|
|
|
|
onSaved: (value) {},
|
|
|
|
|
// validator: (value) {
|
|
|
|
|
// return TextValidator().validateName(value);
|
|
|
|
|
// },
|
|
|
|
|
inputFormatter: ONLY_LETTERS),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
|
|
|
|
|
child: Wrap(
|
|
|
|
|
alignment: WrapAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
AppButton(
|
|
|
|
|
title: "Search",
|
|
|
|
|
color: Color(0xff58434F),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
MedicineProvider medicineProvider =
|
|
|
|
|
Provider.of<MedicineProvider>(context);
|
|
|
|
|
searchMedicine(context, medicineProvider);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: SizeConfig.screenWidth * 0.80,
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
itemCount: data == null ? 0 : data.length,
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
return InkWell(
|
|
|
|
|
child: MedicineItemWidget(
|
|
|
|
|
label: data[index]["ItemDescription"],
|
|
|
|
|
),
|
|
|
|
|
onTap: () {
|
|
|
|
|
//Navigator.of(context).pushNamed(PHARMACIES_LIST);
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => PharmaciesListScreen(
|
|
|
|
|
itemID: data[index]["ItemID"]),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
_medicineProvider = Provider.of(context);
|
|
|
|
|
return AppScaffold(
|
|
|
|
|
appBarTitle: "Search Medicine",
|
|
|
|
|
body: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
RoundedContainer(
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Icon(
|
|
|
|
|
Icons.search,
|
|
|
|
|
size: SizeConfig.imageSizeMultiplier * 15,
|
|
|
|
|
),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
bottom: SizeConfig.heightMultiplier * 5,
|
|
|
|
|
right: SizeConfig.heightMultiplier * 3,
|
|
|
|
|
left: SizeConfig.heightMultiplier * 3,
|
|
|
|
|
top: SizeConfig.heightMultiplier * 3),
|
|
|
|
|
child: AppTextFormField(
|
|
|
|
|
hintText: 'Type Medicine Name Here..',
|
|
|
|
|
controller: myController,
|
|
|
|
|
onSaved: (value) {},
|
|
|
|
|
// validator: (value) {
|
|
|
|
|
// return TextValidator().validateName(value);
|
|
|
|
|
// },
|
|
|
|
|
inputFormatter: ONLY_LETTERS),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
)),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
|
|
|
|
|
child: Wrap(
|
|
|
|
|
alignment: WrapAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
AppButton(
|
|
|
|
|
title: "Search",
|
|
|
|
|
color: Color(0xff58434F),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
searchMedicine(context);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Container(
|
|
|
|
|
width: SizeConfig.screenWidth * 0.80,
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
itemCount: data == null ? 0 : data.length,
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
return InkWell(
|
|
|
|
|
child: MedicineItemWidget(
|
|
|
|
|
label: data[index]["ItemDescription"],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
))));
|
|
|
|
|
onTap: () {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
builder: (context) => ChangeNotifierProvider(
|
|
|
|
|
create: (_) => MedicineProvider(),
|
|
|
|
|
child: PharmaciesListScreen(
|
|
|
|
|
itemID: data[index]["ItemID"]),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
searchMedicine(context, MedicineProvider medicineProvider) {
|
|
|
|
|
searchMedicine(context) {
|
|
|
|
|
FocusScope.of(context).unfocus();
|
|
|
|
|
|
|
|
|
|
if (myController.text.isNullOrEmpty()) {
|
|
|
|
|
this.setState(() {
|
|
|
|
|
data = null;
|
|
|
|
|
@ -133,29 +119,10 @@ class _MedicineSearchState extends State<MedicineSearchScreen> {
|
|
|
|
|
helpers.showErrorToast("Type Medicine Name");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
_medicineModel.PHR_itemName = myController.text;
|
|
|
|
|
medicineProvider.getMedicineItem(_medicineModel).then((res) {
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
print("ListMedicine " + res['ListPharmcy'].toString());
|
|
|
|
|
this.setState(() {
|
|
|
|
|
data = res['ListPharmcy'];
|
|
|
|
|
});
|
|
|
|
|
//Navigator.of(context).pushNamed(PHARMACIES_LIST);
|
|
|
|
|
} else {
|
|
|
|
|
// handel error
|
|
|
|
|
this.setState(() {
|
|
|
|
|
data = null;
|
|
|
|
|
});
|
|
|
|
|
widget.showCenterShortLoadingToast("watting");
|
|
|
|
|
helpers.showErrorToast(res['ErrorEndUserMessage']);
|
|
|
|
|
}
|
|
|
|
|
// Navigator.of(context).pushNamed(HOME);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print('$err');
|
|
|
|
|
_medicineProvider.getMedicineItem(myController.text).then((str) {
|
|
|
|
|
this.setState(() {
|
|
|
|
|
data = null;
|
|
|
|
|
data = _medicineProvider.pharmacyItemsList;
|
|
|
|
|
});
|
|
|
|
|
helpers.showErrorToast();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|