removed the extra boz coming for the dashboard chart
This commit is contained in:
parent
2fb3c36ba4
commit
2013447904
@ -64,49 +64,36 @@ class AttendanceDashboardChart extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Obx(() {
|
return Obx(() {
|
||||||
final isChartView = controller.isChartView.value;
|
final isChartView = controller.isChartView.value;
|
||||||
final selectedRange = controller.selectedRange.value;
|
final selectedRange = controller.selectedRange.value;
|
||||||
final isLoading = controller.isLoading.value;
|
final isLoading = controller.isLoading.value;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
decoration: const BoxDecoration(
|
// flat white background
|
||||||
gradient: LinearGradient(
|
color: Colors.white,
|
||||||
colors: [Color(0xfff0f4f8), Color(0xffe2ebf0)],
|
padding: const EdgeInsets.all(10),
|
||||||
begin: Alignment.topLeft,
|
child: Column(
|
||||||
end: Alignment.bottomRight,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_buildHeader(selectedRange, isChartView),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
AnimatedSwitcher(
|
||||||
|
duration: const Duration(milliseconds: 300),
|
||||||
|
child: isLoading
|
||||||
|
? SkeletonLoaders.buildLoadingSkeleton()
|
||||||
|
: filteredData.isEmpty
|
||||||
|
? _buildNoDataMessage()
|
||||||
|
: isChartView
|
||||||
|
? _buildChart()
|
||||||
|
: _buildTable(),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
child: Card(
|
),
|
||||||
color: Colors.white,
|
);
|
||||||
elevation: 6,
|
});
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
}
|
||||||
shadowColor: Colors.black12,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
_buildHeader(selectedRange, isChartView),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
AnimatedSwitcher(
|
|
||||||
duration: const Duration(milliseconds: 300),
|
|
||||||
child: isLoading
|
|
||||||
? SkeletonLoaders.buildLoadingSkeleton()
|
|
||||||
: filteredData.isEmpty
|
|
||||||
? _buildNoDataMessage()
|
|
||||||
: isChartView
|
|
||||||
? _buildChart()
|
|
||||||
: _buildTable(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildHeader(String selectedRange, bool isChartView) {
|
Widget _buildHeader(String selectedRange, bool isChartView) {
|
||||||
return Padding(
|
return Padding(
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import 'package:marco/controller/dashboard/dashboard_controller.dart';
|
|||||||
import 'package:marco/controller/project_controller.dart';
|
import 'package:marco/controller/project_controller.dart';
|
||||||
import 'package:marco/helpers/services/storage/local_storage.dart';
|
import 'package:marco/helpers/services/storage/local_storage.dart';
|
||||||
import 'package:marco/helpers/utils/mixins/ui_mixin.dart';
|
import 'package:marco/helpers/utils/mixins/ui_mixin.dart';
|
||||||
import 'package:marco/helpers/utils/my_shadow.dart';
|
|
||||||
import 'package:marco/helpers/widgets/my_card.dart';
|
import 'package:marco/helpers/widgets/my_card.dart';
|
||||||
import 'package:marco/helpers/widgets/my_container.dart';
|
import 'package:marco/helpers/widgets/my_container.dart';
|
||||||
import 'package:marco/helpers/widgets/my_spacing.dart';
|
import 'package:marco/helpers/widgets/my_spacing.dart';
|
||||||
@ -26,14 +25,12 @@ class DashboardScreen extends StatefulWidget {
|
|||||||
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";
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<DashboardScreen> createState() => _DashboardScreenState();
|
State<DashboardScreen> createState() => _DashboardScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
||||||
final DashboardController dashboardController =
|
final DashboardController dashboardController = Get.put(DashboardController());
|
||||||
Get.put(DashboardController());
|
|
||||||
bool hasMpin = true;
|
bool hasMpin = true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -43,10 +40,8 @@ class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _checkMpinStatus() async {
|
Future<void> _checkMpinStatus() async {
|
||||||
final bool mpinStatus = await LocalStorage.getIsMpin();
|
hasMpin = await LocalStorage.getIsMpin();
|
||||||
setState(() {
|
if (mounted) setState(() {});
|
||||||
hasMpin = mpinStatus;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -57,107 +52,50 @@ class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
_buildDashboardStats(),
|
_buildDashboardStats(context),
|
||||||
MySpacing.height(24),
|
MySpacing.height(24),
|
||||||
GetBuilder<ProjectController>(
|
_buildAttendanceChartSection(),
|
||||||
id: 'dashboard_controller',
|
|
||||||
builder: (projectController) {
|
|
||||||
final bool isProjectSelected =
|
|
||||||
projectController.selectedProject != null;
|
|
||||||
|
|
||||||
return Opacity(
|
|
||||||
opacity: isProjectSelected ? 1.0 : 0.4,
|
|
||||||
child: IgnorePointer(
|
|
||||||
ignoring: !isProjectSelected,
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
AttendanceDashboardChart(),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildDashboardStats() {
|
/// Dashboard Statistics Section with ProjectController
|
||||||
|
Widget _buildDashboardStats(BuildContext context) {
|
||||||
final stats = [
|
final stats = [
|
||||||
_StatItem(LucideIcons.scan_face, "Attendance", contentTheme.success,
|
_StatItem(LucideIcons.scan_face, "Attendance", contentTheme.success, DashboardScreen.attendanceRoute),
|
||||||
DashboardScreen.attendanceRoute),
|
_StatItem(LucideIcons.users, "Employees", contentTheme.warning, DashboardScreen.employeesRoute),
|
||||||
_StatItem(LucideIcons.users, "Employees", contentTheme.warning,
|
_StatItem(LucideIcons.logs, "Daily Task Planing", contentTheme.info, DashboardScreen.dailyTasksRoute),
|
||||||
DashboardScreen.employeesRoute),
|
_StatItem(LucideIcons.list_todo, "Daily Task Progress", contentTheme.info, DashboardScreen.dailyTasksProgressRoute),
|
||||||
_StatItem(LucideIcons.logs, "Daily Task Planing", contentTheme.info,
|
_StatItem(LucideIcons.folder, "Directory", contentTheme.info, DashboardScreen.directoryMainPageRoute),
|
||||||
DashboardScreen.dailyTasksRoute),
|
_StatItem(LucideIcons.badge_dollar_sign, "Expense", contentTheme.info, DashboardScreen.expenseMainPageRoute),
|
||||||
_StatItem(LucideIcons.list_todo, "Daily Task Progress", contentTheme.info,
|
|
||||||
DashboardScreen.dailyTasksProgressRoute),
|
|
||||||
_StatItem(LucideIcons.folder, "Directory", contentTheme.info,
|
|
||||||
DashboardScreen.directoryMainPageRoute),
|
|
||||||
_StatItem(LucideIcons.badge_dollar_sign, "Expense", contentTheme.info,
|
|
||||||
DashboardScreen.expenseMainPageRoute),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return GetBuilder<ProjectController>(
|
return GetBuilder<ProjectController>(
|
||||||
id: 'dashboard_controller',
|
id: 'dashboard_controller',
|
||||||
builder: (controller) {
|
builder: (controller) {
|
||||||
final bool isLoading = controller.isLoading.value;
|
if (controller.isLoading.value) {
|
||||||
final bool isProjectSelected = controller.selectedProject != null;
|
return _buildLoadingSkeleton(context);
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return Wrap(
|
|
||||||
spacing: 10,
|
|
||||||
runSpacing: 10,
|
|
||||||
children: List.generate(
|
|
||||||
4,
|
|
||||||
(index) =>
|
|
||||||
_buildStatCardSkeleton(MediaQuery.of(context).size.width / 3),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final isProjectSelected = controller.selectedProject != null;
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (!isProjectSelected)
|
if (!isProjectSelected) _buildNoProjectMessage(),
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
||||||
child: MyCard(
|
|
||||||
color: Colors.orange.withOpacity(0.1),
|
|
||||||
paddingAll: 12,
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
const Icon(Icons.info_outline, color: Colors.orange),
|
|
||||||
MySpacing.width(8),
|
|
||||||
Expanded(
|
|
||||||
child: MyText.bodySmall(
|
|
||||||
"No projects assigned yet. Please contact your manager to get started.",
|
|
||||||
color: Colors.orange.shade800,
|
|
||||||
maxLines: 3,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
LayoutBuilder(
|
LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
double maxWidth = constraints.maxWidth;
|
final maxWidth = constraints.maxWidth;
|
||||||
int crossAxisCount = (maxWidth / 100).floor().clamp(2, 4);
|
final crossAxisCount = (maxWidth / 100).floor().clamp(2, 4);
|
||||||
double cardWidth =
|
final cardWidth = (maxWidth - (crossAxisCount - 1) * 10) / crossAxisCount;
|
||||||
(maxWidth - (crossAxisCount - 1) * 10) / crossAxisCount;
|
|
||||||
|
|
||||||
return Wrap(
|
return Wrap(
|
||||||
spacing: 10,
|
spacing: 10,
|
||||||
runSpacing: 10,
|
runSpacing: 10,
|
||||||
children: stats
|
children: stats
|
||||||
.map((stat) =>
|
.map((stat) => _buildStatCard(stat, cardWidth, isProjectSelected))
|
||||||
_buildStatCard(stat, cardWidth, isProjectSelected))
|
|
||||||
.toList(),
|
.toList(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -168,6 +106,64 @@ class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Attendance Chart Section
|
||||||
|
Widget _buildAttendanceChartSection() {
|
||||||
|
return GetBuilder<ProjectController>(
|
||||||
|
id: 'dashboard_controller',
|
||||||
|
builder: (projectController) {
|
||||||
|
final isProjectSelected = projectController.selectedProject != null;
|
||||||
|
return Opacity(
|
||||||
|
opacity: isProjectSelected ? 1.0 : 0.4,
|
||||||
|
child: IgnorePointer(
|
||||||
|
ignoring: !isProjectSelected,
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(12),
|
||||||
|
child: AttendanceDashboardChart(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// No Project Assigned Message
|
||||||
|
Widget _buildNoProjectMessage() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
child: MyCard(
|
||||||
|
color: Colors.orange.withOpacity(0.1),
|
||||||
|
paddingAll: 12,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.info_outline, color: Colors.orange),
|
||||||
|
MySpacing.width(8),
|
||||||
|
Expanded(
|
||||||
|
child: MyText.bodySmall(
|
||||||
|
"No projects assigned yet. Please contact your manager to get started.",
|
||||||
|
color: Colors.orange.shade800,
|
||||||
|
maxLines: 3,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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) {
|
Widget _buildStatCardSkeleton(double width) {
|
||||||
return MyCard.bordered(
|
return MyCard.bordered(
|
||||||
width: width,
|
width: width,
|
||||||
@ -175,7 +171,6 @@ class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
|||||||
paddingAll: 5,
|
paddingAll: 5,
|
||||||
borderRadiusAll: 10,
|
borderRadiusAll: 10,
|
||||||
border: Border.all(color: Colors.grey.withOpacity(0.15)),
|
border: Border.all(color: Colors.grey.withOpacity(0.15)),
|
||||||
shadow: MyShadow(elevation: 1.5, position: MyShadowPosition.bottom),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -195,27 +190,14 @@ class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stat Card
|
||||||
Widget _buildStatCard(_StatItem statItem, double width, bool isEnabled) {
|
Widget _buildStatCard(_StatItem statItem, double width, bool isEnabled) {
|
||||||
return Opacity(
|
return Opacity(
|
||||||
opacity: isEnabled ? 1.0 : 0.4,
|
opacity: isEnabled ? 1.0 : 0.4,
|
||||||
child: IgnorePointer(
|
child: IgnorePointer(
|
||||||
ignoring: !isEnabled,
|
ignoring: !isEnabled,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () => _handleStatCardTap(statItem, isEnabled),
|
||||||
if (!isEnabled) {
|
|
||||||
Get.defaultDialog(
|
|
||||||
title: "No Project Selected",
|
|
||||||
middleText:
|
|
||||||
"You need to select a project before accessing this section.",
|
|
||||||
confirm: ElevatedButton(
|
|
||||||
onPressed: () => Get.back(),
|
|
||||||
child: const Text("OK"),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
Get.toNamed(statItem.route);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
child: MyCard.bordered(
|
child: MyCard.bordered(
|
||||||
width: width,
|
width: width,
|
||||||
@ -223,7 +205,6 @@ class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
|||||||
paddingAll: 5,
|
paddingAll: 5,
|
||||||
borderRadiusAll: 10,
|
borderRadiusAll: 10,
|
||||||
border: Border.all(color: Colors.grey.withOpacity(0.15)),
|
border: Border.all(color: Colors.grey.withOpacity(0.15)),
|
||||||
shadow: MyShadow(elevation: 1.5, position: MyShadowPosition.bottom),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -243,6 +224,23 @@ class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Handle Tap
|
||||||
|
void _handleStatCardTap(_StatItem statItem, bool isEnabled) {
|
||||||
|
if (!isEnabled) {
|
||||||
|
Get.defaultDialog(
|
||||||
|
title: "No Project Selected",
|
||||||
|
middleText: "You need to select a project before accessing this section.",
|
||||||
|
confirm: ElevatedButton(
|
||||||
|
onPressed: () => Get.back(),
|
||||||
|
child: const Text("OK"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Get.toNamed(statItem.route);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Stat Icon
|
||||||
Widget _buildStatCardIcon(_StatItem statItem) {
|
Widget _buildStatCardIcon(_StatItem statItem) {
|
||||||
return MyContainer.rounded(
|
return MyContainer.rounded(
|
||||||
paddingAll: 10,
|
paddingAll: 10,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user