Merge branch 'SearchMedicineAndReturnMedicineList' into 'master'
design for search medicine and return medicine list See merge request Cloud_Solution/diplomatic-quarter!6merge-requests/13/merge
commit
ae2f9a077d
@ -1 +1 @@
|
|||||||
enum ViewState { Idle, Busy, Error }
|
enum ViewState { Idle, Busy, Error, BusyLocal, ErrorLocal }
|
||||||
|
|||||||
@ -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<String, dynamic> 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<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<String, dynamic> 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<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<PharmaciesModel> _pharmaciesList = List();
|
||||||
|
|
||||||
|
List<PharmaciesModel> 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<PharmacyService>();
|
||||||
|
|
||||||
|
List<PharmaciesModel> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<MedicineSearch> {
|
||||||
|
final textController = TextEditingController();
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BaseView<PharmacyViewModel>(
|
||||||
|
builder: (BuildContext context, PharmacyViewModel model, Widget child) =>
|
||||||
|
AppScaffold(
|
||||||
|
baseViewModel: model,
|
||||||
|
appBarTitle: 'Search Medicine',
|
||||||
|
body: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
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<PharmaciesModel> hospitals) => ListView.builder(
|
||||||
|
itemCount: hospitals.length,
|
||||||
|
itemBuilder: (BuildContext context, int index) => Container(
|
||||||
|
child: Texts(hospitals[index].itemDes),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -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<PharmaciesList> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BaseView<PharmacyViewModel>(
|
||||||
|
//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: <Widget>[
|
||||||
|
RoundedContainer(
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
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: <Widget>[],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Image imageFromBase64String(String base64String) {
|
||||||
|
return Image.memory(base64Decode(base64String));
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint8List dataFromBase64String(String base64String) {
|
||||||
|
return base64Decode(base64String);
|
||||||
|
}
|
||||||
|
|
||||||
|
String base64String(Uint8List data) {
|
||||||
|
return base64Encode(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<RoundedContainer> {
|
||||||
|
@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,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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<MedicineItemWidget> {
|
||||||
|
@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: <Widget>[
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue