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, "date": date,
"time": time, "time": time,
"reason": reason, "reason": reason,
"leaveType":leaveType, "leaveType":'$leaveType Leave',
}); });
setLoading(false); setLoading(false);
if (response.statusCode == 200) { if (response.statusCode == 200) {

View File

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

View File

@ -15,12 +15,13 @@ class AddSalesProductScreen extends StatefulWidget {
final String pdRdId; final String pdRdId;
final String? inventoryId; final String? inventoryId;
const AddSalesProductScreen( const AddSalesProductScreen({
{super.key, super.key,
required this.distributorType, required this.distributorType,
required this.tradeName, required this.tradeName,
required this.pdRdId, required this.pdRdId,
this.inventoryId}); this.inventoryId,
});
@override @override
State<AddSalesProductScreen> createState() => _AddSalesProductScreenState(); State<AddSalesProductScreen> createState() => _AddSalesProductScreenState();
@ -34,250 +35,240 @@ class _AddSalesProductScreenState extends State<AddSalesProductScreen> {
@override @override
void initState() { void initState() {
super.initState();
salesTaskProvider = Provider.of<AddSalesProvider>(context, listen: false); 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(); salesTaskProvider.getTask();
}); });
super.initState();
} }
@override @override
void dispose() { void dispose() {
searchController.dispose();
dateController.dispose();
if (mounted) { if (mounted) {
salesTaskProvider.resetProducts(); salesTaskProvider.resetProducts();
} }
super.dispose(); 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return PopScope( return PopScope(
canPop: true, canPop: true,
child: CommonBackground( child: CommonBackground(
child: Scaffold( child: Scaffold(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
appBar: CommonAppBar( appBar: CommonAppBar(
actions: [ actions: [
IconButton( IconButton(
onPressed: () => Navigator.pop(context), onPressed: () => Navigator.pop(context),
icon: Image.asset('assets/Back_attendance.png'), icon: Image.asset('assets/Back_attendance.png'),
padding: const EdgeInsets.only(right: 20)) padding: const EdgeInsets.only(right: 20),
], )
title: Text('${widget.distributorType}\n${widget.tradeName}', ],
textAlign: TextAlign.center, title: Text(
style: const TextStyle( '${widget.distributorType}\n${widget.tradeName}',
fontSize: 20, textAlign: TextAlign.center,
color: Colors.black, style: const TextStyle(
fontWeight: FontWeight.w400, fontSize: 20,
fontFamily: 'Anek')), color: Colors.black,
backgroundColor: Colors.transparent, fontWeight: FontWeight.w400,
elevation: 0), fontFamily: 'Anek',
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.')),
);
}
}
}))
]
]))),
],
),
), ),
body: ),
Consumer<AddSalesProvider>(builder: (context, value, child) { backgroundColor: Colors.transparent,
return Stack(children: [ elevation: 0,
Column(children: [ ),
GestureDetector( drawer: const CommonDrawer(),
onTap: () => datePicker(), bottomNavigationBar: Consumer<AddSalesProvider>(
child: AbsorbPointer( builder: (context, value, child) => Column(
child: Padding( mainAxisSize: MainAxisSize.min,
padding: const EdgeInsets.all(8.0), children: [
child: Form( Align(
key: formKey, alignment: value.tasksList.isEmpty
child: TextFormField( ? Alignment.center
controller: dateController, : Alignment.bottomCenter,
validator: (value) { child: Padding(
if (value!.isEmpty) { padding: const EdgeInsets.all(16.0),
return 'Please select a date'; child: Column(
} mainAxisSize: MainAxisSize.min,
return null; children: [
}, FloatingActionButton.extended(
decoration: const InputDecoration( onPressed: () => _showProductSelectionBottomSheet(context),
labelText: 'Date', backgroundColor: Colors.white,
fillColor: Colors.white, icon: const Icon(Icons.add, color: Colors.black),
filled: true, label: const Text('Add Products', style: TextStyle(color: Colors.black)),
border: InputBorder.none, ),
suffixIcon: Icon(Icons.calendar_today), 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)
if (value.selectedProducts.isNotEmpty) Expanded(
Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: value.selectedProducts.length, itemCount: value.selectedProducts.length,
itemBuilder: (context, index) { itemBuilder: (context, index) {
return ProductBlock( return ProductBlock(
onUpdate: (updatedProduct) { onUpdate: (updatedProduct) {
setState(() { setState(() {
value.selectedProducts[index] = value.selectedProducts[index] = updatedProduct;
updatedProduct; });
}); },
}, onRemove: () {
onRemove: () { setState(() {
setState(() { value.selectedProducts.removeAt(index);
value.selectedProducts.removeAt(index); });
}); },
}, product: value.selectedProducts[index],
product: value.selectedProducts[index]); );
})) },
]), ),
(value.isLoading) ),
? Container( ],
color: Colors.black12, ),
child: if (value.isLoading)
const Center(child: CircularProgressIndicator())) Container(
: const SizedBox() 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 { class ProductBlock extends StatefulWidget {
final SalesProduct product; final SalesProduct product;
final ValueChanged<SalesProduct> onUpdate; final ValueChanged<SalesProduct> onUpdate;
@ -304,9 +295,8 @@ class _ProductBlockState extends State<ProductBlock> {
void initState() { void initState() {
super.initState(); super.initState();
saleAmountController.text = (widget.product.SalesAmount ?? '').toString(); saleAmountController.text = (widget.product.SalesAmount ?? '').toString();
commentController.text = (widget.product.comments?? '').toString(); commentController.text = (widget.product.comments ?? '').toString();
quantitySoldController.text = quantitySoldController.text = (widget.product.QuantitySold ?? '').toString();
(widget.product.QuantitySold ?? '').toString();
} }
void validateInput() { void validateInput() {
@ -326,7 +316,7 @@ class _ProductBlockState extends State<ProductBlock> {
if (quantitySoldError == null && salesAmountError == null) { if (quantitySoldError == null && salesAmountError == null) {
int quantitySold = int.parse(quantitySoldController.text); int quantitySold = int.parse(quantitySoldController.text);
int salesAmount = int.parse(saleAmountController.text); int salesAmount = int.parse(saleAmountController.text);
String comments =commentController.text; String comments = commentController.text;
widget.onUpdate(SalesProduct( widget.onUpdate(SalesProduct(
SKU: widget.product.SKU, SKU: widget.product.SKU,
@ -344,80 +334,86 @@ class _ProductBlockState extends State<ProductBlock> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Card( return Card(
color: Colors.white, color: Colors.white,
margin: const EdgeInsets.all(8), margin: const EdgeInsets.all(8),
child: Stack(children: [ child: Stack(
children: [
Padding( Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: child: Column(
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ crossAxisAlignment: CrossAxisAlignment.start,
Text('Product: ${widget.product.ProductName}', children: [
style: const TextStyle(fontSize: 16)), Text('Product: ${widget.product.ProductName}',
Text('SKU: ${widget.product.SKU}', style: const TextStyle(fontSize: 16)),
style: const TextStyle(fontSize: 15)), Text('SKU: ${widget.product.SKU}',
const SizedBox(height: 8), style: const TextStyle(fontSize: 15)),
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 8),
TextField( Column(
controller: saleAmountController, crossAxisAlignment: CrossAxisAlignment.start,
onTapOutside: (event) => FocusScope.of(context).unfocus(), children: [
inputFormatters: [FilteringTextInputFormatter.digitsOnly], TextField(
decoration: InputDecoration( controller: saleAmountController,
onTapOutside: (event) => FocusScope.of(context).unfocus(),
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
decoration: InputDecoration(
labelText: 'Sales amount', labelText: 'Sales amount',
errorText: saleAmountController.text.isEmpty errorText: saleAmountController.text.isEmpty
? 'Sales amount cannot be empty.' ? 'Sales amount cannot be empty.'
: null), : null,
keyboardType: TextInputType.number, ),
enabled: true, keyboardType: TextInputType.number,
onChanged: (_) => validateInput()), enabled: true,
TextField( onChanged: (_) => validateInput(),
controller: quantitySoldController, ),
onTapOutside: (event) => FocusScope.of(context).unfocus(), TextField(
inputFormatters: [FilteringTextInputFormatter.digitsOnly], controller: quantitySoldController,
decoration: InputDecoration( onTapOutside: (event) => FocusScope.of(context).unfocus(),
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
decoration: InputDecoration(
labelText: 'Quantity sold', labelText: 'Quantity sold',
errorText: quantitySoldController.text.isEmpty errorText: quantitySoldController.text.isEmpty
? 'Quantity sold cannot be empty.' ? 'Quantity sold cannot be empty.'
: null), : null,
keyboardType: TextInputType.number, ),
enabled: true, keyboardType: TextInputType.number,
onChanged: (_) => validateInput()), enabled: true,
TextField( onChanged: (_) => validateInput(),
controller: commentController, ),
onTapOutside: (event) => FocusScope.of(context).unfocus(), TextField(
decoration: const InputDecoration( controller: commentController,
labelText: 'Comments',), onTapOutside: (event) => FocusScope.of(context).unfocus(),
enabled: true, decoration: const InputDecoration(
onChanged: (_) => validateInput()) labelText: 'Comments',
]), ),
]), enabled: true,
onChanged: (_) => validateInput(),
),
],
),
],
),
), ),
Positioned( Positioned(
top: 0, top: 0,
right: 0, right: 0,
child: IconButton( child: IconButton(
icon: const Icon( icon: const Icon(
Icons.delete_outlined, Icons.delete_outlined,
color: Colors.red, color: Colors.red,
), ),
onPressed: widget.onRemove)), onPressed: widget.onRemove,
])); ),
),
],
),
);
} }
}
class ProductModel { @override
final String sku; void dispose() {
final String productName; saleAmountController.dispose();
final int? sale; quantitySoldController.dispose();
final int? inventory; commentController.dispose();
final String? comments; super.dispose();
final String? date; }
}
ProductModel({
required this.sku,
required this.productName,
this.sale,
this.inventory,
this.comments,
this.date,
});
}

View File

@ -1,4 +1,3 @@
import 'package:cheminova/provider/markleave_provider.dart';
import 'package:cheminova/screens/Attendance_success.dart'; import 'package:cheminova/screens/Attendance_success.dart';
import 'package:cheminova/widgets/common_drawer.dart'; import 'package:cheminova/widgets/common_drawer.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -7,6 +6,7 @@ import 'package:geocoding/geocoding.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../provider/markleave_provider.dart';
import '../widgets/common_app_bar.dart'; import '../widgets/common_app_bar.dart';
import '../widgets/common_elevated_button.dart'; import '../widgets/common_elevated_button.dart';
import '../widgets/common_text_form_field.dart'; import '../widgets/common_text_form_field.dart';
@ -22,10 +22,10 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
late MarkLeaveProvider _markLeaveProvider; late MarkLeaveProvider _markLeaveProvider;
final dateController = TextEditingController( final dateController = TextEditingController(
text: DateFormat('dd/MM/yyyy').format(DateTime.now())); text: DateFormat('yyyy/MM/dd').format(DateTime.now()));
final timeController = final timeController =
TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now())); TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now()));
final locationController = TextEditingController(); final locationController = TextEditingController();
final notesController = TextEditingController(); final notesController = TextEditingController();
@ -43,7 +43,8 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
return GestureDetector( return GestureDetector(
onTap: () => onLeaveTypeSelected(leaveType), onTap: () => onLeaveTypeSelected(leaveType),
child: Container(margin: const EdgeInsets.only(bottom: 10), child: Container(
margin: const EdgeInsets.only(bottom: 10),
width: 120, width: 120,
padding: const EdgeInsets.symmetric(vertical: 5.0), padding: const EdgeInsets.symmetric(vertical: 5.0),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -62,6 +63,7 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
), ),
); );
} }
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -92,8 +94,8 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
debugPrint('position--- $position'); debugPrint('position--- $position');
List<Placemark> placeMarks = List<Placemark> placeMarks =
await placemarkFromCoordinates(position.latitude, position.longitude) await placemarkFromCoordinates(position.latitude, position.longitude)
.timeout(const Duration(seconds: 10)); .timeout(const Duration(seconds: 10));
debugPrint('place mark--- $placeMarks'); debugPrint('place mark--- $placeMarks');
Placemark place = placeMarks[0]; Placemark place = placeMarks[0];
@ -105,129 +107,139 @@ class _OnLeaveScreenState extends State<OnLeaveScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ChangeNotifierProvider<MarkLeaveProvider>( return ChangeNotifierProvider<MarkLeaveProvider>(
create: (_) => _markLeaveProvider, create: (_) => _markLeaveProvider,
builder: (context, child) => builder: (context, child) => CommonBackground(
CommonBackground( child: Scaffold(
child: Scaffold(backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
appBar: CommonAppBar( appBar: CommonAppBar(
actions: [ actions: [
IconButton( IconButton(
onPressed: () onPressed: () {
{ Navigator.pop(context);
Navigator.pop(context); },
}, icon: Image.asset('assets/Back_attendance.png'),
icon: Image.asset('assets/Back_attendance.png'), padding: const EdgeInsets.only(right: 20), 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(),));
}),
)
),
],
),
), ),
], ],
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( CommonTextFormField(
title: 'Meeting Summary:', title: 'Meeting Summary:',
fillColor: Colors.white, fillColor: Colors.white,
maxLines: 4, maxLines: 3,
controller: meetingSummaryController), controller: meetingSummaryController),
const SizedBox(height: 15), const SizedBox(height: 15),
CommonTextFormField( CommonTextFormField(
title: 'Follow-up Actions:', title: 'Follow-up Actions:',
fillColor: Colors.white, fillColor: Colors.white,
maxLines: 4, maxLines: 3,
controller: followUpActionsController), controller: followUpActionsController),
const SizedBox(height: 15), const SizedBox(height: 15),
CommonTextFormField( CommonTextFormField(

View File

@ -21,6 +21,6 @@ class ApiUrls {
static const String kycSelectTaskUrl = '${baseUrl}task/task/type/Collect KYC'; static const String kycSelectTaskUrl = '${baseUrl}task/task/type/Collect KYC';
static const String updateTaskInventoryUrl = '${baseUrl}task/update-task-status/'; static const String updateTaskInventoryUrl = '${baseUrl}task/update-task-status/';
static const String getProductsManual = '${baseUrl}productmanual/getall'; 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'; static const String postSalesTaskUrl = '${baseUrl}sales/add-SC';
} }