diff --git a/lib/config/config.dart b/lib/config/config.dart index d7dc1325..60e9bbd3 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -2,9 +2,9 @@ import 'package:diplomaticquarterapp/models/Request.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'dart:io'; +const MAX_SMALL_SCREEN = 660; -const MAX_SMALL_SCREEN = 660; const BASE_URL = 'https://hmgwebservices.com/Services'; @@ -18,7 +18,8 @@ const GET_CLINICS_LIST_URL = "Services/lists.svc/REST/GetClinicCentralized"; //URL to get doctors list const GET_DOCTORS_LIST_URL = "Services/Doctors.svc/REST/SearchDoctorsByTime"; - +const GET_PHARMCY_ITEMS = "/Lists.svc/REST/GetPharmcyItems_Region"; +const GET_PHARMACY_LIST = "/Patients.svc/REST/GetPharmcyList"; class AppGlobal { static var context; AppSharedPreferences sharedPref = AppSharedPreferences(); diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 66cc2c3f..c762812d 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -79,4 +79,10 @@ const Map> localizedValues = { "dob": {"en": "Birth Date:", "ar": "تاريخ الميلاد"}, "hijri-date": {"en": "Hijri Date", "ar": "التاريخ الهجري"}, "gregorian-date": {"en": "Gregorian Date", "ar": "التاريخ الميلادي"}, + 'searchMedicine': {'en': 'Search Medicine', 'ar': 'البحث عن الدواء'}, + 'pharmaciesList': {'en': 'Pharmacies List', 'ar': 'قائمة الصيدلايات'}, + 'searchMedicineHere': { + 'en': 'Search Medicine Here', + 'ar': 'ابحث عن الدواء هنا' + }, }; diff --git a/lib/core/enum/viewstate.dart b/lib/core/enum/viewstate.dart index 09b5d34b..94d79bec 100644 --- a/lib/core/enum/viewstate.dart +++ b/lib/core/enum/viewstate.dart @@ -1 +1 @@ -enum ViewState { Idle, Busy, Error } +enum ViewState { Idle, Busy, Error, BusyLocal, ErrorLocal } diff --git a/lib/core/model/hospitals/hospitals_model.dart b/lib/core/model/hospitals/hospitals_model.dart index a0628c60..a8308de8 100644 --- a/lib/core/model/hospitals/hospitals_model.dart +++ b/lib/core/model/hospitals/hospitals_model.dart @@ -18,21 +18,21 @@ class HospitalsModel { HospitalsModel( {this.desciption, - this.desciptionN, - this.iD, - this.legalName, - this.legalNameN, - this.name, - this.nameN, - this.phoneNumber, - this.setupID, - this.distanceInKilometers, - this.isActive, - this.latitude, - this.longitude, - this.mainProjectID, - this.projectOutSA, - this.usingInDoctorApp}); + this.desciptionN, + this.iD, + this.legalName, + this.legalNameN, + this.name, + this.nameN, + this.phoneNumber, + this.setupID, + this.distanceInKilometers, + this.isActive, + this.latitude, + this.longitude, + this.mainProjectID, + this.projectOutSA, + this.usingInDoctorApp}); HospitalsModel.fromJson(Map json) { desciption = json['Desciption']; diff --git a/lib/core/model/pharmacies/pharmacies_list_model.dart b/lib/core/model/pharmacies/pharmacies_list_model.dart new file mode 100644 index 00000000..34228e11 --- /dev/null +++ b/lib/core/model/pharmacies/pharmacies_list_model.dart @@ -0,0 +1,69 @@ +class PharmaciesListModel { + int itemID; + int patientTypeID; + int languageID; + String stamp; + String iPAdress; + double versionID; + String tokenID; + String sessionID; + bool isLoginForDoctorApp; + int patientOutSA; + int channel; + int doctorID; + int editedBy; + int projectID; + int clinicID; + + PharmaciesListModel({ + this.itemID, + this.patientTypeID = 1, + this.languageID = 2, + this.stamp = '2020-04-23T21:01:21.492Z', + this.iPAdress = '11.11.11.11', + this.versionID = 1.2, + this.tokenID, + this.sessionID = 'e29zoooEJ4', + this.isLoginForDoctorApp = true, + this.channel = 9, + //this.patientOutSA = true, + }); + + PharmaciesListModel.fromJson(Map json) { + itemID = json['ItemID']; + patientTypeID = json['PatientTypeID']; + languageID = json['LanguageID']; + stamp = json['stamp']; + iPAdress = json['IPAdress']; + versionID = json['VersionID']; + tokenID = json['TokenID']; + sessionID = json['SessionID']; + isLoginForDoctorApp = json['IsLoginForDoctorApp']; + patientOutSA = json['PatientOutSA']; + channel = json['Channel']; + doctorID = json['DoctorID']; + editedBy = json['EditedBy']; + projectID = json['ProjectID']; + clinicID = json['ClinicID']; + } + + Map toJson() { + final Map data = new Map(); + data['ItemID'] = this.itemID; + data['PatientTypeID'] = this.patientTypeID; + data['LanguageID'] = this.languageID; + data['stamp'] = this.stamp; + data['IPAdress'] = this.iPAdress; + data['VersionID'] = this.versionID; + data['TokenID'] = this.tokenID; + data['SessionID'] = this.sessionID; + data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; + data['PatientOutSA'] = this.patientOutSA; + data['Channel'] = this.channel; + data['DoctorID'] = this.doctorID; + data['EditedBy'] = this.editedBy; + data['ProjectID'] = this.projectID; + data['ClinicID'] = this.clinicID; + return data; + } +} diff --git a/lib/core/model/pharmacies/pharmacies_model.dart b/lib/core/model/pharmacies/pharmacies_model.dart new file mode 100644 index 00000000..69576dd2 --- /dev/null +++ b/lib/core/model/pharmacies/pharmacies_model.dart @@ -0,0 +1,94 @@ +class PharmaciesModel { + String pHRItemName; + int pageIndex; + int pageSize; + double versionID; + int channel; + int languageID; + String iPAdress; + String generalid; + int patientOutSA; + String sessionID; + bool isDentalAllowedBackend; + int deviceTypeID; + int doctorID; + int editedBy; + int projectID; + int clinicID; + String tokenID; + String stamp; + bool isLoginForDoctorApp; + String itemDes; + String productImage; + + PharmaciesModel( + {this.pHRItemName, + this.pageIndex, + this.pageSize, + this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID, + this.doctorID, + this.editedBy, + this.projectID, + this.clinicID, + this.tokenID, + this.stamp, + this.itemDes, + this.productImage, + this.isLoginForDoctorApp}); + + PharmaciesModel.fromJson(Map json) { + productImage = json['ProductImageBase64']; + itemDes = json['ItemDescription']; + pHRItemName = json['PHR_itemName']; + pageIndex = json['PageIndex']; + pageSize = json['PageSize']; + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; + doctorID = json['DoctorID']; + editedBy = json['EditedBy']; + projectID = json['ProjectID']; + clinicID = json['ClinicID']; + tokenID = json['TokenID']; + stamp = json['stamp']; + isLoginForDoctorApp = json['IsLoginForDoctorApp']; + } + + Map toJson() { + final Map data = new Map(); + data['PHR_itemName'] = this.pHRItemName; + data['PageIndex'] = this.pageIndex; + data['PageSize'] = this.pageSize; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['IPAdress'] = this.iPAdress; + data['generalid'] = this.generalid; + data['PatientOutSA'] = this.patientOutSA; + data['SessionID'] = this.sessionID; + data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; + data['DeviceTypeID'] = this.deviceTypeID; + data['DoctorID'] = this.doctorID; + data['EditedBy'] = this.editedBy; + data['ProjectID'] = this.projectID; + data['ClinicID'] = this.clinicID; + data['TokenID'] = this.tokenID; + data['stamp'] = this.stamp; + data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; + return data; + } +} diff --git a/lib/core/service/pharmacies_service.dart b/lib/core/service/pharmacies_service.dart new file mode 100644 index 00000000..fb59dceb --- /dev/null +++ b/lib/core/service/pharmacies_service.dart @@ -0,0 +1,72 @@ +import 'package:diplomaticquarterapp/config/config.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/pharmacies_list_model.dart'; +import 'package:diplomaticquarterapp/core/service/base_service.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/pharmacies_model.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/pharmacies_list_model.dart'; + +class PharmacyService extends BaseService { + List _pharmaciesList = List(); + + List get pharmaciesList => _pharmaciesList; + bool isFinished = true; + bool hasError = false; + String errorMsg = ''; + + void clearPharmaciesLis() { + _pharmaciesList.clear(); + } + + PharmaciesModel _requestGetPharmaciesModel = PharmaciesModel( + channel: 3, + clinicID: 1, + deviceTypeID: 2, + doctorID: 1485, + editedBy: 1485, + generalid: "Cs2020@2016\$2958", + iPAdress: "11.11.11.11", + isDentalAllowedBackend: false, + isLoginForDoctorApp: true, + languageID: 2, + pageIndex: 0, + pageSize: 20, + patientOutSA: 0, + pHRItemName: "panadol", + projectID: 15, + sessionID: "BlUSkYymTt", + stamp: "2020-04-27T12:17:17.721Z", + tokenID: "6EfeKCLRu0GPdFutIt3m7Q==", + versionID: 5.3); + + Future getMedicine({String drugName}) async { + hasError = false; + _requestGetPharmaciesModel.pHRItemName = drugName ?? 'panadol'; + try { + await baseAppClient.post(GET_PHARMCY_ITEMS, + onSuccess: (dynamic response, int statusCode) { + _pharmaciesList.clear(); + response['ListPharmcy_Region'].forEach((item) { + _pharmaciesList.add(PharmaciesModel.fromJson(item)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: _requestGetPharmaciesModel.toJson()); + } catch (error) { + throw error; + } + } + + Future getMedicineList({String name}) async { + _requestGetPharmaciesModel.pHRItemName = name ?? 'panadol'; + await baseAppClient.post(GET_PHARMACY_LIST, + onSuccess: (dynamic response, int statusCode) { + _pharmaciesList.clear(); + response['PharmList'].forEach((item) { + _pharmaciesList.add(PharmaciesModel.fromJson(item)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: _requestGetPharmaciesModel.toJson()); + } +} diff --git a/lib/core/viewModels/pharmacies_view_model.dart b/lib/core/viewModels/pharmacies_view_model.dart new file mode 100644 index 00000000..da40fbe3 --- /dev/null +++ b/lib/core/viewModels/pharmacies_view_model.dart @@ -0,0 +1,36 @@ +import '../../locator.dart'; +import 'base_view_model.dart'; +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/pharmacies_model.dart'; +import 'package:diplomaticquarterapp/core/service/pharmacies_service.dart'; + +class PharmacyViewModel extends BaseViewModel { + bool isFinished = true; + bool hasError = false; + String errorMsg = ''; + PharmacyService _pharmacyService = locator(); + + List get pharmacy => _pharmacyService.pharmaciesList; + + Future getMedicine() async { + setState(ViewState.Busy); + await _pharmacyService.getMedicine(); + if (_pharmacyService.hasError) { + error = _pharmacyService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + + Future getMedicine2({String name}) async { + hasError = false; + _pharmacyService.clearPharmaciesLis(); + setState(ViewState.BusyLocal); + await _pharmacyService.getMedicine(drugName: name); + if (_pharmacyService.hasError) { + error = _pharmacyService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } +} diff --git a/lib/locator.dart b/lib/locator.dart index 3d44f4ce..f6a76c1c 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -2,6 +2,8 @@ import 'package:get_it/get_it.dart'; import 'core/service/hospital_service.dart'; import 'core/viewModels/hospital_view_model.dart'; +import 'core/viewModels/pharmacies_view_model.dart'; +import 'core/service/pharmacies_service.dart'; GetIt locator = GetIt.instance; @@ -9,7 +11,9 @@ GetIt locator = GetIt.instance; void setupLocator() { /// Services locator.registerLazySingleton(() => HospitalService()); + locator.registerLazySingleton(() => PharmacyService()); /// View Model locator.registerFactory(() => HospitalViewModel()); + locator.registerFactory(() => PharmacyViewModel()); } diff --git a/lib/pages/landing/home_page.dart b/lib/pages/landing/home_page.dart index 0c449410..d94251bd 100644 --- a/lib/pages/landing/home_page.dart +++ b/lib/pages/landing/home_page.dart @@ -4,6 +4,8 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/pharmacies_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacies_view_model.dart'; import '../base/base_view.dart'; @@ -15,24 +17,23 @@ class HomePage extends StatefulWidget { class _HomePageState extends State { @override Widget build(BuildContext context) { - return BaseView( - onModelReady: (model) => model.getHospitals(), - builder: (BuildContext context, HospitalViewModel model, Widget child) => + return BaseView( + // onModelReady: (model) => model.getMedicine(), + builder: (BuildContext context, PharmacyViewModel model, Widget child) => AppScaffold( baseViewModel: model, body: Column( children: [ InkWell( onTap: () { - model.getHospitals(); + model.getMedicine(); }, child: Container( - child: Texts('call api '), + child: Texts('call api'), ), - ), Expanded( - child: _getHospitals(model.hospitals), + child: _getHospitals(model.pharmacy), ) // BaseView( // onModelReady: (dctorViewModel) => dctorViewModel.getHospitals(), @@ -60,10 +61,10 @@ class _HomePageState extends State { ); } - Widget _getHospitals(List hospitals) => ListView.builder( - itemCount: hospitals.length, - itemBuilder: (BuildContext context, int index) => Container( - child: Texts(hospitals[index].name), - ), - ); + Widget _getHospitals(List hospitals) => ListView.builder( + itemCount: hospitals.length, + itemBuilder: (BuildContext context, int index) => Container( + child: Texts(hospitals[index].itemDes), + ), + ); } diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index 3b02024d..06cf861b 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -3,6 +3,7 @@ import 'package:diplomaticquarterapp/core/model/auth/select_device_imei_res.dart import 'package:diplomaticquarterapp/pages/ToDoList/ToDo.dart'; import 'package:diplomaticquarterapp/pages/landing/replay_page.dart'; import 'package:diplomaticquarterapp/providers/auth_provider.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/medicine_search_screen.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/bottom_navigation/bottom_nav_bar.dart'; import 'package:diplomaticquarterapp/widgets/drawer/app_drawer_widget.dart'; @@ -47,7 +48,6 @@ class _LandingPageState extends State { return Scaffold( appBar: AppBar( elevation: 0, - backgroundColor: Colors.grey, textTheme: TextTheme( headline6: TextStyle(color: Colors.white, fontWeight: FontWeight.bold), @@ -69,7 +69,7 @@ class _LandingPageState extends State { body: PageView( physics: NeverScrollableScrollPhysics(), controller: pageController, - children: [HomePage(), ReplayPage(), Container(), ToDo()], + children: [HomePage(), MedicineSearch(), Container(), Container()], ), bottomNavigationBar: BottomNavBar(changeIndex: _changeCurrentTab), ); @@ -80,7 +80,7 @@ class _LandingPageState extends State { case 0: return TranslationBase.of(context).home; case 1: - return 'asd'; + return 'Search Medicine'; case 2: return TranslationBase.of(context).mySchedule; case 3: diff --git a/lib/pages/pharmacies/medicine_search_screen.dart b/lib/pages/pharmacies/medicine_search_screen.dart new file mode 100644 index 00000000..200a7838 --- /dev/null +++ b/lib/pages/pharmacies/medicine_search_screen.dart @@ -0,0 +1,145 @@ +import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/pharmacies_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacies_view_model.dart'; +import '../base/base_view.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/BottomButton.dart'; +import 'package:diplomaticquarterapp/widgets/pharmacy/drug_item.dart'; +import '../../locator.dart'; +import 'package:diplomaticquarterapp/core/service/pharmacies_service.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/pharmacies_list_screen.dart'; + +class MedicineSearch extends StatefulWidget { + @override + _MedicineSearchState createState() => _MedicineSearchState(); +} + +class _MedicineSearchState extends State { + final textController = TextEditingController(); + final _formKey = GlobalKey(); + @override + Widget build(BuildContext context) { + return BaseView( + builder: (BuildContext context, PharmacyViewModel model, Widget child) => + AppScaffold( + baseViewModel: model, + appBarTitle: 'Search Medicine', + body: Column( + children: [ + Padding( + padding: EdgeInsets.only( + bottom: SizeConfig.heightMultiplier * 1, + right: SizeConfig.heightMultiplier * 2.5, + top: SizeConfig.heightMultiplier * 4, + left: SizeConfig.heightMultiplier * 2.5, + ), + child: Form( + key: _formKey, + child: TextFields( + hintText: 'Search Medicine here ', + inputAction: TextInputAction.search, + onSaved: (value) {}, + onSubmit: (value) { + searchMedicine(model); + }, + controller: textController, + validator: (value) { + if (value.isEmpty) { + return 'please enter medicine name'; + } + return null; + }, + ), + ), + ), + Container( + margin: EdgeInsets.only( + bottom: SizeConfig.heightMultiplier * 0.0, + right: SizeConfig.heightMultiplier * 5, + top: SizeConfig.heightMultiplier * 1, + left: SizeConfig.heightMultiplier * 5, + ), + child: Wrap( + children: [ + Container( + child: Button( + loading: model.state == ViewState.BusyLocal, + label: 'Search', + onTap: () { + searchMedicine(model); + }), + width: 350.0, + ), + ], + ), + ), + Container( + margin: + EdgeInsets.only(left: SizeConfig.heightMultiplier * 2), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + 'You Can Find ' + + '${model.pharmacy == null ? '0' : model.pharmacy.length.toString()}' + ' Item In Search ', + ), + ], + ), + ), + if (model.state == ViewState.ErrorLocal) + Container( + child: Texts(model.error), + ), + Expanded( + child: Container( + width: SizeConfig.screenWidth * 0.85, + //child: _getHospitals(model.pharmacy), + child: ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: model.pharmacy == null + ? 0 + : model.pharmacy.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + child: MedicineItemWidget( + label: model.pharmacy[index].itemDes, + url: model.pharmacy[index].productImage), + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => PharmaciesList()), + ); + }, + ); + }), + ), + ) + ], + )), + ); + } + + searchMedicine(PharmacyViewModel model) { + Utils.hideKeyboard(context); + if (_formKey.currentState.validate()) + model.getMedicine2(name: textController.text); + } + + Widget _getHospitals(List hospitals) => ListView.builder( + itemCount: hospitals.length, + itemBuilder: (BuildContext context, int index) => Container( + child: Texts(hospitals[index].itemDes), + ), + ); +} diff --git a/lib/pages/pharmacies/pharmacies_list_screen.dart b/lib/pages/pharmacies/pharmacies_list_screen.dart new file mode 100644 index 00000000..8a43af56 --- /dev/null +++ b/lib/pages/pharmacies/pharmacies_list_screen.dart @@ -0,0 +1,99 @@ +import 'package:flutter/material.dart'; +import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:flutter/cupertino.dart'; +import '../base/base_view.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; +import 'package:diplomaticquarterapp/widgets/others/rounded_container.dart'; +import 'dart:typed_data'; +import 'dart:convert'; + +import 'package:diplomaticquarterapp/core/viewModels/pharmacies_view_model.dart'; +import 'package:map_launcher/map_launcher.dart'; + +class PharmaciesList extends StatefulWidget { + String medicineID; + int url; + + PharmaciesList({this.url, this.medicineID}); + + @override + _PharmaciesListState createState() => _PharmaciesListState(); + +// +} + +class _PharmaciesListState extends State { + @override + Widget build(BuildContext context) { + return BaseView( + //onModelReady: (model) => model.getMedicine(), + builder: (BuildContext context, PharmacyViewModel model, Widget child) => + AppScaffold( + appBarTitle: 'Pharmacies List', + body: !model.isFinished + ? AppCircularProgressIndicator() + : model.hasError + ? Center( + child: Text( + model.errorMsg, + style: TextStyle(color: Colors.red), + ), + ) + : Container( + height: SizeConfig.screenHeight, + child: ListView( + shrinkWrap: true, + scrollDirection: Axis.vertical, + physics: AlwaysScrollableScrollPhysics(), + children: [ + RoundedContainer( + child: Row( + children: [ + Expanded( + flex: 1, + child: ClipRRect( + borderRadius: BorderRadius.all( + Radius.circular(7), + ), + child: Image.memory( + dataFromBase64String( + widget.url.toString()), + height: + SizeConfig.imageSizeMultiplier * 19, + width: + SizeConfig.imageSizeMultiplier * 18, + fit: BoxFit.cover, + ), + ), + ), + Expanded( + flex: 3, + child: Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.stretch, + children: [], + ), + ) + ], + )) + ], + ), + )), + ); + } + + Image imageFromBase64String(String base64String) { + return Image.memory(base64Decode(base64String)); + } + + Uint8List dataFromBase64String(String base64String) { + return base64Decode(base64String); + } + + String base64String(Uint8List data) { + return base64Encode(data); + } +} diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index bbeef4e0..26d30363 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -122,6 +122,10 @@ class TranslationBase { String get hijriDate => localizedValues['hijri-date'][locale.languageCode]; String get gregorianDate => localizedValues['gregorian-date'][locale.languageCode]; + String get searchMedicine => + localizedValues['searchMedicine'][locale.languageCode]; + String get searchMedicineHere => + localizedValues['searchMedicineHere'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/data_display/text.dart b/lib/widgets/data_display/text.dart index 5360a7d6..851c678d 100644 --- a/lib/widgets/data_display/text.dart +++ b/lib/widgets/data_display/text.dart @@ -15,6 +15,7 @@ class Texts extends StatefulWidget { final String style; final bool allowExpand; final double fontSize; + final String fontWeight; Texts(this.text, {Key key, @@ -30,7 +31,8 @@ class Texts extends StatefulWidget { this.maxLines, this.readMore = false, this.style, - this.fontSize}) + this.fontSize, + this.fontWeight}) : super(key: key); @override @@ -208,8 +210,7 @@ class _TextsState extends State { ) : TextStyle( fontStyle: widget.italic ? FontStyle.italic : null, - color: - widget.color ?? Colors.black, + color: widget.color ?? Colors.black, fontSize: widget.fontSize ?? _getFontSize(), letterSpacing: widget.variant == "overline" ? 1.5 : null, diff --git a/lib/widgets/others/network_base_view.dart b/lib/widgets/others/network_base_view.dart index 8188db26..78c47783 100644 --- a/lib/widgets/others/network_base_view.dart +++ b/lib/widgets/others/network_base_view.dart @@ -19,7 +19,9 @@ class NetworkBaseView extends StatelessWidget { buildBaseViewWidget() { switch (baseViewModel.state) { + case ViewState.ErrorLocal: case ViewState.Idle: + case ViewState.BusyLocal: return child; break; case ViewState.Busy: diff --git a/lib/widgets/others/rounded_container.dart b/lib/widgets/others/rounded_container.dart new file mode 100644 index 00000000..93dc6cc4 --- /dev/null +++ b/lib/widgets/others/rounded_container.dart @@ -0,0 +1,84 @@ +import 'package:flutter/material.dart'; + +class RoundedContainer extends StatefulWidget { + final double width; + final double height; + final double raduis; + final Color backgroundColor; + final double margin; + final double elevation; + final bool showBorder; + final Color borderColor; + final bool customCornerRaduis; + final double topLeft; + final double bottomRight; + final double topRight; + final double bottomLeft; + final Widget child; + final double borderWidth; + + RoundedContainer( + {@required this.child, + this.width, + this.height, + this.raduis = 10, + this.backgroundColor = Colors.white, + this.margin = 10, + this.elevation = 1, + this.showBorder = false, + this.borderColor = Colors.red, + this.customCornerRaduis = false, + this.topLeft = 0, + this.topRight = 0, + this.bottomRight = 0, + this.bottomLeft = 0, + this.borderWidth = 1}); + + @override + _RoundedContainerState createState() => _RoundedContainerState(); +} + +class _RoundedContainerState extends State { + @override + Widget build(BuildContext context) { + return Container( + width: widget.width, + height: widget.height, + margin: EdgeInsets.all(widget.margin), + decoration: widget.showBorder == true + ? BoxDecoration( + color: Theme.of(context).primaryColor, + border: Border.all( + color: widget.borderColor, width: widget.borderWidth), + borderRadius: widget.customCornerRaduis + ? BorderRadius.only( + topLeft: Radius.circular(widget.topLeft), + topRight: Radius.circular(widget.topRight), + bottomRight: Radius.circular(widget.bottomRight), + bottomLeft: Radius.circular(widget.bottomLeft)) + : BorderRadius.circular(widget.raduis), + boxShadow: [ + BoxShadow( + color: Colors.grey.withOpacity(0.1), + spreadRadius: 10, + blurRadius: 5, + offset: Offset(0, 5), // changes position of shadow + ), + ]) + : null, + child: Card( + margin: EdgeInsets.all(0), + shape: RoundedRectangleBorder( + borderRadius: widget.customCornerRaduis + ? BorderRadius.only( + topLeft: Radius.circular(widget.topLeft), + topRight: Radius.circular(widget.topRight), + bottomRight: Radius.circular(widget.bottomRight), + bottomLeft: Radius.circular(widget.bottomLeft)) + : BorderRadius.circular(widget.raduis), + ), + color: widget.backgroundColor, + child: widget.child, + )); + } +} diff --git a/lib/widgets/pharmacy/drug_item.dart b/lib/widgets/pharmacy/drug_item.dart new file mode 100644 index 00000000..608b1b98 --- /dev/null +++ b/lib/widgets/pharmacy/drug_item.dart @@ -0,0 +1,84 @@ +import 'dart:convert'; +import 'dart:typed_data'; + +import 'package:diplomaticquarterapp/widgets/others/rounded_container.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/config/size_config.dart'; + +import 'package:flutter/material.dart'; + +class MedicineItemWidget extends StatefulWidget { + final String label; + final Color backgroundColor; + final bool showBorder; + final Color borderColor; + final String url; + + MedicineItemWidget( + {@required this.label, + this.backgroundColor = Colors.white, + this.showBorder = false, + this.borderColor = Colors.white, + this.url}); + + @override + _MedicineItemWidgetState createState() => _MedicineItemWidgetState(); +} + +class _MedicineItemWidgetState extends State { + @override + Widget build(BuildContext context) { + return new RoundedContainer( + height: SizeConfig.heightMultiplier * 10.5, + child: Padding( + padding: const EdgeInsets.all(2.0), + child: Row( + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + if (widget.url != null) + Container( + height: 39, + width: 39, + child: ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(7)), + child: Image.memory( + dataFromBase64String(widget.url), + height: SizeConfig.imageSizeMultiplier * 11, + width: SizeConfig.imageSizeMultiplier * 11, + fit: BoxFit.cover, + ), + ), + ), + Expanded( + child: Padding( + padding: EdgeInsets.all(3), + child: Align( + alignment: Alignment.centerLeft, + child: Texts(widget.label), + ), + ), + ) + ], + ), + ), + backgroundColor: widget.backgroundColor, + showBorder: widget.showBorder, + borderColor: widget.borderColor, + margin: 4, + raduis: 10, + ); + } + + Image imageFromBase64String(String base64String) { + return Image.memory(base64Decode(base64String)); + } + + Uint8List dataFromBase64String(String base64String) { + return base64Decode(base64String); + } + + String base64String(Uint8List data) { + return base64Encode(data); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 9a13dcdd..77e6d45b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,7 +39,7 @@ dependencies: shared_preferences: ^0.5.8 flutter_flexible_toast: ^0.1.4 firebase_messaging: ^6.0.16 - + # Progress bar progress_hud_v2: ^2.0.0 percent_indicator: ^2.1.5 @@ -78,6 +78,11 @@ dependencies: # SVG Images flutter_svg: ^0.17.4 + # Location Helper + map_launcher: ^0.8.1 + + +