change base Url

This commit is contained in:
Vaibhav 2024-09-11 18:32:52 +05:30
parent 67ed0ce21c
commit 11b3b130d9
6 changed files with 436 additions and 425 deletions

View File

@ -64,7 +64,7 @@ class MarkLeaveProvider extends ChangeNotifier{
"date": date,
"time": time,
"reason": reason,
"leaveType":leaveType,
"leaveType":'$leaveType Leave',
});
setLoading(false);
if (response.statusCode == 200) {

View File

@ -12,7 +12,7 @@ class SelectTaskProvider extends ChangeNotifier {
}
final _apiClient = ApiClient();
List<Tasks> tasksList=[];
List<Tasks> tasksList = [];
bool _isLoading = false;
@ -30,7 +30,10 @@ class SelectTaskProvider extends ChangeNotifier {
setLoading(false);
if (response.statusCode == 200) {
final data = SelectTaskKycResponse.fromJson(response.data);
tasksList = data.tasks ?? [];
tasksList = data!.tasks!
.where(
(element) => element.taskStatus!.toLowerCase() != "completed")
.toList();
notifyListeners();
}
} catch (e) {

View File

@ -15,12 +15,13 @@ class AddSalesProductScreen extends StatefulWidget {
final String pdRdId;
final String? inventoryId;
const AddSalesProductScreen(
{super.key,
required this.distributorType,
required this.tradeName,
required this.pdRdId,
this.inventoryId});
const AddSalesProductScreen({
super.key,
required this.distributorType,
required this.tradeName,
required this.pdRdId,
this.inventoryId,
});
@override
State<AddSalesProductScreen> createState() => _AddSalesProductScreenState();
@ -34,250 +35,240 @@ class _AddSalesProductScreenState extends State<AddSalesProductScreen> {
@override
void initState() {
super.initState();
salesTaskProvider = Provider.of<AddSalesProvider>(context, listen: false);
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
dateController.text = DateFormat('dd/MM/yyyy').format(DateTime.now());
WidgetsBinding.instance.addPostFrameCallback((_) {
salesTaskProvider.getTask();
});
super.initState();
}
@override
void dispose() {
searchController.dispose();
dateController.dispose();
if (mounted) {
salesTaskProvider.resetProducts();
}
super.dispose();
}
datePicker() async {
final DateTime? picked = await showDatePicker(
context: context,
initialDate: DateTime.now(),
firstDate: DateTime(2000),
lastDate: DateTime(2101),
);
if (picked != null) {
setState(
() => dateController.text = DateFormat('dd/MM/yyyy').format(picked));
}
}
@override
Widget build(BuildContext context) {
return PopScope(
canPop: true,
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: Text('${widget.distributorType}\n${widget.tradeName}',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 20,
color: Colors.black,
fontWeight: FontWeight.w400,
fontFamily: 'Anek')),
backgroundColor: Colors.transparent,
elevation: 0),
drawer: const CommonDrawer(),
bottomNavigationBar: Consumer<AddSalesProvider>(
builder: (context, value, child) => Column(
mainAxisSize: MainAxisSize.min,
children: [
Align(
alignment: value.tasksList.isEmpty
? Alignment.center
: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FloatingActionButton.extended(
onPressed: () {
showModalBottomSheet(
isScrollControlled: true,
constraints: BoxConstraints(
maxHeight: MediaQuery.of(context)
.size
.height *
0.9),
context: context,
builder: (BuildContext context) {
return Consumer<AddSalesProvider>(
builder:
(context, value, child) =>
StatefulBuilder(builder:
(context,
setState) {
return Column(
children: [
Padding(
padding:
const EdgeInsets
.all(
18.0),
child: TextField(
controller: searchController,
decoration: const InputDecoration(labelText: 'Search by name or SKU', border: OutlineInputBorder(), prefixIcon: Icon(Icons.search)),
onChanged: (val) {
value.filterProducts(
val);
setState(
() {});
})),
Expanded(
child: ListView
.builder(
itemCount: searchController.text.isEmpty
? value.tasksList.length
: value.searchList.length,
itemBuilder: (context, index) {
bool isAlreadySelected = value.selectedProducts.any((selectedProduct) => selectedProduct.SKU == value.tasksList[index].SKU);
final data = searchController.text.isEmpty ? value.tasksList[index] : value.searchList[index];
return Card(
child: ListTile(
title: Text(data.ProductName ?? '', style: TextStyle(color: isAlreadySelected ? Colors.grey : Colors.black)),
subtitle: Text(data.SKU ?? '', style: TextStyle(color: isAlreadySelected ? Colors.grey : Colors.black)),
onTap: isAlreadySelected
? null
: () {
setState(() => value.selectedProducts.add(data));
Navigator.pop(context);
}));
}))
]);
}));
},
).whenComplete(() => setState(() {}));
},
backgroundColor: Colors.white,
icon: const Icon(Icons.add,
color: Colors.black),
label: const Text('Add Products',
style:
TextStyle(color: Colors.black))),
if (value.selectedProducts.isNotEmpty) ...[
const SizedBox(height: 16.0),
Consumer<AddSalesProvider>(
builder: (context, value, child) =>
CommonElevatedButton(
borderRadius: 30,
width: double.infinity,
height: kToolbarHeight - 10,
text: 'SUBMIT',
backgroundColor:
const Color(0xff004791),
onPressed: () {
if (formKey.currentState!
.validate()) {
if (value.selectedProducts
.isNotEmpty &&
value.selectedProducts.every((product) =>
product.SKU!
.isNotEmpty &&
product.ProductName!
.isNotEmpty &&
product.SalesAmount !=
null &&
product.QuantitySold !=
null)) {
value.submitProducts(
distributorType: widget
.distributorType,
pdRdId: widget.pdRdId,
inventoryId:
widget.inventoryId,
date: dateController
.text
.trim(),
tradeName:
widget.tradeName);
} else {
ScaffoldMessenger.of(
context)
.showSnackBar(
const SnackBar(
content: Text(
'Please fill out all product details, including sale and inventory.')),
);
}
}
}))
]
]))),
],
),
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: Text(
'${widget.distributorType}\n${widget.tradeName}',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 20,
color: Colors.black,
fontWeight: FontWeight.w400,
fontFamily: 'Anek',
),
body:
Consumer<AddSalesProvider>(builder: (context, value, child) {
return Stack(children: [
Column(children: [
GestureDetector(
onTap: () => datePicker(),
child: AbsorbPointer(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Form(
key: formKey,
child: TextFormField(
controller: dateController,
validator: (value) {
if (value!.isEmpty) {
return 'Please select a date';
}
return null;
},
decoration: const InputDecoration(
labelText: 'Date',
fillColor: Colors.white,
filled: true,
border: InputBorder.none,
suffixIcon: Icon(Icons.calendar_today),
),
),
),
backgroundColor: Colors.transparent,
elevation: 0,
),
drawer: const CommonDrawer(),
bottomNavigationBar: Consumer<AddSalesProvider>(
builder: (context, value, child) => Column(
mainAxisSize: MainAxisSize.min,
children: [
Align(
alignment: value.tasksList.isEmpty
? Alignment.center
: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FloatingActionButton.extended(
onPressed: () => _showProductSelectionBottomSheet(context),
backgroundColor: Colors.white,
icon: const Icon(Icons.add, color: Colors.black),
label: const Text('Add Products', style: TextStyle(color: Colors.black)),
),
if (value.selectedProducts.isNotEmpty) ...[
const SizedBox(height: 16.0),
CommonElevatedButton(
borderRadius: 30,
width: double.infinity,
height: kToolbarHeight - 10,
text: 'SUBMIT',
backgroundColor: const Color(0xff004791),
onPressed: () => _submitProducts(value),
),
],
],
),
),
),
],
),
),
body: Consumer<AddSalesProvider>(
builder: (context, value, child) {
return Stack(
children: [
Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
controller: dateController,
readOnly: true,
decoration: const InputDecoration(
labelText: 'Date',
fillColor: Colors.white,
filled: true,
border: InputBorder.none,
suffixIcon: Icon(Icons.calendar_today),
),
),
),
),
if (value.selectedProducts.isNotEmpty)
Expanded(
if (value.selectedProducts.isNotEmpty)
Expanded(
child: ListView.builder(
itemCount: value.selectedProducts.length,
itemBuilder: (context, index) {
return ProductBlock(
onUpdate: (updatedProduct) {
setState(() {
value.selectedProducts[index] =
updatedProduct;
});
},
onRemove: () {
setState(() {
value.selectedProducts.removeAt(index);
});
},
product: value.selectedProducts[index]);
}))
]),
(value.isLoading)
? Container(
color: Colors.black12,
child:
const Center(child: CircularProgressIndicator()))
: const SizedBox()
]);
}))),
itemCount: value.selectedProducts.length,
itemBuilder: (context, index) {
return ProductBlock(
onUpdate: (updatedProduct) {
setState(() {
value.selectedProducts[index] = updatedProduct;
});
},
onRemove: () {
setState(() {
value.selectedProducts.removeAt(index);
});
},
product: value.selectedProducts[index],
);
},
),
),
],
),
if (value.isLoading)
Container(
color: Colors.black12,
child: const Center(child: CircularProgressIndicator()),
),
],
);
},
),
),
),
);
}
void _showProductSelectionBottomSheet(BuildContext context) {
showModalBottomSheet(
isScrollControlled: true,
context: context,
builder: (BuildContext context) {
return Consumer<AddSalesProvider>(
builder: (context, value, child) => StatefulBuilder(
builder: (context, setState) {
return Column(
children: [
Padding(
padding: const EdgeInsets.all(18.0),
child: TextField(
controller: searchController,
decoration: const InputDecoration(
labelText: 'Search by name or SKU',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.search),
),
onChanged: (val) {
value.filterProducts(val);
setState(() {});
},
),
),
Expanded(
child: ListView.builder(
itemCount: searchController.text.isEmpty
? value.tasksList.length
: value.searchList.length,
itemBuilder: (context, index) {
final data = searchController.text.isEmpty
? value.tasksList[index]
: value.searchList[index];
bool isAlreadySelected = value.selectedProducts
.any((selectedProduct) => selectedProduct.SKU == data.SKU);
return Card(
child: ListTile(
title: Text(
data.ProductName ?? '',
style: TextStyle(color: isAlreadySelected ? Colors.grey : Colors.black),
),
subtitle: Text(
data.SKU ?? '',
style: TextStyle(color: isAlreadySelected ? Colors.grey : Colors.black),
),
onTap: isAlreadySelected
? null
: () {
setState(() => value.selectedProducts.add(data));
Navigator.pop(context);
},
),
);
},
),
),
],
);
},
),
);
},
).whenComplete(() => setState(() {}));
}
void _submitProducts(AddSalesProvider value) {
if (formKey.currentState!.validate()) {
if (value.selectedProducts.isNotEmpty &&
value.selectedProducts.every((product) =>
product.SKU!.isNotEmpty &&
product.ProductName!.isNotEmpty &&
product.SalesAmount != null &&
product.QuantitySold != null)) {
value.submitProducts(
distributorType: widget.distributorType,
pdRdId: widget.pdRdId,
inventoryId: widget.inventoryId,
date: dateController.text.trim(),
tradeName: widget.tradeName,
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Please fill out all product details, including sale and inventory.'),
),
);
}
}
}
}
// The ProductBlock class remains unchanged
class ProductBlock extends StatefulWidget {
final SalesProduct product;
final ValueChanged<SalesProduct> onUpdate;
@ -304,9 +295,8 @@ class _ProductBlockState extends State<ProductBlock> {
void initState() {
super.initState();
saleAmountController.text = (widget.product.SalesAmount ?? '').toString();
commentController.text = (widget.product.comments?? '').toString();
quantitySoldController.text =
(widget.product.QuantitySold ?? '').toString();
commentController.text = (widget.product.comments ?? '').toString();
quantitySoldController.text = (widget.product.QuantitySold ?? '').toString();
}
void validateInput() {
@ -326,7 +316,7 @@ class _ProductBlockState extends State<ProductBlock> {
if (quantitySoldError == null && salesAmountError == null) {
int quantitySold = int.parse(quantitySoldController.text);
int salesAmount = int.parse(saleAmountController.text);
String comments =commentController.text;
String comments = commentController.text;
widget.onUpdate(SalesProduct(
SKU: widget.product.SKU,
@ -344,80 +334,86 @@ class _ProductBlockState extends State<ProductBlock> {
@override
Widget build(BuildContext context) {
return Card(
color: Colors.white,
margin: const EdgeInsets.all(8),
child: Stack(children: [
color: Colors.white,
margin: const EdgeInsets.all(8),
child: Stack(
children: [
Padding(
padding: const EdgeInsets.all(16),
child:
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text('Product: ${widget.product.ProductName}',
style: const TextStyle(fontSize: 16)),
Text('SKU: ${widget.product.SKU}',
style: const TextStyle(fontSize: 15)),
const SizedBox(height: 8),
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
TextField(
controller: saleAmountController,
onTapOutside: (event) => FocusScope.of(context).unfocus(),
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
decoration: InputDecoration(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Product: ${widget.product.ProductName}',
style: const TextStyle(fontSize: 16)),
Text('SKU: ${widget.product.SKU}',
style: const TextStyle(fontSize: 15)),
const SizedBox(height: 8),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextField(
controller: saleAmountController,
onTapOutside: (event) => FocusScope.of(context).unfocus(),
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
decoration: InputDecoration(
labelText: 'Sales amount',
errorText: saleAmountController.text.isEmpty
? 'Sales amount cannot be empty.'
: null),
keyboardType: TextInputType.number,
enabled: true,
onChanged: (_) => validateInput()),
TextField(
controller: quantitySoldController,
onTapOutside: (event) => FocusScope.of(context).unfocus(),
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
decoration: InputDecoration(
: null,
),
keyboardType: TextInputType.number,
enabled: true,
onChanged: (_) => validateInput(),
),
TextField(
controller: quantitySoldController,
onTapOutside: (event) => FocusScope.of(context).unfocus(),
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
decoration: InputDecoration(
labelText: 'Quantity sold',
errorText: quantitySoldController.text.isEmpty
? 'Quantity sold cannot be empty.'
: null),
keyboardType: TextInputType.number,
enabled: true,
onChanged: (_) => validateInput()),
TextField(
controller: commentController,
onTapOutside: (event) => FocusScope.of(context).unfocus(),
decoration: const InputDecoration(
labelText: 'Comments',),
enabled: true,
onChanged: (_) => validateInput())
]),
]),
: null,
),
keyboardType: TextInputType.number,
enabled: true,
onChanged: (_) => validateInput(),
),
TextField(
controller: commentController,
onTapOutside: (event) => FocusScope.of(context).unfocus(),
decoration: const InputDecoration(
labelText: 'Comments',
),
enabled: true,
onChanged: (_) => validateInput(),
),
],
),
],
),
),
Positioned(
top: 0,
right: 0,
child: IconButton(
icon: const Icon(
Icons.delete_outlined,
color: Colors.red,
),
onPressed: widget.onRemove)),
]));
top: 0,
right: 0,
child: IconButton(
icon: const Icon(
Icons.delete_outlined,
color: Colors.red,
),
onPressed: widget.onRemove,
),
),
],
),
);
}
}
class ProductModel {
final String sku;
final String productName;
final int? sale;
final int? inventory;
final String? comments;
final String? date;
ProductModel({
required this.sku,
required this.productName,
this.sale,
this.inventory,
this.comments,
this.date,
});
}
@override
void dispose() {
saleAmountController.dispose();
quantitySoldController.dispose();
commentController.dispose();
super.dispose();
}
}

View File

@ -1,4 +1,3 @@
import 'package:cheminova/provider/markleave_provider.dart';
import 'package:cheminova/screens/Attendance_success.dart';
import 'package:cheminova/widgets/common_drawer.dart';
import 'package:flutter/material.dart';
@ -7,6 +6,7 @@ import 'package:geocoding/geocoding.dart';
import 'package:geolocator/geolocator.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import '../provider/markleave_provider.dart';
import '../widgets/common_app_bar.dart';
import '../widgets/common_elevated_button.dart';
import '../widgets/common_text_form_field.dart';
@ -22,10 +22,10 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
late MarkLeaveProvider _markLeaveProvider;
final dateController = TextEditingController(
text: DateFormat('dd/MM/yyyy').format(DateTime.now()));
text: DateFormat('yyyy/MM/dd').format(DateTime.now()));
final timeController =
TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now()));
TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now()));
final locationController = TextEditingController();
final notesController = TextEditingController();
@ -43,7 +43,8 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
return GestureDetector(
onTap: () => onLeaveTypeSelected(leaveType),
child: Container(margin: const EdgeInsets.only(bottom: 10),
child: Container(
margin: const EdgeInsets.only(bottom: 10),
width: 120,
padding: const EdgeInsets.symmetric(vertical: 5.0),
decoration: BoxDecoration(
@ -62,6 +63,7 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
),
);
}
@override
void initState() {
super.initState();
@ -92,8 +94,8 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
debugPrint('position--- $position');
List<Placemark> placeMarks =
await placemarkFromCoordinates(position.latitude, position.longitude)
.timeout(const Duration(seconds: 10));
await placemarkFromCoordinates(position.latitude, position.longitude)
.timeout(const Duration(seconds: 10));
debugPrint('place mark--- $placeMarks');
Placemark place = placeMarks[0];
@ -105,129 +107,139 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<MarkLeaveProvider>(
create: (_) => _markLeaveProvider,
builder: (context, 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: const Text('On Leave',
style: TextStyle(
fontSize: 28,
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: '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),
const Text('Leave type',
style: TextStyle(
fontSize: 15,
color: Colors.black,
fontWeight: FontWeight.w400,
fontFamily: 'Anek')),
const SizedBox(height:3 ),
Wrap(direction: Axis.horizontal,
children: [
buildLeaveTypeOption('Sick'),
const SizedBox(width: 10),
buildLeaveTypeOption('Personal'),
const SizedBox(width: 10),
buildLeaveTypeOption('Privilege '),
],
),
const SizedBox(height: 15),
CommonTextFormField(
height: 100,
title: 'Reason',
fillColor: Colors.white,
maxLines: 4,
controller: notesController),
const SizedBox(height: 16),
Align(
alignment: Alignment.center,
child: Consumer<MarkLeaveProvider>(
builder: (context, value, child) =>CommonElevatedButton(
borderRadius: 30,
width: double.infinity,
height: kToolbarHeight - 10,
text: 'ON LEAVE',
backgroundColor: const Color(0xff00784C),
onPressed: () {
value
.markLeave(
dateController.text.trim(),
timeController.text.trim(),
locationController.text.trim(),
notesController.text.trim(), selectedLeaveType)
.then(
(result) {
var (status, message) = result;
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content: Text(message)));
if (status) {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) =>
const AttendanceSuccess()));
}
},
);
// Navigator.push(context, MaterialPageRoute(builder:(context) => const AttendanceSuccess(),));
}),
)
),
],
),
create: (_) => _markLeaveProvider,
builder: (context, 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: const Text('On Leave',
style: TextStyle(
fontSize: 28,
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: '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),
const Text('Leave type',
style: TextStyle(
fontSize: 15,
color: Colors.black,
fontWeight: FontWeight.w400,
fontFamily: 'Anek')),
const SizedBox(height: 3),
Wrap(
direction: Axis.horizontal,
children: [
buildLeaveTypeOption('Sick'),
const SizedBox(width: 10),
buildLeaveTypeOption('Personal'),
const SizedBox(width: 10),
buildLeaveTypeOption('Privilege '),
],
),
const SizedBox(height: 15),
CommonTextFormField(
height: 100,
title: 'Reason',
fillColor: Colors.white,
maxLines: 4,
controller: notesController),
const SizedBox(height: 16),
Align(
alignment: Alignment.center,
child: Consumer<MarkLeaveProvider>(
builder: (context, value, child) =>
CommonElevatedButton(
borderRadius: 30,
width: double.infinity,
height: kToolbarHeight - 10,
text: 'ON LEAVE',
backgroundColor:
const Color(0xff00784C),
onPressed: () {
value
.markLeave(
dateController.text
.trim(),
timeController.text
.trim(),
locationController.text
.trim(),
notesController.text
.trim(),
selectedLeaveType)
.then(
(result) {
var (status, message) =
result;
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content:
Text(message)));
if (status) {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) =>
const AttendanceSuccess()));
}
},
);
// Navigator.push(context, MaterialPageRoute(builder:(context) => const AttendanceSuccess(),));
}),
)),
],
),
),
],
),
),
),
),
),),
)
);
));
}
}
}

View File

@ -146,13 +146,13 @@ class VisitDealersScreenState extends State<VisitDealersScreen> {
CommonTextFormField(
title: 'Meeting Summary:',
fillColor: Colors.white,
maxLines: 4,
maxLines: 3,
controller: meetingSummaryController),
const SizedBox(height: 15),
CommonTextFormField(
title: 'Follow-up Actions:',
fillColor: Colors.white,
maxLines: 4,
maxLines: 3,
controller: followUpActionsController),
const SizedBox(height: 15),
CommonTextFormField(

View File

@ -21,6 +21,6 @@ class ApiUrls {
static const String kycSelectTaskUrl = '${baseUrl}task/task/type/Collect KYC';
static const String updateTaskInventoryUrl = '${baseUrl}task/update-task-status/';
static const String getProductsManual = '${baseUrl}productmanual/getall';
static const String salesTaskUrl = '${baseUrl}product/getAll/user/?category=Bottle';
static const String salesTaskUrl = '${baseUrl}product/getAll/user/';
static const String postSalesTaskUrl = '${baseUrl}sales/add-SC';
}