diff --git a/lib/model/finance/add_payment_request_bottom_sheet.dart b/lib/model/finance/add_payment_request_bottom_sheet.dart index c7cc543..138f7b1 100644 --- a/lib/model/finance/add_payment_request_bottom_sheet.dart +++ b/lib/model/finance/add_payment_request_bottom_sheet.dart @@ -117,6 +117,7 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet> : "Create Payment Request", isSubmitting: controller.isSubmitting.value, onCancel: Get.back, + submitText: "Save as Draft", onSubmit: () async { if (_formKey.currentState!.validate() && _validateSelections()) { final success = await controller.submitPaymentRequest(); diff --git a/lib/view/finance/payment_request_detail_screen.dart b/lib/view/finance/payment_request_detail_screen.dart index f588173..a9fc907 100644 --- a/lib/view/finance/payment_request_detail_screen.dart +++ b/lib/view/finance/payment_request_detail_screen.dart @@ -105,76 +105,78 @@ class _PaymentRequestDetailScreenState extends State return Scaffold( backgroundColor: Colors.white, appBar: _buildAppBar(), - body: SafeArea( - child: Obx(() { - if (controller.isLoading.value) { - return SkeletonLoaders.paymentRequestDetailSkeletonLoader(); - } - final request = controller.paymentRequest.value; - if (controller.errorMessage.isNotEmpty || request == null) { - return Center(child: MyText.bodyMedium("No data to display.")); - } + body: SafeArea(child: Obx(() { + if (controller.isLoading.value && + controller.paymentRequest.value == null) { + // Show skeleton only if data not yet loaded + return SkeletonLoaders.paymentRequestDetailSkeletonLoader(); + } - return MyRefreshIndicator( - onRefresh: controller.fetchPaymentRequestDetail, - child: SingleChildScrollView( - padding: EdgeInsets.fromLTRB( - 12, - 12, - 12, - 60 + MediaQuery.of(context).padding.bottom, - ), - child: Center( - child: Container( - constraints: const BoxConstraints(maxWidth: 520), - child: Card( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5)), - elevation: 3, - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 14, horizontal: 14), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _Header(request: request, colorParser: _parseColor), - const Divider(height: 30, thickness: 1.2), - _Logs( - logs: request.updateLogs, - colorParser: _parseColor), - const Divider(height: 30, thickness: 1.2), - _Parties(request: request), - const Divider(height: 30, thickness: 1.2), - _DetailsTable(request: request), - const Divider(height: 30, thickness: 1.2), - _Documents(documents: request.attachments), - MySpacing.height(24), - ], - ), + final request = controller.paymentRequest.value; + + if (controller.errorMessage.isNotEmpty) { + return Center( + child: MyText.bodyMedium(controller.errorMessage.value)); + } + + if (request == null) { + return Center(child: MyText.bodyMedium("No data to display.")); + } + + // ✅ Actual content + return MyRefreshIndicator( + onRefresh: controller.fetchPaymentRequestDetail, + child: SingleChildScrollView( + padding: EdgeInsets.fromLTRB( + 12, + 12, + 12, + 60 + MediaQuery.of(context).padding.bottom, + ), + child: Center( + child: Container( + constraints: const BoxConstraints(maxWidth: 520), + child: Card( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5)), + elevation: 3, + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 14, horizontal: 14), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _Header(request: request, colorParser: _parseColor), + const Divider(height: 30, thickness: 1.2), + _Logs( + logs: request.updateLogs, colorParser: _parseColor), + const Divider(height: 30, thickness: 1.2), + _Parties(request: request), + const Divider(height: 30, thickness: 1.2), + _DetailsTable(request: request), + const Divider(height: 30, thickness: 1.2), + _Documents(documents: request.attachments), + MySpacing.height(24), + ], ), ), ), ), ), - ); - }), - ), + ), + ); + })), bottomNavigationBar: _buildBottomActionBar(), // ✅ Added Floating Action Button for Edit floatingActionButton: Obx(() { - if (controller.isLoading.value) return const SizedBox.shrink(); - final request = controller.paymentRequest.value; - if (controller.errorMessage.isNotEmpty || request == null) { - return const SizedBox.shrink(); - } - if (!_checkedPermission) { - _checkedPermission = true; - WidgetsBinding.instance.addPostFrameCallback((_) { - _checkPermissionToSubmit(request); - }); + // Don't show FAB if loading or data not loaded + if (controller.isLoading.value || + request == null || + employeeInfo == null) { + return const SizedBox.shrink(); } final canEdit = PaymentRequestPermissionHelper.canEditPaymentRequest(