127 lines
4.0 KiB
Dart
127 lines
4.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:cheminova/models/Daily_Task_Response.dart';
|
|
import 'package:cheminova/widgets/common_app_bar.dart';
|
|
import 'package:cheminova/widgets/common_background.dart';
|
|
import 'package:cheminova/widgets/common_drawer.dart';
|
|
import '../constants/constant.dart';
|
|
import '../provider/daily_task_provider.dart';
|
|
import 'Add_products_screen.dart';
|
|
|
|
class UpdateInventoryTaskScreen extends StatefulWidget {
|
|
const UpdateInventoryTaskScreen({super.key});
|
|
|
|
@override
|
|
_UpdateInventoryTaskScreenState createState() => _UpdateInventoryTaskScreenState();
|
|
}
|
|
|
|
class _UpdateInventoryTaskScreenState extends State<UpdateInventoryTaskScreen> {
|
|
late DailyTaskProvider _dailyTaskProvider;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_dailyTaskProvider = DailyTaskProvider();
|
|
_dailyTaskProvider.getTask(type: 'New');
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ChangeNotifierProvider(
|
|
create: (context) => _dailyTaskProvider,
|
|
child: Scaffold(
|
|
extendBodyBehindAppBar: true,
|
|
appBar: _buildAppBar(),
|
|
drawer: const CommonDrawer(),
|
|
body: CommonBackground(
|
|
child: SafeArea(
|
|
child: _buildTaskList(),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
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(
|
|
'Inventory Update Tasks',
|
|
style: TextStyle(color: Colors.black87, fontSize: 20),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildTaskList() {
|
|
return Consumer<DailyTaskProvider>(
|
|
builder: (context, value, child) =>
|
|
value.isLoading
|
|
? const Center(child: CircularProgressIndicator())
|
|
: ListView.separated(
|
|
padding: const EdgeInsets.all(16),
|
|
itemCount: value.newTasksList.length,
|
|
separatorBuilder: (context, index) => const SizedBox(height: 8),
|
|
itemBuilder: (context, index) {
|
|
final task = value.newTasksList[index];
|
|
if (task.task?.toLowerCase() == 'update inventory data') {
|
|
return _buildTaskCard(task);
|
|
} else {
|
|
return const SizedBox.shrink();
|
|
}
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildTaskCard(Tasks tasksList) {
|
|
return InkWell(
|
|
onTap: () {
|
|
if (tasksList.sId != null && tasksList.addedFor != null) {
|
|
Navigator.push(
|
|
navigatorKey.currentContext!,
|
|
MaterialPageRoute(
|
|
builder: (context) => AddProductsScreen(
|
|
distributorType: tasksList.addedFor!,
|
|
tradeName: tasksList.tradeName??'',
|
|
pdRdId: tasksList.sId!)));
|
|
}
|
|
},
|
|
child: Card(
|
|
color: Colors.white,
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
|
|
child: ListTile(
|
|
leading: const Icon(Icons.inventory, color: Colors.blueAccent),
|
|
title: Text(
|
|
tasksList.task ?? '',
|
|
style: const TextStyle(
|
|
color: Colors.black87,
|
|
fontWeight: FontWeight.w700,
|
|
fontSize: 16,
|
|
fontFamily: 'Anek',
|
|
),
|
|
),
|
|
subtitle: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text('Distributor: ${tasksList.addedFor ?? ""}'),
|
|
Text('Trader Name: ${tasksList.tradeName??''}'),
|
|
if(tasksList.taskDueDate != null) Text('Due Date: ${DateFormat('dd/MM/yyyy').format(DateTime.parse(tasksList.taskDueDate!))}'),
|
|
Text('Priority: ${tasksList.taskPriority}'),
|
|
],
|
|
),
|
|
trailing: const Icon(Icons.arrow_forward_ios, color: Colors.black87),
|
|
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |