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,46 +130,103 @@ class _DashboardScreenState extends State<DashboardScreen> with UIMixin {
|
|||||||
DashboardScreen.dailyTasksProgressRoute),
|
DashboardScreen.dailyTasksProgressRoute),
|
||||||
];
|
];
|
||||||
|
|
||||||
return LayoutBuilder(
|
return GetBuilder<ProjectController>(
|
||||||
builder: (context, constraints) {
|
id: 'dashboard_controller',
|
||||||
double maxWidth = constraints.maxWidth;
|
builder: (controller) {
|
||||||
int crossAxisCount = (maxWidth / 100).floor().clamp(2, 4);
|
final bool isProjectSelected = controller.selectedProject != null;
|
||||||
double cardWidth =
|
|
||||||
(maxWidth - (crossAxisCount - 1) * 10) / crossAxisCount;
|
|
||||||
|
|
||||||
return Wrap(
|
return Column(
|
||||||
spacing: 10,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
runSpacing: 10,
|
children: [
|
||||||
children:
|
if (!isProjectSelected)
|
||||||
stats.map((stat) => _buildStatCard(stat, cardWidth)).toList(),
|
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) {
|
||||||
|
double maxWidth = constraints.maxWidth;
|
||||||
|
int crossAxisCount = (maxWidth / 100).floor().clamp(2, 4);
|
||||||
|
double cardWidth =
|
||||||
|
(maxWidth - (crossAxisCount - 1) * 10) / crossAxisCount;
|
||||||
|
|
||||||
|
return Wrap(
|
||||||
|
spacing: 10,
|
||||||
|
runSpacing: 10,
|
||||||
|
children: stats
|
||||||
|
.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,
|
||||||
borderRadius: BorderRadius.circular(10),
|
child: IgnorePointer(
|
||||||
child: MyCard.bordered(
|
ignoring: !isEnabled,
|
||||||
width: width,
|
child: InkWell(
|
||||||
height: 100,
|
onTap: () {
|
||||||
paddingAll: 5,
|
if (!isEnabled) {
|
||||||
borderRadiusAll: 10,
|
Get.defaultDialog(
|
||||||
border: Border.all(color: Colors.grey.withOpacity(0.15)),
|
title: "No Project Selected",
|
||||||
shadow: MyShadow(elevation: 1.5, position: MyShadowPosition.bottom),
|
middleText:
|
||||||
child: Column(
|
"You need to select a project before accessing this section.",
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
confirm: ElevatedButton(
|
||||||
children: [
|
onPressed: () => Get.back(),
|
||||||
_buildStatCardIcon(statItem),
|
child: const Text("OK"),
|
||||||
MySpacing.height(8),
|
),
|
||||||
MyText.labelSmall(
|
);
|
||||||
statItem.title,
|
} else {
|
||||||
maxLines: 2,
|
Get.toNamed(statItem.route);
|
||||||
overflow: TextOverflow.visible,
|
}
|
||||||
textAlign: TextAlign.center,
|
},
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
child: MyCard.bordered(
|
||||||
|
width: width,
|
||||||
|
height: 100,
|
||||||
|
paddingAll: 5,
|
||||||
|
borderRadiusAll: 10,
|
||||||
|
border: Border.all(color: Colors.grey.withOpacity(0.15)),
|
||||||
|
shadow: MyShadow(elevation: 1.5, position: MyShadowPosition.bottom),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
_buildStatCardIcon(statItem),
|
||||||
|
MySpacing.height(8),
|
||||||
|
MyText.labelSmall(
|
||||||
|
statItem.title,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.visible,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user