Commit 185e0896 authored by Sai Srinivas's avatar Sai Srinivas
Browse files

changes by mohit

parent ee5b7a8e
......@@ -11,6 +11,7 @@ class ProfileResponse {
String? profilePic;
int? sessionExists;
ProfileResponse(
{this.totpSecret,
this.empId,
......
......@@ -715,17 +715,30 @@ class Accountslistprovider extends ChangeNotifier {
notifyListeners();
}
Future<void> commonAccountListAPIFunction(context) async {
String? _errorMessage;
String? get errorMessage => _errorMessage;
// Common Account list provider
Future<void> commonAccountListAPIFunction(
BuildContext context, {
bool append = false,
}) async {
try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false);
if (_pageNum == 1) {
if (!append) {
// Fresh load / Refresh
_accountsList.clear();
_pageNum = 1;
_hasMoreData = true;
_isLoading = true;
notifyListeners();
} else {
_isLoading = true;
}
if (!_hasMoreData || !_isLoading) return;
_hasMoreData = true;
notifyListeners();
final data = await ApiCalling.commonAccountListAPI(
......@@ -735,23 +748,37 @@ class Accountslistprovider extends ChangeNotifier {
companyNameController.text,
mobileNumberController.text,
);
if (data != null) {
print("pageNum $_pageNum");
if (data.error == "0") {
_hasMoreData = true;
_accountsList.addAll(data.accountList!);
_pageNum++;
_isLoading = false;
notifyListeners();
debugPrint('empId: ${prov.empId}, session: ${prov.session}, pageNumber: $_pageNum');
if (data != null && data.error == "0") {
if (data.accountList != null) {
if (append) {
// Append with deduplication
final existingIds = _accountsList.map((e) => e.id).toSet();
final newItems = data.accountList!
.where((item) => !existingIds.contains(item.id))
.toList();
_accountsList.addAll(newItems);
} else {
_hasMoreData = false;
_accountsList = data.accountList!;
}
// Check if we still have more records
_hasMoreData = data.accountList!.length >= 10;
if (_hasMoreData) _pageNum++;
}
}
} catch (e, s) {
debugPrint("Error in commonAccountListAPIFunction: $e");
} finally {
_isLoading = false;
notifyListeners();
}
}
} catch (e, s) {}
}
resetValues() {
print("rv");
......
......@@ -1120,8 +1120,26 @@ class Leadlistprovider extends ChangeNotifier {
}
}
bool _isLoadingMore = false;
bool get isLoadingMore => _isLoadingMore;
bool _hasMoreData = true;
bool get hasMoreData => _hasMoreData;
int _currentPage = 1;
String? _errorMessage;
String? get errorMessage => _errorMessage;
/// Reset pagination
void resetPagination() {
_currentPage = 1;
_hasMoreData = true;
_crmLeadList.clear();
notifyListeners();
}
Future<void> crmLeadListAPIFunction(
context,
BuildContext context,
String? mode,
String? leadStatus,
String? openStatus,
......@@ -1129,13 +1147,21 @@ class Leadlistprovider extends ChangeNotifier {
String? referenceID,
String? teamID,
String? segmentID,
String? alphabet,
) async {
String? alphabet, {
bool append = false,
}) async {
try {
var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false);
if (!append) {
_isLoading = true;
_crmLeadList.clear();
_errorMessage = null;
notifyListeners();
var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false);
} else {
_isLoadingMore = true;
notifyListeners();
}
final data = await ApiCalling.crmLeadListFilterSubmitAPI(
HomeProv.empId,
HomeProv.session,
......@@ -1149,28 +1175,59 @@ class Leadlistprovider extends ChangeNotifier {
teamID,
segmentID,
alphabet,
_currentPage.toString(), //
);
if (data != null) {
_isLoading = true;
notifyListeners();
if (data.error == "0") {
_crmLeadList = data.leadList?.where((lead) => lead != null).toList() ?? [];
_isLoading = false;
checkDropDownValues();
notifyListeners();
debugPrint('empId: ${HomeProv.empId}, session: ${HomeProv.session}, pageNumber: $_currentPage');
if (data != null && data.error == "0") {
if (append) {
_crmLeadList.addAll(data.leadList ?? []);
} else {
_isLoading = false;
notifyListeners();
_crmLeadList = data.leadList ?? [];
}
if (data.leadList == null || data.leadList!.length < 10) {
_hasMoreData = false; // no more pages
}
} else {
_isLoading = false;
notifyListeners();
if (!append) _errorMessage = "No leads found!";
_hasMoreData = false;
}
} catch (e, s) {
print('crmLeadListAPIFunction error: $e, stack: $s');
_errorMessage = "Error: $e";
}
_isLoading = false;
_isLoadingMore = false;
notifyListeners();
}
/// Load next page
Future<void> loadMore(
BuildContext context,
String? mode,
String? leadStatus,
String? openStatus,
String? sourceID,
String? referenceID,
String? teamID,
String? segmentID,
String? alphabet,
) async {
if (_isLoadingMore || !_hasMoreData) return;
_currentPage++;
await crmLeadListAPIFunction(
context,
mode,
leadStatus,
openStatus,
sourceID,
referenceID,
teamID,
segmentID,
alphabet,
append: true,
);
}
onChangedLeadId(String? value) {
......
......@@ -110,6 +110,7 @@ class ProspectListProvider extends ChangeNotifier {
employeeID,
mobileNumberController.text,
companyNameController.text,
"1"
);
if (data != null) {
_isLoading = true;
......
......@@ -625,39 +625,88 @@ class Requestionlistprovider extends ChangeNotifier {
}
}
int _pageNum = 1;
bool _hasMoreData = true;
bool _isLoadingMore = false;
bool get isLoadingMore => _isLoadingMore;
bool get hasMoreData => _hasMoreData;
int _currentPage = 1;
int get currentPage => _currentPage;
/// Reset before a fresh load (pull-to-refresh or filter change)
void resetPagination() {
_currentPage = 1;
_hasMoreData = true;
_requisitionList.clear();
notifyListeners();
}
Future<void> paymentRequestionListsAPIFunction(
context,
mode,
from,
to,
) async {
BuildContext context,
String mode,
String from,
String to, {
bool append = false,
}) async {
try {
var homeProvider = Provider.of<HomescreenNotifier>(
context,
listen: false,
);
if (!append) {
// reset for first page
_pageNum = 1;
_hasMoreData = true;
_requisitionList.clear();
_isLoading = true;
} else {
_isLoadingMore = true;
}
notifyListeners();
final data = await ApiCalling.paymentRequestionListsAPI(
homeProvider.empId,
homeProvider.session,
mode,
from,
to,
_pageNum.toString(),
);
if (data != null) {
if (data.error == "0") {
_isLoading = false;
_requisitionList = data.requistionList!;
} else if (data.error == "1") {
_isLoading = false;
debugPrint('empId: ${homeProvider.empId}, session: ${homeProvider.session}, pageNumber: $_pageNum');
if (data != null && data.error == "0") {
if (append) {
final existingIds = _requisitionList.map((e) => e.id).toSet();
final newItems = data.requistionList!
.where((item) => !existingIds.contains(item.id))
.toList();
_requisitionList.addAll(newItems);
} else {
_requisitionList = data.requistionList ?? [];
}
// check if more data
if (data.requistionList == null || data.requistionList!.length < 10) {
_hasMoreData = false;
} else {
_pageNum++;
}
} else {
_hasMoreData = false;
}
} catch (e) {
_hasMoreData = false;
} finally {
_isLoading = false;
_isLoadingMore = false;
notifyListeners();
}
} catch (e, s) {}
}
void showDatePickerDialog(BuildContext context) {
showCupertinoModalPopup<void>(
context: context,
......
......@@ -366,28 +366,80 @@ class Paymentreceiptsprovider extends ChangeNotifier {
}
}
Future<void> paymentsListAPI(context, from, to) async {
bool _isLoadingMore = false;
bool get isLoadingMore => _isLoadingMore;
bool _hasMoreData = true;
bool get hasMoreData => _hasMoreData;
int _currentPage = 1;
String? _errorMessage;
String? get errorMessage => _errorMessage;
/// Reset pagination
void resetPagination() {
_currentPage = 1;
_hasMoreData = true;
_receiptsList.clear();
notifyListeners();
}
Future<void> paymentsListAPI(
BuildContext context,
String from,
String to, {
bool append = false,
}) async {
try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false);
if (!append) {
_isLoading = true;
_errorMessage = null;
notifyListeners();
} else {
_isLoadingMore = true;
notifyListeners();
}
final data = await ApiCalling.paymentRequisitionPaymentReceiptListAPI(
prov.empId,
prov.session,
from,
to,
_currentPage.toString(),
);
if (data != null) {
if (data.error == "0") {
_receiptsList = data.receiptsList!;
_isLoading = false;
notifyListeners();
} else if (data.error == "1") {
_isLoading = false;
debugPrint('empId: ${prov.empId}, session: ${prov.session}, pageNumber: $_currentPage');
if (data != null && data.error == "0") {
if (append) {
_receiptsList.addAll(data.receiptsList ?? []);
} else {
_receiptsList = data.receiptsList ?? [];
}
if (data.receiptsList == null || data.receiptsList!.length < 10) {
_hasMoreData = false; // no more pages
}
} else {
if (!append) _errorMessage = "No receipts found!";
_hasMoreData = false;
}
} catch (e) {
_errorMessage = "Error: $e";
}
_isLoading = false;
_isLoadingMore = false;
notifyListeners();
}
} catch (e, s) {}
/// Load next page
Future<void> loadMore(BuildContext context, String from, String to) async {
if (_isLoadingMore || !_hasMoreData) return;
_currentPage++;
await paymentsListAPI(context, from, to, append: true);
}
Future<void> paymentsListDetailsAPI(context, paymentId) async {
......
......@@ -38,26 +38,79 @@ class Paymentrequisitionpaymentslistprovider extends ChangeNotifier{
notifyListeners();
}
Future<void> paymentsListAPI(context,from,to) async {
try{
var prov = Provider.of<HomescreenNotifier>(context,listen: false);
bool _isLoadingMore = false;
bool get isLoadingMore => _isLoadingMore;
bool _hasMoreData = true;
bool get hasMoreData => _hasMoreData;
int _currentPage = 1;
String? _errorMessage;
String? get errorMessage => _errorMessage;
/// Reset pagination before new filter or refresh
void resetPagination() {
_currentPage = 1;
_hasMoreData = true;
_paymentsList.clear();
notifyListeners();
}
Future<void> paymentsListAPI(
BuildContext context,
String from,
String to, {
bool append = false,
}) async {
try {
var prov = Provider.of<HomescreenNotifier>(context, listen: false);
if (!append) {
_isLoading = true;
_errorMessage = null;
notifyListeners();
final data = await ApiCalling.paymentRequisitionPaymentListAPI(prov.empId, prov.session,from,to);
if(data!=null){
if(data.error=="0"){
_isLoading = false;
_paymentsList = data.paymentsList!;
} else {
_isLoadingMore = true;
notifyListeners();
}else if(data.error=="1"){
_isLoading = false;
}
notifyListeners();
final data = await ApiCalling.paymentRequisitionPaymentListAPI(
prov.empId,
prov.session,
from,
to,
_currentPage.toString(), // pass page number
);
debugPrint('empId: ${prov.empId}, session: ${prov.session}, pageNumber: $_currentPage');
if (data != null && data.error == "0") {
if (append) {
_paymentsList.addAll(data.paymentsList ?? []);
} else {
_paymentsList = data.paymentsList ?? [];
}
}catch(e,s){
if (data.paymentsList == null || data.paymentsList!.length < 10) {
_hasMoreData = false; // no more pages
}
} else {
if (!append) _errorMessage = "No data found!";
_hasMoreData = false;
}
} catch (e) {
_errorMessage = "Error: $e";
}
_isLoading = false;
_isLoadingMore = false;
notifyListeners();
}
/// Load next page
Future<void> loadMore(BuildContext context, String from, String to) async {
if (_isLoadingMore || !_hasMoreData) return;
_currentPage++;
await paymentsListAPI(context, from, to, append: true);
}
Future<void> paymentsListDetailsAPI(context,paymentId) async {
......
......@@ -51,7 +51,8 @@ class TourExpensesProvider extends ChangeNotifier {
}
/// Fetch tour expenses list
Future<void> fetchTourExpenses(BuildContext context, String pageNumber) async {
Future<void> fetchTourExpenses(BuildContext context, String pageNumber,
{bool append = false}) async {
_isLoading = true;
_errorMessage = null;
notifyListeners();
......@@ -65,10 +66,22 @@ class TourExpensesProvider extends ChangeNotifier {
pageNumber,
);
debugPrint('empId: ${provider.empId}, session: ${provider.session}');
debugPrint(
'empId: ${provider.empId}, session: ${provider.session}, pageNumber: $pageNumber');
if (result != null) {
if (append && _response != null && _response!.tourList != null) {
// Append with deduplication
final existingIds = _response!.tourList!.map((e) => e.id).toSet();
final newItems = (result.tourList ?? [])
.where((item) => !existingIds.contains(item.id))
.toList();
_response!.tourList!.addAll(newItems);
} else {
// First page or refresh
_response = result;
}
} else {
_errorMessage = "No data found!";
}
......@@ -80,6 +93,8 @@ class TourExpensesProvider extends ChangeNotifier {
notifyListeners();
}
Future<void> fetchTourExpensesAddView(BuildContext context, String tourBillId) async {
_isLoading = true;
_errorMessage = null;
......
......@@ -324,42 +324,112 @@ class Pagesdashboardprovider extends ChangeNotifier {
} catch (e, s) {}
}
bool _isLoadingMore = false;
bool get isLoadingMore => _isLoadingMore;
bool _hasMoreData = true;
bool get hasMoreData => _hasMoreData;
int _currentPage = 1;
String? _errorMessage;
String? get errorMessage => _errorMessage;
/// Reset everything
void resetPagination() {
_ordersList.clear();
_currentPage = 1;
_hasMoreData = true;
_isLoading = false;
_isLoadingMore = false;
_errorMessage = null;
notifyListeners();
}
Future<void> ordersListByModeAPIFunction(
context,
mode,
teamEmployee,
status,
) async {
BuildContext context,
String mode,
String teamEmployee,
String status, {
bool append = false,
}) async {
try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
if (!append) {
_isLoading = true;
_errorMessage = null;
notifyListeners();
} else {
_isLoadingMore = true;
notifyListeners();
}
final data = await ApiCalling.ordersListByModeAPI(
provider.empId,
provider.session,
mode,
teamEmployee,
status,
_currentPage.toString(),
);
if (data != null) {
_ordersList.clear();
_isLoading = true;
notifyListeners();
if (data.error == "0") {
_ordersList = data.orderList!;
_isLoading = false;
debugPrint('empId: ${provider.empId}, session: ${provider.session}, pageNumber: $_currentPage');
if (data != null && data.error == "0") {
if (append) {
_ordersList.addAll(data.orderList ?? []);
} else {
_ordersList = data.orderList ?? [];
if (_selectedEmployee != null &&
!_employeesList.contains(_selectedEmployee)) {
_selectedEmployee = null;
_selectedEmpID = "";
_selectedEmpName = "";
}
notifyListeners();
}
if (data.orderList == null || data.orderList!.length < 10) {
_hasMoreData = false;
}
} else {
if (!append) _errorMessage = "No orders found!";
_hasMoreData = false;
}
} catch (e, s) {
_errorMessage = "Error: $e";
}
if (_selectedEmployee != null &&
!_employeesList.contains(_selectedEmployee)) {
_selectedEmployee = null;
_selectedEmpID = "";
_selectedEmpName = "";
}
_isLoading = false;
_isLoadingMore = false;
notifyListeners();
}
}
} catch (e, s) {}
/// Load next page
Future<void> loadMore(
BuildContext context,
String mode,
String teamEmployee,
String status,
) async {
if (_isLoadingMore || !_hasMoreData) return;
_currentPage++;
await ordersListByModeAPIFunction(
context,
mode,
teamEmployee,
status,
append: true,
);
}
Future<void> ordersDetailsByModeAPIFunction(context, orderId, mode) async {
......
......@@ -120,40 +120,89 @@ class Paymentsprovider extends ChangeNotifier {
} catch (e, s) {}
}
bool _isLoadingMore = false;
bool get isLoadingMore => _isLoadingMore;
bool _hasMoreData = true;
bool get hasMoreData => _hasMoreData;
int _currentPage = 1;
String? _errorMessage;
String? get errorMessage => _errorMessage;
void resetPagination() {
_paymentsList.clear();
_currentPage = 1;
_hasMoreData = true;
_isLoading = false;
_isLoadingMore = false;
_errorMessage = null;
notifyListeners();
}
Future<void> paymentsListsByModeAPIFunction(
context,
mode,
teamEmployee,
) async {
BuildContext context,
String mode,
String teamEmployee, {
bool append = false,
}) async {
try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
if (!append) {
_isLoading = true;
_errorMessage = null;
notifyListeners();
} else {
_isLoadingMore = true;
notifyListeners();
}
final data = await ApiCalling.paymentListsByModeAPI(
provider.empId,
provider.session,
mode,
teamEmployee,
_currentPage.toString(),
);
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 = "";
debugPrint('empId: ${provider.empId}, session: ${provider.session}, pageNumber: $_currentPage');
if (data != null && data.error == "0") {
if (append) {
_paymentsList.addAll(data.orderList ?? []);
} else {
_paymentsList = data.orderList ?? [];
}
if (data.orderList == null || data.orderList!.length < 10) {
_hasMoreData = false;
}
notifyListeners();
} else {
_isLoading = false;
if (!append) _errorMessage = "No payments found!";
_hasMoreData = false;
}
} catch (e, s) {
_errorMessage = "Error: $e";
}
_isLoading = false;
_isLoadingMore = false;
notifyListeners();
}
} catch (e, s) {}
Future<void> loadMore(
BuildContext context,
String mode,
String teamEmployee,
) async {
if (_isLoadingMore || !_hasMoreData) return;
_currentPage++;
await paymentsListsByModeAPIFunction(
context,
mode,
teamEmployee,
append: true,
);
}
Future<void> paymentsDetailsByModeAPIFunction(
......
......@@ -101,53 +101,139 @@ class Tpcagentsprovider extends ChangeNotifier{
}
Future<void> TPCAgentsListAPIFunction(context, mode,) async {
bool _isLoadingMore = false;
bool get isLoadingMore => _isLoadingMore;
bool _hasMoreData = true;
bool get hasMoreData => _hasMoreData;
int _currentPage = 1;
String? _errorMessage;
String? get errorMessage => _errorMessage;
void resetPagination() {
_tpcAgentsList.clear();
_currentPage = 1;
_hasMoreData = true;
_isLoading = false;
_isLoadingMore = false;
_errorMessage = null;
notifyListeners();
}
Future<void> TPCAgentsListAPIFunction(
BuildContext context,
String mode, {
bool append = false,
}) async {
try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
if (!append) {
_isLoading = true;
_errorMessage = null;
notifyListeners();
} else {
_isLoadingMore = true;
notifyListeners();
}
final data = await ApiCalling.TPCAgentListAPI(
provider.empId,
provider.session,
mode,
_currentPage.toString(), // page number
);
if (data != null) {
_tpcAgentsList.clear();
_isLoading = true;
notifyListeners();
if (data.error == "0") {
_tpcAgentsList = data.tpcAgentList!;
_isLoading = false;
debugPrint('empId: ${provider.empId}, session: ${provider.session}, pageNumber: $_currentPage');
if (data != null && data.error == "0") {
if (append) {
_tpcAgentsList.addAll(data.tpcAgentList ?? []);
} else {
_isLoading = false;
_tpcAgentsList = data.tpcAgentList ?? [];
}
// stop if API returns less than page size
if (data.tpcAgentList == null || data.tpcAgentList!.length < 10) {
_hasMoreData = false;
}
} else {
if (!append) _errorMessage = "No agents found!";
_hasMoreData = false;
}
} catch (e, s) {
_errorMessage = "Error: $e";
}
_isLoading = false;
_isLoadingMore = false;
notifyListeners();
}
} catch (e, s) {}
Future<void> loadMore(BuildContext context, String mode) async {
if (_isLoadingMore || !_hasMoreData) return;
_currentPage++;
await TPCAgentsListAPIFunction(context, mode, append: true);
}
Future<void> TPCAgentsIssueListAPIFunction(context,) async {
Future<void> TPCAgentsIssueListAPIFunction(
BuildContext context, {
bool append = false,
}) async {
try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
if (!append) {
_isLoading = true;
_errorMessage = null;
_currentPage = 1;
notifyListeners();
} else {
_isLoadingMore = true;
notifyListeners();
}
final data = await ApiCalling.pendingTPCAgentIssueListAPI(
provider.empId,
provider.session,
_currentPage.toString(), // page number
);
if (data != null) {
_tpcAgentsIssueList.clear();
_isLoading = true;
notifyListeners();
if (data.error == "0") {
_tpcAgentsIssueList = data.pendingTpcIssueList!;
_isLoading = false;
debugPrint('empId: ${provider.empId}, session: ${provider.session}, pageNumber: $_currentPage');
notifyListeners();
if (data != null && data.error == "0") {
if (append) {
_tpcAgentsIssueList.addAll(data.pendingTpcIssueList ?? []);
} else {
_isLoading = false;
_tpcAgentsIssueList = data.pendingTpcIssueList ?? [];
}
// if API returns less than page size, stop loading more
if (data.pendingTpcIssueList == null ||
data.pendingTpcIssueList!.length < 10) {
_hasMoreData = false;
}
} else {
if (!append) _errorMessage = "No issues found!";
_hasMoreData = false;
}
} catch (e) {
_errorMessage = "Error: $e";
}
_isLoading = false;
_isLoadingMore = false;
notifyListeners();
}
} catch (e, s) {}
Future<void> loadMoreIssues(BuildContext context) async {
if (_isLoadingMore || !_hasMoreData) return;
_currentPage++;
await TPCAgentsIssueListAPIFunction(context, append: true);
}
Future<void> TPCAgentsDetailsAPIFunction(context, tpc_agent_id) async {
try {
var provider = Provider.of<HomescreenNotifier>(context, listen: false);
......
......@@ -7,7 +7,7 @@ class AppColors {
static Color greenish = Color(0xFF00BC57);
static Color grey_semi = Color(0xFF999999);
static Color grey_thick = Color(0xFF818181);
static Color red = Color (0xFFFF0000);
static Color red = Color(0xFFFF0000);
static Color thick_navy_blue = Color(0xff023047);
static Color cyan_blue = Color(0xFF219EBC);
static Color profile_card_gradient1 = Color(0xFFCFEEFF);
......@@ -26,5 +26,5 @@ class AppColors {
static Color requested_bg_color = Color(0xFFE6F6FF);
static Color rejected_bg_color = Color(0xFFFFF5F5);
static Color approved_bg_color = Color(0xFFE9FFE8);
static Color processed_bg_color = Color(0xFFEFFF8E5);
static Color processed_bg_color = Color(0xffefff8e5);
}
......@@ -18,8 +18,9 @@ import 'WebSocketManager.dart';
class BackgroundLocation {
// The channel to be used for communication.
// This channel is also refrenced inside both iOS and Abdroid classes
static const MethodChannel _channel =
MethodChannel('com.almoullim.background_location/methods');
static const MethodChannel _channel = MethodChannel(
'com.almoullim.background_location/methods',
);
static Timer? _locationTimer;
static get context => null;
......@@ -57,7 +58,8 @@ class BackgroundLocation {
requestAlertPermission: false,
requestBadgePermission: false,
requestSoundPermission: false,
));
),
);
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
// Disable sound for the default notification channel
......@@ -71,7 +73,8 @@ class BackgroundLocation {
);
await flutterLocalNotificationsPlugin
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
AndroidFlutterLocalNotificationsPlugin
>()
?.createNotificationChannel(androidChannel);
// print("Flutter Local Notifications initialized successfully.");
......@@ -87,9 +90,10 @@ class BackgroundLocation {
// Check if location services are enabled
isLocationEnabled = await Geolocator.isLocationServiceEnabled();
// Check if the app has been granted location permission
// Check if the app has been granted location permission
LocationPermission permission = await Geolocator.checkPermission();
hasLocationPermission = permission == LocationPermission.always ||
hasLocationPermission =
permission == LocationPermission.always ||
permission == LocationPermission.whileInUse;
final loc.Location location = loc.Location();
......@@ -131,12 +135,14 @@ class BackgroundLocation {
const NotificationDetails platformChannelSpecifics = NotificationDetails(
android: androidPlatformChannelSpecifics,
iOS: darwinNotificationDetails);
iOS: darwinNotificationDetails,
);
// Check if the notification with the same ID is already being shown
final List<PendingNotificationRequest> pendingNotifications =
await flutterLocalNotificationsPlugin.pendingNotificationRequests();
final notificationAlreadyExists = pendingNotifications
.any((notification) => notification.id == notificationId);
final notificationAlreadyExists = pendingNotifications.any(
(notification) => notification.id == notificationId,
);
// If notification already exists, update it; otherwise, show a new one
if (notificationAlreadyExists) {
await flutterLocalNotificationsPlugin.show(
......@@ -209,14 +215,18 @@ class BackgroundLocation {
// Notify user to enable GPS
checkAndRequestLocationPermissions();
showNotification(
"GEN ERP", "You're Offline !, Check your GPS connection.");
"GEN ERP",
"You're Offline !, Check your GPS connection.",
);
// print(
// 'GPS is not enabled. Please enable GPS to start the location service.');
}
if (!isNetworkAvailable) {
// Notify user to connect to a network
showNotification(
"GEN ERP", "You're Offline !, Check your network connection.");
"GEN ERP",
"You're Offline !, Check your network connection.",
);
// print(
// 'Network is not available. Please connect to a network to start the location service.');
}
......@@ -266,16 +276,16 @@ class BackgroundLocation {
saveLastLocationTime();
var completer = Completer<Location>();
var _location = Location();
var location = Location();
await getLocationUpdates((location) {
_location.latitude = location.latitude;
_location.longitude = location.longitude;
_location.accuracy = location.accuracy;
_location.altitude = location.altitude;
_location.bearing = location.bearing;
_location.speed = location.speed;
_location.time = location.time;
completer.complete(_location);
location.latitude = location.latitude;
location.longitude = location.longitude;
location.accuracy = location.accuracy;
location.altitude = location.altitude;
location.bearing = location.bearing;
location.speed = location.speed;
location.time = location.time;
completer.complete(location);
});
return completer.future;
......@@ -300,12 +310,14 @@ class BackgroundLocation {
bearing: locationData['bearing'],
speed: locationData['speed'],
time: locationData['time'],
isMock: locationData['is_mock']),
isMock: locationData['is_mock'],
),
);
//Send location updates using WebSocketManager
if (await webSocketManager.isNetworkAvailable()) {
webSocketManager.sendMessage(jsonEncode({
webSocketManager.sendMessage(
jsonEncode({
"command": "server_request",
"route": "attendenece_live_location_update",
"session_id": sessionId,
......@@ -321,8 +333,9 @@ class BackgroundLocation {
"speed_accuracy": locationData['speedAccuracyMetersPerSecond'],
"location_accuracy": locationData['accuracy'],
"location_provider": "",
}
}));
},
}),
);
// print("Hello GENERP! You're Online!");
showNotification("GEN ERP", "You're Online!");
} else {
......@@ -438,15 +451,16 @@ class Location {
double? time;
bool? isMock;
Location(
{@required this.longitude,
Location({
@required this.longitude,
@required this.latitude,
@required this.altitude,
@required this.accuracy,
@required this.bearing,
@required this.speed,
@required this.time,
@required this.isMock});
@required this.isMock,
});
toMap() {
var obj = {
......@@ -457,7 +471,7 @@ class Location {
'accuracy': accuracy,
'speed': speed,
'time': time,
'is_mock': isMock
'is_mock': isMock,
};
return obj;
}
......
......@@ -42,7 +42,7 @@ PreferredSizeWidget appbar(BuildContext context, title) {
);
}
PreferredSizeWidget appbarNew(BuildContext context, title,int color) {
PreferredSizeWidget appbarNew(BuildContext context, title, int color) {
return AppBar(
backgroundColor: Color(color),
automaticallyImplyLeading: false,
......@@ -53,9 +53,12 @@ PreferredSizeWidget appbarNew(BuildContext context, title,int color) {
children: [
InkResponse(
onTap: () => Navigator.pop(context, true),
child: SvgPicture.asset("assets/svg/appbar_back_button.svg", height: 25),
child: SvgPicture.asset(
"assets/svg/appbar_back_button.svg",
height: 25,
),
SizedBox(width: 10,),
),
SizedBox(width: 10),
InkResponse(
onTap: () => Navigator.pop(context, true),
child: Text(
......@@ -128,7 +131,13 @@ PreferredSizeWidget appbar2(BuildContext context, title, reset, widget) {
);
}
PreferredSizeWidget appbar2New(BuildContext context, title, reset, widget,int color) {
PreferredSizeWidget appbar2New(
BuildContext context,
title,
reset,
widget,
int color,
) {
return AppBar(
backgroundColor: Color(color),
automaticallyImplyLeading: false,
......@@ -141,22 +150,23 @@ PreferredSizeWidget appbar2New(BuildContext context, title, reset, widget,int co
InkResponse(
onTap: () {
HapticFeedback.selectionClick();
if(reset!=null){
if (reset != null) {
reset();
}
Navigator.pop(context, true);
},
child: SvgPicture.asset("assets/svg/appbar_back_button.svg", height: 25),
child: SvgPicture.asset(
"assets/svg/appbar_back_button.svg",
height: 25,
),
),
SizedBox(width: 10,),
SizedBox(width: 10),
Expanded(
flex: 4,
child: InkResponse(
onTap: () {
HapticFeedback.selectionClick();
if(reset!=null){
if (reset != null) {
reset();
}
Navigator.pop(context, true);
......@@ -207,10 +217,11 @@ Widget TextWidget(context, text) {
}
Widget errorWidget(context, text) {
if (text != null)
if (text != null) {
return Text(text!, style: TextStyle(color: Colors.red, fontSize: 12));
else
} else {
return SizedBox(height: 10);
}
}
Widget textControllerWidget(
......@@ -230,14 +241,17 @@ Widget textControllerWidget(
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if(textHead!="")...[
if (textHead != "") ...[
Padding(
padding: const EdgeInsets.only(bottom: 5.0, top: 8.0),
child: Text(textHead),
),
],
Container(
height: hintText == "Enter Description" || hintText=="Write Feedback" ? 150 : 50,
height:
hintText == "Enter Description" || hintText == "Write Feedback"
? 150
: 50,
alignment: Alignment.center,
decoration: BoxDecoration(
color: readonly ? Color(0xFFD7D7D7) : AppColors.text_field_color,
......@@ -250,7 +264,10 @@ Widget textControllerWidget(
controller: controller,
readOnly: readonly,
keyboardType: inputtype,
maxLines: hintText == "Enter Description" || hintText=="Write Feedback" ? 60 : 1,
maxLines:
hintText == "Enter Description" || hintText == "Write Feedback"
? 60
: 1,
onChanged: onChanged,
focusNode: focusNode,
onTapUpOutside: (event) {
......@@ -415,6 +432,6 @@ class MyNavigatorObserver extends NavigatorObserver {
routeSettingName = route.settings.name.toString();
// Called when a route has been popped off the navigator.
print('Route popped: ${route.settings.name}');
print('didPopped: ${didPopped}');
print('didPopped: $didPopped');
}
}
......@@ -32,13 +32,12 @@ class Dropdowntheme {
),
scrollbarTheme: ScrollbarThemeData(
radius: const Radius.circular(15),
thickness: MaterialStateProperty.all<double>(6),
thumbVisibility: MaterialStateProperty.all<bool>(true),
thickness: WidgetStateProperty.all<double>(6),
thumbVisibility: WidgetStateProperty.all<bool>(true),
),
);
final menuItemStyleData = const MenuItemStyleData(
height: 40,
padding: EdgeInsets.only(left: 14, right: 14),
);
}
This diff is collapsed.
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_svg/svg.dart';
import '../../Utils/app_colors.dart';
class JobDescriptionScreen extends StatefulWidget {
final String htmlData;
final String title;
final String designation;
const JobDescriptionScreen({
Key? key,
required this.htmlData,
this.title = "Job Description",
required this.designation,
}) : super(key: key);
@override
State<JobDescriptionScreen> createState() => _JobDescriptionScreenState();
}
class _JobDescriptionScreenState extends State<JobDescriptionScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.scaffold_bg_color,
/// AppBar
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.white,
title: Row(
children: [
InkResponse(
onTap: () => Navigator.pop(context, true),
child: SvgPicture.asset(
"assets/svg/appbar_back_button.svg",
height: 25,
),
),
const SizedBox(width: 10),
Text(
"Job Description",
style: TextStyle(
fontSize: 18,
fontFamily: "Plus Jakarta Sans",
fontWeight: FontWeight.w600,
color: AppColors.semi_black,
),
),
],
),
),
/// Body
body: SafeArea(
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 18),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
/// Designation Heading
Text(
widget.designation,
style: TextStyle(
color: AppColors.app_blue,
fontFamily: "JakartaSemiBold",
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 12),
/// HTML Description
Html(
data: widget.htmlData,
style: {
"h2": Style(
wordSpacing: 0,
letterSpacing: 0,
fontSize: FontSize(16),
fontFamily: "JakartaMedium",
color: AppColors.semi_black,
),
"h3": Style(
wordSpacing: 0,
letterSpacing: 0,
fontSize: FontSize(12),
fontFamily: "JakartaMedium",
color: AppColors.semi_black,
),
"p": Style(
wordSpacing: 0,
letterSpacing: 0,
fontSize: FontSize(12),
fontFamily: "JakartaMedium",
color: AppColors.grey_semi,
lineHeight: LineHeight.number(2.4),
),
"ul": Style(
wordSpacing: 0,
letterSpacing: 0,
fontSize: FontSize(15),
fontFamily: "JakartaMedium",
color: AppColors.grey_semi,
padding: HtmlPaddings.only(left: 12, right: 8),
lineHeight: LineHeight.number(1.4),
),
"li": Style(
wordSpacing: 0,
letterSpacing: 0,
fontSize: FontSize(14),
fontFamily: "JakartaMedium",
color: Colors.black,
padding: HtmlPaddings.only(left: 4),
lineHeight: LineHeight.number(1.4),
margin: Margins.only(bottom: 10),
),
"a": Style(
color: Colors.blue,
textDecoration: TextDecoration.underline,
),
},
onLinkTap: (url, _, __) {
debugPrint("Link tapped: $url");
if (url != null) {
// launchUrl(Uri.parse(url)); //
}
},
),
],
),
),
),
);
}
}
......@@ -27,15 +27,13 @@ Future main() async {
class WebERPIOS extends StatefulWidget {
final String url;
const WebERPIOS({Key? key, required this.url}) : super(key: key);
const WebERPIOS({super.key, required this.url});
@override
State<WebERPIOS> createState() => _WebERPIOSState();
}
class _WebERPIOSState extends State<WebERPIOS> {
Map _source = {ConnectivityResult.mobile: true};
final MyConnectivity _connectivity = MyConnectivity.instance;
......@@ -100,12 +98,18 @@ class _WebERPIOSState extends State<WebERPIOS> {
default:
connection = 'Offline';
}
return connection=="Online"?Platform.isAndroid
return connection == "Online"
? Platform.isAndroid
? WillPopScope(
onWillPop: () => onBackPressed(context),
child: SafeArea(top: false, bottom: true, child: _scaffold(context)),
child: SafeArea(
top: false,
bottom: true,
child: _scaffold(context),
),
)
: _scaffold(context):NoNetwork(context);
: _scaffold(context)
: NoNetwork(context);
}
Widget _scaffold(BuildContext context) {
......
......@@ -19,52 +19,88 @@ class Accountslist extends StatefulWidget {
}
class _AccountslistState extends State<Accountslist> {
ScrollController scrollController = ScrollController();
FocusNode focusNode1 = FocusNode();
FocusNode focusNode2 = FocusNode();
final ScrollController _scrollController = ScrollController();
int _currentPage = 1;
bool _isLoadingMore = false;
bool _hasMoreItems = true;
Map _source = {ConnectivityResult.mobile: true};
final MyConnectivity _connectivity = MyConnectivity.instance;
@override
void initState() {
// TODO: implement initState
super.initState();
_connectivity.initialise();
_connectivity.myStream.listen((source) {
setState(() => _source = source);
});
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
var provider = Provider.of<Accountslistprovider>(context, listen: false);
provider.commonAccountListAPIFunction(context);
provider.pageNum = 1;
provider.commonAccountListAPIFunction(context);
// if (scrollController.position.maxScrollExtent ==
// scrollController.offset) {
scrollController.addListener(() {
if (scrollController.position.pixels >=
scrollController.position.maxScrollExtent * 0.9 &&
!provider.isLoading &&
provider.hasMoreData) {
_scrollController.addListener(_scrollListener);
// fetch first page once
Future.microtask(() {
final provider =
Provider.of<Accountslistprovider>(context, listen: false);
provider.commonAccountListAPIFunction(context);
}
});
});
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
scrollController.dispose();
_scrollController.removeListener(_scrollListener);
_scrollController.dispose();
_connectivity.disposeStream();
super.dispose();
}
void _scrollListener() {
if (_scrollController.position.pixels >=
_scrollController.position.maxScrollExtent) {
_loadMoreItems(context);
}
}
void _loadMoreItems(BuildContext context) {
if (_isLoadingMore || !_hasMoreItems) return;
final provider = Provider.of<Accountslistprovider>(context, listen: false);
setState(() {
_isLoadingMore = true;
_currentPage++;
});
provider.commonAccountListAPIFunction(context, append: true).then((_) {
setState(() {
_isLoadingMore = false;
final newItems = provider.accountsList;
if (newItems.length < _currentPage * 15) {
//api gives 15 records
_hasMoreItems = false;
}
});
}).catchError((_) {
setState(() {
_isLoadingMore = false;
_currentPage--; // rollback
});
});
}
void _refreshList(BuildContext context) {
final provider = Provider.of<Accountslistprovider>(context, listen: false);
setState(() {
_currentPage = 1;
_hasMoreItems = true;
_isLoadingMore = false;
});
provider.commonAccountListAPIFunction(context);
}
@override
Widget build(BuildContext context) {
switch (_source.keys.toList()[0]) {
case ConnectivityResult.mobile:
connection = 'Online';
break;
case ConnectivityResult.wifi:
connection = 'Online';
break;
......@@ -72,6 +108,7 @@ class _AccountslistState extends State<Accountslist> {
default:
connection = 'Offline';
}
return (connection == "Online")
? Platform.isAndroid
? WillPopScope(
......@@ -86,12 +123,21 @@ class _AccountslistState extends State<Accountslist> {
: NoNetwork(context);
}
@override
Widget _scaffold(BuildContext context) {
return Consumer<Accountslistprovider>(
builder: (context, provider, child) {
var accountList = provider.accountsList;
print(accountList.length);
final accountList = provider.accountsList;
if (provider.isLoading && _currentPage == 1) {
return const Scaffold(
body: Center(child: CircularProgressIndicator()),
);
}
if (accountList.isEmpty) {
return Scaffold(body: Emptywidget(context));
}
return Scaffold(
resizeToAvoidBottomInset: true,
appBar: appbar2New(
......@@ -99,66 +145,44 @@ class _AccountslistState extends State<Accountslist> {
"Account List",
provider.resetValues,
Container(
padding: EdgeInsets.symmetric(horizontal: 5, vertical: 5),
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5),
child: InkResponse(
onTap: () {
_showFilterSheet1(context);
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: SvgPicture.asset("assets/svg/filter_ic.svg", height: 18),
child:
SvgPicture.asset("assets/svg/filter_ic.svg", height: 18),
),
),
),
0xFFFFFFFF
0xFFFFFFFF,
),
backgroundColor: AppColors.scaffold_bg_color,
body:
provider.isLoading
? Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation(AppColors.app_blue),
),
)
: accountList.isNotEmpty
? SizedBox(
child: Scrollbar(
child: SingleChildScrollView(
controller: scrollController,
child: Column(
children: [
ListView.builder(
itemCount:
accountList.length +
(provider.hasMoreData && provider.isLoading
? 1
: 0),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
body: RefreshIndicator(
onRefresh: () async => _refreshList(context),
child: ListView.builder(
controller: _scrollController,
padding: const EdgeInsets.all(12),
itemCount: accountList.length + (_hasMoreItems ? 1 : 0),
itemBuilder: (context, index) {
if (accountList.isEmpty) {
return SizedBox(
child: Center(
child: Text("No Data Available"),
),
);
}
if (index == accountList.length &&
!provider.isLoading) {
if (index >= accountList.length) {
return Padding(
padding: EdgeInsets.all(8.0),
padding: const EdgeInsets.symmetric(vertical: 16),
child: Center(
child: CircularProgressIndicator.adaptive(
valueColor:
AlwaysStoppedAnimation<Color>(
AppColors.app_blue,
),
),
child: _isLoadingMore
? const CircularProgressIndicator(
color: Colors.blue,
)
: !_hasMoreItems
? const Text("No more accounts to load")
: const SizedBox.shrink(),
),
);
}
final account = accountList[index];
return InkResponse(
onTap: () async {
print(
......@@ -260,132 +284,11 @@ class _AccountslistState extends State<Accountslist> {
);
},
),
],
),
),
),
)
: Emptywidget(context),
);
},
);
}
Future<void> _showFilterSheet(BuildContext context) {
return showModalBottomSheet(
useSafeArea: true,
isDismissible: true,
isScrollControlled: true,
showDragHandle: true,
backgroundColor: Colors.white,
enableDrag: true,
context: context,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
return SafeArea(
child: Consumer<Accountslistprovider>(
builder: (context, provider, child) {
return Container(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
margin: EdgeInsets.only(
bottom: 15,
left: 15,
right: 15,
top: 10,
),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: EdgeInsets.symmetric(vertical: 10),
child: Text(
"Filter",
style: TextStyle(
color: AppColors.app_blue,
fontSize: 16,
fontFamily: "JakartaMedium",
),
),
),
textControllerWidget(
context,
provider.companyNameController,
"Company Name",
"Enter Company Name",
(p0) {},
TextInputType.text,
false,
null,
focusNode1,
focusNode2,
TextInputAction.next,
),
textControllerWidget(
context,
provider.mobileNumberController,
"Mobile Number",
"Enter Mobile Number",
(p0) {},
TextInputType.number,
false,
FilteringTextInputFormatter.digitsOnly,
focusNode2,
null,
TextInputAction.done,
10,
),
InkResponse(
onTap: () {
Navigator.pop(context);
provider.pageNum = 1;
provider.commonAccountListAPIFunction(context);
provider.companyNameController.clear();
provider.mobileNumberController.clear();
},
child: Container(
height: 45,
alignment: Alignment.center,
margin: EdgeInsets.symmetric(
horizontal: 10,
vertical: 15,
),
padding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
decoration: BoxDecoration(
color: AppColors.app_blue,
borderRadius: BorderRadius.circular(15),
),
child: Text(
"Search",
style: TextStyle(
fontSize: 15,
fontFamily: "JakartaMedium",
color: Colors.white,
),
),
),
),
],
),
),
);
},
),
);
},
);
},
);
}
Future<void> _showFilterSheet1(BuildContext context) {
List<bool> isSelected = List.generate(
2,
......@@ -617,14 +520,9 @@ class _AccountslistState extends State<Accountslist> {
},
);
}
Future<bool> _onBackPressed(BuildContext context) async {
Provider.of<Accountslistprovider>(context, listen: false).pageNum = 1;
Navigator.pop(context, true);
return true;
}
}
// Divider(
// thickness: 0.5,
// color: Color(0xFFD7D7D7),
......
This diff is collapsed.
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