feat: Enhance dashboard stats display with project selection validation and user feedback
This commit is contained in:
parent
602d8a8dc9
commit
658f3f26e0
@ -10,6 +10,7 @@ import 'package:marco/helpers/widgets/my_text.dart';
|
|||||||
import 'package:marco/view/layouts/layout.dart';
|
import 'package:marco/view/layouts/layout.dart';
|
||||||
import 'package:marco/helpers/services/storage/local_storage.dart';
|
import 'package:marco/helpers/services/storage/local_storage.dart';
|
||||||
import 'package:marco/helpers/widgets/my_button.dart';
|
import 'package:marco/helpers/widgets/my_button.dart';
|
||||||
|
import 'package:marco/controller/project_controller.dart';
|
||||||
|
|
||||||
class DashboardScreen extends StatefulWidget {
|
class DashboardScreen extends StatefulWidget {
|
||||||
const DashboardScreen({super.key});
|
const DashboardScreen({super.key});
|
||||||
@ -129,7 +130,38 @@ class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
|||||||
DashboardScreen.dailyTasksProgressRoute),
|
DashboardScreen.dailyTasksProgressRoute),
|
||||||
];
|
];
|
||||||
|
|
||||||
return LayoutBuilder(
|
return GetBuilder<ProjectController>(
|
||||||
|
id: 'dashboard_controller',
|
||||||
|
builder: (controller) {
|
||||||
|
final bool isProjectSelected = controller.selectedProject != null;
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if (!isProjectSelected)
|
||||||
|
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(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
double maxWidth = constraints.maxWidth;
|
double maxWidth = constraints.maxWidth;
|
||||||
int crossAxisCount = (maxWidth / 100).floor().clamp(2, 4);
|
int crossAxisCount = (maxWidth / 100).floor().clamp(2, 4);
|
||||||
@ -139,16 +171,40 @@ class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
|||||||
return Wrap(
|
return Wrap(
|
||||||
spacing: 10,
|
spacing: 10,
|
||||||
runSpacing: 10,
|
runSpacing: 10,
|
||||||
children:
|
children: stats
|
||||||
stats.map((stat) => _buildStatCard(stat, cardWidth)).toList(),
|
.map((stat) =>
|
||||||
|
_buildStatCard(stat, cardWidth, isProjectSelected))
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildStatCard(_StatItem statItem, double width) {
|
Widget _buildStatCard(_StatItem statItem, double width, bool isEnabled) {
|
||||||
return InkWell(
|
return Opacity(
|
||||||
onTap: () => Get.toNamed(statItem.route),
|
opacity: isEnabled ? 1.0 : 0.4,
|
||||||
|
child: IgnorePointer(
|
||||||
|
ignoring: !isEnabled,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
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,
|
||||||
@ -171,6 +227,8 @@ class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user