haroon_dev
Haroon Amjad 3 days ago
parent 1a68ffd500
commit d194b5a45b

@ -199,8 +199,8 @@ class ApiClientImp implements ApiClient {
body['TokenID'] = "@dm!n"; body['TokenID'] = "@dm!n";
} }
// body['TokenID'] = "@dm!n"; body['TokenID'] = "@dm!n";
// body['PatientID'] = 809289; body['PatientID'] = 2007395;
// body['PatientTypeID'] = 1; // body['PatientTypeID'] = 1;
// body['PatientOutSA'] = 0; // body['PatientOutSA'] = 0;
// body['SessionID'] = "45786230487560q"; // body['SessionID'] = "45786230487560q";

@ -3,6 +3,7 @@ import 'package:hmg_patient_app_new/core/api/api_client.dart';
import 'package:hmg_patient_app_new/core/api_consts.dart'; import 'package:hmg_patient_app_new/core/api_consts.dart';
import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart'; import 'package:hmg_patient_app_new/core/common_models/generic_api_model.dart';
import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart'; import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart';
import 'package:hmg_patient_app_new/features/habib_wallet/models/patient_advance_balance_response_model.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart'; import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart';
import 'package:hmg_patient_app_new/services/logger_service.dart'; import 'package:hmg_patient_app_new/services/logger_service.dart';
@ -40,18 +41,22 @@ class HabibWalletRepoImp implements HabibWalletRepo {
}, },
onSuccess: (response, statusCode, {messageStatus, errorMessage}) { onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try { try {
// final list = response['ListPLO']; final list = response['List_PatientAdvanceBalanceAmount'];
// if (list == null || list.isEmpty) { // if (list == null || list.isEmpty) {
// throw Exception("lab list is empty"); // throw Exception("lab list is empty");
// } // }
// final labOrders = list.map((item) => PatientLabOrdersResponseModel.fromJson(item as Map<String, dynamic>)).toList().cast<PatientLabOrdersResponseModel>(); final List<PatientAdvanceBalanceResponseModel> balanceAmountList = list.map((item) => PatientAdvanceBalanceResponseModel.fromJson(item as Map<String, dynamic>)).toList().cast<PatientAdvanceBalanceResponseModel>();
for (var element in balanceAmountList) {
element.totalAmount = response['TotalAdvanceBalanceAmount'];
}
apiResponse = GenericApiModel<dynamic>( apiResponse = GenericApiModel<dynamic>(
messageStatus: messageStatus, messageStatus: messageStatus,
statusCode: statusCode, statusCode: statusCode,
errorMessage: null, errorMessage: null,
data: response["TotalAdvanceBalanceAmount"], data: balanceAmountList,
); );
} catch (e) { } catch (e) {
failure = DataParsingFailure(e.toString()); failure = DataParsingFailure(e.toString());

@ -1,6 +1,7 @@
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_repo.dart'; import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_repo.dart';
import 'package:hmg_patient_app_new/features/habib_wallet/models/patient_advance_balance_response_model.dart';
import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart'; import 'package:hmg_patient_app_new/features/my_appointments/models/resp_models/hospital_model.dart';
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/services/error_handler_service.dart'; import 'package:hmg_patient_app_new/services/error_handler_service.dart';
@ -30,6 +31,8 @@ class HabibWalletViewModel extends ChangeNotifier {
num selectedRechargeType = 1; num selectedRechargeType = 1;
List<PatientAdvanceBalanceResponseModel> habibWalletBalanceList = [];
HabibWalletViewModel({required this.habibWalletRepo, required this.errorHandlerService}); HabibWalletViewModel({required this.habibWalletRepo, required this.errorHandlerService});
initHabibWalletProvider() { initHabibWalletProvider() {
@ -39,6 +42,7 @@ class HabibWalletViewModel extends ChangeNotifier {
walletRechargeAmount = 0; walletRechargeAmount = 0;
selectedRechargeType = 1; selectedRechargeType = 1;
advancePaymentHospitals.clear(); advancePaymentHospitals.clear();
habibWalletBalanceList.clear();
selectedHospital = null; selectedHospital = null;
fileNumber = ''; fileNumber = '';
depositorName = ''; depositorName = '';
@ -103,7 +107,11 @@ class HabibWalletViewModel extends ChangeNotifier {
if (apiResponse.messageStatus == 2) { if (apiResponse.messageStatus == 2) {
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {}); // dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
} else if (apiResponse.messageStatus == 1) { } else if (apiResponse.messageStatus == 1) {
habibWalletAmount = apiResponse.data!; habibWalletBalanceList = apiResponse.data;
habibWalletAmount = habibWalletBalanceList.first.totalAmount ?? 0.0;
habibWalletBalanceList.sort((a, b) => b.patientAdvanceBalanceAmount!.compareTo(a.patientAdvanceBalanceAmount!));
isWalletAmountLoading = false; isWalletAmountLoading = false;
notifyListeners(); notifyListeners();
if (onSuccess != null) { if (onSuccess != null) {

@ -0,0 +1,27 @@
class PatientAdvanceBalanceResponseModel {
num? distanceInKilometers;
num? patientAdvanceBalanceAmount;
String? projectDescription;
int? projectID;
num? totalAmount;
PatientAdvanceBalanceResponseModel({this.distanceInKilometers, this.patientAdvanceBalanceAmount, this.projectDescription, this.projectID, this.totalAmount});
PatientAdvanceBalanceResponseModel.fromJson(Map<String, dynamic> json) {
distanceInKilometers = json['DistanceInKilometers'];
patientAdvanceBalanceAmount = json['PatientAdvanceBalanceAmount'];
projectDescription = json['ProjectDescription'];
projectID = json['ProjectID'];
totalAmount = json['TotalAmount'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = Map<String, dynamic>();
data['DistanceInKilometers'] = distanceInKilometers;
data['PatientAdvanceBalanceAmount'] = patientAdvanceBalanceAmount;
data['ProjectDescription'] = projectDescription;
data['ProjectID'] = projectID;
data['TotalAmount'] = totalAmount;
return data;
}
}

@ -1,3 +1,5 @@
import 'dart:async';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart'; import 'package:hmg_patient_app_new/core/app_assets.dart';
@ -26,6 +28,16 @@ class HabibWalletPage extends StatefulWidget {
class _HabibWalletState extends State<HabibWalletPage> { class _HabibWalletState extends State<HabibWalletPage> {
late HabibWalletViewModel habibWalletVM; late HabibWalletViewModel habibWalletVM;
@override
void initState() {
scheduleMicrotask(() async {
habibWalletVM.initHabibWalletProvider();
habibWalletVM.getPatientBalanceAmount();
});
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
habibWalletVM = Provider.of<HabibWalletViewModel>(context, listen: false); habibWalletVM = Provider.of<HabibWalletViewModel>(context, listen: false);
@ -44,7 +56,7 @@ class _HabibWalletState extends State<HabibWalletPage> {
width: double.infinity, width: double.infinity,
height: 180.h, height: 180.h,
decoration: RoundedRectangleBorder().toSmoothCornerDecoration( decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.blackBgColor, color: AppColors.whiteColor,
borderRadius: 24, borderRadius: 24,
), ),
child: Padding( child: Padding(
@ -59,18 +71,18 @@ class _HabibWalletState extends State<HabibWalletPage> {
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
"${_appState.getAuthenticatedUser()!.firstName!} ${_appState.getAuthenticatedUser()!.lastName!}".toText19(isBold: true, color: AppColors.whiteColor), "${_appState.getAuthenticatedUser()!.firstName!} ${_appState.getAuthenticatedUser()!.lastName!}".toText19(isBold: true, color: AppColors.textColor),
"MRN: ${_appState.getAuthenticatedUser()!.patientId!}".toText14(weight: FontWeight.w500, color: AppColors.greyTextColor), "MRN: ${_appState.getAuthenticatedUser()!.patientId!}".toText14(weight: FontWeight.w500, color: AppColors.greyTextColor),
], ],
).expanded, ).expanded,
Utils.buildSvgWithAssets(icon: AppAssets.habiblogo, width: 24.h, height: 24.h), Utils.buildSvgWithAssets(icon: AppAssets.habiblogo, width: 24.h, height: 24.h, applyThemeColor: false),
], ],
), ),
Spacer(), Spacer(),
LocaleKeys.balanceAmount.tr(context: context).toText14(weight: FontWeight.w500, color: AppColors.whiteColor), LocaleKeys.balanceAmount.tr(context: context).toText14(weight: FontWeight.w500, color: AppColors.textColor),
SizedBox(height: 4.h), SizedBox(height: 4.h),
Consumer<HabibWalletViewModel>(builder: (context, habibWalletVM, child) { Consumer<HabibWalletViewModel>(builder: (context, habibWalletVM, child) {
return Utils.getPaymentAmountWithSymbol2(habibWalletVM.habibWalletAmount, textColor: AppColors.whiteColor, iconColor: AppColors.whiteColor, iconSize: 13, isExpanded: false) return Utils.getPaymentAmountWithSymbol2(habibWalletVM.habibWalletAmount, textColor: AppColors.textColor, iconColor: AppColors.textColor, iconSize: 16, isExpanded: false)
.toShimmer2(isShow: habibWalletVM.isWalletAmountLoading, radius: 12.h, width: 80.h, height: 24.h); .toShimmer2(isShow: habibWalletVM.isWalletAmountLoading, radius: 12.h, width: 80.h, height: 24.h);
}), }),
], ],
@ -86,7 +98,7 @@ class _HabibWalletState extends State<HabibWalletPage> {
icon: AppAssets.recharge_icon, icon: AppAssets.recharge_icon,
iconSize: 24.w, iconSize: 24.w,
backgroundColor: AppColors.infoColor, backgroundColor: AppColors.infoColor,
textColor: AppColors.whiteColor, textColor: Colors.white,
text: LocaleKeys.recharge.tr(context: context), text: LocaleKeys.recharge.tr(context: context),
borderWidth: 0.w, borderWidth: 0.w,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
@ -99,12 +111,42 @@ class _HabibWalletState extends State<HabibWalletPage> {
page: RechargeWalletPage(), page: RechargeWalletPage(),
)) ))
.then((val) { .then((val) {
habibWalletVM.initHabibWalletProvider();
habibWalletVM.getPatientBalanceAmount(); habibWalletVM.getPatientBalanceAmount();
}); });
}, },
), ),
], ],
), ),
SizedBox(height: 16.h),
Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor,
borderRadius: 24.r,
hasShadow: false,
),
child: Consumer<HabibWalletViewModel>(builder: (context, habibWalletVM, child) {
return ListView.separated(
itemCount: habibWalletVM.habibWalletBalanceList.length,
physics: NeverScrollableScrollPhysics(),
padding: EdgeInsets.only(top: 8, bottom: 8),
shrinkWrap: true,
itemBuilder: (context, index) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(child: habibWalletVM.habibWalletBalanceList[index].projectDescription!.toText16(weight: FontWeight.w500, color: AppColors.textColor)),
Utils.getPaymentAmountWithSymbol2(habibWalletVM.habibWalletBalanceList[index].patientAdvanceBalanceAmount!, textColor: AppColors.textColor, iconColor: AppColors.textColor, iconSize: 18.h, isExpanded: false, fontSize: 28.f, fontWeight: FontWeight.w500),
],
).paddingSymmetrical(0, 12.h);
},
separatorBuilder: (BuildContext context, int index) {
return Divider(height: 1, color: AppColors.textColor.withAlpha(20));
},
).paddingSymmetrical(16.h, 24.h).toShimmer2(isShow: habibWalletVM.isWalletAmountLoading);
}),
),
SizedBox(height: 24.h),
], ],
), ),
), ),

Loading…
Cancel
Save