removed the unwanted menus
This commit is contained in:
parent
d02211d389
commit
1993676470
@ -10,25 +10,15 @@ import 'package:marco/helpers/widgets/my_container.dart';
|
|||||||
import 'package:marco/helpers/widgets/my_spacing.dart';
|
import 'package:marco/helpers/widgets/my_spacing.dart';
|
||||||
import 'package:marco/helpers/widgets/my_text.dart';
|
import 'package:marco/helpers/widgets/my_text.dart';
|
||||||
import 'package:marco/helpers/widgets/dashbaord/attendance_overview_chart.dart';
|
import 'package:marco/helpers/widgets/dashbaord/attendance_overview_chart.dart';
|
||||||
import 'package:marco/helpers/widgets/dashbaord/project_progress_chart.dart';
|
|
||||||
import 'package:marco/view/layouts/layout.dart';
|
import 'package:marco/view/layouts/layout.dart';
|
||||||
import 'package:marco/controller/dynamicMenu/dynamic_menu_controller.dart';
|
|
||||||
import 'package:marco/helpers/widgets/dashbaord/dashboard_overview_widgets.dart';
|
|
||||||
|
|
||||||
class DashboardScreen extends StatefulWidget {
|
class DashboardScreen extends StatefulWidget {
|
||||||
const DashboardScreen({super.key});
|
const DashboardScreen({super.key});
|
||||||
|
|
||||||
static const String dashboardRoute = "/dashboard";
|
|
||||||
static const String employeesRoute = "/dashboard/employees";
|
static const String employeesRoute = "/dashboard/employees";
|
||||||
static const String projectsRoute = "/dashboard";
|
|
||||||
static const String attendanceRoute = "/dashboard/attendance";
|
static const String attendanceRoute = "/dashboard/attendance";
|
||||||
static const String tasksRoute = "/dashboard/daily-task";
|
|
||||||
static const String dailyTasksRoute = "/dashboard/daily-task-Planning";
|
|
||||||
static const String dailyTasksProgressRoute =
|
|
||||||
"/dashboard/daily-task-progress";
|
|
||||||
static const String directoryMainPageRoute = "/dashboard/directory-main-page";
|
static const String directoryMainPageRoute = "/dashboard/directory-main-page";
|
||||||
static const String expenseMainPageRoute = "/dashboard/expense-main-page";
|
static const String expenseMainPageRoute = "/dashboard/expense-main-page";
|
||||||
static const String documentMainPageRoute = "/dashboard/document-main-page";
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DashboardScreen> createState() => _DashboardScreenState();
|
State<DashboardScreen> createState() => _DashboardScreenState();
|
||||||
@ -37,7 +27,6 @@ class DashboardScreen extends StatefulWidget {
|
|||||||
class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
||||||
final DashboardController dashboardController =
|
final DashboardController dashboardController =
|
||||||
Get.put(DashboardController(), permanent: true);
|
Get.put(DashboardController(), permanent: true);
|
||||||
final DynamicMenuController menuController = Get.put(DynamicMenuController());
|
|
||||||
|
|
||||||
bool hasMpin = true;
|
bool hasMpin = true;
|
||||||
|
|
||||||
@ -62,82 +51,34 @@ class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
|||||||
children: [
|
children: [
|
||||||
_buildDashboardStats(context),
|
_buildDashboardStats(context),
|
||||||
MySpacing.height(24),
|
MySpacing.height(24),
|
||||||
SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
child: DashboardOverviewWidgets.teamsOverview(),
|
|
||||||
),
|
|
||||||
MySpacing.height(24),
|
|
||||||
SizedBox(
|
|
||||||
width: double.infinity,
|
|
||||||
child: DashboardOverviewWidgets.tasksOverview(),
|
|
||||||
),
|
|
||||||
MySpacing.height(24),
|
|
||||||
_buildAttendanceChartSection(),
|
_buildAttendanceChartSection(),
|
||||||
MySpacing.height(24),
|
|
||||||
_buildProjectProgressChartSection(),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Project Progress Chart Section
|
|
||||||
Widget _buildProjectProgressChartSection() {
|
|
||||||
return Obx(() {
|
|
||||||
|
|
||||||
|
|
||||||
if (dashboardController.projectChartData.isEmpty) {
|
|
||||||
return const Padding(
|
|
||||||
padding: EdgeInsets.all(16),
|
|
||||||
child: Center(
|
|
||||||
child: Text("No project progress data available."),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(5),
|
|
||||||
child: SizedBox(
|
|
||||||
height: 400,
|
|
||||||
child: ProjectProgressChart(
|
|
||||||
data: dashboardController.projectChartData,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Attendance Chart Section
|
/// Attendance Chart Section
|
||||||
Widget _buildAttendanceChartSection() {
|
Widget _buildAttendanceChartSection() {
|
||||||
return Obx(() {
|
return GetBuilder<ProjectController>(
|
||||||
|
id: 'dashboard_controller',
|
||||||
final isAttendanceAllowed = menuController.isMenuAllowed("Attendance");
|
builder: (projectController) {
|
||||||
|
final isProjectSelected = projectController.selectedProject != null;
|
||||||
if (!isAttendanceAllowed) {
|
return Opacity(
|
||||||
// 🚫 Don't render anything if attendance menu is not allowed
|
opacity: isProjectSelected ? 1.0 : 0.4,
|
||||||
return const SizedBox.shrink();
|
child: IgnorePointer(
|
||||||
}
|
ignoring: !isProjectSelected,
|
||||||
|
child: ClipRRect(
|
||||||
return GetBuilder<ProjectController>(
|
borderRadius: BorderRadius.circular(5),
|
||||||
id: 'dashboard_controller',
|
child: SizedBox(
|
||||||
builder: (projectController) {
|
height: 400,
|
||||||
final isProjectSelected = projectController.selectedProject != null;
|
child: AttendanceDashboardChart(),
|
||||||
return Opacity(
|
|
||||||
opacity: isProjectSelected ? 1.0 : 0.4,
|
|
||||||
child: IgnorePointer(
|
|
||||||
ignoring: !isProjectSelected,
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: BorderRadius.circular(5),
|
|
||||||
child: SizedBox(
|
|
||||||
height: 400,
|
|
||||||
child: AttendanceDashboardChart(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
);
|
||||||
);
|
},
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// No Project Assigned Message
|
/// No Project Assigned Message
|
||||||
@ -165,116 +106,48 @@ class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loading Skeletons
|
|
||||||
Widget _buildLoadingSkeleton(BuildContext context) {
|
|
||||||
return Wrap(
|
|
||||||
spacing: 10,
|
|
||||||
runSpacing: 10,
|
|
||||||
children: List.generate(
|
|
||||||
4,
|
|
||||||
(index) =>
|
|
||||||
_buildStatCardSkeleton(MediaQuery.of(context).size.width / 3),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Skeleton Card
|
|
||||||
Widget _buildStatCardSkeleton(double width) {
|
|
||||||
return MyCard.bordered(
|
|
||||||
width: width,
|
|
||||||
height: 100,
|
|
||||||
paddingAll: 5,
|
|
||||||
borderRadiusAll: 5,
|
|
||||||
border: Border.all(color: Colors.grey.withOpacity(0.15)),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
MyContainer.rounded(
|
|
||||||
paddingAll: 12,
|
|
||||||
color: Colors.grey.shade300,
|
|
||||||
child: const SizedBox(width: 18, height: 18),
|
|
||||||
),
|
|
||||||
MySpacing.height(8),
|
|
||||||
Container(
|
|
||||||
height: 12,
|
|
||||||
width: 60,
|
|
||||||
color: Colors.grey.shade300,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Dashboard Statistics Section
|
/// Dashboard Statistics Section
|
||||||
Widget _buildDashboardStats(BuildContext context) {
|
Widget _buildDashboardStats(BuildContext context) {
|
||||||
return Obx(() {
|
final stats = [
|
||||||
if (menuController.isLoading.value) {
|
_StatItem(LucideIcons.scan_face, "Attendance", contentTheme.success,
|
||||||
return _buildLoadingSkeleton(context);
|
DashboardScreen.attendanceRoute),
|
||||||
}
|
_StatItem(LucideIcons.users, "Employees", contentTheme.warning,
|
||||||
|
DashboardScreen.employeesRoute),
|
||||||
|
_StatItem(LucideIcons.folder, "Directory", contentTheme.info,
|
||||||
|
DashboardScreen.directoryMainPageRoute),
|
||||||
|
_StatItem(LucideIcons.badge_dollar_sign, "Expense", contentTheme.info,
|
||||||
|
DashboardScreen.expenseMainPageRoute),
|
||||||
|
];
|
||||||
|
|
||||||
if (menuController.hasError.value && menuController.menuItems.isEmpty) {
|
final projectController = Get.find<ProjectController>();
|
||||||
return Padding(
|
final isProjectSelected = projectController.selectedProject != null;
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Center(
|
|
||||||
child: MyText.bodySmall(
|
|
||||||
"Failed to load menus. Please try again later.",
|
|
||||||
color: Colors.red,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final stats = [
|
return Column(
|
||||||
_StatItem(LucideIcons.scan_face, "Attendance", contentTheme.success,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
DashboardScreen.attendanceRoute),
|
children: [
|
||||||
_StatItem(LucideIcons.users, "Employees", contentTheme.warning,
|
if (!isProjectSelected) _buildNoProjectMessage(),
|
||||||
DashboardScreen.employeesRoute),
|
LayoutBuilder(
|
||||||
_StatItem(LucideIcons.logs, "Daily Task Planning", contentTheme.info,
|
builder: (context, constraints) {
|
||||||
DashboardScreen.dailyTasksRoute),
|
int crossAxisCount = (constraints.maxWidth ~/ 80).clamp(2, 8);
|
||||||
_StatItem(LucideIcons.list_todo, "Daily Progress Report",
|
double cardWidth =
|
||||||
contentTheme.info, DashboardScreen.dailyTasksProgressRoute),
|
(constraints.maxWidth - (crossAxisCount - 1) * 6) /
|
||||||
_StatItem(LucideIcons.folder, "Directory", contentTheme.info,
|
crossAxisCount;
|
||||||
DashboardScreen.directoryMainPageRoute),
|
|
||||||
_StatItem(LucideIcons.badge_dollar_sign, "Expense", contentTheme.info,
|
|
||||||
DashboardScreen.expenseMainPageRoute),
|
|
||||||
_StatItem(LucideIcons.file_text, "Documents", contentTheme.info,
|
|
||||||
DashboardScreen.documentMainPageRoute),
|
|
||||||
];
|
|
||||||
|
|
||||||
final projectController = Get.find<ProjectController>();
|
return Wrap(
|
||||||
final isProjectSelected = projectController.selectedProject != null;
|
spacing: 6,
|
||||||
|
runSpacing: 6,
|
||||||
return Column(
|
alignment: WrapAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
children: stats
|
||||||
children: [
|
.map((stat) =>
|
||||||
if (!isProjectSelected) _buildNoProjectMessage(),
|
_buildStatCard(stat, isProjectSelected, cardWidth))
|
||||||
LayoutBuilder(
|
.toList()
|
||||||
builder: (context, constraints) {
|
.cast<Widget>(),
|
||||||
// ✅ smaller width cards → fit more in a row
|
);
|
||||||
int crossAxisCount = (constraints.maxWidth ~/ 80).clamp(2, 8);
|
},
|
||||||
double cardWidth =
|
),
|
||||||
(constraints.maxWidth - (crossAxisCount - 1) * 6) /
|
],
|
||||||
crossAxisCount;
|
);
|
||||||
|
|
||||||
return Wrap(
|
|
||||||
spacing: 6,
|
|
||||||
runSpacing: 6,
|
|
||||||
alignment: WrapAlignment.start,
|
|
||||||
children: stats
|
|
||||||
.where((stat) {
|
|
||||||
if (stat.title == "Documents") return true;
|
|
||||||
return menuController.isMenuAllowed(stat.title);
|
|
||||||
})
|
|
||||||
.map((stat) =>
|
|
||||||
_buildStatCard(stat, isProjectSelected, cardWidth))
|
|
||||||
.toList()
|
|
||||||
.cast<Widget>(),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stat Card (Compact + Small)
|
/// Stat Card (Compact + Small)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user