link api task for daily_tasks_screen
This commit is contained in:
parent
18e50b5354
commit
bf3ea7172a
@ -8,6 +8,7 @@ import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import '../constants/constant.dart';
|
||||
import '../services/api_urls.dart';
|
||||
|
||||
class CollectKycProvider extends ChangeNotifier {
|
||||
@ -260,13 +261,41 @@ class CollectKycProvider extends ChangeNotifier {
|
||||
|
||||
if (response.data['success'] == true) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(response.data['message'].toString())));
|
||||
|
||||
|
||||
if (inventoryId!=null ) {
|
||||
_apiClient.put(ApiUrls.updateTaskInventoryUrl+inventoryId!,data:null).then((value) {
|
||||
debugPrint('Task Updated');
|
||||
if (value.statusCode == 200) {
|
||||
Navigator.push(
|
||||
context,
|
||||
navigatorKey.currentContext!,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const DataSubmitSuccessFullScreen()));
|
||||
}
|
||||
else{
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
const SnackBar(content: Text('Task not updated')),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
Navigator.push(
|
||||
navigatorKey.currentContext!,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const DataSubmitSuccessFullScreen()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(response.data['message'].toString())));
|
||||
}
|
||||
} else {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
@ -286,4 +315,10 @@ class CollectKycProvider extends ChangeNotifier {
|
||||
selectedTask = s;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
String? inventoryId;
|
||||
void setId(String id) {
|
||||
inventoryId = id;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class ProductProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> submitProducts(
|
||||
{required String distributorType, required String pdRdId}) async {
|
||||
{required String distributorType, required String pdRdId, String? inventoryId}) async {
|
||||
setLoading(true);
|
||||
try {
|
||||
Response response = await _apiClient.post(ApiUrls.submitProductUrl,
|
||||
@ -72,12 +72,33 @@ class ProductProvider extends ChangeNotifier {
|
||||
).showSnackBar(
|
||||
SnackBar(content: Text(response.data['message'])),
|
||||
);
|
||||
if (inventoryId!=null ) {
|
||||
_apiClient.put(ApiUrls.updateTaskInventoryUrl+inventoryId,data:null).then((value) {
|
||||
debugPrint('Task Updated');
|
||||
if (value.statusCode == 200) {
|
||||
resetProducts();
|
||||
Navigator.push(
|
||||
navigatorKey.currentContext!,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const DataSubmitSuccessFullScreen()));
|
||||
}
|
||||
else{
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
const SnackBar(content: Text('Task not updated')),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
else{
|
||||
resetProducts();
|
||||
Navigator.push(
|
||||
navigatorKey.currentContext!,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const DataSubmitSuccessFullScreen()));
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
debugPrint("Error: $e");
|
||||
|
33
lib/provider/visit_pdrd_provider.dart
Normal file
33
lib/provider/visit_pdrd_provider.dart
Normal file
@ -0,0 +1,33 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../constants/constant.dart';
|
||||
import '../screens/data_submit_successfull.dart';
|
||||
import '../services/api_client.dart';
|
||||
import '../services/api_urls.dart';
|
||||
|
||||
class VisitPdRdProvider with ChangeNotifier {
|
||||
final _apiClient = ApiClient();
|
||||
bool _isLoading = false;
|
||||
void setLoading(bool loading) {
|
||||
_isLoading = loading;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> submitVisitPdRd(String id) async {
|
||||
setLoading(true);
|
||||
try {
|
||||
Response response = await _apiClient.put(ApiUrls.updateTaskInventoryUrl+id);
|
||||
debugPrint('Response: $response');
|
||||
setLoading(false);
|
||||
if (response.statusCode == 200) {
|
||||
Navigator.push(
|
||||
navigatorKey.currentContext!,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const DataSubmitSuccessFullScreen()));
|
||||
}
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
debugPrint("Error: $e");
|
||||
}
|
||||
}
|
||||
}
|
@ -12,12 +12,13 @@ class AddProductsScreen extends StatefulWidget {
|
||||
final String distributorType;
|
||||
final String tradeName;
|
||||
final String pdRdId;
|
||||
final String? inventoryId;
|
||||
|
||||
const AddProductsScreen({
|
||||
super.key,
|
||||
required this.distributorType,
|
||||
required this.tradeName,
|
||||
required this.pdRdId
|
||||
required this.pdRdId, this.inventoryId
|
||||
});
|
||||
|
||||
@override
|
||||
@ -177,7 +178,7 @@ class _AddProductsScreenState extends State<AddProductsScreen> {
|
||||
product.inventory != null)) {
|
||||
value.submitProducts(
|
||||
distributorType: widget.distributorType,
|
||||
pdRdId: widget.pdRdId
|
||||
pdRdId: widget.pdRdId, inventoryId: widget.inventoryId!
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
|
@ -1,175 +0,0 @@
|
||||
import 'package:cheminova/widgets/common_drawer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cheminova/widgets/common_background.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../widgets/common_app_bar.dart';
|
||||
import '../widgets/common_elevated_button.dart';
|
||||
import '../widgets/common_text_form_field.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class VisitDealersScreen extends StatefulWidget {
|
||||
const VisitDealersScreen({super.key});
|
||||
|
||||
@override
|
||||
State<VisitDealersScreen> createState() => VisitDealersScreenState();
|
||||
}
|
||||
|
||||
class VisitDealersScreenState extends State<VisitDealersScreen> {
|
||||
final dateController = TextEditingController(
|
||||
text: DateFormat('dd/MM/yyyy').format(DateTime.now()));
|
||||
|
||||
final timeController =
|
||||
TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now()));
|
||||
|
||||
final notesController = TextEditingController();
|
||||
final dealerController = TextEditingController();
|
||||
final meetingSummaryController = TextEditingController();
|
||||
final followUpActionsController = TextEditingController();
|
||||
final nextVisitDateController = TextEditingController();
|
||||
|
||||
String selectedPurpose = 'Sales';
|
||||
List<String> purposeOptions = ['Sales', 'Dues collection', 'Others'];
|
||||
|
||||
Future<void> _pickImage() async {
|
||||
final ImagePicker picker = ImagePicker();
|
||||
await picker.pickImage(source: ImageSource.camera);
|
||||
// Handle the picked image
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CommonBackground(
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: CommonAppBar(
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Image.asset('assets/Back_attendance.png'),
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
),
|
||||
],
|
||||
title: const Text('Visit Retailers',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontFamily: 'Anek')),
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
),
|
||||
drawer: const CommonDrawer(),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: SingleChildScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const SizedBox(height: 16),
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.all(20.0).copyWith(top: 30, bottom: 30),
|
||||
// margin: const EdgeInsets.symmetric(horizontal: 30.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.white),
|
||||
color: const Color(0xffB4D1E5).withOpacity(0.9),
|
||||
borderRadius: BorderRadius.circular(26.0)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
CommonTextFormField(
|
||||
title: 'Select Retailer',
|
||||
fillColor: Colors.white,
|
||||
controller: dealerController),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
title: 'Visit date',
|
||||
readOnly: true,
|
||||
fillColor: Colors.white,
|
||||
controller: dateController),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
title: 'Time',
|
||||
readOnly: true,
|
||||
fillColor: Colors.white,
|
||||
controller: timeController),
|
||||
const SizedBox(height: 15),
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Purpose of visit',
|
||||
fillColor: Colors.white,
|
||||
filled: true,
|
||||
),
|
||||
value: selectedPurpose,
|
||||
items: purposeOptions.map((String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (String? newValue) {
|
||||
setState(() {
|
||||
selectedPurpose = newValue!;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
title: 'Meeting Summary:',
|
||||
fillColor: Colors.white,
|
||||
maxLines: 4,
|
||||
controller: meetingSummaryController),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
title: 'Follow-up Actions:',
|
||||
fillColor: Colors.white,
|
||||
maxLines: 4,
|
||||
controller: followUpActionsController),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
title: 'Next visit date:',
|
||||
readOnly: true,
|
||||
fillColor: Colors.white,
|
||||
controller: nextVisitDateController),
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: CommonTextFormField(
|
||||
title: 'Attach Documents/Photos',
|
||||
fillColor: Colors.white,
|
||||
controller: notesController),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.camera_alt),
|
||||
onPressed: _pickImage,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
child: CommonElevatedButton(
|
||||
borderRadius: 30,
|
||||
width: double.infinity,
|
||||
height: kToolbarHeight - 10,
|
||||
text: 'SUBMIT',
|
||||
backgroundColor: const Color(0xff004791),
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ class CollectKycScreenState extends State<CollectKycScreen>
|
||||
@override
|
||||
void initState() {
|
||||
collectKycProvider = CollectKycProvider();
|
||||
collectKycProvider.setId(widget.id);
|
||||
collectKycProvider.tabController = TabController(length: 3, vsync: this);
|
||||
super.initState();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:cheminova/models/Daily_Task_Response.dart';
|
||||
import 'package:cheminova/screens/Add_products_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cheminova/screens/visit_dealers_screen.dart';
|
||||
import 'package:cheminova/screens/visit_rd_pd_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';
|
||||
@ -158,20 +158,6 @@ class _DailyTasksScreenState extends State<DailyTasksScreen> {
|
||||
}
|
||||
|
||||
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 Consumer<DailyTaskProvider>(
|
||||
builder: (context, value, child) => value.isLoading
|
||||
@ -218,17 +204,19 @@ class _DailyTasksScreenState extends State<DailyTasksScreen> {
|
||||
builder: (context) => AddProductsScreen(
|
||||
distributorType: tasksList.addedFor!,
|
||||
tradeName: tasksList.tradeName ?? '',
|
||||
pdRdId: tasksList.sId!)));
|
||||
pdRdId: tasksList.sId!, inventoryId:tasksList.sId!)));
|
||||
} else if (tasksList.task == 'Update Sales Data') {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const DisplaySalesScreen()));
|
||||
} else if (tasksList.task == 'Visit Dealers/Retailers') {
|
||||
} else if (tasksList.task == 'Visit RD/PD') {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const VisitDealersScreen()));
|
||||
builder: (context) => VisitDealersScreen(
|
||||
tradeName: tasksList.tradeName??'',id: tasksList.sId!,
|
||||
)));
|
||||
}
|
||||
},
|
||||
child: Card(
|
||||
@ -252,14 +240,15 @@ class _DailyTasksScreenState extends State<DailyTasksScreen> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (tasksList.task?.toLowerCase() == 'collect kyc')
|
||||
Text('Note: ${tasksList.note}')
|
||||
else if (tasksList.task?.toLowerCase() ==
|
||||
'update inventory data')
|
||||
if (tasksList.note != null)
|
||||
Text('Note: ${tasksList.note}'),
|
||||
if(tasksList.addedFor != null)
|
||||
Text('Distributor: ${tasksList.addedFor ?? ""}'),
|
||||
if(tasksList.tradeName != null) Text('Trade Name: ${tasksList.tradeName ?? ""}'),
|
||||
if(tasksList.taskDueDate != null) Text('Due Date: ${DateFormat('dd/MM/yyyy').format(DateTime.parse(tasksList.taskDueDate!))}'),
|
||||
Text('Priority: ${tasksList.taskPriority}'),
|
||||
if(
|
||||
tasksList.taskPriority != null
|
||||
)Text('Priority: ${tasksList.taskPriority}'),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -268,57 +257,5 @@ class _DailyTasksScreenState extends State<DailyTasksScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'package:cheminova/notification_services.dart';
|
||||
import 'package:cheminova/provider/home_provider.dart';
|
||||
import 'package:cheminova/screens/Update_inventorytask_screen.dart';
|
||||
import 'package:cheminova/screens/profile_screen.dart';
|
||||
import 'package:cheminova/screens/rejected_application_screen.dart';
|
||||
import 'package:cheminova/screens/calendar_screen.dart';
|
||||
import 'package:cheminova/screens/collect_kyc_screen.dart';
|
||||
|
101
lib/screens/profile_screen.dart
Normal file
101
lib/screens/profile_screen.dart
Normal file
@ -0,0 +1,101 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:cheminova/widgets/common_app_bar.dart';
|
||||
import 'package:cheminova/widgets/common_background.dart';
|
||||
import 'package:cheminova/widgets/common_drawer.dart';
|
||||
|
||||
class ProfileScreen extends StatelessWidget {
|
||||
const ProfileScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
children: [
|
||||
CommonBackground(
|
||||
isFullWidth: true,
|
||||
child: Scaffold(
|
||||
drawer: const CommonDrawer(),
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: CommonAppBar(
|
||||
title: const Text('Profile'),
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Image.asset('assets/Back_attendance.png'),
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(20.0).copyWith(top: 15, bottom: 30),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 30.0, vertical: 20.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.white),
|
||||
color: const Color(0xffB4D1E5).withOpacity(0.9),
|
||||
borderRadius: BorderRadius.circular(26.0),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// const Text(
|
||||
// 'User Profile',
|
||||
// style: TextStyle(
|
||||
// fontSize: 30,
|
||||
// color: Colors.black,
|
||||
// fontWeight: FontWeight.w500,
|
||||
// fontFamily: 'Roboto',
|
||||
// ),
|
||||
// ),
|
||||
const SizedBox(height: 20),
|
||||
_buildProfileItem('Name', 'Vaibhav Gurjar'),
|
||||
_buildProfileItem('ID', 'EMP001'),
|
||||
_buildProfileItem('Designation', 'Sales Cordinator'),
|
||||
_buildProfileItem('Email ID', 'vaibhav.gurjar20001@gmail.com'),
|
||||
_buildProfileItem('Mobile Number', '8839033630'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProfileItem(String label, String value) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Color(0xff004791),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 5),
|
||||
Text(
|
||||
value,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
const Divider(color: Colors.grey),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
206
lib/screens/visit_rd_pd_screen.dart
Normal file
206
lib/screens/visit_rd_pd_screen.dart
Normal file
@ -0,0 +1,206 @@
|
||||
import 'package:cheminova/provider/visit_pdrd_provider.dart';
|
||||
import 'package:cheminova/widgets/common_drawer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cheminova/widgets/common_background.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../widgets/common_app_bar.dart';
|
||||
import '../widgets/common_elevated_button.dart';
|
||||
import '../widgets/common_text_form_field.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class VisitDealersScreen extends StatefulWidget {
|
||||
final String? tradeName;
|
||||
final String? id;
|
||||
const VisitDealersScreen({super.key, required this.tradeName, this.id});
|
||||
|
||||
@override
|
||||
State<VisitDealersScreen> createState() => VisitDealersScreenState();
|
||||
}
|
||||
|
||||
class VisitDealersScreenState extends State<VisitDealersScreen> {
|
||||
late VisitPdRdProvider _visitPdRdProvider;
|
||||
final dateController = TextEditingController(
|
||||
text: DateFormat('dd/MM/yyyy').format(DateTime.now()));
|
||||
|
||||
final timeController =
|
||||
TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now()));
|
||||
|
||||
final notesController = TextEditingController();
|
||||
final dealerController = TextEditingController();
|
||||
final meetingSummaryController = TextEditingController();
|
||||
final followUpActionsController = TextEditingController();
|
||||
final nextVisitDateController = TextEditingController();
|
||||
late TextEditingController retailerController = TextEditingController();
|
||||
|
||||
String selectedPurpose = 'Sales';
|
||||
List<String> purposeOptions = ['Sales', 'Dues collection', 'Others'];
|
||||
|
||||
Future<void> _pickImage() async {
|
||||
final ImagePicker picker = ImagePicker();
|
||||
await picker.pickImage(source: ImageSource.camera);
|
||||
// Handle the picked image
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_visitPdRdProvider = VisitPdRdProvider();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
retailerController = TextEditingController(text: widget.tradeName);
|
||||
|
||||
return ChangeNotifierProvider(
|
||||
create: (context) => _visitPdRdProvider,
|
||||
child: CommonBackground(
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: CommonAppBar(
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Image.asset('assets/Back_attendance.png'),
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
),
|
||||
],
|
||||
title: Column(
|
||||
children: [
|
||||
const Text('Visit Retailers',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontFamily: 'Anek')),
|
||||
Text(widget.tradeName??'',
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontFamily: 'Anek')),
|
||||
],
|
||||
),
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
),
|
||||
drawer: const CommonDrawer(),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: SingleChildScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const SizedBox(height: 16),
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.all(20.0).copyWith(top: 30, bottom: 30),
|
||||
// margin: const EdgeInsets.symmetric(horizontal: 30.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.white),
|
||||
color: const Color(0xffB4D1E5).withOpacity(0.9),
|
||||
borderRadius: BorderRadius.circular(26.0)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
CommonTextFormField(
|
||||
readOnly: true,
|
||||
title: 'Select Retailer',
|
||||
fillColor: Colors.white,
|
||||
controller: retailerController),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
title: 'Visit date',
|
||||
readOnly: true,
|
||||
fillColor: Colors.white,
|
||||
controller: dateController),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
title: 'Time',
|
||||
readOnly: true,
|
||||
fillColor: Colors.white,
|
||||
controller: timeController),
|
||||
const SizedBox(height: 15),
|
||||
DropdownButtonFormField<String>(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Purpose of visit',
|
||||
fillColor: Colors.white,
|
||||
filled: true,
|
||||
),
|
||||
value: selectedPurpose,
|
||||
items: purposeOptions.map((String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (String? newValue) {
|
||||
setState(() {
|
||||
selectedPurpose = newValue!;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
title: 'Meeting Summary:',
|
||||
fillColor: Colors.white,
|
||||
maxLines: 4,
|
||||
controller: meetingSummaryController),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
title: 'Follow-up Actions:',
|
||||
fillColor: Colors.white,
|
||||
maxLines: 4,
|
||||
controller: followUpActionsController),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
title: 'Next visit date:',
|
||||
readOnly: true,
|
||||
fillColor: Colors.white,
|
||||
controller: nextVisitDateController),
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: CommonTextFormField(
|
||||
title: 'Attach Documents/Photos',
|
||||
fillColor: Colors.white,
|
||||
controller: notesController),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.camera_alt),
|
||||
onPressed: _pickImage,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
Consumer<VisitPdRdProvider>(builder: (context, value, child) => Align(
|
||||
alignment: Alignment.center,
|
||||
child: CommonElevatedButton(
|
||||
borderRadius: 30,
|
||||
width: double.infinity,
|
||||
height: kToolbarHeight - 10,
|
||||
text: 'SUBMIT',
|
||||
backgroundColor: const Color(0xff004791),
|
||||
onPressed: () {
|
||||
value.submitVisitPdRd(widget.id ?? '');
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -19,4 +19,5 @@ class ApiUrls {
|
||||
static const String selectTaskUrl = '${baseUrl}task/tasks';
|
||||
static const String dailyTaskUrl = '${baseUrl}task/tasks/';
|
||||
static const String kycSelectTaskUrl = '${baseUrl}task/task/type/Collect KYC';
|
||||
static const String updateTaskInventoryUrl = '${baseUrl}task/update-task-status/';
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ import 'package:cheminova/provider/home_provider.dart';
|
||||
import 'package:cheminova/screens/change_password_screen.dart';
|
||||
import 'package:cheminova/screens/home_screen.dart';
|
||||
import 'package:cheminova/screens/login_screen.dart';
|
||||
import 'package:cheminova/screens/profile_screen.dart';
|
||||
import 'package:cheminova/services/secure__storage_service.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@ -45,13 +46,17 @@ class CommonDrawer extends StatelessWidget {
|
||||
title: const Text('Home'),
|
||||
onTap: () => Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) => const HomePage()))),
|
||||
// ListTile(
|
||||
// leading: const Icon(Icons.account_circle),
|
||||
// title: const Text('Profile'),
|
||||
// onTap: () {
|
||||
// Navigator.pop(context);
|
||||
// },
|
||||
// ),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.person),
|
||||
title: const Text('Profile'),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ProfileScreen(),
|
||||
));
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.settings),
|
||||
title: const Text('Change Password'),
|
||||
|
Loading…
Reference in New Issue
Block a user