family file change
parent
47c42808fd
commit
327c4585a6
@ -0,0 +1,92 @@
|
|||||||
|
class AddFamilyFileReq {
|
||||||
|
int searchType;
|
||||||
|
int sharedPatientID;
|
||||||
|
String sharedPatientIdentificationID;
|
||||||
|
String sharedPatientMobileNumber;
|
||||||
|
String zipCode;
|
||||||
|
bool isRegister;
|
||||||
|
int patientStatus;
|
||||||
|
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;
|
||||||
|
|
||||||
|
AddFamilyFileReq(
|
||||||
|
{this.searchType,
|
||||||
|
this.sharedPatientID,
|
||||||
|
this.sharedPatientIdentificationID,
|
||||||
|
this.sharedPatientMobileNumber,
|
||||||
|
this.zipCode,
|
||||||
|
this.isRegister,
|
||||||
|
this.patientStatus,
|
||||||
|
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});
|
||||||
|
|
||||||
|
AddFamilyFileReq.fromJson(Map<String, dynamic> json) {
|
||||||
|
searchType = json['SearchType'];
|
||||||
|
sharedPatientID = json['SharedPatientID'];
|
||||||
|
sharedPatientIdentificationID = json['SharedPatientIdentificationID'];
|
||||||
|
sharedPatientMobileNumber = json['SharedPatientMobileNumber'];
|
||||||
|
zipCode = json['ZipCode'];
|
||||||
|
isRegister = json['isRegister'];
|
||||||
|
patientStatus = json['PatientStatus'];
|
||||||
|
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['SearchType'] = this.searchType;
|
||||||
|
data['SharedPatientID'] = this.sharedPatientID;
|
||||||
|
data['SharedPatientIdentificationID'] = this.sharedPatientIdentificationID;
|
||||||
|
data['SharedPatientMobileNumber'] = this.sharedPatientMobileNumber;
|
||||||
|
data['ZipCode'] = this.zipCode;
|
||||||
|
data['isRegister'] = this.isRegister;
|
||||||
|
data['PatientStatus'] = this.patientStatus;
|
||||||
|
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,80 @@
|
|||||||
|
class InsertSharePatientFileReq {
|
||||||
|
int responseID;
|
||||||
|
String shareFamilyPatientName;
|
||||||
|
int status;
|
||||||
|
int regionID;
|
||||||
|
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;
|
||||||
|
|
||||||
|
InsertSharePatientFileReq(
|
||||||
|
{this.responseID,
|
||||||
|
this.shareFamilyPatientName,
|
||||||
|
this.status,
|
||||||
|
this.regionID,
|
||||||
|
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});
|
||||||
|
|
||||||
|
InsertSharePatientFileReq.fromJson(Map<String, dynamic> json) {
|
||||||
|
responseID = json['ResponseID'];
|
||||||
|
shareFamilyPatientName = json['ShareFamilyPatientName'];
|
||||||
|
status = json['Status'];
|
||||||
|
regionID = json['RegionID'];
|
||||||
|
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['ResponseID'] = this.responseID;
|
||||||
|
data['ShareFamilyPatientName'] = this.shareFamilyPatientName;
|
||||||
|
data['Status'] = this.status;
|
||||||
|
data['RegionID'] = this.regionID;
|
||||||
|
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,245 @@
|
|||||||
|
import 'package:diplomaticquarterapp/config/size_config.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/model/family-file/add_family_file_request.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/model/family-file/insert_share_file_request.dart';
|
||||||
|
import 'package:diplomaticquarterapp/routes.dart';
|
||||||
|
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/family/add-family_type.dart';
|
||||||
|
import 'package:diplomaticquarterapp/services/family_files/family_files_provider.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/input/text_field.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/otp/sms-popup.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
||||||
|
|
||||||
|
class AddMember extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_AddMember createState() => _AddMember();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AddMember extends State<AddMember> {
|
||||||
|
final util = Utils();
|
||||||
|
final nationalIDorFile = TextEditingController();
|
||||||
|
final int loginType = AddFamilyMemberType.loginType;
|
||||||
|
String mobileNo;
|
||||||
|
String countryCode = '966';
|
||||||
|
bool isButtonDisabled = true;
|
||||||
|
var sharedPref = new AppSharedPreferences();
|
||||||
|
final authService = new AuthProvider();
|
||||||
|
bool isLoading = false;
|
||||||
|
var familyFileProvider = FamilyFilesProvider();
|
||||||
|
|
||||||
|
var patientShareRequestID;
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AppScaffold(
|
||||||
|
appBarTitle: TranslationBase.of(context).myFamilyFiles,
|
||||||
|
isShowAppBar: true,
|
||||||
|
body: isLoading == true
|
||||||
|
? AppCircularProgressIndicator()
|
||||||
|
: SingleChildScrollView(
|
||||||
|
child: Container(
|
||||||
|
padding:
|
||||||
|
EdgeInsets.only(top: 10, left: 20, right: 20, bottom: 30),
|
||||||
|
height: SizeConfig.realScreenHeight * .9,
|
||||||
|
width: SizeConfig.realScreenWidth,
|
||||||
|
child: Column(children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
flex: 2,
|
||||||
|
child: AppText(
|
||||||
|
TranslationBase.of(context).enterNationalId,
|
||||||
|
fontSize: SizeConfig.textMultiplier * 3.5,
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
)),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: <Widget>[
|
||||||
|
MobileNo(
|
||||||
|
onNumberChange: (value) =>
|
||||||
|
{mobileNo = value, validateForm()},
|
||||||
|
onCountryChange: (value) => countryCode = value),
|
||||||
|
Container(
|
||||||
|
child: TextFields(
|
||||||
|
controller: nationalIDorFile,
|
||||||
|
onChanged: (value) => {validateForm()},
|
||||||
|
prefixIcon: Icon(
|
||||||
|
loginType == 1
|
||||||
|
? Icons.chrome_reader_mode
|
||||||
|
: Icons.receipt,
|
||||||
|
color: Colors.red),
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
top: 20, bottom: 20, left: 10, right: 10),
|
||||||
|
hintText: loginType == 1
|
||||||
|
? TranslationBase.of(context).nationalID
|
||||||
|
: TranslationBase.of(context).fileNo,
|
||||||
|
))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 3,
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: <Widget>[
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: DefaultButton(
|
||||||
|
TranslationBase.of(context).add,
|
||||||
|
() => {this.addMember()},
|
||||||
|
color: isButtonDisabled == true
|
||||||
|
? Colors.grey
|
||||||
|
: Colors.grey[900],
|
||||||
|
textColor: Colors.white,
|
||||||
|
))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
))
|
||||||
|
]),
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void validateForm() {
|
||||||
|
if (util.validateIDBox(nationalIDorFile.text, loginType) == true &&
|
||||||
|
mobileNo.length >= 9 &&
|
||||||
|
util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true) {
|
||||||
|
setState(() {
|
||||||
|
isButtonDisabled = false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
isButtonDisabled = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addMember() {
|
||||||
|
var request = AddFamilyFileReq();
|
||||||
|
if (this.loginType == 1) {
|
||||||
|
request.sharedPatientID = 0;
|
||||||
|
request.sharedPatientIdentificationID = this.nationalIDorFile.text;
|
||||||
|
} else if (this.loginType == 2) {
|
||||||
|
request.sharedPatientID = int.parse(this.nationalIDorFile.text);
|
||||||
|
request.sharedPatientIdentificationID = '';
|
||||||
|
}
|
||||||
|
request.searchType = this.loginType;
|
||||||
|
request.sharedPatientMobileNumber = this.mobileNo;
|
||||||
|
request.zipCode = countryCode;
|
||||||
|
request.isRegister = false;
|
||||||
|
request.patientStatus = 2;
|
||||||
|
loading(true);
|
||||||
|
familyFileProvider
|
||||||
|
.addFamilyFile(request)
|
||||||
|
.then((value) => manageFamily(value))
|
||||||
|
.catchError(() {
|
||||||
|
loading(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
manageFamily(addMemberResult) {
|
||||||
|
loading(false);
|
||||||
|
ConfirmDialog dialog = new ConfirmDialog(
|
||||||
|
context: context,
|
||||||
|
confirmMessage: addMemberResult['ShareFamilyFileObj']['Message'],
|
||||||
|
okText: TranslationBase.of(context).confirm,
|
||||||
|
cancelText: TranslationBase.of(context).cancel_nocaps,
|
||||||
|
okFunction: () => {
|
||||||
|
insertFamilyData(addMemberResult),
|
||||||
|
ConfirmDialog.closeAlertDialog(context)
|
||||||
|
},
|
||||||
|
cancelFunction: () => {});
|
||||||
|
dialog.showAlertDialog(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
insertFamilyData(addMemberResult) {
|
||||||
|
var request = InsertSharePatientFileReq();
|
||||||
|
request.responseID = addMemberResult['ShareFamilyFileObj']['ReponseID'];
|
||||||
|
request.shareFamilyPatientName =
|
||||||
|
addMemberResult['ShareFamilyFileObj']['SharedPatientName'];
|
||||||
|
request.status = 2;
|
||||||
|
if (request.patientOutSA == 1) {
|
||||||
|
request.regionID = 2;
|
||||||
|
} else {
|
||||||
|
request.regionID = 1;
|
||||||
|
}
|
||||||
|
loading(true);
|
||||||
|
this
|
||||||
|
.familyFileProvider
|
||||||
|
.insertNewMember(request)
|
||||||
|
.then((value) => sendActivationCode(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
sendActivationCode(result) {
|
||||||
|
// var request = this.getCommonRequest();
|
||||||
|
loading(true);
|
||||||
|
patientShareRequestID = result['PatientShareRequestID'];
|
||||||
|
this
|
||||||
|
.familyFileProvider
|
||||||
|
.sendActivationCode(mobileNo, countryCode, nationalIDorFile.text)
|
||||||
|
.then((result) => {
|
||||||
|
if (result != null && result['isSMSSent'] == true)
|
||||||
|
{this.startSMSService(1, result)}
|
||||||
|
// {loading(false), this.startSMSService(type)}
|
||||||
|
// else
|
||||||
|
// {loading(false)}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
startSMSService(type, result) {
|
||||||
|
loading(false);
|
||||||
|
new SMSOTP(
|
||||||
|
context,
|
||||||
|
type,
|
||||||
|
this.mobileNo,
|
||||||
|
(value) => {this.checkActivationCode(value, result)},
|
||||||
|
() => {
|
||||||
|
print('Faild..'),
|
||||||
|
},
|
||||||
|
).displayDialog(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
checkActivationCode(value, result) {
|
||||||
|
this
|
||||||
|
.familyFileProvider
|
||||||
|
.checkActivationCode(
|
||||||
|
result['LogInTokenID'], value, nationalIDorFile.text, mobileNo)
|
||||||
|
.then((result) => {
|
||||||
|
SMSOTP.hideSMSBox(context),
|
||||||
|
handleFamilyRequests(this.patientShareRequestID, 3)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleFamilyRequests(id, stauts) {
|
||||||
|
this
|
||||||
|
.familyFileProvider
|
||||||
|
.acceptAndRejectRecievedRequests(id, stauts)
|
||||||
|
.then((result) => {
|
||||||
|
sharedPref.remove(FAMILY_FILE),
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
MY_FAMILIY,
|
||||||
|
)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
loading(flag) {
|
||||||
|
setState(() {
|
||||||
|
isLoading = flag;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,154 @@
|
|||||||
|
import 'package:diplomaticquarterapp/config/size_config.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/card/rounded_container.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/text/app_texts_widget.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:diplomaticquarterapp/routes.dart';
|
||||||
|
|
||||||
|
class AddFamilyMemberType extends StatelessWidget {
|
||||||
|
static int loginType = 0;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AppScaffold(
|
||||||
|
appBarTitle: TranslationBase.of(context).myFamilyFiles,
|
||||||
|
isShowAppBar: true,
|
||||||
|
body: Padding(
|
||||||
|
padding: EdgeInsets.all(20),
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
flex: 6,
|
||||||
|
child: Column(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Image.asset(
|
||||||
|
'assets/images/habib-logo.png',
|
||||||
|
height: 80,
|
||||||
|
width: 80,
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.all(20),
|
||||||
|
child: AppText(
|
||||||
|
TranslationBase.of(context).registerInfoFamily,
|
||||||
|
fontSize: SizeConfig.textMultiplier * 3.5,
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: EdgeInsets.all(20),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () => {
|
||||||
|
AddFamilyMemberType.loginType = 1,
|
||||||
|
Navigator.of(context)
|
||||||
|
.pushNamed(ADD_FAMILY_MEMBER)
|
||||||
|
},
|
||||||
|
child: RoundedContainer(
|
||||||
|
borderColor: Colors.grey,
|
||||||
|
showBorder: true,
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
20, 10, 20, 10),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Image.asset(
|
||||||
|
'assets/images/id_card_icon.png',
|
||||||
|
height: SizeConfig
|
||||||
|
.imageSizeMultiplier *
|
||||||
|
12,
|
||||||
|
width: SizeConfig
|
||||||
|
.imageSizeMultiplier *
|
||||||
|
15,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
AppText(
|
||||||
|
TranslationBase.of(context)
|
||||||
|
.nationalID,
|
||||||
|
fontSize: SizeConfig
|
||||||
|
.textMultiplier *
|
||||||
|
2,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)))),
|
||||||
|
Expanded(
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () => {
|
||||||
|
AddFamilyMemberType.loginType = 2,
|
||||||
|
Navigator.of(context)
|
||||||
|
.pushNamed(ADD_FAMILY_MEMBER)
|
||||||
|
},
|
||||||
|
child: RoundedContainer(
|
||||||
|
borderColor: Colors.grey,
|
||||||
|
showBorder: true,
|
||||||
|
child: Padding(
|
||||||
|
padding: EdgeInsets.fromLTRB(
|
||||||
|
25, 10, 25, 10),
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Image.asset(
|
||||||
|
'assets/images/my_file_white_icon.png',
|
||||||
|
height: SizeConfig
|
||||||
|
.imageSizeMultiplier *
|
||||||
|
12,
|
||||||
|
width: SizeConfig
|
||||||
|
.imageSizeMultiplier *
|
||||||
|
15,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
AppText(
|
||||||
|
TranslationBase.of(context)
|
||||||
|
.fileNo,
|
||||||
|
fontSize: SizeConfig
|
||||||
|
.textMultiplier *
|
||||||
|
2,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
))))
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
Divider(
|
||||||
|
color: Colors.grey,
|
||||||
|
height: 2,
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
// Expanded(
|
||||||
|
// flex: 2,
|
||||||
|
// child: Column(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
// children: <Widget>[
|
||||||
|
// Row(
|
||||||
|
// children: <Widget>[
|
||||||
|
// Expanded(
|
||||||
|
// child: DefaultButton(
|
||||||
|
// TranslationBase.of(context).registerNow,
|
||||||
|
// () => {
|
||||||
|
// Navigator.of(context).pushNamed(
|
||||||
|
// REGISTER,
|
||||||
|
// )
|
||||||
|
// },
|
||||||
|
// ))
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ))
|
||||||
|
],
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,334 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:diplomaticquarterapp/config/config.dart';
|
||||||
|
import 'package:diplomaticquarterapp/config/size_config.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
||||||
|
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
|
||||||
|
import 'package:diplomaticquarterapp/models/Appointments/DoctorProfile.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/BookAppointment/BookingOptions.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/BookAppointment/DoctorProfile.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/BookAppointment/Search.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/landing/landing_page.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/medical/medical_profile_page.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/medical/my_admissions_page.dart';
|
||||||
|
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
|
||||||
|
import 'package:diplomaticquarterapp/services/robo_search/search_provider.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/bottom_navigation/bottom_nav_bar.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_tts/flutter_tts.dart';
|
||||||
|
import 'package:hexcolor/hexcolor.dart';
|
||||||
|
import 'package:permission_handler/permission_handler.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_to_text.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/robo-search/robosearch.dart';
|
||||||
|
import 'dart:math';
|
||||||
|
import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart';
|
||||||
|
|
||||||
|
class BottomBarSearch extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_SearchBot createState() => _SearchBot();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SearchBot extends State<BottomBarSearch> {
|
||||||
|
SearchProvider searchProvider = new SearchProvider();
|
||||||
|
RobotProvider eventProvider = RobotProvider();
|
||||||
|
bool isLoading = false;
|
||||||
|
bool isError = false;
|
||||||
|
final SpeechToText speech = SpeechToText();
|
||||||
|
String error = '';
|
||||||
|
String _currentLocaleId = "";
|
||||||
|
String lastError;
|
||||||
|
double level = 0.0;
|
||||||
|
|
||||||
|
double minSoundLevel = 50000;
|
||||||
|
double maxSoundLevel = -50000;
|
||||||
|
String reconizedWord = '';
|
||||||
|
FlutterTts flutterTts = FlutterTts();
|
||||||
|
var selectedLang;
|
||||||
|
bool isSearching = false;
|
||||||
|
|
||||||
|
String lastStatus;
|
||||||
|
|
||||||
|
bool _isInit = true;
|
||||||
|
TextEditingController searchController = TextEditingController();
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
requestPermissions();
|
||||||
|
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BottomAppBar(
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: SizedBox(
|
||||||
|
height: 64,
|
||||||
|
child: Material(
|
||||||
|
type: MaterialType.transparency,
|
||||||
|
child: TextField(
|
||||||
|
keyboardType: TextInputType.multiline,
|
||||||
|
maxLines: null,
|
||||||
|
controller: searchController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'How May I Help You?',
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
icon: Icon(Icons.mic),
|
||||||
|
onPressed: () async {
|
||||||
|
setState(() {
|
||||||
|
searchController.text = '';
|
||||||
|
});
|
||||||
|
// await flutterTts.speak("Hello!");
|
||||||
|
//Future.delayed(const Duration(seconds: 1), () {
|
||||||
|
initSpeechState()
|
||||||
|
.then((value) => startVoiceSearch());
|
||||||
|
//});
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
startVoiceSearch() async {
|
||||||
|
speech.listen(
|
||||||
|
onResult: resultListener,
|
||||||
|
listenFor: Duration(seconds: 10),
|
||||||
|
localeId: _currentLocaleId,
|
||||||
|
onSoundLevelChange: soundLevelListener,
|
||||||
|
cancelOnError: true,
|
||||||
|
partialResults: true,
|
||||||
|
onDevice: true,
|
||||||
|
listenMode: ListenMode.confirmation);
|
||||||
|
}
|
||||||
|
|
||||||
|
void resultListener(SpeechRecognitionResult result) {
|
||||||
|
// lastWords = "${result.recognizedWords} - ${result.finalResult}";
|
||||||
|
|
||||||
|
if (result.finalResult == true) {
|
||||||
|
// setState(() {
|
||||||
|
reconizedWord = result.recognizedWords;
|
||||||
|
//});
|
||||||
|
setState(() {
|
||||||
|
searchController.text = reconizedWord;
|
||||||
|
});
|
||||||
|
Future.delayed(const Duration(seconds: 1), () {
|
||||||
|
_speak(reconizedWord);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future _speak(reconizedWord) async {
|
||||||
|
await flutterTts.speak(reconizedWord);
|
||||||
|
|
||||||
|
getPages(reconizedWord);
|
||||||
|
}
|
||||||
|
|
||||||
|
void soundLevelListener(double level) {
|
||||||
|
minSoundLevel = min(minSoundLevel, level);
|
||||||
|
maxSoundLevel = max(maxSoundLevel, level);
|
||||||
|
// print("sound level $level: $minSoundLevel - $maxSoundLevel ");
|
||||||
|
//setState(() {
|
||||||
|
this.level = level;
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
void requestPermissions() async {
|
||||||
|
Map<Permission, PermissionStatus> statuses = await [
|
||||||
|
Permission.microphone,
|
||||||
|
].request();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> initSpeechState() async {
|
||||||
|
await speech.initialize(onError: errorListener, onStatus: statusListener);
|
||||||
|
|
||||||
|
_currentLocaleId =
|
||||||
|
TranslationBase.of(AppGlobal.context).locale.languageCode == 'en'
|
||||||
|
? 'en-GB'
|
||||||
|
: 'ar-SA'; // systemLocale.localeId;
|
||||||
|
flutterTts.setLanguage(_currentLocaleId);
|
||||||
|
|
||||||
|
// if (!mounted) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void errorListener(SpeechRecognitionError error) {
|
||||||
|
//setState(() {
|
||||||
|
// reconizedWord = "${error.errorMsg} - ${error.permanent}";
|
||||||
|
//});
|
||||||
|
}
|
||||||
|
|
||||||
|
void statusListener(String status) {
|
||||||
|
//setState(() {
|
||||||
|
reconizedWord = status == 'listening' ? 'Lisening...' : 'Sorry....';
|
||||||
|
|
||||||
|
//});
|
||||||
|
}
|
||||||
|
|
||||||
|
getPages(text) {
|
||||||
|
var request = {
|
||||||
|
'VoiceMessage': text,
|
||||||
|
'Lang': TranslationBase.of(AppGlobal.context).locale.languageCode == 'en'
|
||||||
|
? 'En'
|
||||||
|
: 'Ar'
|
||||||
|
};
|
||||||
|
|
||||||
|
searchProvider
|
||||||
|
.getBotPages(request)
|
||||||
|
.then((value) => {getCommands(value['Understand'])});
|
||||||
|
//getDoctorsList(12, 17, 40036, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
getCommands(result) async {
|
||||||
|
//RoboSearch.closeAlertDialog(context);
|
||||||
|
print(result);
|
||||||
|
|
||||||
|
//getDoctorsList(12, 17, 40036, context);
|
||||||
|
|
||||||
|
switch (result["CommandNumber"]) {
|
||||||
|
case 100:
|
||||||
|
if (result['ProjectId'] != null &&
|
||||||
|
result['ClinicId'] != null &&
|
||||||
|
result['DoctorId'] != null) {
|
||||||
|
getDoctorsList(
|
||||||
|
result['ProjectId'],
|
||||||
|
result['ClinicId'],
|
||||||
|
context,
|
||||||
|
doctorId: result['DoctorId'],
|
||||||
|
);
|
||||||
|
} else if (result['ProjectId'] != null && result['ClinicId'] != null) {
|
||||||
|
getDoctorsList(
|
||||||
|
result['ProjectId'],
|
||||||
|
result['ClinicId'],
|
||||||
|
context,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// case '101':
|
||||||
|
// Navigator.push(
|
||||||
|
// AppGlobal.context,
|
||||||
|
// MaterialPageRoute(
|
||||||
|
// builder: (context) => Search(
|
||||||
|
// type: 0,
|
||||||
|
// )));
|
||||||
|
// break;
|
||||||
|
// case '102':
|
||||||
|
// Navigator.push(
|
||||||
|
// AppGlobal.context,
|
||||||
|
// MaterialPageRoute(
|
||||||
|
// builder: (context) => Search(
|
||||||
|
// type: 1,
|
||||||
|
// )));
|
||||||
|
// break;
|
||||||
|
// case '103':
|
||||||
|
// eventProvider.setValue({"clinic_id": understand});
|
||||||
|
// break;
|
||||||
|
|
||||||
|
// case '104':
|
||||||
|
// eventProvider.setValue({"project_id": understand});
|
||||||
|
// break;
|
||||||
|
// case '105':
|
||||||
|
// eventProvider.setValue({"doctor_id": understand});
|
||||||
|
// break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
if (result['ProjectId'] != null && result['ClinicId'] != null) {
|
||||||
|
getDoctorsList(
|
||||||
|
result['ProjectId'],
|
||||||
|
result['ClinicId'],
|
||||||
|
context,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (_currentLocaleId == 'en-GB' && result['ReturnMessage'] != null) {
|
||||||
|
await flutterTts.speak(result['ReturnMessage']);
|
||||||
|
} else if (result['ReturnMessage_Ar'] != null) {
|
||||||
|
await flutterTts.speak(result['ReturnMessage_Ar']);
|
||||||
|
}
|
||||||
|
//searchProvider.setLisener(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
getDoctorProfile(projectId, clinicId, doctorId, context, doctorData) {
|
||||||
|
List<DoctorProfileList> docProfileList = [];
|
||||||
|
DoctorsListService service = new DoctorsListService();
|
||||||
|
|
||||||
|
service
|
||||||
|
.getDoctorsProfile(doctorId, clinicId, projectId, context)
|
||||||
|
.then((res) {
|
||||||
|
if (res['MessageStatus'] == 1) {
|
||||||
|
if (res['DoctorProfileList'].length != 0) {
|
||||||
|
res['DoctorProfileList'].forEach((v) {
|
||||||
|
docProfileList.add(new DoctorProfileList.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
navigateToDoctorProfile(context, doctorData[0], docProfileList[0],
|
||||||
|
isAppo: true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getDoctorsList(projectId, clinicId, context, {doctorId}) {
|
||||||
|
List<DoctorList> doctorsList = [];
|
||||||
|
DoctorsListService service = new DoctorsListService();
|
||||||
|
service
|
||||||
|
.getDoctorsList(clinicId, projectId, context, doctorId: doctorId)
|
||||||
|
.then((res) {
|
||||||
|
if (res['MessageStatus'] == 1) {
|
||||||
|
setState(() {
|
||||||
|
if (res['DoctorList'].length != 0) {
|
||||||
|
doctorsList.clear();
|
||||||
|
res['DoctorList'].forEach((v) {
|
||||||
|
doctorsList.add(new DoctorList.fromJson(v));
|
||||||
|
});
|
||||||
|
if (doctorId == null) {
|
||||||
|
navigateToSearchResults(context, doctorsList);
|
||||||
|
} else {
|
||||||
|
getDoctorProfile(
|
||||||
|
projectId, clinicId, doctorId, context, doctorsList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
AppToast.showErrorToast(message: res['ErrorEndUserMessage']);
|
||||||
|
}
|
||||||
|
}).catchError((err) {
|
||||||
|
print(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future navigateToDoctorProfile(context, docObject, docProfile,
|
||||||
|
{isAppo}) async {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => DoctorProfile(
|
||||||
|
doctor: docObject,
|
||||||
|
docProfileList: docProfile,
|
||||||
|
isOpenAppt: isAppo,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
Future navigateToSearchResults(context, docList) async {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => SearchResults(doctorsList: docList)));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue