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", : "Create Payment Request",
isSubmitting: controller.isSubmitting.value, isSubmitting: controller.isSubmitting.value,
onCancel: Get.back, onCancel: Get.back,
submitText: "Save as Draft",
onSubmit: () async { onSubmit: () async {
if (_formKey.currentState!.validate() && _validateSelections()) { if (_formKey.currentState!.validate() && _validateSelections()) {
final success = await controller.submitPaymentRequest(); final success = await controller.submitPaymentRequest();

View File

@ -105,76 +105,78 @@ class _PaymentRequestDetailScreenState extends State<PaymentRequestDetailScreen>
return Scaffold( return Scaffold(
backgroundColor: Colors.white, backgroundColor: Colors.white,
appBar: _buildAppBar(), appBar: _buildAppBar(),
body: SafeArea( body: SafeArea(child: Obx(() {
child: Obx(() { if (controller.isLoading.value &&
if (controller.isLoading.value) { controller.paymentRequest.value == null) {
return SkeletonLoaders.paymentRequestDetailSkeletonLoader(); // Show skeleton only if data not yet loaded
} return SkeletonLoaders.paymentRequestDetailSkeletonLoader();
final request = controller.paymentRequest.value; }
if (controller.errorMessage.isNotEmpty || request == null) {
return Center(child: MyText.bodyMedium("No data to display."));
}
return MyRefreshIndicator( final request = controller.paymentRequest.value;
onRefresh: controller.fetchPaymentRequestDetail,
child: SingleChildScrollView( if (controller.errorMessage.isNotEmpty) {
padding: EdgeInsets.fromLTRB( return Center(
12, child: MyText.bodyMedium(controller.errorMessage.value));
12, }
12,
60 + MediaQuery.of(context).padding.bottom, if (request == null) {
), return Center(child: MyText.bodyMedium("No data to display."));
child: Center( }
child: Container(
constraints: const BoxConstraints(maxWidth: 520), // Actual content
child: Card( return MyRefreshIndicator(
shape: RoundedRectangleBorder( onRefresh: controller.fetchPaymentRequestDetail,
borderRadius: BorderRadius.circular(5)), child: SingleChildScrollView(
elevation: 3, padding: EdgeInsets.fromLTRB(
child: Padding( 12,
padding: const EdgeInsets.symmetric( 12,
vertical: 14, horizontal: 14), 12,
child: Column( 60 + MediaQuery.of(context).padding.bottom,
crossAxisAlignment: CrossAxisAlignment.start, ),
children: [ child: Center(
_Header(request: request, colorParser: _parseColor), child: Container(
const Divider(height: 30, thickness: 1.2), constraints: const BoxConstraints(maxWidth: 520),
_Logs( child: Card(
logs: request.updateLogs, shape: RoundedRectangleBorder(
colorParser: _parseColor), borderRadius: BorderRadius.circular(5)),
const Divider(height: 30, thickness: 1.2), elevation: 3,
_Parties(request: request), child: Padding(
const Divider(height: 30, thickness: 1.2), padding: const EdgeInsets.symmetric(
_DetailsTable(request: request), vertical: 14, horizontal: 14),
const Divider(height: 30, thickness: 1.2), child: Column(
_Documents(documents: request.attachments), crossAxisAlignment: CrossAxisAlignment.start,
MySpacing.height(24), 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(), bottomNavigationBar: _buildBottomActionBar(),
// Added Floating Action Button for Edit // Added Floating Action Button for Edit
floatingActionButton: Obx(() { floatingActionButton: Obx(() {
if (controller.isLoading.value) return const SizedBox.shrink();
final request = controller.paymentRequest.value; final request = controller.paymentRequest.value;
if (controller.errorMessage.isNotEmpty || request == null) {
return const SizedBox.shrink();
}
if (!_checkedPermission) { // Don't show FAB if loading or data not loaded
_checkedPermission = true; if (controller.isLoading.value ||
WidgetsBinding.instance.addPostFrameCallback((_) { request == null ||
_checkPermissionToSubmit(request); employeeInfo == null) {
}); return const SizedBox.shrink();
} }
final canEdit = PaymentRequestPermissionHelper.canEditPaymentRequest( final canEdit = PaymentRequestPermissionHelper.canEditPaymentRequest(