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,24 +748,38 @@ class Accountslistprovider extends ChangeNotifier {
companyNameController.text,
mobileNumberController.text,
);
if (data != null) {
print("pageNum $_pageNum");
if (data.error == "0") {
_hasMoreData = true;
_accountsList.addAll(data.accountList!);
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 {
_accountsList = data.accountList!;
}
_pageNum++;
_isLoading = false;
notifyListeners();
} else {
_hasMoreData = false;
_isLoading = false;
notifyListeners();
// Check if we still have more records
_hasMoreData = data.accountList!.length >= 10;
if (_hasMoreData) _pageNum++;
}
}
} catch (e, s) {}
} catch (e, s) {
debugPrint("Error in commonAccountListAPIFunction: $e");
} finally {
_isLoading = false;
notifyListeners();
}
}
resetValues() {
print("rv");
_selectedAccountType = null;
......
......@@ -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 {
_isLoading = true;
_crmLeadList.clear();
notifyListeners();
var HomeProv = Provider.of<HomescreenNotifier>(context, listen: false);
if (!append) {
_isLoading = true;
_errorMessage = null;
notifyListeners();
} 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');
_isLoading = false;
notifyListeners();
_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,
);
_requisitionList.clear();
_isLoading = true;
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 ?? [];
}
notifyListeners();
// check if more data
if (data.requistionList == null || data.requistionList!.length < 10) {
_hasMoreData = false;
} else {
_pageNum++;
}
} else {
_hasMoreData = false;
}
} catch (e, s) {}
} catch (e) {
_hasMoreData = false;
} finally {
_isLoading = false;
_isLoadingMore = false;
notifyListeners();
}
}
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);
_isLoading = true;
notifyListeners();
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 ?? [];
}
notifyListeners();
if (data.receiptsList == null || data.receiptsList!.length < 10) {
_hasMoreData = false; // no more pages
}
} else {
if (!append) _errorMessage = "No receipts found!";
_hasMoreData = false;
}
} catch (e, s) {}
} 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 {
......
......@@ -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);
_paymentsList.clear();
_isLoading = true;
notifyListeners();
final data = await ApiCalling.paymentRequisitionPaymentListAPI(prov.empId, prov.session,from,to);
if(data!=null){
if(data.error=="0"){
_isLoading = false;
_paymentsList = data.paymentsList!;
notifyListeners();
}else if(data.error=="1"){
_isLoading = 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();
} else {
_isLoadingMore = true;
notifyListeners();
}
}catch(e,s){
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 ?? [];
}
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) {
_response = result;
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();
} else {
_isLoading = false;
notifyListeners();
}
if (data.orderList == null || data.orderList!.length < 10) {
_hasMoreData = false;
}
} else {
if (!append) _errorMessage = "No orders found!";
_hasMoreData = false;
}
} catch (e, s) {}
} catch (e, s) {
_errorMessage = "Error: $e";
}
if (_selectedEmployee != null &&
!_employeesList.contains(_selectedEmployee)) {
_selectedEmployee = null;
_selectedEmpID = "";
_selectedEmpName = "";
}
_isLoading = false;
_isLoadingMore = false;
notifyListeners();
}
/// 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 = "";
}
notifyListeners();
debugPrint('empId: ${provider.empId}, session: ${provider.session}, pageNumber: $_currentPage');
if (data != null && data.error == "0") {
if (append) {
_paymentsList.addAll(data.orderList ?? []);
} else {
_isLoading = false;
_paymentsList = data.orderList ?? [];
}
notifyListeners();
if (data.orderList == null || data.orderList!.length < 10) {
_hasMoreData = false;
}
} else {
if (!append) _errorMessage = "No payments found!";
_hasMoreData = false;
}
} catch (e, s) {}
} catch (e, s) {
_errorMessage = "Error: $e";
}
_isLoading = false;
_isLoadingMore = false;
notifyListeners();
}
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 ?? [];
}
notifyListeners();
// 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) {}
} catch (e, s) {
_errorMessage = "Error: $e";
}
_isLoading = false;
_isLoadingMore = false;
notifyListeners();
}
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 ?? [];
}
notifyListeners();
// 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, s) {}
} catch (e) {
_errorMessage = "Error: $e";
}
_isLoading = false;
_isLoadingMore = false;
notifyListeners();
}
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,12 +7,12 @@ 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);
static Color profile_card_gradient2 = Color(0xFF97D9FF);
static Color profile_card = Color(0xFFDBF2FF);
static Color profile_card_gradient1 = Color(0xFFCFEEFF);
static Color profile_card_gradient2 = Color(0xFF97D9FF);
static Color profile_card = Color(0xFFDBF2FF);
static Color scaffold_bg_color = Color(0xFFF6F6F8);
static Color button_disabled = Color(0xFFBEE5FB);
static Color text_field_color = Color(0xFFF0F4F5);
......@@ -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);
}
\ No newline at end of file
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;
......@@ -52,26 +53,28 @@ class BackgroundLocation {
try {
final InitializationSettings initializationSettings =
InitializationSettings(
android: AndroidInitializationSettings('@mipmap/ic_launcher'),
iOS: DarwinInitializationSettings(
requestAlertPermission: false,
requestBadgePermission: false,
requestSoundPermission: false,
));
android: AndroidInitializationSettings('@mipmap/ic_launcher'),
iOS: DarwinInitializationSettings(
requestAlertPermission: false,
requestBadgePermission: false,
requestSoundPermission: false,
),
);
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
// Disable sound for the default notification channel
const AndroidNotificationChannel androidChannel =
AndroidNotificationChannel(
customChannelId,
customChannelName,
description: customChannelDescription,
importance: Importance.max,
playSound: false, // Set this to false to disable playing sound
);
customChannelId,
customChannelName,
description: customChannelDescription,
importance: Importance.max,
playSound: false, // Set this to false to disable playing sound
);
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();
......@@ -114,29 +118,31 @@ class BackgroundLocation {
static void showNotification(String title, String message) async {
const AndroidNotificationDetails androidPlatformChannelSpecifics =
AndroidNotificationDetails(
customChannelId,
customChannelName,
importance: Importance.defaultImportance,
ticker: 'ticker',
ongoing: true,
playSound: false,
);
customChannelId,
customChannelName,
importance: Importance.defaultImportance,
ticker: 'ticker',
ongoing: true,
playSound: false,
);
const DarwinNotificationDetails darwinNotificationDetails =
DarwinNotificationDetails(
presentSound: false,
sound: "",
// Set this to false to disable playing sound
);
presentSound: false,
sound: "",
// Set this to false to disable playing sound
);
const NotificationDetails platformChannelSpecifics = NotificationDetails(
android: androidPlatformChannelSpecifics,
iOS: darwinNotificationDetails);
android: androidPlatformChannelSpecifics,
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;
......@@ -293,36 +303,39 @@ class BackgroundLocation {
// Call the user passed function
location(
Location(
latitude: locationData['latitude'],
longitude: locationData['longitude'],
altitude: locationData['altitude'],
accuracy: locationData['accuracy'],
bearing: locationData['bearing'],
speed: locationData['speed'],
time: locationData['time'],
isMock: locationData['is_mock']),
latitude: locationData['latitude'],
longitude: locationData['longitude'],
altitude: locationData['altitude'],
accuracy: locationData['accuracy'],
bearing: locationData['bearing'],
speed: locationData['speed'],
time: locationData['time'],
isMock: locationData['is_mock'],
),
);
//Send location updates using WebSocketManager
if (await webSocketManager.isNetworkAvailable()) {
webSocketManager.sendMessage(jsonEncode({
"command": "server_request",
"route": "attendenece_live_location_update",
"session_id": sessionId,
"ref_data": {
webSocketManager.sendMessage(
jsonEncode({
"command": "server_request",
"route": "attendenece_live_location_update",
"session_id": sessionId,
"location":
"${locationData['latitude']},${locationData['longitude']}",
"speed": locationData['speed'],
"altitude": locationData['altitude'],
"direction": locationData['bearing'],
"direction_accuracy": locationData['bearingAccuracyDegrees'],
"altitude_accuracy": locationData['verticalAccuracyMeters'],
"speed_accuracy": locationData['speedAccuracyMetersPerSecond'],
"location_accuracy": locationData['accuracy'],
"location_provider": "",
}
}));
"ref_data": {
"session_id": sessionId,
"location":
"${locationData['latitude']},${locationData['longitude']}",
"speed": locationData['speed'],
"altitude": locationData['altitude'],
"direction": locationData['bearing'],
"direction_accuracy": locationData['bearingAccuracyDegrees'],
"altitude_accuracy": locationData['verticalAccuracyMeters'],
"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,
@required this.latitude,
@required this.altitude,
@required this.accuracy,
@required this.bearing,
@required this.speed,
@required this.time,
@required this.isMock});
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,
});
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!="")...[
Padding(
padding: const EdgeInsets.only(bottom: 5.0, top: 8.0),
child: Text(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),
);
}
\ No newline at end of file
}
This source diff could not be displayed because it is too large. You can view the blob instead.
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
? WillPopScope(
onWillPop: () => onBackPressed(context),
child: SafeArea(top: false, bottom: true, child: _scaffold(context)),
)
: _scaffold(context):NoNetwork(context);
return connection == "Online"
? Platform.isAndroid
? WillPopScope(
onWillPop: () => onBackPressed(context),
child: SafeArea(
top: false,
bottom: true,
child: _scaffold(context),
),
)
: _scaffold(context)
: NoNetwork(context);
}
Widget _scaffold(BuildContext context) {
......
This diff is collapsed.
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