fixed the loading issue

This commit is contained in:
Vaibhav Surve 2025-11-10 14:38:10 +05:30
parent fd57686c8a
commit a88d085001
2 changed files with 61 additions and 58 deletions

View File

@ -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();

View File

@ -105,76 +105,78 @@ class _PaymentRequestDetailScreenState extends State<PaymentRequestDetailScreen>
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(