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.
153 lines
5.8 KiB
Dart
153 lines
5.8 KiB
Dart
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
import 'package:doctor_app_flutter/models/pharmacies_List_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/helpers.dart';
|
|
import 'package:doctor_app_flutter/widgets/medicine/medicine_item_widget.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
DrAppSharedPreferances sharedPref = DrAppSharedPreferances();
|
|
|
|
class PharmaciesListScreen extends StatefulWidget {
|
|
final int itemID;
|
|
|
|
// In the constructor, require a item id.
|
|
PharmaciesListScreen({Key key, @required this.itemID}) : super(key: key);
|
|
|
|
@override
|
|
_PharmaciesListState createState() => _PharmaciesListState();
|
|
}
|
|
|
|
class _PharmaciesListState extends State<PharmaciesListScreen> {
|
|
var data;
|
|
Helpers helpers = new Helpers();
|
|
|
|
var _pharmaciesModel = PharmaciesListRequestModel(
|
|
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",
|
|
Channel: 9,
|
|
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: "Pharmacies List",
|
|
body: Column(
|
|
children: <Widget>[
|
|
RoundedContainer(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: <Widget>[
|
|
AppText(
|
|
"Description",
|
|
margin: 10,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
AppText(
|
|
"ItemDescription",
|
|
marginLeft: 10,
|
|
marginTop: 0,
|
|
marginRight: 10,
|
|
marginBottom: 10,
|
|
),
|
|
AppText(
|
|
"Price",
|
|
margin: 10,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
AppText("SellingPrice",
|
|
marginLeft: 10,
|
|
marginTop: 0,
|
|
marginRight: 10,
|
|
marginBottom: 10,
|
|
),
|
|
],
|
|
)),
|
|
Container(
|
|
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
|
|
child: Align(
|
|
alignment: Alignment.centerLeft,
|
|
child: AppText(
|
|
"You can Find it in",
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: SizeConfig.textMultiplier * 3,
|
|
))),
|
|
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"]),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
// RaisedButton(
|
|
// onPressed: () {
|
|
//
|
|
// },
|
|
// )
|
|
)));
|
|
}
|
|
|
|
pharmaciesList(context) {
|
|
_pharmaciesModel.ItemID = widget.itemID;
|
|
MedicineProvider medicineProvider =
|
|
Provider.of<MedicineProvider>(context);
|
|
medicineProvider.getPharmaciesList(_pharmaciesModel).then((res) {
|
|
print(res.toString());
|
|
if (res['MessageStatus'] == 1) {
|
|
print("ListPharmcy " + res['PharmList'].toString());
|
|
this.setState(() {
|
|
data = res['PharmList'];
|
|
});
|
|
|
|
//Navigator.of(context).pushNamed();
|
|
} else {
|
|
// handel error
|
|
// widget.showCenterShortLoadingToast("watting");
|
|
//helpers.showErrorToast(res['ErrorEndUserMessage']);
|
|
print(res['MessageStatus'].toString());
|
|
}
|
|
// Navigator.of(context).pushNamed(HOME);
|
|
}).catchError((err) {
|
|
print('$err');
|
|
//helpers.showErrorToast();
|
|
});
|
|
}
|
|
}
|