updates
parent
6b2ec5aa2c
commit
ccd29f0cf9
@ -0,0 +1,58 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
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/common_models/generic_api_model.dart';
|
||||
import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart';
|
||||
import 'package:hmg_patient_app_new/services/logger_service.dart';
|
||||
|
||||
abstract class HabibWalletRepo {
|
||||
Future<Either<Failure, GenericApiModel<dynamic>>> getPatientBalanceAmount();
|
||||
}
|
||||
|
||||
class HabibWalletRepoImp implements HabibWalletRepo {
|
||||
final ApiClient apiClient;
|
||||
final LoggerService loggerService;
|
||||
|
||||
HabibWalletRepoImp({required this.loggerService, required this.apiClient});
|
||||
|
||||
@override
|
||||
Future<Either<Failure, GenericApiModel<dynamic>>> getPatientBalanceAmount() async {
|
||||
Map<String, dynamic> mapDevice = {};
|
||||
|
||||
try {
|
||||
GenericApiModel<dynamic>? apiResponse;
|
||||
Failure? failure;
|
||||
await apiClient.post(
|
||||
GET_PATIENT_AdVANCE_BALANCE_AMOUNT,
|
||||
body: mapDevice,
|
||||
onFailure: (error, statusCode, {messageStatus, failureType}) {
|
||||
failure = failureType;
|
||||
},
|
||||
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
|
||||
try {
|
||||
// final list = response['ListPLO'];
|
||||
// if (list == null || list.isEmpty) {
|
||||
// throw Exception("lab list is empty");
|
||||
// }
|
||||
|
||||
// final labOrders = list.map((item) => PatientLabOrdersResponseModel.fromJson(item as Map<String, dynamic>)).toList().cast<PatientLabOrdersResponseModel>();
|
||||
|
||||
apiResponse = GenericApiModel<dynamic>(
|
||||
messageStatus: messageStatus,
|
||||
statusCode: statusCode,
|
||||
errorMessage: null,
|
||||
data: response["TotalAdvanceBalanceAmount"],
|
||||
);
|
||||
} catch (e) {
|
||||
failure = DataParsingFailure(e.toString());
|
||||
}
|
||||
},
|
||||
);
|
||||
if (failure != null) return Left(failure!);
|
||||
if (apiResponse == null) return Left(ServerFailure("Unknown error"));
|
||||
return Right(apiResponse!);
|
||||
} catch (e) {
|
||||
return Left(UnknownFailure(e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hmg_patient_app_new/features/habib_wallet/models/habib_wallet_repo.dart';
|
||||
import 'package:hmg_patient_app_new/services/error_handler_service.dart';
|
||||
|
||||
class HabibWalletViewModel extends ChangeNotifier {
|
||||
bool isWalletAmountLoading = false;
|
||||
num habibWalletAmount = 0;
|
||||
|
||||
HabibWalletRepo habibWalletRepo;
|
||||
ErrorHandlerService errorHandlerService;
|
||||
|
||||
HabibWalletViewModel({required this.habibWalletRepo, required this.errorHandlerService});
|
||||
|
||||
initHabibWalletProvider() {
|
||||
isWalletAmountLoading = true;
|
||||
habibWalletAmount = 0;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> getPatientBalanceAmount({Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
||||
final result = await habibWalletRepo.getPatientBalanceAmount();
|
||||
|
||||
result.fold(
|
||||
(failure) async => await errorHandlerService.handleError(failure: failure),
|
||||
(apiResponse) {
|
||||
if (apiResponse.messageStatus == 2) {
|
||||
// dialogService.showErrorDialog(message: apiResponse.errorMessage!, onOkPressed: () {});
|
||||
} else if (apiResponse.messageStatus == 1) {
|
||||
habibWalletAmount = apiResponse.data!;
|
||||
isWalletAmountLoading = false;
|
||||
notifyListeners();
|
||||
if (onSuccess != null) {
|
||||
onSuccess(apiResponse);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,111 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
||||
import 'package:hmg_patient_app_new/core/app_state.dart';
|
||||
import 'package:hmg_patient_app_new/core/dependencies.dart';
|
||||
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
||||
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
||||
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||||
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
||||
import 'package:hmg_patient_app_new/features/habib_wallet/models/habib_wallet_view_model.dart';
|
||||
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
||||
import 'package:hmg_patient_app_new/presentation/habib_wallet/recharge_wallet_page.dart';
|
||||
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/transitions/fade_page.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class HabibWalletPage extends StatefulWidget {
|
||||
const HabibWalletPage({super.key});
|
||||
|
||||
@override
|
||||
State<HabibWalletPage> createState() => _HabibWalletState();
|
||||
}
|
||||
|
||||
class _HabibWalletState extends State<HabibWalletPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
AppState _appState = getIt.get<AppState>();
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.bgScaffoldColor,
|
||||
appBar: AppBar(
|
||||
title: LocaleKeys.myWallet.tr(context: context).toText18(),
|
||||
backgroundColor: AppColors.bgScaffoldColor,
|
||||
),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.all(24.h),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
LocaleKeys.myWallet.tr(context: context).toText24(isBold: true),
|
||||
SizedBox(height: 24.h),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 180.h,
|
||||
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||
color: AppColors.blackBgColor,
|
||||
borderRadius: 24,
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16.h),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
"${_appState.getAuthenticatedUser()!.firstName!} ${_appState.getAuthenticatedUser()!.lastName!}".toText19(isBold: true, color: AppColors.whiteColor),
|
||||
"MRN: ${_appState.getAuthenticatedUser()!.patientId!}".toText14(weight: FontWeight.w500, color: AppColors.greyTextColor),
|
||||
],
|
||||
),
|
||||
Utils.buildSvgWithAssets(icon: AppAssets.habiblogo, width: 24.h, height: 24.h),
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
LocaleKeys.balanceAmount.tr(context: context).toText14(weight: FontWeight.w500, color: AppColors.whiteColor),
|
||||
Consumer<HabibWalletViewModel>(builder: (context, habibWalletVM, child) {
|
||||
return Utils.getPaymentAmountWithSymbol(habibWalletVM.habibWalletAmount.toString().toText32(isBold: true, color: AppColors.whiteColor), AppColors.whiteColor, 13.h,
|
||||
isExpanded: false)
|
||||
.toShimmer2(isShow: habibWalletVM.isWalletAmountLoading, radius: 12.h);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16.h),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CustomButton(
|
||||
icon: AppAssets.recharge_icon,
|
||||
iconSize: 21.h,
|
||||
text: "Recharge".needTranslation,
|
||||
onPressed: () {
|
||||
Navigator.of(context).push(
|
||||
FadePage(
|
||||
page: RechargeWalletPage(),
|
||||
),
|
||||
);
|
||||
},
|
||||
backgroundColor: AppColors.infoColor,
|
||||
borderColor: AppColors.infoColor,
|
||||
textColor: AppColors.whiteColor,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
borderRadius: 12,
|
||||
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
||||
height: 40.h,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,105 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
||||
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
||||
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
||||
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
||||
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/input_widget.dart';
|
||||
|
||||
class RechargeWalletPage extends StatefulWidget {
|
||||
const RechargeWalletPage({super.key});
|
||||
|
||||
@override
|
||||
State<RechargeWalletPage> createState() => _RechargeWalletPageState();
|
||||
}
|
||||
|
||||
class _RechargeWalletPageState extends State<RechargeWalletPage> {
|
||||
|
||||
FocusNode textFocusNode = FocusNode();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.bgScaffoldColor,
|
||||
appBar: AppBar(
|
||||
title: LocaleKeys.createAdvancedPayment.tr(context: context).toText18(),
|
||||
backgroundColor: AppColors.bgScaffoldColor,
|
||||
),
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(24.h),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
LocaleKeys.createAdvancedPayment.tr(context: context).toText20(isBold: true),
|
||||
SizedBox(height: 24.h),
|
||||
Container(
|
||||
height: 135.h,
|
||||
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||
color: AppColors.whiteColor,
|
||||
borderRadius: 24.h,
|
||||
hasShadow: false,
|
||||
side: BorderSide(color: AppColors.textColor, width: 2.h),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16.h),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
"Enter an amount".needTranslation.toText14(color: AppColors.greyTextColor, weight: FontWeight.w500),
|
||||
Spacer(),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Utils.getPaymentAmountWithSymbol(
|
||||
SizedBox(
|
||||
width: 150.h,
|
||||
child: TextInputWidget(
|
||||
labelText: "",
|
||||
hintText: "",
|
||||
isEnable: true,
|
||||
prefix: null,
|
||||
isAllowRadius: true,
|
||||
isBorderAllowed: false,
|
||||
isAllowLeadingIcon: true,
|
||||
autoFocus: true,
|
||||
fontSize: 40,
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.h, vertical: 0.h),
|
||||
focusNode: textFocusNode,
|
||||
isWalletAmountInput: true,
|
||||
// leadingIcon: AppAssets.student_card,
|
||||
),
|
||||
),
|
||||
AppColors.textColor,
|
||||
13.h,
|
||||
isExpanded: false),
|
||||
const Spacer(),
|
||||
"SAR".needTranslation.toText20(color: AppColors.greyTextColor, weight: FontWeight.w500),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)),
|
||||
Container(
|
||||
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
||||
color: AppColors.whiteColor,
|
||||
borderRadius: 24.h,
|
||||
hasShadow: false,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue