dev_aamir #186

Merged
Haroon6138 merged 2 commits from dev_aamir into master 15 hours ago

@ -76,7 +76,6 @@ class AuthenticationViewModel extends ChangeNotifier {
nameController = TextEditingController(),
emailController = TextEditingController();
CountryEnum selectedCountrySignup = CountryEnum.saudiArabia;
MaritalStatusTypeEnum? maritalStatus;
GenderTypeEnum? genderType;
@ -583,8 +582,13 @@ class AuthenticationViewModel extends ChangeNotifier {
MedicalFileViewModel medicalVm = getIt<MedicalFileViewModel>();
if (!_appState.getIsChildLoggedIn) {
await medicalVm.getFamilyFiles(status: 0);
if (isFormFamilyFile) {
await medicalVm.getAllPendingRecordsByResponseId();
_navigationService.pushAndReplace(AppRoutes.medicalFilePage);
} else {
_navigationService.replaceAllRoutesAndNavigateToLanding();
}
// await medicalVm.getAllPendingRecordsByResponseId();
_navigationService.replaceAllRoutesAndNavigateToLanding();
}
} else {
if (activation.list != null && activation.list!.isNotEmpty) {
@ -744,10 +748,12 @@ class AuthenticationViewModel extends ChangeNotifier {
Future<void> onWrongActivationCode({String? message}) async {
otpScreenNotifier.value = true;
await _dialogService.showErrorBottomSheet(message: message ?? "Something went wrong. ", onOkPressed: () {
LoaderBottomSheet.hideLoader();
_navigationService.pushAndReplace(AppRoutes.loginScreen);
});
await _dialogService.showErrorBottomSheet(
message: message ?? "Something went wrong. ",
onOkPressed: () {
LoaderBottomSheet.hideLoader();
_navigationService.pushAndReplace(AppRoutes.loginScreen);
});
}
loginWithFingerPrintFace(Function success) async {

@ -439,11 +439,10 @@ class MedicalFileViewModel extends ChangeNotifier {
);
// Clear and start fresh with current user
patientFamilyFiles.clear();
patientFamilyFiles.add(currentUserFamilyFile);
final List<FamilyFileResponseModelLists> newPatientFamilyFiles = [currentUserFamilyFile];
final List<FamilyFileResponseModelLists> activeFamilyFiles = [];
final List<FamilyFileResponseModelLists> pendingFamilyFiles = [];
final List<FamilyFileResponseModelLists> newPendingFamilyFiles = [];
for (var element in apiResponse.data!) {
if (element.status == null) {
@ -484,7 +483,7 @@ class MedicalFileViewModel extends ChangeNotifier {
if (isPending) {
familyFile.isRequestFromMySide = true;
pendingFamilyFiles.add(familyFile);
newPendingFamilyFiles.add(familyFile);
}
if (isActive) {
activeFamilyFiles.add(familyFile);
@ -492,13 +491,14 @@ class MedicalFileViewModel extends ChangeNotifier {
}
for (var activeFile in activeFamilyFiles) {
if (!patientFamilyFiles.any((e) => e.responseId == activeFile.responseId)) {
patientFamilyFiles.add(activeFile);
if (!newPatientFamilyFiles.any((e) => e.responseId == activeFile.responseId)) {
newPatientFamilyFiles.add(activeFile);
}
}
this.pendingFamilyFiles.clear();
this.pendingFamilyFiles.addAll(pendingFamilyFiles);
// Assign new list instances
patientFamilyFiles = newPatientFamilyFiles;
pendingFamilyFiles = newPendingFamilyFiles;
}
notifyListeners();
@ -553,7 +553,9 @@ class MedicalFileViewModel extends ChangeNotifier {
}
}
// pendingFamilyFiles.addAll(tempPendingFamilyFiles.where((element) => !pendingFamilyFiles.any((e) => e.responseId == element.responseId)));
pendingFamilyFiles.addAll(tempPendingFamilyFiles.where((element) => !pendingFamilyFiles.any((e) => e.patientId == element.patientId)));
final existingIds = pendingFamilyFiles.map((e) => e.patientId).toSet();
final newItems = tempPendingFamilyFiles.where((element) => !existingIds.contains(element.patientId)).toList();
pendingFamilyFiles = [...pendingFamilyFiles, ...newItems];
}
notifyListeners();
}
@ -589,7 +591,7 @@ class MedicalFileViewModel extends ChangeNotifier {
onUnHandledFailure: (failure) {
LoaderBottomSheet.hideLoader();
_dialogService.showErrorBottomSheet(
message: failure.message!,
message: failure.message,
onOkPressed: () {
navigationService.pop();
});
@ -663,7 +665,7 @@ class MedicalFileViewModel extends ChangeNotifier {
navigationService.pop();
});
} else if (apiResponse.messageStatus == 1) {
patientFamilyFiles.removeWhere((element) => element.id == id);
patientFamilyFiles = patientFamilyFiles.where((element) => element.id != id).toList();
getFamilyFiles();
getAllPendingRecordsByResponseId();
LoaderBottomSheet.hideLoader();
@ -741,11 +743,12 @@ class MedicalFileViewModel extends ChangeNotifier {
// moveProfile.status = 3;
// moveProfile.statusDescription = "Approved";
// patientFamilyFiles.add(moveProfile);
pendingFamilyFiles.removeWhere((element) => element.id == id);
pendingFamilyFiles = pendingFamilyFiles.where((element) => element.id != id).toList();
//TODO: Call Api Here To Load Family Members
getFamilyFiles(status: 0);
getAllPendingRecordsByResponseId();
LoaderBottomSheet.hideLoader();
notifyListeners();
// onFamilyFileTabChange(0);
}
},

@ -1,4 +1,3 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
@ -20,14 +19,7 @@ import 'package:hmg_patient_app_new/widgets/custom_tab_bar.dart';
import 'package:provider/provider.dart';
class FamilyMedicalScreen extends StatefulWidget {
final List<FamilyFileResponseModelLists> profiles;
final Function(FamilyFileResponseModelLists) onSelect;
const FamilyMedicalScreen({
super.key,
required this.profiles,
required this.onSelect,
});
const FamilyMedicalScreen({super.key});
@override
State<FamilyMedicalScreen> createState() => _FamilyMedicalScreenState();
@ -43,7 +35,6 @@ class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> {
WidgetsBinding.instance.addPostFrameCallback((_) {
medicalVM?.onFamilyFileTabChange(0);
medicalVM?.getAllPendingRecordsByResponseId();
});
}
@ -55,27 +46,28 @@ class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> {
title: LocaleKeys.familyTitle.tr(context: context),
bottomChild: appState.getAuthenticatedUser()!.isParentUser!
? Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor,
customBorder: BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24)),
),
padding: EdgeInsets.symmetric(vertical: 10.h, horizontal: 20.h),
child: CustomButton(
text: LocaleKeys.addANewFamilyMember.tr(context: context),
onPressed: () {
DialogService dialogService = getIt.get<DialogService>();
medicalVM!.clearAuthValues();
dialogService.showAddFamilyFileSheet(
label: LocaleKeys.addFamilyMember.tr(context: context),
message: LocaleKeys.pleaseFillBelowFieldToAddNewFamilyMember.tr(context: context),
onVerificationPress: () {
medicalVM!.addFamilyFile(otpTypeEnum: OTPTypeEnum.sms);
});
},
icon: AppAssets.add_icon,
fontSize: 16.f,
borderRadius: 12.r,
fontWeight: FontWeight.w500)).paddingOnly(bottom: 20.h)
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor,
customBorder: BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24)),
),
padding: EdgeInsets.symmetric(vertical: 10.h, horizontal: 20.h),
child: CustomButton(
text: LocaleKeys.addANewFamilyMember.tr(context: context),
onPressed: () {
DialogService dialogService = getIt.get<DialogService>();
medicalVM!.clearAuthValues();
dialogService.showAddFamilyFileSheet(
label: LocaleKeys.addFamilyMember.tr(context: context),
message: LocaleKeys.pleaseFillBelowFieldToAddNewFamilyMember.tr(context: context),
onVerificationPress: () {
medicalVM!.addFamilyFile(otpTypeEnum: OTPTypeEnum.sms);
});
},
icon: AppAssets.add_icon,
fontSize: 16.f,
borderRadius: 12.r,
fontWeight: FontWeight.w500))
.paddingOnly(bottom: 20.h)
: SizedBox(),
child: Column(
mainAxisSize: MainAxisSize.min,
@ -96,18 +88,28 @@ class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> {
),
),
appState.isChildLoggedIn ? SizedBox() : SizedBox(height: 25.h),
Selector<MedicalFileViewModel, int>(selector: (_, model) => model.getSelectedFamilyFileTabIndex, builder: (context, selectedIndex, child) => getFamilyTabs(index: selectedIndex)),
Selector<MedicalFileViewModel, ({int selectedIndex, List<FamilyFileResponseModelLists> patientFiles, List<FamilyFileResponseModelLists> pendingFiles})>(
selector: (_, model) => (selectedIndex: model.getSelectedFamilyFileTabIndex, patientFiles: model.patientFamilyFiles, pendingFiles: model.pendingFamilyFiles),
shouldRebuild: (previous, next) {
return previous.selectedIndex != next.selectedIndex || previous.patientFiles.length != next.patientFiles.length || previous.pendingFiles.length != next.pendingFiles.length;
},
builder: (context, data, child) => getFamilyTabs(index: data.selectedIndex, patientFiles: data.patientFiles, pendingFiles: data.pendingFiles),
),
SizedBox(height: 20.h),
],
).paddingSymmetrical(20, 0),
);
}
Widget getFamilyTabs({required int index}) {
Widget getFamilyTabs({
required int index,
required List<FamilyFileResponseModelLists> patientFiles,
required List<FamilyFileResponseModelLists> pendingFiles,
}) {
switch (index) {
case 0:
return FamilyCards(
profiles: medicalVM!.patientFamilyFiles,
profiles: patientFiles,
onSelect: (FamilyFileResponseModelLists profile) {
medicalVM!.switchFamilyFiles(responseID: profile.responseId, patientID: profile.patientId, phoneNumber: profile.mobileNumber);
},
@ -120,7 +122,7 @@ class _FamilyMedicalScreenState extends State<FamilyMedicalScreen> {
);
case 1:
return FamilyCards(
profiles: medicalVM!.pendingFamilyFiles,
profiles: pendingFiles,
isRequestDesign: medicalVM!.getSelectedFamilyFileTabIndex == 1,
onSelect: (FamilyFileResponseModelLists profile) {
medicalVM!.acceptRejectFileFromFamilyMembers(id: profile.id, status: 3);

@ -308,6 +308,7 @@ class _FamilyCardsState extends State<FamilyCards> {
alignment: WrapAlignment.start,
children: [
(profile.patientName ?? "").toText14(isBold: false, isCenter: true, maxlines: 1, weight: FontWeight.w600),
SizedBox(width: 2.w,),
(getStatusTextByRequest(
FamilyFileEnum.values.firstWhere((e) => e.toInt == profile.status), profile.isRequestFromMySide ?? false))
.toText14(

@ -101,14 +101,18 @@ class DialogServiceImp implements DialogService {
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
builder: (_) => ExceptionBottomSheet(
message: message,
showCancel: onCancelPressed != null ? true : false,
onOkPressed: onOkPressed,
onCancelPressed: () {
if (onCancelPressed != null) {
Navigator.of(context).pop();
}
builder: (_) => StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return ExceptionBottomSheet(
message: message,
showCancel: onCancelPressed != null ? true : false,
onOkPressed: onOkPressed,
onCancelPressed: () {
if (onCancelPressed != null) {
Navigator.of(context).pop();
}
},
);
},
),
);
@ -181,12 +185,8 @@ class DialogServiceImp implements DialogService {
textColor: AppColors.primaryRedBorderColor,
height: 48.h,
onPressed: () {
navigationService.pushPage(
page: FamilyMedicalScreen(
profiles: profiles,
onSelect: (FamilyFileResponseModelLists p1) {},
),
);
navigationService.pop();
navigationService.pushPage(page: FamilyMedicalScreen());
})
],
),

@ -10,7 +10,7 @@ import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
class ExceptionBottomSheet extends StatelessWidget {
class ExceptionBottomSheet extends StatefulWidget {
final String? title;
final String message;
final bool showOKButton;
@ -28,6 +28,11 @@ class ExceptionBottomSheet extends StatelessWidget {
this.onCancelPressed,
});
@override
State<ExceptionBottomSheet> createState() => _ExceptionBottomSheetState();
}
class _ExceptionBottomSheetState extends State<ExceptionBottomSheet> {
@override
Widget build(BuildContext context) {
return SafeArea(
@ -53,7 +58,7 @@ class ExceptionBottomSheet extends StatelessWidget {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
(title ?? LocaleKeys.notice.tr()).toText28(),
(widget.title ?? LocaleKeys.notice.tr()).toText28(),
InkWell(
onTap: () {
Navigator.of(context).pop();
@ -66,18 +71,18 @@ class ExceptionBottomSheet extends StatelessWidget {
],
),
SizedBox(height: 10.h),
(message).toText16(isBold: false, color: AppColors.textColor),
(widget.message).toText16(isBold: false, color: AppColors.textColor),
SizedBox(height: 10.h),
SizedBox(height: 24.h),
if (showOKButton && showCancel)
if (widget.showOKButton && widget.showCancel)
Row(
children: [
Expanded(
child: CustomButton(
height: 56.h,
text: LocaleKeys.cancel.tr(),
onPressed: onCancelPressed != null
? onCancelPressed!
onPressed: widget.onCancelPressed != null
? widget.onCancelPressed!
: () {
Navigator.of(context).pop();
},
@ -92,8 +97,8 @@ class ExceptionBottomSheet extends StatelessWidget {
Expanded(
child: CustomButton(
height: 56.h,
text: showCancel ? LocaleKeys.confirm.tr() : LocaleKeys.ok.tr(),
onPressed: onOkPressed,
text: widget.showCancel ? LocaleKeys.confirm.tr() : LocaleKeys.ok.tr(),
onPressed: widget.onOkPressed,
backgroundColor: AppColors.bgGreenColor,
borderColor: AppColors.bgGreenColor,
textColor: Colors.white,
@ -102,13 +107,13 @@ class ExceptionBottomSheet extends StatelessWidget {
),
],
),
if (showOKButton && !showCancel)
if (widget.showOKButton && !widget.showCancel)
Padding(
padding: EdgeInsets.only(bottom: 10.h),
child: CustomButton(
height: 56.h,
text: LocaleKeys.ok.tr(),
onPressed: onOkPressed,
onPressed: widget.onOkPressed,
backgroundColor: AppColors.primaryRedColor,
borderColor: AppColors.primaryRedBorderColor,
textColor: Colors.white,

@ -14,24 +14,29 @@ import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/dropdown/country_dropdown_widget.dart';
import 'package:hmg_patient_app_new/widgets/input_widget.dart';
import 'package:provider/provider.dart';
class FamilyFileAddWidget extends StatelessWidget {
class FamilyFileAddWidget extends StatefulWidget {
final Function()? onVerificationPress;
final String message;
const FamilyFileAddWidget(this.onVerificationPress, this.message, {super.key});
@override
State<FamilyFileAddWidget> createState() => _FamilyFileAddWidgetState();
}
class _FamilyFileAddWidgetState extends State<FamilyFileAddWidget> {
@override
Widget build(BuildContext context) {
AuthenticationViewModel authVm = getIt.get<AuthenticationViewModel>();
MedicalFileViewModel? medicalVM = getIt.get<MedicalFileViewModel>();
// TODO: implement build
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
message.toText16(color: AppColors.textColor, weight: FontWeight.w500),
widget.message.toText16(color: AppColors.textColor, weight: FontWeight.w500),
SizedBox(height: 20.h),
Container(
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(24)),
@ -59,21 +64,26 @@ class FamilyFileAddWidget extends StatelessWidget {
leadingIcon: AppAssets.student_card,
).paddingOnly(top: 8.h, bottom: 8.h),
Divider(height: 1.h, color: AppColors.spacerLineColor),
TextInputWidget(
labelText: LocaleKeys.phoneNumber.tr(),
hintText: "",
controller: authVm.phoneNumberController,
isEnable: true,
prefix: authVm.selectedCountrySignup.countryCode,
isAllowRadius: true,
isBorderAllowed: false,
isAllowLeadingIcon: true,
autoFocus: true,
keyboardType: TextInputType.number,
fontFamily: "Poppins",
padding: EdgeInsets.symmetric(vertical: 8.h),
leadingIcon: AppAssets.smart_phone,
).paddingOnly(top: 8.h, bottom: 4.h),
Selector<AuthenticationViewModel, String>(
selector: (_, model) => model.selectedCountrySignup.countryCode,
builder: (context, countryCode, child) {
return TextInputWidget(
labelText: LocaleKeys.phoneNumber.tr(),
hintText: "",
controller: authVm.phoneNumberController,
isEnable: true,
prefix: countryCode,
isAllowRadius: true,
isBorderAllowed: false,
isAllowLeadingIcon: true,
autoFocus: true,
keyboardType: TextInputType.number,
fontFamily: "Poppins",
padding: EdgeInsets.symmetric(vertical: 8.h),
leadingIcon: AppAssets.smart_phone,
).paddingOnly(top: 8.h, bottom: 4.h);
},
),
],
),
),
@ -91,8 +101,8 @@ class FamilyFileAddWidget extends StatelessWidget {
},
)) {
// authVm.addFamilyMember(otpTypeEnum: OTPTypeEnum.sms, isExcludedUser: true);
if (onVerificationPress != null) {
onVerificationPress!();
if (widget.onVerificationPress != null) {
widget.onVerificationPress!();
}
}
},

Loading…
Cancel
Save