fixed the loading issue
This commit is contained in:
parent
fd57686c8a
commit
a88d085001
@ -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();
|
||||
|
||||
@ -105,16 +105,25 @@ class _PaymentRequestDetailScreenState extends State<PaymentRequestDetailScreen>
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: _buildAppBar(),
|
||||
body: SafeArea(
|
||||
child: Obx(() {
|
||||
if (controller.isLoading.value) {
|
||||
body: SafeArea(child: Obx(() {
|
||||
if (controller.isLoading.value &&
|
||||
controller.paymentRequest.value == null) {
|
||||
// Show skeleton only if data not yet loaded
|
||||
return SkeletonLoaders.paymentRequestDetailSkeletonLoader();
|
||||
}
|
||||
|
||||
final request = controller.paymentRequest.value;
|
||||
if (controller.errorMessage.isNotEmpty || request == null) {
|
||||
|
||||
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(
|
||||
@ -140,8 +149,7 @@ class _PaymentRequestDetailScreenState extends State<PaymentRequestDetailScreen>
|
||||
_Header(request: request, colorParser: _parseColor),
|
||||
const Divider(height: 30, thickness: 1.2),
|
||||
_Logs(
|
||||
logs: request.updateLogs,
|
||||
colorParser: _parseColor),
|
||||
logs: request.updateLogs, colorParser: _parseColor),
|
||||
const Divider(height: 30, thickness: 1.2),
|
||||
_Parties(request: request),
|
||||
const Divider(height: 30, thickness: 1.2),
|
||||
@ -157,24 +165,18 @@ class _PaymentRequestDetailScreenState extends State<PaymentRequestDetailScreen>
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
})),
|
||||
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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user