Finish H2O Services
parent
b853bede68
commit
b1b6c77d62
@ -0,0 +1,76 @@
|
||||
class InsertUserActivityRequestModel {
|
||||
String identificationNo;
|
||||
String mobileNumber;
|
||||
int quantityIntake;
|
||||
double versionID;
|
||||
int channel;
|
||||
int languageID;
|
||||
String iPAdress;
|
||||
String generalid;
|
||||
int patientOutSA;
|
||||
String sessionID;
|
||||
bool isDentalAllowedBackend;
|
||||
int deviceTypeID;
|
||||
int patientID;
|
||||
String tokenID;
|
||||
int patientTypeID;
|
||||
int patientType;
|
||||
|
||||
InsertUserActivityRequestModel(
|
||||
{this.identificationNo,
|
||||
this.mobileNumber,
|
||||
this.quantityIntake,
|
||||
this.versionID,
|
||||
this.channel,
|
||||
this.languageID,
|
||||
this.iPAdress,
|
||||
this.generalid,
|
||||
this.patientOutSA,
|
||||
this.sessionID,
|
||||
this.isDentalAllowedBackend,
|
||||
this.deviceTypeID,
|
||||
this.patientID,
|
||||
this.tokenID,
|
||||
this.patientTypeID,
|
||||
this.patientType});
|
||||
|
||||
InsertUserActivityRequestModel.fromJson(Map<String, dynamic> json) {
|
||||
identificationNo = json['IdentificationNo'];
|
||||
mobileNumber = json['MobileNumber'];
|
||||
quantityIntake = json['QuantityIntake'];
|
||||
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'];
|
||||
patientID = json['PatientID'];
|
||||
tokenID = json['TokenID'];
|
||||
patientTypeID = json['PatientTypeID'];
|
||||
patientType = json['PatientType'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['IdentificationNo'] = this.identificationNo;
|
||||
data['MobileNumber'] = this.mobileNumber;
|
||||
data['QuantityIntake'] = this.quantityIntake;
|
||||
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['PatientID'] = this.patientID;
|
||||
data['TokenID'] = this.tokenID;
|
||||
data['PatientTypeID'] = this.patientTypeID;
|
||||
data['PatientType'] = this.patientType;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,107 @@
|
||||
import 'package:diplomaticquarterapp/core/model/AlHabibMedicalService/insert_user_activity_request_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/H2O_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class ConfirmAddAmountDialog extends StatefulWidget {
|
||||
final int amount;
|
||||
final String unit;
|
||||
final H2OViewModel model;
|
||||
|
||||
|
||||
ConfirmAddAmountDialog(
|
||||
{Key key, this.model,this.amount,this.unit ="ml"});
|
||||
|
||||
@override
|
||||
_ConfirmAddAmountDialogState createState() => _ConfirmAddAmountDialogState();
|
||||
}
|
||||
|
||||
class _ConfirmAddAmountDialogState extends State<ConfirmAddAmountDialog> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SimpleDialog(
|
||||
contentPadding: EdgeInsets.fromLTRB(28.0, 24.0, 28.0, 0.0),
|
||||
title: Center(
|
||||
child: Texts(
|
||||
"Confirm",
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Divider(),
|
||||
Center(
|
||||
child: Texts(
|
||||
"Are you sure you want to Add ${widget.amount} ${widget.unit} ?",
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
),
|
||||
Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
child: Center(
|
||||
child: Texts(
|
||||
TranslationBase.of(context).cancel.toUpperCase(),
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 1,
|
||||
height: 30,
|
||||
color: Colors.grey[500],
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () async{
|
||||
InsertUserActivityRequestModel insertUserActivityRequestModel= InsertUserActivityRequestModel(quantityIntake:widget.amount );
|
||||
await widget.model.insertUserActivity(insertUserActivityRequestModel);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Center(
|
||||
child: Texts(
|
||||
TranslationBase.of(context).ok,
|
||||
fontWeight: FontWeight.w400,
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,157 @@
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// ignore: must_be_immutable
|
||||
class SelectAmountDialog extends StatefulWidget {
|
||||
List<AmountModel> searchAmount = [
|
||||
AmountModel(name: "l",nameAr:"لتر",value: 1),
|
||||
AmountModel(name: "ml",nameAr:"مم لتر",value: 2),
|
||||
];
|
||||
final Function(AmountModel) onValueSelected;
|
||||
AmountModel selectedAmount;
|
||||
|
||||
SelectAmountDialog(
|
||||
{Key key, this.onValueSelected, this.selectedAmount});
|
||||
|
||||
@override
|
||||
_SelectAmountDialogState createState() => _SelectAmountDialogState();
|
||||
}
|
||||
|
||||
class _SelectAmountDialogState extends State<SelectAmountDialog> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
widget.selectedAmount = widget.selectedAmount ?? widget.searchAmount[0];
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SimpleDialog(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Texts("Select the preferred unit", fontSize: 20,),
|
||||
Divider(),
|
||||
...List.generate(
|
||||
widget.searchAmount.length,
|
||||
(index) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 2,
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
widget.selectedAmount = widget.searchAmount[index];
|
||||
});
|
||||
},
|
||||
child: ListTile(
|
||||
title: Text(widget.searchAmount[index].name),
|
||||
leading: Radio(
|
||||
value: widget.searchAmount[index],
|
||||
groupValue: widget.selectedAmount,
|
||||
activeColor: Colors.red[800],
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
widget.selectedAmount = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
),
|
||||
Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
child: Center(
|
||||
child: Texts(
|
||||
TranslationBase.of(context).cancel.toUpperCase(),
|
||||
color: Colors.red,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 1,
|
||||
height: 30,
|
||||
color: Colors.grey[500],
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
widget.onValueSelected(widget.selectedAmount);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Center(
|
||||
child: Texts(
|
||||
TranslationBase.of(context).ok,
|
||||
fontWeight: FontWeight.w400,
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
class AmountModel {
|
||||
String name;
|
||||
String nameAr;
|
||||
int value;
|
||||
|
||||
AmountModel({this.name, this.nameAr, this.value});
|
||||
|
||||
AmountModel.fromJson(Map<String, dynamic> json) {
|
||||
name = json['name'];
|
||||
nameAr = json['nameAr'];
|
||||
value = json['value'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['name'] = this.name;
|
||||
data['nameAr'] = this.nameAr;
|
||||
data['value'] = this.value;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,131 @@
|
||||
import 'package:diplomaticquarterapp/core/viewModels/AlHabibMedicalService/H2O_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/h2o/Dialog/confirm_add_amount_dialog.dart';
|
||||
import 'package:diplomaticquarterapp/pages/medical/balance/new_text_Field.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
|
||||
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 'Dialog/select_amount_dialog.dart';
|
||||
|
||||
class AddCustomAmount extends StatefulWidget {
|
||||
final H2OViewModel model;
|
||||
final Function changePageViewIndex;
|
||||
|
||||
const AddCustomAmount({Key key, this.model, this.changePageViewIndex})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
_AddCustomAmountState createState() => _AddCustomAmountState();
|
||||
}
|
||||
|
||||
class _AddCustomAmountState extends State<AddCustomAmount> {
|
||||
TextEditingController _nameTextController = TextEditingController();
|
||||
AmountModel selectedAmount;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
setState(() {
|
||||
_nameTextController.text = "0";
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppScaffold(
|
||||
isShowAppBar: true,
|
||||
appBarTitle: "Enter amount",
|
||||
body: SingleChildScrollView(
|
||||
physics: ScrollPhysics(),
|
||||
child: Container(
|
||||
margin: EdgeInsets.all(12),
|
||||
child: Center(
|
||||
child: FractionallySizedBox(
|
||||
widthFactor: 0.94,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
NewTextFields(
|
||||
hintText: "Enter the amount of water:",
|
||||
// type: "Number",
|
||||
controller: _nameTextController,
|
||||
),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () => confirmAmountTypeDialog(),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(12),
|
||||
width: double.infinity,
|
||||
height: 65,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: Colors.white),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Texts(getAmountName()),
|
||||
Icon(Icons.arrow_drop_down)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
SecondaryButton(
|
||||
textColor: Colors.white,
|
||||
label: "OK",
|
||||
onTap: () async {
|
||||
Navigator.of(context).pop();
|
||||
showConfirmMessage (int.parse(_nameTextController.text), widget.model);
|
||||
},
|
||||
// loading: model.state == ViewState.BusyLocal,
|
||||
disabled: _nameTextController.text.isEmpty || selectedAmount == null),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void confirmAmountTypeDialog() {
|
||||
showDialog(
|
||||
context: context,
|
||||
child: SelectAmountDialog(
|
||||
selectedAmount: selectedAmount,
|
||||
onValueSelected: (value) {
|
||||
setState(() {
|
||||
selectedAmount = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
String getAmountName() {
|
||||
if (selectedAmount != null)
|
||||
return selectedAmount.name;
|
||||
else
|
||||
return "Select unit";
|
||||
}
|
||||
|
||||
|
||||
|
||||
void showConfirmMessage(int amount, H2OViewModel model) {
|
||||
showDialog(context: context, child: ConfirmAddAmountDialog(model: model,amount:amount,));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue