family screen add fixes & remove & switch & widgets

pull/79/head
aamir-csol 3 weeks ago
parent c1b88a958f
commit bf8f98ffb1

@ -276,6 +276,7 @@ class ApiClientImp implements ApiClient {
logApiEndpointError(endPoint, parsed['ErrorSearchMsg'], statusCode);
}
} else {
onFailure(
parsed['message'] ?? parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
statusCode,

@ -1,2 +1,6 @@
export '../routes/app_routes.dart';
export 'utils/size_utils.dart';

@ -149,13 +149,11 @@ class AuthenticationRepoImp implements AuthenticationRepo {
sendActivationCodeReq.isDentalAllowedBackend = false;
final payload = sendActivationCodeReq.toJson();
if (isFormFamilyFile) {
payload.remove("MobileNo");
payload.remove("NationalID");
payload.remove("SMSSignature");
payload.remove("ResponseID");
print("=================== Final Payload ===================");
print(payload);
print("=====================================================");
// payload.remove("ResponseID");
}
try {

@ -86,6 +86,7 @@ class AuthenticationViewModel extends ChangeNotifier {
LoginTypeEnum loginTypeEnum = LoginTypeEnum.sms;
final ValueNotifier<bool> otpScreenNotifier = ValueNotifier<bool>(false);
int patientShareRequestID = 0;
//==================
@ -346,7 +347,8 @@ class AuthenticationViewModel extends ChangeNotifier {
);
}
Future<void> sendActivationCode({required OTPTypeEnum otpTypeEnum,
Future<void> sendActivationCode(
{required OTPTypeEnum otpTypeEnum,
required String nationalIdOrFileNumber,
required String phoneNumber,
required bool isForRegister,
@ -354,6 +356,7 @@ class AuthenticationViewModel extends ChangeNotifier {
bool isComingFromResendOTP = false,
bool isExcludedUser = false,
bool isFormFamilyFile = false,
bool isNeedLoading = false,
int? responseID}) async {
var request = RequestUtils.getCommonRequestSendActivationCode(
otpTypeEnum: otpTypeEnum,
@ -362,7 +365,7 @@ class AuthenticationViewModel extends ChangeNotifier {
zipCode: selectedCountrySignup.countryCode,
nationalId: int.parse(nationalIdOrFileNumber),
isFileNo: isForRegister ? isPatientHasFile(request: payload) : false,
patientId: 0,
patientId: isFormFamilyFile ? _appState.getAuthenticatedUser()!.patientId : 0,
isForRegister: isForRegister,
patientOutSA: isForRegister
? isPatientOutsideSA(request: payload)
@ -376,7 +379,9 @@ class AuthenticationViewModel extends ChangeNotifier {
// TODO: GET APP SMS SIGNATURE HERE
request.sMSSignature = await getSignature();
if (isNeedLoading) {
LoaderBottomSheet.showLoader();
}
if (checkIsUserComingForRegister(request: payload)) {
_appState.setUserRegistrationPayload = RegistrationDataModelPayload.fromJson(payload);
}
@ -387,9 +392,18 @@ class AuthenticationViewModel extends ChangeNotifier {
resultEither.fold(
(failure) async => await _errorHandlerService.handleError(failure: failure),
(apiResponse) async {
int? patientShareRequestID = 0;
if (isFormFamilyFile) {
if (apiResponse.data['PatientShareRequestID'] != null && apiResponse.data['PatientShareRequestID'] == 0 && apiResponse.messageStatus == 1) {
LoaderBottomSheet.hideLoader();
_dialogService.showErrorBottomSheet(
message: apiResponse.data["ErrorMessage"],
onOkPressed: () {
_navigationService.pop();
});
return;
}
patientShareRequestID = apiResponse.data['PatientShareRequestID'];
print("PatientShareRequestID ==============: $patientShareRequestID");
_appState.setFamilyFileTokenID = apiResponse.data['LogInTokenID'];
}
if (apiResponse.messageStatus == 2) {
@ -573,28 +587,29 @@ class AuthenticationViewModel extends ChangeNotifier {
}
// _appState.setUserBloodGroup = (activation.patientBlodType ?? "");
_appState.setAppAuthToken = activation.authenticationTokenId;
final request = await RequestUtils.getAuthanticatedCommonRequest().toJson();
final request = RequestUtils.getAuthanticatedCommonRequest().toJson();
bool isUserAgreedBefore = await checkIfUserAgreedBefore(request: request);
//updating the last login type in app state to show the fingerprint/face id option on home screen
if (_appState.getSelectDeviceByImeiRespModelElement != null) {
_appState.getSelectDeviceByImeiRespModelElement!.logInType = loginTypeEnum.toInt;
}
LoaderBottomSheet.hideLoader();
//
if (!isSwitchUser && !_appState.getIsChildLoggedIn) {
MedicalFileViewModel medicalVm = getIt<MedicalFileViewModel>();
await insertPatientIMEIData(loginTypeEnum.toInt);
await medicalVm.getFamilyFiles(status: 0); //TODO: Remove status: 1 by Aamir Need to Discuss With Sultan
await medicalVm.getAllPendingRecordsByResponseId();
insertPatientIMEIData(loginTypeEnum.toInt);
medicalVm.getFamilyFiles(status: 0); //TODO: Remove status: 1 by Aamir Need to Discuss With Sultan
medicalVm.getAllPendingRecordsByResponseId();
}
await clearDefaultInputValues();
if (isUserAgreedBefore) {
LoaderBottomSheet.hideLoader();
navigateToHomeScreen();
} else {
MyAppointmentsViewModel myAppointmentsVM = getIt<MyAppointmentsViewModel>();
myAppointmentsVM.setIsAppointmentDataToBeLoaded(true);
LoaderBottomSheet.hideLoader();
navigateToHomeScreen();
//Agreement page not designed yet so we are navigating to home screen directly
// getUserAgreementContent(request: request);
@ -944,6 +959,7 @@ class AuthenticationViewModel extends ChangeNotifier {
gender: _appState.getAuthenticatedUser()!.gender)
.toJson());
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
if (apiResponse.messageStatus == 2) {}
if (apiResponse.messageStatus == 1) {
log("Insert Device Data Success");
} else {

@ -298,9 +298,7 @@ class MedicalFileRepoImp implements MedicalFileRepo {
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
final list = response['GetAllSharedRecordsByStatusList'];
// if (list == null || list.isEmpty) {
// throw Exception("lab list is empty");
// }
final familyLists = list.map((item) => FamilyFileResponseModelLists.fromJson(item as Map<String, dynamic>)).toList().cast<FamilyFileResponseModelLists>();

@ -287,7 +287,7 @@ class MedicalFileViewModel extends ChangeNotifier {
),
(apiResponse) {
if (apiResponse.messageStatus == 2) {
_dialogService.showErrorBottomSheet(message: apiResponse.errorMessage!, onOkPressed: () {});
// _dialogService.showErrorBottomSheet(message: apiResponse.errorMessage!, onOkPressed: () {});
} else if (apiResponse.messageStatus == 1) {
if (apiResponse.data != null) {
// Add current user as the first active family file
@ -385,7 +385,7 @@ class MedicalFileViewModel extends ChangeNotifier {
(failure) async => await errorHandlerService.handleError(failure: failure),
(apiResponse) {
if (apiResponse.messageStatus == 2) {
_dialogService.showErrorBottomSheet(message: apiResponse.errorMessage!, onOkPressed: () {});
// _dialogService.showErrorBottomSheet(message: apiResponse.errorMessage!, onOkPressed: () {});
} else if (apiResponse.messageStatus == 1) {
if (apiResponse.data != null) {
final List<FamilyFileResponseModelLists> tempPendingFamilyFiles = [];
@ -439,6 +439,9 @@ class MedicalFileViewModel extends ChangeNotifier {
);
}
Future<void> addFamilyFile({required OTPTypeEnum otpTypeEnum}) async {
LoaderBottomSheet.showLoader();
AuthenticationViewModel authVM = getIt.get<AuthenticationViewModel>();
@ -449,6 +452,7 @@ class MedicalFileViewModel extends ChangeNotifier {
final resultEither = await medicalFileRepo.addFamilyFile(request: request.toJson());
resultEither.fold((failure) async => await errorHandlerService.handleError(failure: failure), (apiResponse) async {
if (apiResponse.messageStatus == 2) {
print("=======");
LoaderBottomSheet.hideLoader();
_dialogService.showErrorBottomSheet(
message: apiResponse.errorMessage!,
@ -463,7 +467,7 @@ class MedicalFileViewModel extends ChangeNotifier {
_dialogService.showExceptionBottomSheet(
message: apiResponse.data["Message"],
onOkPressed: () {
LoaderBottomSheet.showLoader();
navigationService.pop();
authVM.sendActivationCode(
otpTypeEnum: otpTypeEnum,
nationalIdOrFileNumber: request.sharedPatientIdentificationId!,
@ -471,6 +475,7 @@ class MedicalFileViewModel extends ChangeNotifier {
isForRegister: false,
isExcludedUser: apiResponse.data['IsPatientExcluded'],
responseID: apiResponse.data["ReponseID"],
isNeedLoading: true,
isFormFamilyFile: true);
},
onCancelPressed: () {
@ -510,6 +515,8 @@ class MedicalFileViewModel extends ChangeNotifier {
});
} else if (apiResponse.messageStatus == 1) {
patientFamilyFiles.removeWhere((element) => element.id == id);
getFamilyFiles();
getAllPendingRecordsByResponseId();
LoaderBottomSheet.hideLoader();
notifyListeners();
navigationService.pop();
@ -575,11 +582,11 @@ class MedicalFileViewModel extends ChangeNotifier {
(apiResponse) {
if (apiResponse.messageStatus == 2) {
LoaderBottomSheet.hideLoader();
_dialogService.showErrorBottomSheet(
message: apiResponse.errorMessage!,
onOkPressed: () {
navigationService.pop();
});
// _dialogService.showErrorBottomSheet(
// message: apiResponse.errorMessage!,
// onOkPressed: () {
// navigationService.pop();
// });
} else if (apiResponse.messageStatus == 1) {
// FamilyFileResponseModelLists moveProfile = pendingFamilyFiles.firstWhere((element) => element.id == patientID);
// moveProfile.status = 3;

@ -53,7 +53,7 @@ class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> {
AppState appState = getIt.get<AppState>();
return CollapsingListView(
title: "My Medical File".needTranslation,
title: "Medical Files".needTranslation,
bottomChild: appState.getAuthenticatedUser()!.isParentUser!
? Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
@ -82,17 +82,17 @@ class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CustomTabBar(
appState.isChildLoggedIn
? SizedBox()
: CustomTabBar(
activeBackgroundColor: AppColors.secondaryLightRedColor,
activeTextColor: AppColors.primaryRedColor,
tabs: appState.isChildLoggedIn
? [CustomTabBarModel(null, LocaleKeys.medicalFile.tr())]
: [CustomTabBarModel(null, LocaleKeys.medicalFile.tr()), CustomTabBarModel(null, LocaleKeys.request.tr())],
tabs: [CustomTabBarModel(null, LocaleKeys.family.tr()), CustomTabBarModel(null, LocaleKeys.request.tr())],
onTabChange: (index) {
medicalVM!.onFamilyFileTabChange(index);
},
),
SizedBox(height: 25.h),
appState.isChildLoggedIn ? SizedBox() : SizedBox(height: 25.h),
Selector<MedicalFileViewModel, int>(selector: (_, model) => model.getSelectedFamilyFileTabIndex, builder: (context, selectedIndex, child) => getFamilyTabs(index: selectedIndex)),
SizedBox(height: 20.h),
],

@ -67,7 +67,9 @@ class _FamilyCardsState extends State<FamilyCards> {
],
),
SizedBox(height: 24.h),
ListView.builder(
widget.profiles.where((profile) => profile.isRequestFromMySide ?? false).isEmpty
? Utils.getNoDataWidget(context)
: ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
padding: EdgeInsets.zero,
@ -231,7 +233,10 @@ class _FamilyCardsState extends State<FamilyCards> {
Widget manageFamily() {
NavigationService navigationService = getIt<NavigationService>();
return ListView.builder(
return widget.profiles.where((profile) => !(profile.isRequestFromMySide ?? false)).isEmpty
? Utils.getNoDataWidget(context)
: ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
padding: EdgeInsetsGeometry.zero,

@ -301,11 +301,13 @@ class FamilyCardWidget extends StatelessWidget {
runSpacing: 4.h,
children: [
AppCustomChipWidget(labelText: "${profile.age} Years Old".needTranslation),
AppCustomChipWidget(
isActive && appState.getAuthenticatedUser()!.bloodGroup != null
? AppCustomChipWidget(
icon: AppAssets.blood_icon,
labelPadding: EdgeInsetsDirectional.only(start: -6.h, end: 8.h),
labelText: "Blood: ${appState.getAuthenticatedUser()!.bloodGroup ?? "."}",
iconColor: AppColors.primaryRedColor),
labelText: "Blood: ${appState.getAuthenticatedUser()!.bloodGroup ?? ""}",
iconColor: AppColors.primaryRedColor)
: SizedBox(),
Selector<InsuranceViewModel, ({bool isEmpty, int? patientID, bool isLoading, String? cardValidTo})>(
selector: (context, insuranceVM) => (
isEmpty: insuranceVM.patientInsuranceList.isEmpty,
@ -330,7 +332,7 @@ class FamilyCardWidget extends StatelessWidget {
if (isLoading) {
icon = AppAssets.cancel_circle_icon;
labelText = "Insurance";
labelText = "Insurance".needTranslation;
iconColor = AppColors.primaryRedColor;
backgroundColor = AppColors.primaryRedColor;
} else if (isExpired) {
@ -356,82 +358,6 @@ class FamilyCardWidget extends StatelessWidget {
).toShimmer2(isShow: isLoading);
},
)
// Consumer<InsuranceViewModel>(builder: (context, insuranceVM, child) {
// if (insuranceVM.patientInsuranceList.isEmpty) {
// return const SizedBox();
// } else if (profile.responseId != insuranceVM.patientInsuranceList.first.patientID) {
// return SizedBox();
// }
//
// final isLoading = insuranceVM.isInsuranceLoading;
// final isExpired = !isLoading && DateTime.now().isAfter(DateUtil.convertStringToDate(insuranceVM.patientInsuranceList.first.cardValidTo));
//
// final String icon;
// final String labelText;
// final Color iconColor;
// final Color backgroundColor;
//
// if (isLoading) {
// icon = AppAssets.cancel_circle_icon;
// labelText = "Insurance";
// iconColor = AppColors.primaryRedColor;
// backgroundColor = AppColors.primaryRedColor;
// } else if (isExpired) {
// icon = AppAssets.cancel_circle_icon;
// labelText = "Insurance Expired".needTranslation;
// iconColor = AppColors.primaryRedColor;
// backgroundColor = AppColors.primaryRedColor.withValues(alpha: 0.15);
// } else {
// icon = AppAssets.insurance_active_icon;
// labelText = "Insurance Active".needTranslation;
// iconColor = AppColors.successColor;
// backgroundColor = AppColors.successColor.withValues(alpha: 0.15);
// }
//
// return AppCustomChipWidget(
// icon: icon,
// labelText: labelText,
// iconColor: iconColor,
// iconSize: 12,
// backgroundColor: backgroundColor,
// // padding: EdgeInsets.zero,
// ).toShimmer2(isShow: isLoading);
// })
// Consumer<InsuranceViewModel>(builder: (context, insuranceVM, child) {
// return insuranceVM.patientInsuranceList. isNotEmpty ? AppCustomChipWidget(
// icon: insuranceVM.isInsuranceLoading
// ? AppAssets.cancel_circle_icon
// : (DateTime.now().isAfter(
// DateUtil.convertStringToDate(insuranceVM.patientInsuranceList.first.cardValidTo),
// ))
// ? AppAssets.cancel_circle_icon
// : AppAssets.insurance_active_icon,
// labelText: insuranceVM.isInsuranceLoading
// ? "Insurance"
// : (DateTime.now().isAfter(
// DateUtil.convertStringToDate(insuranceVM.patientInsuranceList.first.cardValidTo),
// )
// ? "Insurance Expired".needTranslation
// : "Insurance Active".needTranslation),
// iconColor: insuranceVM.isInsuranceLoading
// ? AppColors.primaryRedColor
// : (DateTime.now().isAfter(
// DateUtil.convertStringToDate(insuranceVM.patientInsuranceList.first.cardValidTo),
// ))
// ? AppColors.primaryRedColor
// : AppColors.successColor,
// iconSize: 14,
// backgroundColor: insuranceVM.isInsuranceLoading
// ? AppColors.primaryRedColor
// : (DateTime.now().isAfter(
// DateUtil.convertStringToDate(insuranceVM.patientInsuranceList.first.cardValidTo),
// ))
// ? AppColors.primaryRedColor.withValues(alpha: 0.15)
// : AppColors.successColor.withValues(alpha: 0.15),
// ).toShimmer2(isShow: insuranceVM.isInsuranceLoading) : SizedBox();
// }),
],
),
),
@ -439,49 +365,6 @@ class FamilyCardWidget extends StatelessWidget {
).paddingOnly(top: 16.h, right: 16.h, left: 16.h, bottom: 12.h).expanded,
1.divider,
_buildActionButton(appState),
// if (appState.getAuthenticatedUser()!.isParentUser ?? false) ...[
// if (member!.responseId != appState.getAuthenticatedUser()!.patientId) ...[
// CustomButton(
// icon: AppAssets.switch_user,
// text: "Switch Family File".needTranslation,
// onPressed: () {
// onFamilySwitchPress(member!);
// },
// ).paddingOnly(top: 12, right: 16, left: 16, bottom: 16),
// ] else
// ...[
// CustomButton(
// icon: AppAssets.add_family,
// text: "Add a new family member".needTranslation,
// onPressed: () {
// onAddFamilyMemberPress();
// },
// ).paddingOnly(top: 12, right: 16, left: 16, bottom: 16),
// ]
// ] else
// ...[
// if (appState.getSuperUserID != null && appState.getSuperUserID == member!.responseId) ...[
// CustomButton(
// icon: AppAssets.switch_user,
// text: "Switch Back To Family File".needTranslation,
// onPressed: () {
// onFamilySwitchPress(member!);
// },
// ).paddingOnly(top: 12, right: 16, left: 16, bottom: 16),
// ] else
// ...[
// CustomButton(
// icon: AppAssets.switch_user,
// text: "Disabled".needTranslation,
// backgroundColor: Colors.grey.shade200,
// borderColor: Colors.grey.shade200,
// textColor: AppColors.greyTextColor,
// onPressed: () {},
// iconColor: AppColors.greyTextColor,
// ).paddingOnly(top: 12, right: 16, left: 16, bottom: 16),
// ]
// ]
],
),
);

@ -59,6 +59,8 @@ class DialogServiceImp implements DialogService {
onOkPressed: () {
if (onOkPressed != null) {
onOkPressed();
} else {
context.pop();
}
},
onCancelPressed: () {

Loading…
Cancel
Save