|
|
|
|
@ -6,6 +6,8 @@ import 'package:diplomaticquarterapp/routes.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/services/family_files/family_files_provider.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/app_toast.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
|
|
|
|
import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart';
|
|
|
|
|
@ -53,8 +55,7 @@ class _AddMember extends State<AddMember> {
|
|
|
|
|
? AppCircularProgressIndicator()
|
|
|
|
|
: SingleChildScrollView(
|
|
|
|
|
child: Container(
|
|
|
|
|
padding:
|
|
|
|
|
EdgeInsets.only(top: 10, left: 20, right: 20, bottom: 30),
|
|
|
|
|
padding: EdgeInsets.only(top: 10, left: 20, right: 20, bottom: 30),
|
|
|
|
|
height: SizeConfig.realScreenHeight * .9,
|
|
|
|
|
width: SizeConfig.realScreenWidth,
|
|
|
|
|
child: Column(children: <Widget>[
|
|
|
|
|
@ -66,60 +67,51 @@ class _AddMember extends State<AddMember> {
|
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
|
)),
|
|
|
|
|
Expanded(
|
|
|
|
|
flex: 3,
|
|
|
|
|
flex: 4,
|
|
|
|
|
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,
|
|
|
|
|
))
|
|
|
|
|
PhoneNumberSelectorWidget(onNumberChange: (value) => {mobileNo = value, validateForm()}, onCountryChange: (value) => countryCode = value),
|
|
|
|
|
//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,
|
|
|
|
|
// ))
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 12,
|
|
|
|
|
),
|
|
|
|
|
inputWidget(loginType == 1 ? TranslationBase.of(context).nationalIdNumber : TranslationBase.of(context).medicalFileNumber, "Xxxxxxxxx", nationalIDorFile),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
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,
|
|
|
|
|
))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
))
|
|
|
|
|
// 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) {
|
|
|
|
|
if (util.validateIDBox(nationalIDorFile.text, loginType) == true && mobileNo.length >= 9 && util.isSAUDIIDValid(nationalIDorFile.text, loginType) == true) {
|
|
|
|
|
setState(() {
|
|
|
|
|
isButtonDisabled = false;
|
|
|
|
|
});
|
|
|
|
|
@ -145,10 +137,7 @@ class _AddMember extends State<AddMember> {
|
|
|
|
|
request.isRegister = false;
|
|
|
|
|
request.patientStatus = 2;
|
|
|
|
|
loading(true);
|
|
|
|
|
familyFileProvider
|
|
|
|
|
.addFamilyFile(request)
|
|
|
|
|
.then((value) => manageFamily(value))
|
|
|
|
|
.catchError(() {
|
|
|
|
|
familyFileProvider.addFamilyFile(request).then((value) => manageFamily(value)).catchError(() {
|
|
|
|
|
loading(false);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
@ -160,10 +149,7 @@ class _AddMember extends State<AddMember> {
|
|
|
|
|
confirmMessage: addMemberResult['ShareFamilyFileObj']['Message'],
|
|
|
|
|
okText: TranslationBase.of(context).confirm,
|
|
|
|
|
cancelText: TranslationBase.of(context).cancel_nocaps,
|
|
|
|
|
okFunction: () => {
|
|
|
|
|
insertFamilyData(addMemberResult),
|
|
|
|
|
ConfirmDialog.closeAlertDialog(context)
|
|
|
|
|
},
|
|
|
|
|
okFunction: () => {insertFamilyData(addMemberResult), ConfirmDialog.closeAlertDialog(context)},
|
|
|
|
|
cancelFunction: () => {});
|
|
|
|
|
dialog.showAlertDialog(context);
|
|
|
|
|
}
|
|
|
|
|
@ -171,8 +157,7 @@ class _AddMember extends State<AddMember> {
|
|
|
|
|
insertFamilyData(addMemberResult) {
|
|
|
|
|
var request = InsertSharePatientFileReq();
|
|
|
|
|
request.responseID = addMemberResult['ShareFamilyFileObj']['ReponseID'];
|
|
|
|
|
request.shareFamilyPatientName =
|
|
|
|
|
addMemberResult['ShareFamilyFileObj']['SharedPatientName'];
|
|
|
|
|
request.shareFamilyPatientName = addMemberResult['ShareFamilyFileObj']['SharedPatientName'];
|
|
|
|
|
request.status = 2;
|
|
|
|
|
if (request.patientOutSA == 1) {
|
|
|
|
|
request.regionID = 2;
|
|
|
|
|
@ -180,29 +165,26 @@ class _AddMember extends State<AddMember> {
|
|
|
|
|
request.regionID = 1;
|
|
|
|
|
}
|
|
|
|
|
loading(true);
|
|
|
|
|
familyFileProvider
|
|
|
|
|
.insertNewMember(request)
|
|
|
|
|
.then((value) => sendActivationCode(value));
|
|
|
|
|
familyFileProvider.insertNewMember(request).then((value) => sendActivationCode(value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendActivationCode(result) {
|
|
|
|
|
// var request = this.getCommonRequest();
|
|
|
|
|
loading(true);
|
|
|
|
|
patientShareRequestID = result['PatientShareRequestID'];
|
|
|
|
|
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)}
|
|
|
|
|
});
|
|
|
|
|
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)}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var tempType;
|
|
|
|
|
startSMSService(type, result) {
|
|
|
|
|
tempType = type;
|
|
|
|
|
loading(false);
|
|
|
|
|
SMSOTP(
|
|
|
|
|
SMSOTP(
|
|
|
|
|
context,
|
|
|
|
|
type,
|
|
|
|
|
mobileNo,
|
|
|
|
|
@ -210,30 +192,32 @@ class _AddMember extends State<AddMember> {
|
|
|
|
|
this.checkActivationCode(value, result);
|
|
|
|
|
},
|
|
|
|
|
() => {
|
|
|
|
|
print('Faild..'),
|
|
|
|
|
Navigator.pop(context),
|
|
|
|
|
},
|
|
|
|
|
).displayDialog(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkActivationCode(value, result) {
|
|
|
|
|
familyFileProvider
|
|
|
|
|
.checkActivationCode(
|
|
|
|
|
result['LogInTokenID'], value, nationalIDorFile.text, mobileNo)
|
|
|
|
|
.then((result) => {
|
|
|
|
|
SMSOTP.hideSMSBox(context),
|
|
|
|
|
handleFamilyRequests(this.patientShareRequestID, 3)
|
|
|
|
|
});
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
familyFileProvider.checkActivationCode(result['LogInTokenID'], value, nationalIDorFile.text, mobileNo).then((result) {
|
|
|
|
|
SMSOTP.hideSMSBox(context);
|
|
|
|
|
handleFamilyRequests(this.patientShareRequestID, 3);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
Future.delayed(Duration(seconds: 1), () {
|
|
|
|
|
AppToast.showErrorToast(message: err);
|
|
|
|
|
startSMSService(tempType, result);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleFamilyRequests(id, stauts) {
|
|
|
|
|
familyFileProvider
|
|
|
|
|
.acceptAndRejectRecievedRequests(id, stauts)
|
|
|
|
|
.then((result) => {
|
|
|
|
|
sharedPref.remove(FAMILY_FILE),
|
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
|
MY_FAMILIY,
|
|
|
|
|
)
|
|
|
|
|
});
|
|
|
|
|
familyFileProvider.acceptAndRejectRecievedRequests(id, stauts).then((result) => {
|
|
|
|
|
sharedPref.remove(FAMILY_FILE),
|
|
|
|
|
Navigator.of(context).pushNamed(
|
|
|
|
|
MY_FAMILIY,
|
|
|
|
|
)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loading(flag) {
|
|
|
|
|
@ -241,4 +225,86 @@ class _AddMember extends State<AddMember> {
|
|
|
|
|
isLoading = flag;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15),
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
borderRadius: BorderRadius.circular(15),
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
border: Border.all(
|
|
|
|
|
color: Color(0xffefefef),
|
|
|
|
|
width: 1,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
child: InkWell(
|
|
|
|
|
onTap: hasSelection ? () {} : null,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Text(
|
|
|
|
|
_labelText,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 11,
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
color: Color(0xff2B353E),
|
|
|
|
|
letterSpacing: -0.44,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
TextField(
|
|
|
|
|
enabled: isEnable,
|
|
|
|
|
scrollPadding: EdgeInsets.zero,
|
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
|
controller: _controller,
|
|
|
|
|
onChanged: (value) => {validateForm()},
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
height: 21 / 14,
|
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
|
color: Color(0xff2B353E),
|
|
|
|
|
letterSpacing: -0.44,
|
|
|
|
|
),
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
isDense: true,
|
|
|
|
|
hintText: _hintText,
|
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
height: 21 / 14,
|
|
|
|
|
fontWeight: FontWeight.w400,
|
|
|
|
|
color: Color(0xff575757),
|
|
|
|
|
letterSpacing: -0.56,
|
|
|
|
|
),
|
|
|
|
|
prefixIconConstraints: BoxConstraints(minWidth: 50),
|
|
|
|
|
prefixIcon: prefix == null
|
|
|
|
|
? null
|
|
|
|
|
: Text(
|
|
|
|
|
"+" + prefix,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
height: 21 / 14,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
color: Color(0xff2E303A),
|
|
|
|
|
letterSpacing: -0.56,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
|
border: InputBorder.none,
|
|
|
|
|
focusedBorder: InputBorder.none,
|
|
|
|
|
enabledBorder: InputBorder.none,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|