256 lines
8.0 KiB
Dart
256 lines
8.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:cheminova/screens/visit_dealers_screen.dart';
|
|
import 'package:cheminova/screens/display_sales_screen.dart';
|
|
import 'package:cheminova/screens/update_inventory_screen.dart';
|
|
import 'package:cheminova/screens/collect_kyc_screen.dart';
|
|
import 'package:cheminova/widgets/common_app_bar.dart';
|
|
import 'package:cheminova/widgets/common_drawer.dart';
|
|
import 'package:cheminova/widgets/common_background.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
class DailyTasksScreen extends StatefulWidget {
|
|
const DailyTasksScreen({super.key});
|
|
|
|
@override
|
|
State<DailyTasksScreen> createState() => _DailyTasksScreenState();
|
|
}
|
|
|
|
class _DailyTasksScreenState extends State<DailyTasksScreen> {
|
|
final List<String> _tabTitles = ['NEW', 'PENDING', 'COMPLETED'];
|
|
int _selectedTabIndex = 0;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
extendBodyBehindAppBar: true,
|
|
appBar: _buildAppBar(),
|
|
drawer: const CommonDrawer(),
|
|
body: CommonBackground(
|
|
child: SafeArea(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
_buildCustomTabBar(),
|
|
Expanded(
|
|
child: _buildTaskList(_selectedTabIndex),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
CommonAppBar _buildAppBar() {
|
|
return CommonAppBar(
|
|
backgroundColor: Colors.transparent,
|
|
elevation: 0,
|
|
actions: [
|
|
IconButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
icon: Image.asset('assets/Back_attendance.png'),
|
|
padding: const EdgeInsets.only(right: 20),
|
|
),
|
|
],
|
|
title: const Text(
|
|
'Daily Tasks',
|
|
style: TextStyle(color: Colors.black87, fontSize: 20),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildCustomTabBar() {
|
|
return Container(
|
|
height: 60,
|
|
margin: const EdgeInsets.symmetric(vertical: 16, horizontal: 8),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
children: List.generate(_tabTitles.length, (index) {
|
|
return GestureDetector(
|
|
onTap: () => setState(() => _selectedTabIndex = index),
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
decoration: BoxDecoration(
|
|
gradient: _selectedTabIndex == index
|
|
? const LinearGradient(
|
|
colors: [Color(0xff004791), Color(0xff1a73e8)],
|
|
begin: Alignment.topLeft,
|
|
end: Alignment.bottomRight,
|
|
)
|
|
: null,
|
|
color: _selectedTabIndex == index
|
|
? Colors.transparent
|
|
: Colors.white,
|
|
borderRadius: BorderRadius.circular(10),
|
|
border: Border.all(color: Colors.black),
|
|
boxShadow: [
|
|
if (_selectedTabIndex == index)
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.1),
|
|
blurRadius: 6,
|
|
offset: const Offset(0, 4),
|
|
),
|
|
],
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Icon(
|
|
_getTabIcon(index),
|
|
color: _selectedTabIndex == index
|
|
? Colors.white
|
|
: Colors.black,
|
|
),
|
|
const SizedBox(width: 8),
|
|
Text(
|
|
_tabTitles[index],
|
|
style: TextStyle(
|
|
color: _selectedTabIndex == index
|
|
? Colors.white
|
|
: Colors.black,
|
|
fontWeight: _selectedTabIndex == index
|
|
? FontWeight.bold
|
|
: FontWeight.normal,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
),
|
|
);
|
|
}
|
|
|
|
IconData _getTabIcon(int index) {
|
|
switch (index) {
|
|
case 0:
|
|
return Icons.new_releases;
|
|
case 1:
|
|
return Icons.pending;
|
|
case 2:
|
|
return Icons.check_circle;
|
|
default:
|
|
return Icons.new_releases;
|
|
}
|
|
}
|
|
|
|
Widget _buildTaskList(int tabIndex) {
|
|
List<TaskItem> tasks;
|
|
switch (tabIndex) {
|
|
case 0:
|
|
tasks = _newTasks;
|
|
break;
|
|
case 1:
|
|
tasks = _pendingTasks;
|
|
break;
|
|
case 2:
|
|
tasks = _completedTasks;
|
|
break;
|
|
default:
|
|
tasks = [];
|
|
}
|
|
|
|
return ListView.separated(
|
|
padding: const EdgeInsets.all(16),
|
|
itemCount: tasks.length,
|
|
separatorBuilder: (context, index) => const SizedBox(height: 8),
|
|
itemBuilder: (context, index) => _buildTaskCard(tasks[index]),
|
|
);
|
|
}
|
|
|
|
Widget _buildTaskCard(TaskItem task) {
|
|
if (task is KycTaskItem) {
|
|
return Card(
|
|
color: Colors.white,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
child: Column(
|
|
children: [
|
|
ListTile(
|
|
leading: const Icon(Icons.task, color: Colors.blueAccent),
|
|
title: Text(
|
|
task.title,
|
|
style: const TextStyle(
|
|
color: Colors.black87,
|
|
fontWeight: FontWeight.w700,
|
|
fontSize: 16,
|
|
fontFamily: 'Anek',
|
|
),
|
|
),
|
|
trailing:
|
|
const Icon(Icons.arrow_forward_ios, color: Colors.black87),
|
|
onTap: () => Navigator.push(context,
|
|
MaterialPageRoute(builder: (context) => task.screen)),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text('Note: ${task.note}'),
|
|
Text('Date: ${task.date.toString().split(' ')[0]}'),
|
|
Text('Priority: ${task.Low}'),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
} else {
|
|
return Card(
|
|
color: Colors.white,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
child: ListTile(
|
|
leading: const Icon(Icons.task, color: Colors.blueAccent),
|
|
title: Text(
|
|
task.title,
|
|
style: const TextStyle(
|
|
color: Colors.black87,
|
|
fontWeight: FontWeight.w700,
|
|
fontSize: 16,
|
|
fontFamily: 'Anek',
|
|
),
|
|
),
|
|
trailing: const Icon(Icons.arrow_forward_ios, color: Colors.black87),
|
|
onTap: () => Navigator.push(
|
|
context, MaterialPageRoute(builder: (context) => task.screen)),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
final List<TaskItem> _newTasks = [
|
|
KycTaskItem('Collect KYC Documents', const CollectKycScreen(id: '',),
|
|
'Collect KYC documents from ABC Trader', DateFormat('dd/MM/yyyy').format(DateTime.now()).toString(), 'Priority'),
|
|
KycTaskItem('REUPLOAD', const CollectKycScreen(id: '',),
|
|
'Reupload Pan Car From Shiv Traders', DateFormat('dd/MM/yyyy').format(DateTime.now()).toString(), 'Priority'),
|
|
KycTaskItem('REUPLOAD', const CollectKycScreen(id: '',),
|
|
'Reupload Pan Car From Shiv Traders', DateFormat('dd/MM/yyyy').format(DateTime.now()).toString(), 'Priority'),
|
|
// TaskItem('Update Inventory Data', const UpdateInventoryScreen()),
|
|
];
|
|
|
|
final List<TaskItem> _pendingTasks = [
|
|
TaskItem('Update Sales Data', const DisplaySalesScreen()),
|
|
TaskItem('Visit Dealers/Retailers', const VisitDealersScreen()),
|
|
];
|
|
|
|
final List<TaskItem> _completedTasks = [
|
|
TaskItem('Completed Task 1', const Placeholder()),
|
|
TaskItem('Completed Task 2', const Placeholder()),
|
|
];
|
|
}
|
|
|
|
class TaskItem {
|
|
final String title;
|
|
final Widget screen;
|
|
|
|
TaskItem(this.title, this.screen);
|
|
}
|
|
|
|
class KycTaskItem extends TaskItem {
|
|
final String note;
|
|
final String date;
|
|
final String Low;
|
|
|
|
KycTaskItem(super.title, super.screen, this.note, this.date, this.Low);
|
|
}
|