added dynamic menu for finance cards as per expense title
This commit is contained in:
parent
3543770654
commit
77a6d50571
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_lucide/flutter_lucide.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:marco/controller/project_controller.dart';
|
||||
import 'package:marco/controller/dynamicMenu/dynamic_menu_controller.dart';
|
||||
import 'package:marco/helpers/utils/mixins/ui_mixin.dart';
|
||||
import 'package:marco/helpers/widgets/my_card.dart';
|
||||
import 'package:marco/helpers/widgets/my_spacing.dart';
|
||||
@ -17,6 +18,7 @@ class FinanceScreen extends StatefulWidget {
|
||||
class _FinanceScreenState extends State<FinanceScreen>
|
||||
with UIMixin, TickerProviderStateMixin {
|
||||
final projectController = Get.find<ProjectController>();
|
||||
final DynamicMenuController menuController = Get.put(DynamicMenuController());
|
||||
late AnimationController _animationController;
|
||||
late Animation<double> _fadeAnimation;
|
||||
|
||||
@ -105,10 +107,38 @@ class _FinanceScreenState extends State<FinanceScreen>
|
||||
),
|
||||
body: FadeTransition(
|
||||
opacity: _fadeAnimation,
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: _buildFinanceModulesCompact(),
|
||||
),
|
||||
child: Obx(() {
|
||||
if (menuController.isLoading.value) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
if (menuController.hasError.value ||
|
||||
menuController.menuItems.isEmpty) {
|
||||
return const Center(
|
||||
child: Text(
|
||||
"Failed to load menus. Please try again later.",
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ✅ Only allow finance cards if "Expense" menu is allowed
|
||||
final isExpenseAllowed = menuController.isMenuAllowed("Expense");
|
||||
|
||||
if (!isExpenseAllowed) {
|
||||
return const Center(
|
||||
child: Text(
|
||||
"You don’t have access to the Finance section.",
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: _buildFinanceModulesCompact(),
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user