|
|
|
|
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/util/dr_app_shared_pref.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
import '../../routes.dart';
|
|
|
|
|
|
|
|
|
|
DrAppSharedPreferances sharedPref = DrAppSharedPreferances();
|
|
|
|
|
|
|
|
|
|
class MedicineSearchScreen extends StatefulWidget with DrAppToastMsg {
|
|
|
|
|
MedicineSearchScreen({this.changeLoadingStata});
|
|
|
|
|
final Function changeLoadingStata;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_MedicineSearchState createState() => _MedicineSearchState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _MedicineSearchState extends State<MedicineSearchScreen> {
|
|
|
|
|
var _medicineModel = PharmaciesItemsRequestModel(
|
|
|
|
|
IsLoginForDoctorApp: true,
|
|
|
|
|
PHR_itemName: "Panadol",
|
|
|
|
|
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");
|
|
|
|
|
@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: RaisedButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
MedicineProvider medicineProvider =
|
|
|
|
|
Provider.of<MedicineProvider>(context);
|
|
|
|
|
searchMedicine(context, medicineProvider);
|
|
|
|
|
Navigator.of(context).pushNamed(PHARMACIES_LIST);
|
|
|
|
|
},
|
|
|
|
|
))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
searchMedicine(
|
|
|
|
|
context, MedicineProvider medicineProvider) {
|
|
|
|
|
|
|
|
|
|
medicineProvider.getMedicineItem(_medicineModel).then((res) {
|
|
|
|
|
|
|
|
|
|
if (res['MessageStatus'] == 1) {
|
|
|
|
|
print("ListMedicine " + res['ListPharmcy'].toString());
|
|
|
|
|
|
|
|
|
|
//Navigator.of(context).pushNamed();
|
|
|
|
|
} else {
|
|
|
|
|
// handel error
|
|
|
|
|
// widget.showCenterShortLoadingToast("watting");
|
|
|
|
|
//helpers.showErrorToast(res['ErrorEndUserMessage']);
|
|
|
|
|
}
|
|
|
|
|
// Navigator.of(context).pushNamed(HOME);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print('$err');
|
|
|
|
|
//helpers.showErrorToast();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|