Commit de740138 authored by Sai Srinivas's avatar Sai Srinivas
Browse files

13-06-2025 By Sai Srinivas

Order Modules: Screens, Providers and Models
parent 75c5b679
......@@ -207,6 +207,20 @@ class Generatordetailsprovider extends ChangeNotifier {
_selectedDescriptionId = value;
}
void resetForm(){
_qrViewController!.dispose();
engNoController.clear();
_selectedComplaintType = null;
_selectedCategoryType= null;
_selectedDescriptionType= null;
_selectedType = "";
_selectedTypeId = "";
_selectedCategory = "";
_selectedCategoryId = "";
_selectedDescriptionId = "";
_selectedDescription = "";
}
initialFunction(from) async {
switch (from) {
case "Generator Details":
......
......@@ -82,6 +82,13 @@ set markers(List<Marker> value){
notifyListeners();
}
void resetAll(){
_currentValue = 1.0;
_selectedItem = "";
_markers= [];
_addresses = [];
}
Future<void> getLocationPermission(context) async {
// Check if location services are enabled
_isLocationEnabled = await Geolocator.isLocationServiceEnabled();
......
......@@ -20,6 +20,11 @@ class Paymentcollectionprovider extends ChangeNotifier {
List<AccountList> get accountList => _accountList;
bool get isLoading => _isLoading;
void resetAll(){
_accountList = [];
_paymentCollectionList = [];
}
Future<void> PaymentCollectionAPI(BuildContext context) async {
try {
var HomeProvider = Provider.of<HomescreenNotifier>(
......
......@@ -68,6 +68,12 @@ class Pendingcomplaintsprovider extends ChangeNotifier {
notifyListeners();
}
void resetAll(){
_submitLoading = false;
_statusId = "";
_image_picked = 0;
}
Future<void> TechnicianPendingComplaints(BuildContext context) async {
var HomeProvider = Provider.of<HomescreenNotifier>(context, listen: false);
try {
......
......@@ -57,4 +57,11 @@ class Accountdetailsprovider extends ChangeNotifier{
return grouped;
}
void resetValues(){
totalCredit = 0.0;
totalDebit = 0.0;
totalRunningBalance = 0.0;
runningBalances = [];
}
}
\ No newline at end of file
......@@ -294,4 +294,11 @@ class Paymentrequisitionpaymentslistprovider extends ChangeNotifier{
print('Error printing data: $e');
}
}
void resetForm() {
_paymentsList = [];
_paymentDetails = PaymentDetails();
_headings = [];
_subHeadings = [];
}
}
\ No newline at end of file
This diff is collapsed.
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:generp/Models/ordersModels/paymentListByModeFilterResponse.dart';
import 'package:generp/Models/ordersModels/paymentListByModeResponse.dart';
import 'package:provider/provider.dart';
import '../../Models/ordersModels/paymentDetailsByModeFilterResponse.dart';
import '../../Utils/commonServices.dart';
import '../../services/api_calling.dart';
import '../HomeScreenNotifier.dart';
class Paymentsprovider extends ChangeNotifier {
TextEditingController approvalRejectionController = TextEditingController();
String? approvalRejectionError;
List<Employees> _employeesList = [];
List<OrderList> _paymentsList = [];
Employees? _selectedEmployee;
String? _selectedEmpID;
String? _selectedEmpName;
bool _isLoading = true;
PaymentDetails _paymentsDetails = PaymentDetails();
List<PaidList> _paidLists = [];
List<String> _headings = [];
List<String> _subHeadings = [];
PaymentDetails get paymentDetails => _paymentsDetails;
List<PaidList> get paidLists => _paidLists;
List<String> get Headings => _headings;
List<String> get subHeadings => _subHeadings;
List<Employees> get employeesList => _employeesList;
List<OrderList> get paymentsList => _paymentsList;
Employees? get selectedEmployee => _selectedEmployee;
String? get selectedEmpID => _selectedEmpID;
String? get selectedEmpName => _selectedEmpName;
bool get isLoading => _isLoading;
set selectedEmployee(Employees? value) {
_selectedEmployee = value;
_selectedEmpID = value?.id!;
_selectedEmpName = value!.name!;
notifyListeners();
}
set selectedEmpID(String? value) {
_selectedEmpID = value;
notifyListeners();
}
set selectedEmpName(String? value) {
_selectedEmpName = value;
notifyListeners();
}
Future<void> paymentsListsByModeFilterAPIFunction(context, mode) async {
try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.paymentListByModeFilterAPI(
provider.empId,
provider.session,
mode,
);
if (data != null) {
if (data.error == "0") {
_employeesList = data.employees!;
notifyListeners();
} else {}
}
} catch (e, s) {}
}
Future<void> paymentsListsByModeAPIFunction(
context,
mode,
teamEmployee,
) async {
try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.paymentListsByModeAPI(
provider.empId,
provider.session,
mode,
teamEmployee,
);
if (data != null) {
_paymentsList.clear();
_isLoading = true;
notifyListeners();
if (data.error == "0") {
_paymentsList = data.orderList!;
print(data.orderList!.length);
_isLoading = false;
if (_selectedEmployee != null &&
!_employeesList.contains(_selectedEmployee)) {
_selectedEmployee = null;
_selectedEmpID = "";
_selectedEmpName = "";
}
notifyListeners();
} else {
_isLoading = false;
}
notifyListeners();
}
} catch (e, s) {}
}
Future<void> paymentsDetailsByModeAPIFunction(context, paymentId, mode) async {
try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.paymentsDetailsByModeAPI(
provider.empId,
provider.session,
paymentId,
);
if (data != null) {
_isLoading = true;
notifyListeners();
if (data.error == "0") {
_paymentsDetails = data.paymentDetails!;
_paidLists = data.paidList!;
_headings = ["Account Name",
"Entered By",
"Payment Type",
"Payment Reference Number",
"Payment Date",
"Adjusted Amount",
"Amount",
"Description",
"Approved Employee",
"Approved Remarks",
"Attachment",
"Created Datetime",
"Description",
"Status",];
_subHeadings = [
_paymentsDetails.accountName??"-",
_paymentsDetails.enteredEmpName??"-",
_paymentsDetails.paymentType??"-",
_paymentsDetails.refNo??"-",
_paymentsDetails.paymentDate??"-",
_paymentsDetails.adjustedAmount??"-",
_paymentsDetails.amount??"-",
_paymentsDetails.description??"-",
_paymentsDetails.approvalEmployee??"-",
_paymentsDetails.approvalEmployee??"-",
_paymentsDetails.attachmentViewFileName??"-",
_paymentsDetails.datetime??"-",
_paymentsDetails.status??"-",
];
_isLoading = false;
} else {
_isLoading = false;
}
notifyListeners();
}
} catch (e, s) {}
}
Future<void> paymentApprovalRejectionAPIFunction(context,paymentId,type) async {
try{
if(!validateApprovalRejectionForm(context)){
return;
}
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.paymentOrderApproveRejectAPI(provider.empId, provider.session, paymentId, type, approvalRejectionController.text);
if(data!=null){
if(data.error=="0"){
toast(context, "${data.message}");
resetForm();
Navigator.pop(context, true);
notifyListeners();
}
}
}catch(e,s){
}
}
Future<void> paymentDeletionAPIFunction(context,paymentId) async {
try{
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.paymentOrderDeleteAPI(provider.empId, provider.session, paymentId);
if(data!=null){
if(data.error=="0"){
toast(context, "${data.message}");
resetForm();
Navigator.pop(context, true);
Navigator.pop(context, true);
notifyListeners();
}
}
}catch(e,s){
}
}
bool validateApprovalRejectionForm(BuildContext context){
bool isValid = true;
approvalRejectionError = null;
if(approvalRejectionController.text.trim().isEmpty){
approvalRejectionError = "Please Enter Remarks";
isValid = false;
}
notifyListeners();
return isValid;
}
void onChangeApprovalRejection(value){
approvalRejectionError = "";
notifyListeners();
}
void resetForm(){
approvalRejectionController.clear();
approvalRejectionError = "";
}
void resetAll() {
approvalRejectionController.clear();
approvalRejectionError = "";
_selectedEmployee = null;
_selectedEmpID = "";
_selectedEmpName = "";
notifyListeners();
}
}
import 'dart:io';
import 'package:camera/camera.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:generp/Models/ordersModels/TPCListResponse.dart';
import 'package:image_picker/image_picker.dart';
import 'package:provider/provider.dart';
import '../../Models/ordersModels/PendingTPCAgentListResponse.dart';
import '../../Models/ordersModels/TPCAgentDetailsResponse.dart';
import '../../Utils/commonServices.dart';
import '../../services/api_calling.dart';
import '../HomeScreenNotifier.dart';
class Tpcagentsprovider extends ChangeNotifier{
TextEditingController tpcNameController = TextEditingController();
TextEditingController tpcMobileNumberController = TextEditingController();
TextEditingController tpcBankNameController = TextEditingController();
TextEditingController tpcBankBeneficiaryNameController = TextEditingController();
TextEditingController tpcBankAccountNumberController = TextEditingController();
TextEditingController tpcBankIFSCController = TextEditingController();
TextEditingController tpcNoteController = TextEditingController();
TextEditingController tpcPaymentModeController = TextEditingController();
TextEditingController tpcPaymentReferenceNoController = TextEditingController();
TextEditingController orderTpcFeedbackController = TextEditingController();
String? tpcNameError = "";
String? tpcMobileNumberError = "";
String? tpcBankNameError = "";
String? tpcBankBeneficiaryNameError = "";
String? tpcBankAccountNumberError = "";
String? tpcBankIFSCError = "";
String? tpcNoteError = "";
String? tpcPaymentModeError = "";
String? tpcPaymentReferenceNoError = "";
String? orderTpcFeedbackError = "";
List<TpcAgentList> _tpcAgentsList = [];
List<PendingTpcIssueList> _tpcAgentsIssueList = [];
TpcAgentDetails _tpcAgentDetails = TpcAgentDetails();
List<TpcRequestedAmounts> _tpcRequestedAmounts = [];
List<String> _headings = [];
List<String> _subHeadings = [];
bool _isLoading = false;
var _image_picked = 0;
final ImagePicker _picker = ImagePicker();
File? _image;
File? _imageName;
List<String> get Headings => _headings;
List<String> get subHeadings => _subHeadings;
List<TpcAgentList> get tpcAgentsList => _tpcAgentsList;
List<PendingTpcIssueList> get tpcAgentsIssueList => _tpcAgentsIssueList;
TpcAgentDetails get TPCAgentsDetails => _tpcAgentDetails;
List<TpcRequestedAmounts> get TPCRequestedAmounts => _tpcRequestedAmounts;
bool get isLoading => _isLoading;
get image_picked => _image_picked;
File? get imagePath => _imageName;
File? get imageFilePath => _image;
get imagePicked => _image_picked;
set imagePath(File? value) {
_imageName = value;
notifyListeners();
}
set imageFilePath(File? value) {
_image = value;
notifyListeners();
}
set imagePicked(value) {
_image_picked = value;
notifyListeners();
}
Future<void> TPCAgentsListAPIFunction(context, mode,) async {
try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.TPCAgentListAPI(
provider.empId,
provider.session,
mode,
);
if (data != null) {
_tpcAgentsList.clear();
_isLoading = true;
notifyListeners();
if (data.error == "0") {
_tpcAgentsList = data.tpcAgentList!;
_isLoading = false;
notifyListeners();
} else {
_isLoading = false;
}
notifyListeners();
}
} catch (e, s) {}
}
Future<void> TPCAgentsIssueListAPIFunction(context,) async {
try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.pendingTPCAgentIssueListAPI(
provider.empId,
provider.session,
);
if (data != null) {
_tpcAgentsIssueList.clear();
_isLoading = true;
notifyListeners();
if (data.error == "0") {
_tpcAgentsIssueList = data.pendingTpcIssueList!;
_isLoading = false;
notifyListeners();
} else {
_isLoading = false;
}
notifyListeners();
}
} catch (e, s) {}
}
Future<void> TPCAgentsDetailsAPIFunction(context, tpc_agent_id) async {
try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.TPCAgentDetailsAPI(
provider.empId,
provider.session,
tpc_agent_id,
);
if (data != null) {
_tpcRequestedAmounts.clear();
_isLoading = true;
notifyListeners();
if (data.error == "0") {
_tpcAgentDetails = data.tpcAgentDetails!;
_tpcRequestedAmounts = data.tpcRequestedAmounts!;
_isLoading = false;
_headings = ["Agent Name",
"Mobile Number",
"TPC Agent Bank Name",
"Bank Beneficiary Name",
"Bank Account No",
"Bank IFSC Code",
"ID Proof",
"Order Received Date",
"Created Date",
"Note",
];
_subHeadings = [
_tpcAgentDetails.name??"-",
_tpcAgentDetails.mobileNumber??"-",
_tpcAgentDetails.bankName??"-",
_tpcAgentDetails.bankBeneficiaryName??"-",
_tpcAgentDetails.bankAccountNo??"-",
_tpcAgentDetails.bankIfscCode??"-",
_tpcAgentDetails.idProofViewFileName??"-",
_tpcAgentDetails.createdDatetime??"-",
_tpcAgentDetails.note??"-"
];
notifyListeners();
} else {
_isLoading = false;
}
notifyListeners();
}
} catch (e, s) {}
}
Future<void> TPCAgentsIssueApprovalAPIFunction(context, orderID,) async {
try {
if (!validateApproveForm(context)) {
// _submitClicked = false;
return;
}
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.TpcIssueListApprovalAPI(
provider.empId,
provider.session,
tpcPaymentModeController.text,
tpcPaymentReferenceNoController.text,
orderID,
orderTpcFeedbackController.text,
_image
);
if (data != null) {
if (data.error == "0") {
toast(context, "Submitted Successfully");
resetApprovalForm();
Navigator.pop(context, true);
notifyListeners();
}
}
} catch (e, s) {}
}
Future<void> addTPCAgentAPIFunction(context) async {
try {
if (!validateAddTPCAgentForm(context)) {
// _submitClicked = false;
return;
}
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
final data = await ApiCalling.ordersAddTPCAgentAPI(
provider.empId,
provider.session,
tpcNameController.text,
tpcMobileNumberController.text,
tpcBankNameController.text,
tpcBankBeneficiaryNameController.text,
tpcBankAccountNumberController.text,
tpcBankIFSCController.text,
tpcNoteController.text,
_image
);
if (data != null) {
if (data.error == "0") {
toast(context, "Submitted Successfully");
resetAddTPCAgentForm();
Navigator.pop(context, true);
notifyListeners();
}
}
} catch (e, s) {}
}
bool validateAddTPCAgentForm(BuildContext context) {
// Reset all errors
tpcNameError = null;
tpcMobileNumberError = null;
tpcBankNameError = null;
tpcBankBeneficiaryNameError = null;
tpcBankAccountNumberError = null;
tpcBankIFSCError = null;
tpcNoteError = null;
bool isValid = true;
if(tpcNameController.text.trim().isEmpty){
tpcNameError = "Please Enter Your Name";
isValid = false;
}
if(tpcMobileNumberController.text.trim().isEmpty){
tpcMobileNumberError = "PLease Enter Your Mobile Number";
isValid = false;
}
if(tpcBankNameController.text.trim().isEmpty){
tpcBankNameError = "Please Enter Bank Name";
isValid = false;
}
if(tpcBankBeneficiaryNameController.text.trim().isEmpty){
tpcBankBeneficiaryNameError = "Please Enter Beneficiery Name";
isValid = false;
}
if(tpcBankAccountNumberController.text.trim().isEmpty){
tpcBankAccountNumberError = "Please Enter Account Number";
isValid = false;
}
if(tpcBankIFSCController.text.trim().isEmpty){
tpcBankIFSCError = "Please Enter IFSC";
isValid = false;
}
notifyListeners();
return isValid;
}
bool validateApproveForm(BuildContext context) {
// Reset all errors
tpcPaymentModeError = null;
tpcPaymentReferenceNoError = null;
orderTpcFeedbackError = null;
bool isValid = true;
if (tpcPaymentModeController.text.trim().isEmpty) {
tpcPaymentModeError = "Please enter a description";
isValid = false;
}
if (tpcPaymentReferenceNoController.text.trim().isEmpty) {
tpcPaymentReferenceNoError = "Please enter a description";
isValid = false;
}
if (orderTpcFeedbackController.text.trim().isEmpty) {
orderTpcFeedbackError = "Please enter a description";
isValid = false;
}
notifyListeners();
return isValid;
}
void onChangeTPCPayment(value){
tpcPaymentModeError = "";
notifyListeners();
}
void onChangeTPCPaymentReference(value){
tpcPaymentReferenceNoError = "";
notifyListeners();
}
void onChangeTpcFeedback(value){
orderTpcFeedbackError = "";
notifyListeners();
}
void onChangetpcName(value){
tpcNameError = "";
notifyListeners();
}
void onChangetpcMobileNumber(value){
tpcMobileNumberError = "";
notifyListeners();
}
void onChangetpcBankName(value){
tpcBankNameError = "";
notifyListeners();
}
void onChangetpcBankBeneficiaryName(value){
tpcBankBeneficiaryNameError = "";
notifyListeners();
}
void onChangetpcBankAccountNumber(value){
tpcBankAccountNumberError = "";
notifyListeners();
}
void onChangetpcBankIFSC(value){
tpcBankIFSCError = "";
notifyListeners();
}
void onChangetpcNote(value){
tpcNoteError = "";
notifyListeners();
}
void resetAddTPCAgentForm() {
tpcNameController.clear();
tpcMobileNumberController.clear();
tpcBankNameController.clear();
tpcBankBeneficiaryNameController.clear();
tpcBankAccountNumberController.clear();
tpcBankIFSCController.clear();
tpcNoteController.clear();
tpcNameError = "";
tpcMobileNumberError = "";
tpcBankNameError = "";
tpcBankBeneficiaryNameError = "";
tpcBankAccountNumberError = "";
tpcBankIFSCError = "";
tpcNoteError = "";
_image = null;
_imageName = null;
_image_picked = 0;
}
void resetApprovalForm() {
tpcPaymentModeController.clear();
tpcPaymentReferenceNoController.clear();
orderTpcFeedbackController.clear();
tpcPaymentModeError = "";
tpcPaymentReferenceNoError = "";
orderTpcFeedbackError = "";
_image = null;
_imageName = null;
_image_picked = 0;
}
void resetAll(){
tpcNameController.clear();
tpcMobileNumberController.clear();
tpcBankNameController.clear();
tpcBankBeneficiaryNameController.clear();
tpcBankAccountNumberController.clear();
tpcBankIFSCController.clear();
tpcNoteController.clear();
tpcPaymentModeController.clear();
tpcPaymentReferenceNoController.clear();
orderTpcFeedbackController.clear();
tpcPaymentModeError = "";
tpcPaymentReferenceNoError = "";
orderTpcFeedbackError = "";
tpcNameError = "";
tpcMobileNumberError = "";
tpcBankNameError = "";
tpcBankBeneficiaryNameError = "";
tpcBankAccountNumberError = "";
tpcBankIFSCError = "";
tpcNoteError = "";
_image = null;
_imageName = null;
_image_picked = 0;
}
imgFromCamera(context) async {
// Capture a photo
try {
final XFile? galleryImage = await _picker.pickImage(
source: ImageSource.camera,
imageQuality: 50,
);
debugPrint("added");
_image = File(galleryImage!.path);
_imageName = File(galleryImage!.name);
_image_picked = 1;
notifyListeners();
} catch (e) {
debugPrint("mmmm: ${e.toString()}");
}
}
imgFromGallery(context) async {
// Pick an image
try {
final XFile? galleryImage = await _picker.pickImage(
source: ImageSource.gallery,
);
final bytes = (await galleryImage?.readAsBytes())?.lengthInBytes;
final kb = bytes! / 1024;
final mb = kb / 1024;
debugPrint("Jenny: bytes:$bytes, kb:$kb, mb: $mb");
_image = File(galleryImage!.path);
_imageName = File(galleryImage!.name);
_image_picked = 1;
notifyListeners();
// var file = FlutterImageCompress.compressWithFile(galleryImage!.path);
} catch (e) {
debugPrint("mmmm: ${e.toString()}");
}
}
}
\ No newline at end of file
......@@ -39,7 +39,7 @@ PreferredSizeWidget appbar(BuildContext context, title) {
);
}
PreferredSizeWidget appbar2(BuildContext context, title,widget) {
PreferredSizeWidget appbar2(BuildContext context, title,reset,widget) {
return AppBar(
automaticallyImplyLeading: false,
elevation: 2.0,
......@@ -49,13 +49,19 @@ PreferredSizeWidget appbar2(BuildContext context, title,widget) {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
InkResponse(
onTap: () => Navigator.pop(context, true),
onTap: (){
reset();
Navigator.pop(context, true);
},
child: SvgPicture.asset("assets/svg/app_bar_back.svg", height: 25),
),
Expanded(
flex:4,
child: InkResponse(
onTap: () => Navigator.pop(context, true),
onTap: () {
reset();
Navigator.pop(context, true);
},
child: Text(
title,
overflow: TextOverflow.ellipsis,
......
......@@ -195,6 +195,9 @@ class MyApp extends StatelessWidget {
ChangeNotifierProvider(create: (_) => Accountslistprovider(),),
ChangeNotifierProvider(create: (_) => Accountdetailsprovider(),),
ChangeNotifierProvider(create: (_) => Accountledgerprovider(),),
ChangeNotifierProvider(create: (_) => Pagesdashboardprovider(),),
ChangeNotifierProvider(create: (_) => Paymentsprovider(),),
ChangeNotifierProvider(create: (_) => Tpcagentsprovider(),),
],
child: Builder(
builder: (BuildContext context) {
......
......@@ -5,6 +5,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:generp/screens/order/orderModuleDashboard.dart';
import 'notifierExports.dart';
import 'screensExports.dart';
import 'package:geolocator/geolocator.dart';
......@@ -119,6 +120,8 @@ class _MyHomePageState extends State<MyHomePage> {
"Whizzdom",
"Common",
"Finance",
"Orders",
"CRM",
];
final icons = [
"assets/svg/home_icons_1.svg",
......@@ -130,6 +133,8 @@ class _MyHomePageState extends State<MyHomePage> {
"assets/svg/home_icons_81.svg",
"assets/svg/home_icons_9.svg",
"assets/svg/home_icons_10.svg",
"assets/svg/home_icons_11.svg",
"assets/svg/home_icons_12.svg",
];
final requiredRoles = [
"430",
......@@ -141,6 +146,8 @@ class _MyHomePageState extends State<MyHomePage> {
"431",
"430",
"430",
"430",
"430",
];
final filteredItems = <Map<String, String>>[];
......@@ -461,6 +468,14 @@ class _MyHomePageState extends State<MyHomePage> {
),
);
break;
case "Orders":
res = await Navigator.push(
context,
MaterialPageRoute(
builder:
(context) => Ordermoduledashboard(),
),
);
default:
print("111");
break;
......
......@@ -59,6 +59,7 @@ class _AccountledgerState extends State<Accountledger> {
appBar: appbar2(
context,
"Account Ledger List",
provider.resetAll,
Row(
children: [
Container(
......
......@@ -41,7 +41,7 @@ class _AccountslistState extends State<Accountslist> {
return WillPopScope(
child: Scaffold(
resizeToAvoidBottomInset: true,
appBar: appbar2(context, "Account List",Container(
appBar: appbar2(context, "Account List",provider.resetValues,Container(
padding: EdgeInsets.symmetric(horizontal: 5, vertical: 5),
child: InkResponse(
......
......@@ -48,7 +48,7 @@ class _AccountslistdetailsState extends State<Accountslistdetails> {
return WillPopScope(
child: Scaffold(
appBar: appbar2(context, "Account Details",Container(
appBar: appbar2(context, "Account Details",provider.resetValues,Container(
padding: EdgeInsets.symmetric(horizontal: 5,vertical: 5),
decoration: BoxDecoration(
......
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
......@@ -85,6 +86,169 @@ class Commondaterangefilter {
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
// Custom calendar widget
// Widget buildCalendar() {
// final firstDayOfMonth = DateTime(displayedMonth.year, displayedMonth.month, 1);
// final lastDayOfMonth = DateTime(displayedMonth.year, displayedMonth.month + 1, 0);
// final firstDayOfWeek = firstDayOfMonth.weekday;
// final daysInMonth = lastDayOfMonth.day;
// final daysBefore = (firstDayOfWeek - 1) % 7;
//
// List<Widget> dayWidgets = [];
// // Weekday headers
// final weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
// dayWidgets.addAll(weekdays.map((day) => Center(
// child: Text(
// day,
// style: TextStyle(
// fontSize: 14,
// fontWeight: FontWeight.w600,
// color: Colors.grey[700],
// ),
// ),
// )));
//
// // Empty cells before the first day
// for (int i = 0; i < daysBefore; i++) {
// dayWidgets.add(Container());
// }
//
// // Days of the month
// for (int day = 1; day <= daysInMonth; day++) {
// final currentDate = DateTime(displayedMonth.year, displayedMonth.month, day);
// bool isSelected = false;
// bool isInRange = false;
// bool isOutsideRange = currentDate.isBefore(DateTime(2020)) ||
// currentDate.isAfter(DateTime(2100));
//
// if (tempStartDate != null && tempEndDate != null) {
// isSelected = currentDate.isAtSameMomentAs(tempStartDate!) ||
// currentDate.isAtSameMomentAs(tempEndDate!);
// isInRange = currentDate.isAfter(tempStartDate!) &&
// currentDate.isBefore(tempEndDate!) &&
// !isSelected;
// }
//
// dayWidgets.add(
// GestureDetector(
// onTap: isOutsideRange
// ? null
// : () {
// setState(() {
// if (tempStartDate == null) {
// tempStartDate = currentDate;
// } else if (tempEndDate == null) {
// if (currentDate.isBefore(tempStartDate!)) {
// tempEndDate = tempStartDate;
// tempStartDate = currentDate;
// } else {
// tempEndDate = currentDate;
// }
// tempSelectedDateRange = DateTimeRange(
// start: tempStartDate!,
// end: tempEndDate!,
// );
// } else {
// tempStartDate = currentDate;
// tempEndDate = null;
// tempSelectedDateRange = null;
// }
// });
// },
// child: Container(
// margin: EdgeInsets.all(2),
// decoration: BoxDecoration(
// color: isSelected
// ? Colors.blue[600]
// : isInRange
// ? Colors.blue[100]
// : null,
// shape: BoxShape.circle,
// ),
// child: Center(
// child: Text(
// '$day',
// style: TextStyle(
// color: isOutsideRange
// ? Colors.grey[400]
// : isSelected
// ? Colors.white
// : Colors.black,
// fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
// ),
// ),
// ),
// ),
// ),
// );
// }
//
// return Column(
// children: [
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// GestureDetector(
// onTap: displayedMonth.isAfter(DateTime(2020))
// ? () {
// setState(() {
// displayedMonth = DateTime(displayedMonth.year, displayedMonth.month - 1);
// });
// }
// : null,
// child: SvgPicture.asset(
// "assets/svg/arrow_left.svg",
// ),
// ),
// // IconButton(
// // icon: Icon(Icons.chevron_left, color: Colors.blue[600]),
// // onPressed: displayedMonth.isAfter(DateTime(2020))
// // ? () {
// // setState(() {
// // displayedMonth = DateTime(displayedMonth.year, displayedMonth.month - 1);
// // });
// // }
// // : null,
// // ),
// Text(
// '${_monthName(displayedMonth.month)} ${displayedMonth.year}',
// style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
// ),
// GestureDetector(
// onTap: displayedMonth.isBefore(DateTime(2100))
// ? () {
// setState(() {
// displayedMonth = DateTime(displayedMonth.year, displayedMonth.month + 1);
// });
// }
// : null,
// child: SvgPicture.asset(
// "assets/svg/arrow_right_new.svg",
// ),
// ),
// // IconButton(
// // icon: Icon(Icons.chevron_right, color: Colors.blue[600]),
// // onPressed: displayedMonth.isBefore(DateTime(2100))
// // ? () {
// // setState(() {
// // displayedMonth = DateTime(displayedMonth.year, displayedMonth.month + 1);
// // });
// // }
// // : null,
// // ),
// ],
// ),
// Container(
// height: 280,
// child: GridView.count(
// crossAxisCount: 7,
// childAspectRatio: 1.2,
// children: dayWidgets,
// physics: NeverScrollableScrollPhysics(),
// ),
// ),
// ],
// );
// }
Widget buildCalendar() {
final firstDayOfMonth = DateTime(displayedMonth.year, displayedMonth.month, 1);
final lastDayOfMonth = DateTime(displayedMonth.year, displayedMonth.month + 1, 0);
......@@ -100,6 +264,7 @@ class Commondaterangefilter {
day,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: Colors.grey[700],
),
),
......@@ -124,6 +289,8 @@ class Commondaterangefilter {
isInRange = currentDate.isAfter(tempStartDate!) &&
currentDate.isBefore(tempEndDate!) &&
!isSelected;
} else if (tempStartDate != null) {
isSelected = currentDate.isAtSameMomentAs(tempStartDate!);
}
dayWidgets.add(
......@@ -133,9 +300,13 @@ class Commondaterangefilter {
: () {
setState(() {
if (tempStartDate == null) {
// No start date selected, set it
tempStartDate = currentDate;
tempSelectedDateRange = null;
} else if (tempEndDate == null) {
// Start date selected, set end date
if (currentDate.isBefore(tempStartDate!)) {
// If the new date is before start date, swap them
tempEndDate = tempStartDate;
tempStartDate = currentDate;
} else {
......@@ -146,6 +317,7 @@ class Commondaterangefilter {
end: tempEndDate!,
);
} else {
// Both dates selected, reset to start a new range
tempStartDate = currentDate;
tempEndDate = null;
tempSelectedDateRange = null;
......@@ -153,7 +325,7 @@ class Commondaterangefilter {
});
},
child: Container(
margin: EdgeInsets.all(1),
margin: EdgeInsets.all(2),
decoration: BoxDecoration(
color: isSelected
? Colors.blue[600]
......@@ -197,16 +369,6 @@ class Commondaterangefilter {
"assets/svg/arrow_left.svg",
),
),
// IconButton(
// icon: Icon(Icons.chevron_left, color: Colors.blue[600]),
// onPressed: displayedMonth.isAfter(DateTime(2020))
// ? () {
// setState(() {
// displayedMonth = DateTime(displayedMonth.year, displayedMonth.month - 1);
// });
// }
// : null,
// ),
Text(
'${_monthName(displayedMonth.month)} ${displayedMonth.year}',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
......@@ -223,16 +385,6 @@ class Commondaterangefilter {
"assets/svg/arrow_right_new.svg",
),
),
// IconButton(
// icon: Icon(Icons.chevron_right, color: Colors.blue[600]),
// onPressed: displayedMonth.isBefore(DateTime(2100))
// ? () {
// setState(() {
// displayedMonth = DateTime(displayedMonth.year, displayedMonth.month + 1);
// });
// }
// : null,
// ),
],
),
Container(
......@@ -247,7 +399,6 @@ class Commondaterangefilter {
],
);
}
return Padding(
padding: EdgeInsets.all(16.0),
child: SingleChildScrollView(
......@@ -405,37 +556,37 @@ class Commondaterangefilter {
}
// Widget to demonstrate usage
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: InkResponse(
onTap: () async {
var cf = Commondaterangefilter();
var result = await cf.showFilterBottomSheet(context);
if (result != null) {
var dateRange = result['dateRange'] as DateTimeRange?;
print("dateRange: $dateRange");
var formatted = result['formatted'] as List<String>;
print("formatted: $formatted");
if (formatted.isNotEmpty) {
var fromDate = formatted[0]; // From date
var toDate = formatted[1]; // To date
print("from_date: $fromDate");
print("to_date: $toDate");
} else {
print("No valid date range selected");
}
} else {
print("Bottom sheet closed without selection");
}
},
child: SvgPicture.asset("assets/svg/filter_ic.svg", height: 25),
),
),
);
}
}
\ No newline at end of file
// class MyWidget extends StatelessWidget {
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// body: Center(
// child: InkResponse(
// onTap: () async {
// var cf = Commondaterangefilter();
// var result = await cf.showFilterBottomSheet(context);
// if (result != null) {
// var dateRange = result['dateRange'] as DateTimeRange?;
// print("dateRange: $dateRange");
//
// var formatted = result['formatted'] as List<String>;
// print("formatted: $formatted");
//
// if (formatted.isNotEmpty) {
// var fromDate = formatted[0]; // From date
// var toDate = formatted[1]; // To date
// print("from_date: $fromDate");
// print("to_date: $toDate");
// } else {
// print("No valid date range selected");
// }
// } else {
// print("Bottom sheet closed without selection");
// }
// },
// child: SvgPicture.asset("assets/svg/filter_ic.svg", height: 25),
// ),
// ),
// );
// }
// }
\ No newline at end of file
......@@ -55,6 +55,7 @@ class _AllpaymentrequesitionlistsbymodesState
appBar: appbar2(
context,
widget.pageTitleName,
provider.resetForm,
Row(
children: [
InkResponse(
......
......@@ -46,6 +46,7 @@ class _PaymentlistpaymentrequisitionState extends State<Paymentlistpaymentrequis
appBar: appbar2(
context,
widget.pageTitleName,
provider.resetForm,
Row(
children: [
InkResponse(
......
......@@ -48,6 +48,7 @@ class _PaymentreceiptlistState extends State<Paymentreceiptlist> {
appBar: appbar2(
context,
widget.pageTitleName,
provider.resetForm,
Row(
children: [
InkResponse(
......
......@@ -95,7 +95,7 @@ class _GeneratordetailsState extends State<Generatordetails> {
resizeToAvoidBottomInset: true,
appBar:
widget.activityName == "NearByGenerators"
? appbar2(context, "Generator Details", sendwidget)
? appbar2(context, "Generator Details",provider.resetForm, sendwidget)
: appbar(context, "Generator Details"),
backgroundColor: AppColors.scaffold_bg_color,
body: Container(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment