medicine search fix bugs =

pull/168/head
Elham Rababah 5 years ago
parent ec3b69f0cb
commit 91cc76a9cf

@ -242,4 +242,11 @@ const Map<String, Map<String, String>> localizedValues = {
'en': 'You don\'t have any Items', 'en': 'You don\'t have any Items',
'ar': 'لا يوجد اي نتائج' 'ar': 'لا يوجد اي نتائج'
}, },
'typeMedicineName': {
'en': 'Type Medicine Name',
'ar': 'اكتب اسم الدواء'
},'moreThan3Letter': {
'en': 'Medicine Name Should Be More Than 3 letter',
'ar': 'يجب أن يكون اسم الدواء أكثر من 3 أحرف'
},
}; };

@ -441,6 +441,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[ children: <Widget>[
Container( Container(
margin: EdgeInsets.only(top: 10),
child: Icon( child: Icon(
DoctorApp.radiology, DoctorApp.radiology,
size: 40, size: 40,
@ -448,6 +449,8 @@ class _DashboardScreenState extends State<DashboardScreen> {
), ),
), ),
Container( Container(
margin: EdgeInsets.only(bottom: 10),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
AppText( AppText(
@ -651,7 +654,6 @@ class _DashboardScreenState extends State<DashboardScreen> {
DashboardItem( DashboardItem(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround, mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Center( Center(
child: Icon( child: Icon(
@ -777,14 +779,18 @@ class _DashboardScreenState extends State<DashboardScreen> {
Column( Column(
children: [ children: [
AppText( AppText(
TranslationBase projectsProvider.isArabic
.of(context) ? TranslationBase.of(context).reader
.qr, : TranslationBase.of(context).qr,
color: Colors.black, color: Colors.black,
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
AppText( AppText(
TranslationBase projectsProvider.isArabic
? TranslationBase
.of(context)
.qr
: TranslationBase
.of(context) .of(context)
.reader, .reader,
color: Colors.black, color: Colors.black,

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
@ -14,19 +16,19 @@ import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart'; import 'package:doctor_app_flutter/widgets/shared/dr_app_circular_progress_Indeicator.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../util/extenstions.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_recognition_error.dart';
import 'package:speech_to_text/speech_recognition_result.dart'; import 'package:speech_to_text/speech_recognition_result.dart';
import 'package:speech_to_text/speech_to_text.dart'; import 'package:speech_to_text/speech_to_text.dart';
import 'dart:math';
import '../../util/extenstions.dart';
DrAppSharedPreferances sharedPref = DrAppSharedPreferances(); DrAppSharedPreferances sharedPref = DrAppSharedPreferances();
class MedicineSearchScreen extends StatefulWidget with DrAppToastMsg { class MedicineSearchScreen extends StatefulWidget with DrAppToastMsg {
MedicineSearchScreen({this.changeLoadingStata}); MedicineSearchScreen({this.changeLoadingStata});
final Function changeLoadingStata; final Function changeLoadingStata;
@override @override
@ -43,6 +45,7 @@ class _MedicineSearchState extends State<MedicineSearchScreen> {
bool _isInit = true; bool _isInit = true;
final SpeechToText speech = SpeechToText(); final SpeechToText speech = SpeechToText();
String lastStatus = ''; String lastStatus = '';
// String lastWords; // String lastWords;
List<LocaleName> _localeNames = []; List<LocaleName> _localeNames = [];
String lastError; String lastError;
@ -50,6 +53,7 @@ class _MedicineSearchState extends State<MedicineSearchScreen> {
double minSoundLevel = 50000; double minSoundLevel = 50000;
double maxSoundLevel = -50000; double maxSoundLevel = -50000;
String reconizedWord; String reconizedWord;
@override @override
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
@ -92,7 +96,8 @@ class _MedicineSearchState extends State<MedicineSearchScreen> {
appBarTitle: TranslationBase.of(context).searchMedicine, appBarTitle: TranslationBase.of(context).searchMedicine,
body: FractionallySizedBox( body: FractionallySizedBox(
widthFactor: 0.97, widthFactor: 0.97,
child: ListView( child: SingleChildScrollView(
child: Column(
children: <Widget>[ children: <Widget>[
Column( Column(
children: <Widget>[ children: <Widget>[
@ -121,14 +126,17 @@ class _MedicineSearchState extends State<MedicineSearchScreen> {
) )
], ],
), ),
SizedBox(height: 15,), SizedBox(
height: 15,
),
FractionallySizedBox( FractionallySizedBox(
widthFactor: 0.9, widthFactor: 0.9,
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Container( Container(
child: AppTextFormField( child: AppTextFormField(
hintText: TranslationBase.of(context).searchMedicineNameHere, hintText: TranslationBase.of(context)
.searchMedicineNameHere,
controller: myController, controller: myController,
onSaved: (value) {}, onSaved: (value) {},
onFieldSubmitted: (value) { onFieldSubmitted: (value) {
@ -150,16 +158,15 @@ class _MedicineSearchState extends State<MedicineSearchScreen> {
// }), // }),
inputFormatter: ONLY_LETTERS), inputFormatter: ONLY_LETTERS),
), ),
SizedBox(height: 15,), SizedBox(
height: 15,
),
Container( Container(
child: Wrap( child: Wrap(
alignment: WrapAlignment.center, alignment: WrapAlignment.center,
children: <Widget>[ children: <Widget>[
AppButton( AppButton(
title: TranslationBase title: TranslationBase.of(context).search,
.of(context)
.search,
onPressed: () { onPressed: () {
searchMedicine(context); searchMedicine(context);
}, },
@ -168,25 +175,25 @@ class _MedicineSearchState extends State<MedicineSearchScreen> {
), ),
), ),
Container( Container(
margin: EdgeInsets.only(left: SizeConfig.heightMultiplier * 2), margin: EdgeInsets.only(
left: SizeConfig.heightMultiplier * 2),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
AppText( AppText(
TranslationBase TranslationBase.of(context).youCanFind +
.of(context)
.youCanFind +
_medicineProvider.pharmacyItemsList.length _medicineProvider.pharmacyItemsList.length
.toString() +" "+ .toString() +
TranslationBase " " +
.of(context) TranslationBase.of(context).itemsInSearch,
.itemsInSearch,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
], ],
), ),
), ),
Container( Container(
height: MediaQuery.of(context).size.height * 0.35,
child: Container(
child: !_medicineProvider.isFinished child: !_medicineProvider.isFinished
? DrAppCircularProgressIndeicator() ? DrAppCircularProgressIndeicator()
: _medicineProvider.hasError : _medicineProvider.hasError
@ -194,25 +201,29 @@ class _MedicineSearchState extends State<MedicineSearchScreen> {
child: Text( child: Text(
_medicineProvider.errorMsg, _medicineProvider.errorMsg,
style: TextStyle( style: TextStyle(
color: Theme.of(context).errorColor), color:
Theme.of(context).errorColor),
), ),
) )
: ListView.builder( : ListView.builder(
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
shrinkWrap: true, shrinkWrap: true,
itemCount: _medicineProvider.pharmacyItemsList == itemCount:
_medicineProvider.pharmacyItemsList ==
null null
? 0 ? 0
: _medicineProvider.pharmacyItemsList.length, : _medicineProvider
itemBuilder: (BuildContext context, int index) { .pharmacyItemsList.length,
itemBuilder:
(BuildContext context, int index) {
return InkWell( return InkWell(
child: MedicineItemWidget( child: MedicineItemWidget(
label: label: _medicineProvider
_medicineProvider.pharmacyItemsList[index] .pharmacyItemsList[index]
["ItemDescription"], ["ItemDescription"],
url: url: _medicineProvider
_medicineProvider.pharmacyItemsList[index] .pharmacyItemsList[index]
["ProductImageBase64"], ["ImageSRCUrl"],
), ),
onTap: () { onTap: () {
Navigator.push( Navigator.push(
@ -221,11 +232,11 @@ class _MedicineSearchState extends State<MedicineSearchScreen> {
builder: (context) => builder: (context) =>
PharmaciesListScreen( PharmaciesListScreen(
itemID: _medicineProvider itemID: _medicineProvider
.pharmacyItemsList[index] .pharmacyItemsList[
["ItemID"], index]["ItemID"],
url: _medicineProvider url: _medicineProvider
.pharmacyItemsList[index] .pharmacyItemsList[
["ProductImageBase64"]), index]["ImageSRCUrl"]),
), ),
); );
}, },
@ -233,12 +244,13 @@ class _MedicineSearchState extends State<MedicineSearchScreen> {
}, },
), ),
), ),
),
], ],
), ),
), ),
], ],
), ),
),
)); ));
} }
@ -246,7 +258,13 @@ class _MedicineSearchState extends State<MedicineSearchScreen> {
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
if (myController.text.isNullOrEmpty()) { if (myController.text.isNullOrEmpty()) {
_medicineProvider.clearPharmacyItemsList(); _medicineProvider.clearPharmacyItemsList();
helpers.showErrorToast("Type Medicine Name"); helpers.showErrorToast(TranslationBase.of(context).typeMedicineName) ;
//"Type Medicine Name")
return;
}
if (myController.text.length < 3) {
_medicineProvider.clearPharmacyItemsList();
helpers.showErrorToast(TranslationBase.of(context).moreThan3Letter);
return; return;
} }
_medicineProvider.getMedicineItem(myController.text); _medicineProvider.getMedicineItem(myController.text);

@ -80,8 +80,8 @@ class _PharmaciesListState extends State<PharmaciesListScreen> {
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.all( borderRadius: BorderRadius.all(
Radius.circular(7)), Radius.circular(7)),
child: widget.url != null ?Image.memory( child: widget.url != null ?Image.network(
dataFromBase64String(widget.url), widget.url,
height: height:
SizeConfig.imageSizeMultiplier * SizeConfig.imageSizeMultiplier *
21, 21,

@ -625,7 +625,8 @@ class _PatientsScreenState extends State<PatientsScreen> {
} }
Widget _locationBar(BuildContext _context) { Widget _locationBar(BuildContext _context) {
return Container( return Expanded(
child: Container(
height: MediaQuery height: MediaQuery
.of(context) .of(context)
.size .size
@ -685,6 +686,7 @@ class _PatientsScreenState extends State<PatientsScreen> {
]); ]);
}).toList(), }).toList(),
), ),
),
); );
} }

@ -271,6 +271,8 @@ class TranslationBase {
localizedValues['searchPatientImageCaptionBody'][locale.languageCode]; localizedValues['searchPatientImageCaptionBody'][locale.languageCode];
String get welcome => localizedValues['welcome'][locale.languageCode]; String get welcome => localizedValues['welcome'][locale.languageCode];
String get typeMedicineName => localizedValues['typeMedicineName'][locale.languageCode];
String get moreThan3Letter => localizedValues['moreThan3Letter'][locale.languageCode];
} }
class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> { class TranslationBaseDelegate extends LocalizationsDelegate<TranslationBase> {

Loading…
Cancel
Save