- Added employee attendance fetching in DashboardController. - Introduced loading state for employees in the dashboard. - Updated API endpoints to include attendance for the dashboard. - Created a new InfraProjectsMainScreen with tab navigation for task planning and progress reporting. - Improved UI components for better user experience in the dashboard. - Refactored project selection and quick actions in the dashboard. - Added permission constants for infrastructure projects.
135 lines
3.6 KiB
Dart
135 lines
3.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:on_field_work/helpers/utils/mixins/ui_mixin.dart';
|
|
import 'package:on_field_work/helpers/widgets/custom_app_bar.dart';
|
|
import 'package:on_field_work/helpers/widgets/pill_tab_bar.dart';
|
|
|
|
import 'package:on_field_work/controller/dynamicMenu/dynamic_menu_controller.dart';
|
|
import 'package:on_field_work/helpers/utils/permission_constants.dart';
|
|
|
|
// === Your 3 Screens ===
|
|
import 'package:on_field_work/view/taskPlanning/daily_progress_report.dart';
|
|
import 'package:on_field_work/view/taskPlanning/daily_task_planning.dart';
|
|
|
|
class InfraProjectsMainScreen extends StatefulWidget {
|
|
const InfraProjectsMainScreen({super.key});
|
|
|
|
@override
|
|
State<InfraProjectsMainScreen> createState() =>
|
|
_InfraProjectsMainScreenState();
|
|
}
|
|
|
|
class _InfraProjectsMainScreenState extends State<InfraProjectsMainScreen>
|
|
with SingleTickerProviderStateMixin, UIMixin {
|
|
late TabController _tabController;
|
|
|
|
final DynamicMenuController menuController = Get.find<DynamicMenuController>();
|
|
|
|
// Final tab list after filtering
|
|
final List<_InfraTab> _tabs = [];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_prepareTabs();
|
|
}
|
|
|
|
void _prepareTabs() {
|
|
// Use the same permission logic used in your dashboard_cards
|
|
final allowedMenu = menuController.menuItems.where((m) => m.available);
|
|
|
|
if (allowedMenu.any((m) => m.id == MenuItems.dailyTaskPlanning)) {
|
|
_tabs.add(
|
|
_InfraTab(
|
|
name: "Task Planning",
|
|
view: DailyTaskPlanningScreen(),
|
|
),
|
|
);
|
|
}
|
|
|
|
if (allowedMenu.any((m) => m.id == MenuItems.dailyProgressReport)) {
|
|
_tabs.add(
|
|
_InfraTab(
|
|
name: "Task Progress",
|
|
view: DailyProgressReportScreen(),
|
|
),
|
|
);
|
|
}
|
|
|
|
_tabController = TabController(length: _tabs.length, vsync: this);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_tabController.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final Color appBarColor = contentTheme.primary;
|
|
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xFFF1F1F1),
|
|
appBar: CustomAppBar(
|
|
title: "Infra Projects",
|
|
onBackPressed: () => Get.back(),
|
|
backgroundColor: appBarColor,
|
|
),
|
|
|
|
body: Stack(
|
|
children: [
|
|
// Top faded gradient
|
|
Container(
|
|
height: 50,
|
|
decoration: BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
appBarColor,
|
|
appBarColor.withOpacity(0.0),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
SafeArea(
|
|
top: false,
|
|
bottom: true,
|
|
child: Column(
|
|
children: [
|
|
// PILL TABS
|
|
PillTabBar(
|
|
controller: _tabController,
|
|
tabs: _tabs.map((e) => e.name).toList(),
|
|
selectedColor: contentTheme.primary,
|
|
unselectedColor: Colors.grey.shade600,
|
|
indicatorColor: contentTheme.primary,
|
|
),
|
|
|
|
// TAB CONTENT
|
|
Expanded(
|
|
child: TabBarView(
|
|
controller: _tabController,
|
|
children: _tabs.map((e) => e.view).toList(),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// INTERNAL MODEL
|
|
class _InfraTab {
|
|
final String name;
|
|
final Widget view;
|
|
|
|
_InfraTab({required this.name, required this.view});
|
|
}
|