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.
129 lines
4.7 KiB
Dart
129 lines
4.7 KiB
Dart
import 'package:doctor_app_flutter/config/config.dart';
|
|
import 'package:doctor_app_flutter/config/size_config.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';
|
|
import 'package:doctor_app_flutter/util/dr_app_toast_msg.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_buttons_widget.dart';
|
|
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
|
|
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 '../../util/extenstions.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 data;
|
|
final myController = TextEditingController();
|
|
Helpers helpers = new Helpers();
|
|
|
|
MedicineProvider _medicineProvider;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
_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) {
|
|
FocusScope.of(context).unfocus();
|
|
if (myController.text.isNullOrEmpty()) {
|
|
this.setState(() {
|
|
data = null;
|
|
});
|
|
helpers.showErrorToast("Type Medicine Name");
|
|
return;
|
|
}
|
|
_medicineProvider.getMedicineItem(myController.text).then((str) {
|
|
this.setState(() {
|
|
data = _medicineProvider.pharmacyItemsList;
|
|
});
|
|
});
|
|
}
|
|
}
|