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),
);
}
......@@ -9,6 +9,7 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:generp/Utils/commonWidgets.dart';
import '../Utils/commonServices.dart';
import 'JobDescription.dart';
import 'genTracker/ScanEnterGeneratorIDScreen.dart';
import 'hrm/HrmDashboardScreen.dart';
import 'notifierExports.dart';
......@@ -20,11 +21,6 @@ import 'package:location/location.dart' as loc;
import '../Utils/app_colors.dart';
import 'inventory/InventoryScreen.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_html/flutter_html.dart' as html;
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
......@@ -46,14 +42,13 @@ class _MyHomePageState extends State<MyHomePage> {
setState(() => _source = source);
});
var prov = Provider.of<HomescreenNotifier>(context, listen: false);
var prof_prov = Provider.of<ProfileNotifer>(context, listen: false);
// var jobDisc_prov = Provider.of<fetchJobDescription>(context, listen: false);
var profProv = Provider.of<ProfileNotifer>(context, listen: false);
Future.microtask(() {
prov.DashboardApiFunction(context);
});
Future.delayed(Duration(milliseconds: 600), () {
prof_prov.ProfileApiFunction(prov, context);
prof_prov.VersionApiFunction();
profProv.ProfileApiFunction(prov, context);
profProv.VersionApiFunction();
});
super.initState();
}
......@@ -68,8 +63,8 @@ class _MyHomePageState extends State<MyHomePage> {
actions: [
TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.white),
overlayColor: MaterialStateProperty.all(Colors.white),
backgroundColor: WidgetStateProperty.all(Colors.white),
overlayColor: WidgetStateProperty.all(Colors.white),
),
onPressed: () => Navigator.of(context).pop(false),
child: Text(
......@@ -80,8 +75,8 @@ class _MyHomePageState extends State<MyHomePage> {
const SizedBox(height: 16),
TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.white),
overlayColor: MaterialStateProperty.all(Colors.white70),
backgroundColor: WidgetStateProperty.all(Colors.white),
overlayColor: WidgetStateProperty.all(Colors.white70),
),
onPressed:
() => SystemChannels.platform.invokeMethod(
......@@ -133,6 +128,7 @@ class _MyHomePageState extends State<MyHomePage> {
Widget build(BuildContext context) {
double screenWidth = MediaQuery.of(context).size.width;
double screenHeight = MediaQuery.of(context).size.height;
double bottomPadding = MediaQuery.of(context).padding.bottom;
switch (_source.keys.toList()[0]) {
case ConnectivityResult.mobile:
connection = 'Online';
......@@ -227,8 +223,8 @@ class _MyHomePageState extends State<MyHomePage> {
toolbarHeight: 0,
backgroundColor: Colors.white,
),
body: SingleChildScrollView(
child: Container(
body: Container(
height: screenHeight,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
......@@ -240,7 +236,26 @@ class _MyHomePageState extends State<MyHomePage> {
end: Alignment.bottomCenter,
),
),
child: SingleChildScrollView(
child: Column(
children: [
Stack(
children: [
// Container(
// height: screenHeight,
// decoration: BoxDecoration(
// gradient: LinearGradient(
// colors: [
// AppColors.scaffold_bg_color,
// AppColors.scaffold_bg_color,
// Color(0xFFCEEDFF),
// ],
// begin: Alignment.topCenter,
// end: Alignment.bottomCenter,
// ),
// ),
// ),
Column(
mainAxisSize: MainAxisSize.min,
children: [
InkResponse(
......@@ -268,7 +283,9 @@ class _MyHomePageState extends State<MyHomePage> {
right: 10,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
borderRadius: BorderRadius.circular(
20,
),
gradient: LinearGradient(
colors: [
AppColors.profile_card,
......@@ -279,7 +296,8 @@ class _MyHomePageState extends State<MyHomePage> {
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment:
MainAxisAlignment.center,
children: [
Expanded(
flex: 8,
......@@ -291,9 +309,11 @@ class _MyHomePageState extends State<MyHomePage> {
),
child: Column(
mainAxisAlignment:
MainAxisAlignment.center,
MainAxisAlignment
.center,
crossAxisAlignment:
CrossAxisAlignment.start,
CrossAxisAlignment
.start,
children: [
// Text(
......@@ -311,8 +331,11 @@ class _MyHomePageState extends State<MyHomePage> {
minFontSize: 12,
style: TextStyle(
fontSize: 16,
color: AppColors.app_blue,
fontFamily: "JakartaSemiBold",
color:
AppColors
.app_blue,
fontFamily:
"JakartaSemiBold",
),
maxLines: 2,
),
......@@ -322,8 +345,11 @@ class _MyHomePageState extends State<MyHomePage> {
minFontSize: 10,
style: TextStyle(
fontSize: 14,
color: AppColors.semi_black,
fontFamily: "JakartaRegular",
color:
AppColors
.semi_black,
fontFamily:
"JakartaRegular",
),
maxLines: 1,
),
......@@ -339,21 +365,27 @@ class _MyHomePageState extends State<MyHomePage> {
Text(
"${profile.employeeeID}",
style: TextStyle(
color: AppColors.semi_black,
fontFamily: "JakartaRegular",
color:
AppColors
.semi_black,
fontFamily:
"JakartaRegular",
fontSize: 14,
),
),
SizedBox(height: 12),
Row(
mainAxisAlignment:
MainAxisAlignment.start,
MainAxisAlignment
.start,
children: [
Container(
width: 12,
height: 12,
decoration: BoxDecoration(
shape: BoxShape.circle,
shape:
BoxShape
.circle,
color:
homescreen.onlineStatus ==
"Online"
......@@ -370,7 +402,9 @@ class _MyHomePageState extends State<MyHomePage> {
fontSize: 14,
fontFamily:
"JakartaRegular",
color: Color(0xFF2D2D2D),
color: Color(
0xFF2D2D2D,
),
),
),
],
......@@ -388,30 +422,43 @@ class _MyHomePageState extends State<MyHomePage> {
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
CrossAxisAlignment
.start,
mainAxisAlignment:
MainAxisAlignment.center,
MainAxisAlignment
.center,
children: [
SizedBox(
width: 60,
height: 60,
child: ClipRRect(
borderRadius:
BorderRadius.circular(50),
BorderRadius.circular(
50,
),
child: CachedNetworkImage(
cacheKey:
profile.profileImage,
profile
.profileImage,
fit: BoxFit.cover,
imageUrl:
"${profile.profileImage}",
useOldImageOnUrlChange:
false,
placeholder:
(context, url) =>
(
context,
url,
) =>
CircularProgressIndicator.adaptive(),
errorWidget:
(context, url, error) =>
Icon(Icons.error),
(
context,
url,
error,
) => Icon(
Icons.error,
),
),
),
),
......@@ -426,7 +473,8 @@ class _MyHomePageState extends State<MyHomePage> {
),
SizedBox(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
// if (coreFilteredItems.isNotEmpty) ...[
// Container(
......@@ -589,14 +637,15 @@ class _MyHomePageState extends State<MyHomePage> {
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(
14,
),
borderRadius:
BorderRadius.circular(14),
),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: List.generate(4, (ic) {
children: List.generate(4, (
ic,
) {
return Expanded(
child: InkResponse(
onTap: () async {
......@@ -608,7 +657,9 @@ class _MyHomePageState extends State<MyHomePage> {
context,
MaterialPageRoute(
builder:
(context) =>
(
context,
) =>
AttendanceScreen(),
settings: RouteSettings(
arguments:
......@@ -618,7 +669,8 @@ class _MyHomePageState extends State<MyHomePage> {
);
break;
case "ERP":
bool isGpsEnabled =
bool
isGpsEnabled =
await Geolocator.isLocationServiceEnabled();
if (isGpsEnabled) {
if (Platform
......@@ -631,8 +683,7 @@ class _MyHomePageState extends State<MyHomePage> {
context,
) => WebErpScreen(
erp_url:
homescreen
.webPageUrl,
homescreen.webPageUrl,
),
),
);
......@@ -645,8 +696,7 @@ class _MyHomePageState extends State<MyHomePage> {
context,
) => WebERPIOS(
url:
homescreen
.webPageUrl,
homescreen.webPageUrl,
),
),
);
......@@ -656,7 +706,8 @@ class _MyHomePageState extends State<MyHomePage> {
}
break;
case "Whizzdom":
bool isGpsEnabled =
bool
isGpsEnabled =
await Geolocator.isLocationServiceEnabled();
if (isGpsEnabled) {
res = await Navigator.push(
......@@ -667,8 +718,7 @@ class _MyHomePageState extends State<MyHomePage> {
context,
) => WebWhizzdomScreen(
whizzdom_url:
homescreen
.whizzdomPageUrl,
homescreen.whizzdomPageUrl,
),
),
);
......@@ -681,7 +731,9 @@ class _MyHomePageState extends State<MyHomePage> {
context,
MaterialPageRoute(
builder:
(context) =>
(
context,
) =>
Financedashboard(),
settings: RouteSettings(
arguments:
......@@ -713,13 +765,16 @@ class _MyHomePageState extends State<MyHomePage> {
filteredItems[ic]['icon'] ??
"-",
),
SizedBox(height: 10),
SizedBox(
height: 10,
),
Text(
filteredItems[ic]['name'] ??
"-",
maxLines: 2,
textAlign:
TextAlign.center,
TextAlign
.center,
style: TextStyle(
fontSize: 12,
fontFamily:
......@@ -761,7 +816,8 @@ class _MyHomePageState extends State<MyHomePage> {
context,
MaterialPageRoute(
builder:
(context) => InventoryScreen(),
(context) =>
InventoryScreen(),
),
);
if (res == true) {
......@@ -780,9 +836,8 @@ class _MyHomePageState extends State<MyHomePage> {
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(
14,
),
borderRadius:
BorderRadius.circular(14),
),
child: Row(
mainAxisAlignment:
......@@ -800,14 +855,16 @@ class _MyHomePageState extends State<MyHomePage> {
child: SizedBox(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
CrossAxisAlignment
.start,
children: [
Text(
"Inventory",
style: TextStyle(
fontSize: 14,
color:
AppColors.app_blue,
AppColors
.app_blue,
fontFamily:
"JakartaMedium",
),
......@@ -817,7 +874,8 @@ class _MyHomePageState extends State<MyHomePage> {
style: TextStyle(
fontSize: 14,
color:
AppColors.grey_semi,
AppColors
.grey_semi,
fontFamily:
"JakartaMedium",
),
......@@ -857,11 +915,13 @@ class _MyHomePageState extends State<MyHomePage> {
),
child: GridView.builder(
shrinkWrap: true,
itemCount: filteredItems.length,
itemCount:
filteredItems.length,
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 2 / 1.1,
childAspectRatio:
2 / 1.1,
),
itemBuilder: (context, ci) {
return InkResponse(
......@@ -876,7 +936,8 @@ class _MyHomePageState extends State<MyHomePage> {
builder:
(context) =>
AttendanceScreen(),
settings: RouteSettings(
settings:
RouteSettings(
arguments:
'AttendanceScreen',
),
......@@ -887,7 +948,8 @@ class _MyHomePageState extends State<MyHomePage> {
bool isGpsEnabled =
await Geolocator.isLocationServiceEnabled();
if (isGpsEnabled) {
if (Platform.isAndroid) {
if (Platform
.isAndroid) {
res = await Navigator.push(
context,
MaterialPageRoute(
......@@ -896,8 +958,7 @@ class _MyHomePageState extends State<MyHomePage> {
context,
) => WebErpScreen(
erp_url:
homescreen
.webPageUrl,
homescreen.webPageUrl,
),
),
);
......@@ -910,8 +971,7 @@ class _MyHomePageState extends State<MyHomePage> {
context,
) => WebERPIOS(
url:
homescreen
.webPageUrl,
homescreen.webPageUrl,
),
),
);
......@@ -932,8 +992,7 @@ class _MyHomePageState extends State<MyHomePage> {
context,
) => WebWhizzdomScreen(
whizzdom_url:
homescreen
.whizzdomPageUrl,
homescreen.whizzdomPageUrl,
),
),
);
......@@ -948,7 +1007,8 @@ class _MyHomePageState extends State<MyHomePage> {
builder:
(context) =>
Financedashboard(),
settings: RouteSettings(
settings:
RouteSettings(
arguments:
'Financedashboard',
),
......@@ -967,24 +1027,30 @@ class _MyHomePageState extends State<MyHomePage> {
},
child: Container(
padding: EdgeInsets.symmetric(
padding:
EdgeInsets.symmetric(
vertical: 5,
horizontal: 15,
),
margin: EdgeInsets.symmetric(
margin:
EdgeInsets.symmetric(
vertical: 7,
horizontal: 5,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius:
BorderRadius.circular(14),
BorderRadius.circular(
14,
),
),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
MainAxisAlignment
.center,
crossAxisAlignment:
CrossAxisAlignment.center,
CrossAxisAlignment
.center,
children: [
Expanded(
flex: 2,
......@@ -1001,10 +1067,10 @@ class _MyHomePageState extends State<MyHomePage> {
filteredItems[ci]['name'] ??
"-",
style: TextStyle(
fontSize: 14,
fontSize:
14,
color:
AppColors
.app_blue,
AppColors.app_blue,
fontFamily:
"JakartaMedium",
),
......@@ -1013,10 +1079,10 @@ class _MyHomePageState extends State<MyHomePage> {
filteredItems[ci]['subtitle'] ??
"-",
style: TextStyle(
fontSize: 12,
fontSize:
12,
color:
AppColors
.grey_semi,
AppColors.grey_semi,
fontFamily:
"JakartaMedium",
),
......@@ -1276,8 +1342,10 @@ class _MyHomePageState extends State<MyHomePage> {
),
child: GridView.builder(
shrinkWrap: true,
itemCount: coreFilteredItems.length,
physics: NeverScrollableScrollPhysics(),
itemCount:
coreFilteredItems.length,
physics:
NeverScrollableScrollPhysics(),
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
......@@ -1296,7 +1364,8 @@ class _MyHomePageState extends State<MyHomePage> {
builder:
(context) =>
Gentrackerdashboard(),
settings: RouteSettings(
settings:
RouteSettings(
arguments:
'Gentrackerdashboard',
),
......@@ -1341,7 +1410,8 @@ class _MyHomePageState extends State<MyHomePage> {
builder:
(context) =>
CrmdashboardScreen(),
settings: RouteSettings(
settings:
RouteSettings(
name:
'CrmdashboardScreen',
),
......@@ -1354,7 +1424,8 @@ class _MyHomePageState extends State<MyHomePage> {
builder:
(context) =>
HrmdashboardScreen(),
settings: RouteSettings(
settings:
RouteSettings(
name:
'CrmdashboardScreen',
),
......@@ -1372,24 +1443,30 @@ class _MyHomePageState extends State<MyHomePage> {
},
child: Container(
padding: EdgeInsets.symmetric(
padding:
EdgeInsets.symmetric(
vertical: 5,
horizontal: 15,
),
margin: EdgeInsets.symmetric(
margin:
EdgeInsets.symmetric(
vertical: 7,
horizontal: 5,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius:
BorderRadius.circular(14),
BorderRadius.circular(
14,
),
),
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
MainAxisAlignment
.center,
crossAxisAlignment:
CrossAxisAlignment.center,
CrossAxisAlignment
.center,
children: [
Expanded(
flex: 2,
......@@ -1406,7 +1483,8 @@ class _MyHomePageState extends State<MyHomePage> {
coreFilteredItems[ci]['name'] ??
"-",
style: TextStyle(
fontSize: 14,
fontSize:
14,
color:
AppColors
.app_blue,
......@@ -1418,7 +1496,8 @@ class _MyHomePageState extends State<MyHomePage> {
coreFilteredItems[ci]['subtitle'] ??
"-",
style: TextStyle(
fontSize: 12,
fontSize:
12,
color:
AppColors
.grey_semi,
......@@ -1436,8 +1515,6 @@ class _MyHomePageState extends State<MyHomePage> {
child: SvgPicture.asset(
coreFilteredItems[ci]['icon'] ??
"-",
height: 40,
width: 40,
),
),
],
......@@ -1451,12 +1528,15 @@ class _MyHomePageState extends State<MyHomePage> {
],
),
),
SizedBox(height: 10),
Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 40,
alignment: Alignment.bottomCenter,
margin: EdgeInsets.only(bottom: 20),
margin: EdgeInsets.only(
bottom: bottomPadding,
),
child: Image.asset(
fit: BoxFit.scaleDown,
"assets/images/horizontal_logo.png",
......@@ -1681,6 +1761,10 @@ class _MyHomePageState extends State<MyHomePage> {
// ),
],
),
],
),
],
),
),
),
// floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
......@@ -1695,6 +1779,12 @@ class _MyHomePageState extends State<MyHomePage> {
}
Future<void> _showProfileBottomSheet(BuildContext context) {
final profileNotifier = Provider.of<ProfileNotifer>(context, listen: false);
profileNotifier.fetchJobDescription(
Provider.of<HomescreenNotifier>(context, listen: false),
context,
);
return showModalBottomSheet(
useSafeArea: true,
isDismissible: true,
......@@ -1819,20 +1909,16 @@ class _MyHomePageState extends State<MyHomePage> {
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 20),
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 15,
),
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
child: ListView.builder(
shrinkWrap: true,
itemCount: 5,
physics:
NeverScrollableScrollPhysics(),
const NeverScrollableScrollPhysics(),
itemCount: 5,
itemBuilder: (context, index) {
final textHeadings = [
"Company",
......@@ -1841,34 +1927,8 @@ class _MyHomePageState extends State<MyHomePage> {
"Employee ID",
"Mobile Number",
];
return SizedBox(
height: 40,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
"${textHeadings[index]}",
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 14,
fontFamily: "JakartaMedium",
color: AppColors.app_blue,
),
),
),
);
},
),
),
Expanded(
flex: 1,
child: ListView.builder(
shrinkWrap: true,
itemCount: 5,
physics:
NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
final textHeadings = [
final textValues = [
profile.company,
profile.branch,
profile.designation,
......@@ -1877,43 +1937,89 @@ class _MyHomePageState extends State<MyHomePage> {
];
final itemText =
textHeadings[index]
?.toString() ??
"-";
textValues[index]?.toString() ?? "-";
return SizedBox(
height: 40,
child: Align(
alignment: Alignment.centerLeft,
child: InkWell(
onTap: () async {
return Padding(
padding: const EdgeInsets.symmetric(
vertical: 10,
),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
/// Heading
Expanded(
flex: 1,
child: Text(
textHeadings[index],
style: TextStyle(
fontSize: 14,
fontFamily: "JakartaMedium",
color: AppColors.app_blue,
),
),
),
/// Value + "View" (only for Designation row)
Expanded(
flex: 1,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
itemText,
style: TextStyle(
fontSize: 14,
color:
AppColors.semi_black,
),
),
if (profileNotifier
.response
?.jobDescription
?.jobDescription !=
null &&
profileNotifier
.response!
.jobDescription!
.jobDescription !=
"")
if (index ==
2) // only for Designation
InkWell(
onTap:
index == 2
? () async {
/// now navigate to job desc screen
final profileNotifier =
Provider.of<
ProfileNotifer
>(
context,
listen: false,
listen:
false,
);
// Call API
await profileNotifier
.fetchJobDescription(
await profileNotifier.fetchJobDescription(
Provider.of<
HomescreenNotifier
>(
context,
listen: false,
listen:
false,
),
context,
);
// fetching, check response
if (profileNotifier
.response !=
null &&
profileNotifier
.response!
.jobDescription !=
null) {
if (profileNotifier
null &&
profileNotifier
.response!
.jobDescription!
.jobDescription !=
......@@ -1923,63 +2029,69 @@ class _MyHomePageState extends State<MyHomePage> {
.jobDescription!
.jobDescription !=
"") {
showJobDescriptionSheet(
context: context,
Navigator.push(
context,
MaterialPageRoute(
builder:
(
context,
) => JobDescriptionScreen(
htmlData:
profileNotifier
.response!
.jobDescription!
.jobDescription ??
profileNotifier.response!.jobDescription!.jobDescription ??
"<p>No description</p>",
title:
"Job Description", //profileNotifier.response!.jobDescription!.name ??
profileNotifier.response!.jobDescription!.name ??
"Job Description",
designation:
itemText,
),
),
);
}
} else {
ScaffoldMessenger.of(
context,
).showSnackBar(
SnackBar(
content: Text(
profileNotifier
.errorMessage ??
profileNotifier.errorMessage ??
"Failed to fetch job description",
),
),
);
}
},
// no click for others
child: Text(
itemText,
textAlign: TextAlign.left,
}
: null,
child: Row(
children: [
Text(
"View",
style: TextStyle(
fontSize: 14,
fontWeight:
FontWeight
.w600,
color:
index == 2
? AppColors
.semi_black
: AppColors
.semi_black,
decoration:
index == 2
? TextDecoration
.underline
: null,
decorationStyle:
TextDecorationStyle
.dotted,
Colors.blue,
),
),
Icon(
Icons.play_arrow,
size: 18,
color: Color(
0xFF1487C9,
),
),
);
},
],
),
),
],
),
),
],
),
);
},
),
),
],
),
......@@ -2041,258 +2153,6 @@ class _MyHomePageState extends State<MyHomePage> {
);
}
// Job Descriptions
Future<void> showJobDescriptionSheet({
required BuildContext context,
required String htmlData, // pass details_articles!.description
String title = "Job Description",
}) {
return showModalBottomSheet(
useSafeArea: true,
isDismissible: true,
isScrollControlled: true,
showDragHandle: true,
enableDrag: true,
backgroundColor: Colors.white,
context: context,
builder: (context) {
return SafeArea(
child: Container(
margin: const EdgeInsets.only(
bottom: 15,
left: 15,
right: 15,
top: 15,
),
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
/// Heading
Text(
title,
style: TextStyle(
fontFamily: "JakartaMedium",
fontSize: 18,
color: AppColors.app_blue,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 5),
/// HTML description
Html(
data: 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: 10,
right: 8,
), // fixed for v3.0.0
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,
), // bullet text line height
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)); // needs url_launcher
}
},
),
const SizedBox(height: 6),
/// Close button
InkWell(
onTap: () => Navigator.pop(context),
child: Container(
alignment: Alignment.center,
height: 45,
margin: const EdgeInsets.symmetric(
horizontal: 5.0,
vertical: 5.0,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.0),
),
child: Center(
child: Text(
"Close",
textAlign: TextAlign.center,
style: TextStyle(
color: AppColors.app_blue,
fontFamily: "JakartaMedium",
fontSize: 15,
),
),
),
),
),
],
),
),
),
);
},
);
}
// Future<void> showJobDescriptionSheet(
// BuildContext context,
// List<String> jobPoints,
// ) {
// return showModalBottomSheet(
// useSafeArea: true,
// isDismissible: true,
// isScrollControlled: true,
// showDragHandle: true,
// enableDrag: true,
// backgroundColor: Colors.white,
// context: context,
// builder: (context) {
// return SafeArea(
// child: Container(
// margin: const EdgeInsets.only(
// bottom: 15,
// left: 15,
// right: 15,
// top: 30,
// ),
// padding: EdgeInsets.only(
// bottom: MediaQuery.of(context).viewInsets.bottom,
// ),
// child: SingleChildScrollView(
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
// children: [
// /// Heading
// Text(
// "Job Description",
// style: TextStyle(
// fontFamily: "JakartaMedium",
// fontSize: 16,
// color: AppColors.app_blue, // same as Logout "Yes, Logout" button
// fontWeight: FontWeight.w600,
// ),
// ),
// const SizedBox(height: 15),
//
// /// Bullet points list
// ...jobPoints.map(
// (point) => Padding(
// padding: const EdgeInsets.symmetric(vertical: 6),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// "• ",
// style: TextStyle(
// fontSize: 14,
// color: AppColors.semi_black,
// ),
// ),
// Expanded(
// child: Text(
// point,
// style: TextStyle(
// fontSize: 14,
// color: AppColors.semi_black,
// fontFamily: "JakartaRegular",
// height: 1.4, // line spacing
// ),
// ),
// ),
// ],
// ),
// ),
// ),
//
// const SizedBox(height: 20),
//
// /// Close button
// InkWell(
// onTap: () => Navigator.pop(context),
// child: Container(
// alignment: Alignment.center,
// height: 45,
// margin: const EdgeInsets.symmetric(
// horizontal: 5.0,
// vertical: 5.0,
// ),
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(15.0),
// ),
// child: Center(
// child: Text(
// "Close",
// textAlign: TextAlign.center,
// style: TextStyle(
// color: AppColors.app_blue,
// fontFamily: "JakartaMedium",
// fontSize: 15,
// ),
// ),
// ),
// ),
// ),
// ],
// ),
// ),
// ),
// );
// },
// );
// }
Future<void> _showLogoutBottomSheet(BuildContext context) {
return showModalBottomSheet(
useSafeArea: true,
......
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),
......
......@@ -42,17 +42,21 @@ class _LeadlistbymodeState extends State<Leadlistbymode> {
Map _source = {ConnectivityResult.mobile: true};
final MyConnectivity _connectivity = MyConnectivity.instance;
final ScrollController _scrollController = ScrollController();
@override
void initState() {
// TODO: implement initState
super.initState();
_connectivity.initialise();
_connectivity.myStream.listen((source) {
setState(() => _source = source);
});
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
WidgetsBinding.instance.addPostFrameCallback((_) {
final provider = Provider.of<Leadlistprovider>(context, listen: false);
provider.crmLeadListViewAPIFunction(context, widget.mode);
provider.resetPagination();
if (widget.filter != null) {
provider.crmLeadListAPIFunction(
context,
......@@ -78,16 +82,32 @@ class _LeadlistbymodeState extends State<Leadlistbymode> {
"",
);
}
_scrollController.addListener(() {
if (_scrollController.position.pixels >=
_scrollController.position.maxScrollExtent - 200) {
provider.loadMore(
context,
widget.mode,
widget.filter?.status ?? "",
widget.filter?.openStatus ?? "",
"",
"",
"",
"",
"",
);
}
});
});
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
_scrollController.dispose();
_connectivity.disposeStream();
super.dispose();
}
@override
Widget build(BuildContext context) {
switch (_source.keys.toList()[0]) {
......@@ -142,29 +162,31 @@ class _LeadlistbymodeState extends State<Leadlistbymode> {
0xFFFFFFFF,
),
backgroundColor: AppColors.scaffold_bg_color,
body:
provider.isLoading
body: provider.isLoading
? Center(
child: CircularProgressIndicator.adaptive(
valueColor: AlwaysStoppedAnimation<Color>(
AppColors.app_blue,
),
valueColor:
AlwaysStoppedAnimation<Color>(AppColors.app_blue),
),
)
: crmLists.isNotEmpty
? SizedBox(
child: Scrollbar(
thumbVisibility: false,
? Scrollbar(
controller: _scrollController,
child: ListView.builder(
itemCount: crmLists.length,
shrinkWrap: true,
physics: AlwaysScrollableScrollPhysics(),
controller: _scrollController,
itemCount: crmLists.length + (provider.hasMoreData ? 1 : 0),
itemBuilder: (context, index) {
if (crmLists.isEmpty) {
return SizedBox(
child: Center(child: Text("No Data Available")),
);
if (index == crmLists.length) {
return provider.isLoadingMore
? const Padding(
padding: EdgeInsets.all(16),
child: Center(
child: CircularProgressIndicator()),
)
: const SizedBox.shrink();
}
final lead = crmLists[index];
return InkResponse(
onTap: () async {
HapticFeedback.selectionClick();
......@@ -266,7 +288,6 @@ class _LeadlistbymodeState extends State<Leadlistbymode> {
);
},
),
),
)
: Emptywidget(context),
);
......@@ -274,1324 +295,8 @@ class _LeadlistbymodeState extends State<Leadlistbymode> {
);
}
// 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<Leadlistprovider>(
// builder: (context, provider, child) {
// return Container(
// margin: EdgeInsets.only(
// bottom: 15,
// left: 15,
// right: 15,
// top: 10,
// ),
// padding: EdgeInsets.only(
// bottom: MediaQuery.of(context).viewInsets.bottom,
// ),
// child: SingleChildScrollView(
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisSize: MainAxisSize.min,
// children: [
// SizedBox(height: 15),
// Row(
// children: [
// Expanded(
// child: Text(
// "Filter",
// style: TextStyle(
// color: AppColors.app_blue,
// fontSize: 14,
// ),
// ),
// ),
// ],
// ),
// textControllerWidget(
// context,
// provider.sLeadIDController,
// "Lead ID",
// "Enter Lead ID",
// provider.onChangedLeadId,
// TextInputType.text,
// false,
// null,
// ),
// if (widget.mode != "executive") ...[
// TextWidget(context, "Employee"),
// DropdownButtonHideUnderline(
// child: Row(
// children: [
// Expanded(
// child: DropdownButton2<Employees>(
// hint: Text(
// "Select Source",
// style: TextStyle(fontSize: 14),
// ),
// items:
// provider.employeesList
// .map(
// (slist) =>
// DropdownMenuItem<Employees>(
// value: slist,
// child: Text(
// slist.name!,
// style: TextStyle(
// fontSize: 14,
// ),
// ),
// ),
// )
// .toList(),
// value:
// provider.employeesList.contains(
// provider.selectedEmployee,
// )
// ? provider.selectedEmployee
// : null,
//
// // value: provider.selectedEmployees,
// onChanged: (Employees? value) {
// if (value != null) {
// if (provider
// .employeesList
// .isNotEmpty) {
// provider.selectedEmployee = value;
// provider.selectedEmployeeId =
// value!.id!;
// provider.selectedEmployeeValue =
// value!.name!;
// provider
// .crmLeadListSourceOnReferenceAPIFunction(
// context,
// widget.mode,
// provider.selectedSourceId,
// );
// }
// }
// },
// isExpanded: true,
// buttonStyleData: ddtheme.buttonStyleData,
// iconStyleData: ddtheme.iconStyleData,
// menuItemStyleData:
// ddtheme.menuItemStyleData,
// dropdownStyleData:
// ddtheme.dropdownStyleData,
// ),
// ),
// ],
// ),
// ),
// ],
// TextWidget(context, "Lead Status"),
// DropdownButtonHideUnderline(
// child: Row(
// children: [
// Expanded(
// child: DropdownButton2<String>(
// hint: Text(
// "Select Lead Status",
// style: TextStyle(fontSize: 14),
// ),
// items:
// provider.leadStatusList
// .map(
// (leadStatus) =>
// DropdownMenuItem<String>(
// value: leadStatus,
// child: Text(
// leadStatus!,
// style: TextStyle(
// fontSize: 14,
// ),
// ),
// ),
// )
// .toList(),
// value: provider.selectedLeadStatus,
// onChanged: (String? value) {
// if (value != null) {
// provider.selectedLeadStatus = value;
// }
// },
// isExpanded: true,
// buttonStyleData: ddtheme.buttonStyleData,
// iconStyleData: ddtheme.iconStyleData,
// menuItemStyleData:
// ddtheme.menuItemStyleData,
// dropdownStyleData:
// ddtheme.dropdownStyleData,
// ),
// ),
// ],
// ),
// ),
//
// TextWidget(context, "Open/Close Status"),
// DropdownButtonHideUnderline(
// child: Row(
// children: [
// Expanded(
// child: DropdownButton2<String>(
// hint: Text(
// "Select Open/Close Status",
// style: TextStyle(fontSize: 14),
// ),
// items:
// provider.openStatusList
// .map(
// (leadStatus) =>
// DropdownMenuItem<String>(
// value: leadStatus,
// child: Text(
// leadStatus!,
// style: TextStyle(
// fontSize: 14,
// ),
// ),
// ),
// )
// .toList(),
// value: provider.selectedOpenStatus,
// onChanged: (String? value) {
// if (value != null) {
// provider.selectedOpenStatus = value;
// }
// },
// isExpanded: true,
// buttonStyleData: ddtheme.buttonStyleData,
// iconStyleData: ddtheme.iconStyleData,
// menuItemStyleData:
// ddtheme.menuItemStyleData,
// dropdownStyleData:
// ddtheme.dropdownStyleData,
// ),
// ),
// ],
// ),
// ),
// textControllerWidget(
// context,
// provider.mobileNumberController,
// "Mobile Number",
// "Enter Mobile Number",
// provider.onChangedMobileNum,
// TextInputType.number,
// false,
// FilteringTextInputFormatter.digitsOnly,
// ),
// textControllerWidget(
// context,
// provider.companyNameController,
// "Company Name",
// "Enter Company Name",
// provider.onChangedCompanyName,
// TextInputType.text,
// false,
// null,
// ),
//
// TextWidget(context, "Source"),
// DropdownButtonHideUnderline(
// child: Row(
// children: [
// Expanded(
// child: DropdownButton2<Sources>(
// hint: Text(
// "Select Source",
// style: TextStyle(fontSize: 14),
// ),
// items:
// provider.sourcesList
// .map(
// (slist) =>
// DropdownMenuItem<Sources>(
// value: slist,
// child: Text(
// slist.name!,
// style: TextStyle(
// fontSize: 14,
// ),
// ),
// ),
// )
// .toList(),
// value: provider.selectedSource,
// onChanged: (Sources? value) {
// if (value != null) {
// if (provider.sourcesList.isNotEmpty) {
// provider.selectedSource = value;
// provider.selectedSourceId =
// value!.id!;
// provider.selectedSourceValue =
// value!.name!;
// provider
// .crmLeadListSourceOnReferenceAPIFunction(
// context,
// widget.mode,
// provider.selectedSourceId,
// );
// }
// }
// },
// isExpanded: true,
// buttonStyleData: ddtheme.buttonStyleData,
// iconStyleData: ddtheme.iconStyleData,
// menuItemStyleData:
// ddtheme.menuItemStyleData,
// dropdownStyleData:
// ddtheme.dropdownStyleData,
// ),
// ),
// ],
// ),
// ),
//
// TextWidget(context, "Reference"),
// DropdownButtonHideUnderline(
// child: Row(
// children: [
// Expanded(
// child: DropdownButton2<References>(
// hint: Text(
// "Select Reference",
// style: TextStyle(fontSize: 14),
// ),
// items:
// provider.referencesList
// .map(
// (slist) =>
// DropdownMenuItem<References>(
// value: slist,
// child: Text(
// slist.name!,
// style: TextStyle(
// fontSize: 14,
// ),
// ),
// ),
// )
// .toList(),
// value: provider.selectedReference,
// onChanged: (References? value) {
// if (value != null) {
// if (provider
// .referencesList
// .isNotEmpty) {
// provider.selectedReference = value;
// provider.selectedReferenceId =
// value!.id!;
// provider.selectedReferenceValue =
// value!.name!;
// }
// }
// },
// isExpanded: true,
// buttonStyleData: ddtheme.buttonStyleData,
// iconStyleData: ddtheme.iconStyleData,
// menuItemStyleData:
// ddtheme.menuItemStyleData,
// dropdownStyleData:
// ddtheme.dropdownStyleData,
// ),
// ),
// ],
// ),
// ),
//
// TextWidget(context, "Team"),
// DropdownButtonHideUnderline(
// child: Row(
// children: [
// Expanded(
// child: DropdownButton2<Teams>(
// hint: Text(
// "Select Team",
// style: TextStyle(fontSize: 14),
// ),
// items:
// provider.teamsList
// .map(
// (slist) =>
// DropdownMenuItem<Teams>(
// value: slist,
// child: Text(
// slist.name!,
// style: TextStyle(
// fontSize: 14,
// ),
// ),
// ),
// )
// .toList(),
// value: provider.selectedTeam,
// onChanged: (Teams? value) {
// if (value != null) {
// if (provider.teamsList.isNotEmpty) {
// provider.selectedTeam = value;
// provider.selectedTeamId = value!.id!;
// provider.selectedTeamValue =
// value!.name!;
// provider
// .crmLeadListSegmentOnTeamAPIFunction(
// context,
// widget.mode,
// provider.selectedTeamId,
// );
// }
// }
// },
// isExpanded: true,
// buttonStyleData: ddtheme.buttonStyleData,
// iconStyleData: ddtheme.iconStyleData,
// menuItemStyleData:
// ddtheme.menuItemStyleData,
// dropdownStyleData:
// ddtheme.dropdownStyleData,
// ),
// ),
// ],
// ),
// ),
//
// TextWidget(context, "Segment"),
// DropdownButtonHideUnderline(
// child: Row(
// children: [
// Expanded(
// child: DropdownButton2<Segments>(
// hint: Text(
// "Select Segment",
// style: TextStyle(fontSize: 14),
// ),
// items:
// provider.segmentsList
// .map(
// (slist) =>
// DropdownMenuItem<Segments>(
// value: slist,
// child: Text(
// slist.name!,
// style: TextStyle(
// fontSize: 14,
// ),
// ),
// ),
// )
// .toList(),
// value: provider.selectedSegment,
// onChanged: (Segments? value) {
// if (value != null) {
// if (provider.segmentsList.isNotEmpty) {
// provider.selectedSegment = value;
// provider.selectedSegmentId =
// value!.id!;
// provider.selectedSegmentValue =
// value!.name!;
// }
// }
// },
// isExpanded: true,
// buttonStyleData: ddtheme.buttonStyleData,
// iconStyleData: ddtheme.iconStyleData,
// menuItemStyleData:
// ddtheme.menuItemStyleData,
// dropdownStyleData:
// ddtheme.dropdownStyleData,
// ),
// ),
// ],
// ),
// ),
//
// TextWidget(context, "State"),
// DropdownButtonHideUnderline(
// child: Row(
// children: [
// Expanded(
// child: DropdownButton2<States>(
// hint: Text(
// "Select State",
// style: TextStyle(fontSize: 14),
// ),
// items:
// provider.statesList
// .map(
// (slist) =>
// DropdownMenuItem<States>(
// value: slist,
// child: Text(
// slist.name!,
// style: TextStyle(
// fontSize: 14,
// ),
// ),
// ),
// )
// .toList(),
// value: provider.selectedStates,
// onChanged: (States? value) {
// if (value != null) {
// if (provider.statesList.isNotEmpty) {
// provider.selectedStates = value;
// provider.selectedStateId = value!.id!;
// provider.selectedStateValue =
// value!.name!;
// if (provider
// .districtsList
// .isNotEmpty) {
// provider.districtsList.clear();
// // provider.selectedDistricts = null;
// provider.selectedDistrictId = null;
// provider.selectedDistrictValue = "";
// }
// provider
// .crmLeadListDistrictsOnStateAPIFunction(
// context,
// widget.mode,
// provider.selectedStateId,
// );
// }
// }
// },
// isExpanded: true,
// buttonStyleData: ddtheme.buttonStyleData,
// iconStyleData: ddtheme.iconStyleData,
// menuItemStyleData:
// ddtheme.menuItemStyleData,
// dropdownStyleData:
// ddtheme.dropdownStyleData,
// ),
// ),
// ],
// ),
// ),
//
// TextWidget(context, "District"),
// DropdownButtonHideUnderline(
// child: Row(
// children: [
// Expanded(
// child: DropdownButton2<Districts>(
// hint: Text(
// "Select District",
// style: TextStyle(fontSize: 14),
// ),
// items:
// provider.districtsList
// .map(
// (slist) =>
// DropdownMenuItem<Districts>(
// value: slist,
// child: Text(
// slist.district!,
// style: TextStyle(
// fontSize: 14,
// ),
// ),
// ),
// )
// .toList(),
// value: provider.selectedDistricts,
// onChanged: (Districts? value) {
// if (value != null) {
// if (provider.districtsList.isNotEmpty) {
// provider.selectedDistricts = value;
// provider.selectedDistrictId =
// value!.id!;
// provider.selectedDistrictValue =
// value!.district!;
// if (provider
// .subLocationsList
// .isNotEmpty) {
// provider.subLocationsList.clear();
// // provider.selectedSubLocations =
// // null;
// provider.selectedSubLocationId =
// null;
// provider.selectedSubLocationValue =
// "";
// }
// provider
// .crmLeadListSubLocOnDistrictAPIFunction(
// context,
// widget.mode,
// provider.selectedDistrictId,
// );
// }
// }
// },
// isExpanded: true,
// buttonStyleData: ddtheme.buttonStyleData,
// iconStyleData: ddtheme.iconStyleData,
// menuItemStyleData:
// ddtheme.menuItemStyleData,
// dropdownStyleData:
// ddtheme.dropdownStyleData,
// ),
// ),
// ],
// ),
// ),
//
// TextWidget(context, "Sub Location"),
// DropdownButtonHideUnderline(
// child: Row(
// children: [
// Expanded(
// child: DropdownButton2<SubLocations>(
// hint: Text(
// "Select Sub Location",
// style: TextStyle(fontSize: 14),
// ),
// items:
// provider.subLocationsList
// .map(
// (slist) => DropdownMenuItem<
// SubLocations
// >(
// value: slist,
// child: Text(
// slist.subLocality!,
// style: TextStyle(
// fontSize: 14,
// ),
// ),
// ),
// )
// .toList(),
// value: provider.selectedSubLocations,
// onChanged: (SubLocations? value) {
// if (value != null) {
// if (provider
// .subLocationsList
// .isNotEmpty) {
// provider.selectedSubLocations = value;
// provider.selectedSubLocationId =
// value!.id!;
// provider.selectedSubLocationValue =
// value!.subLocality!;
// }
// }
// },
// isExpanded: true,
// buttonStyleData: ddtheme.buttonStyleData,
// iconStyleData: ddtheme.iconStyleData,
// menuItemStyleData:
// ddtheme.menuItemStyleData,
// dropdownStyleData:
// ddtheme.dropdownStyleData,
// ),
// ),
// ],
// ),
// ),
//
// InkResponse(
// onTap: () {
// // provider.crmLeadListAPIFunction(
// // context,
// // widget.mode,
// // provider.selectedEmployeeId,
// // provider.selectedLeadStatus,
// // provider.selectedOpenStatus,
// // provider.selectedSourceId,
// // provider.selectedReferenceId,
// // provider.selectedTeamId,
// // provider.selectedSegmentId,
// // provider.selectedStateId,
// // provider.selectedDistrictId,
// // provider.selectedSubLocationId,
// // );
// Navigator.pop(context);
// },
// child: Container(
// height: 45,
// alignment: Alignment.center,
// margin: EdgeInsets.symmetric(horizontal: 10),
// padding: EdgeInsets.symmetric(
// horizontal: 10,
// vertical: 5,
// ),
// decoration: BoxDecoration(
// color: AppColors.app_blue,
// borderRadius: BorderRadius.circular(15),
// ),
// child: Text(
// "Submit",
// style: TextStyle(
// fontSize: 15,
// fontFamily: "JakartaMedium",
// color: Colors.white,
// ),
// ),
// ),
// ),
// ],
// ),
// ),
// );
// },
// ),
// );
// },
// );
// },
// );
// }
Future<void> _showFilterSheetNew1(BuildContext context) {
List<bool> isSelected = List.generate(
9,
(index) => index == 0 ? true : false,
);
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: Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
child: Consumer<Leadlistprovider>(
builder: (context, provider, child) {
int selectedIndex = isSelected.indexWhere(
(element) => element == true,
);
final headings = [
"Lead Status",
"Open/Close Status",
"Mobile Number",
"Company Name",
"Source",
"Reference",
"Team",
"Segment",
];
if (widget.mode != "executive") {
headings.add("Employee");
}
return Container(
height: MediaQuery.of(context).size.height * 0.7,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(left: 15),
child: Text(
"Filter",
style: TextStyle(
color: AppColors.app_blue,
fontSize: 18,
fontFamily: "JakartaSemiBold",
),
),
),
const SizedBox(height: 20),
// Two-Column Layout
Expanded(
child: Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide(
color: const Color(0xFFA5DAF9),
),
bottom: BorderSide(
color: const Color(0xFFA5DAF9),
),
),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Left Column: Headings
Expanded(
flex: 3,
child: Column(
children: List.generate(headings.length, (
jj,
) {
return Expanded(
child: InkResponse(
onTap: () {
setState(() {
// Reset all to false
isSelected = List.generate(
headings.length,
(index) => false,
);
// Set the clicked item to true
isSelected[jj] = true;
});
},
child: Container(
padding:
const EdgeInsets.symmetric(
vertical: 7.5,
horizontal: 10,
),
decoration: BoxDecoration(
border: Border(
left:
isSelected[jj]
? BorderSide(
color:
AppColors
.app_blue,
width: 5.0,
)
: const BorderSide(
color:
Colors
.transparent,
),
bottom:
jj == headings.length - 1
? const BorderSide(
color:
Colors
.transparent,
)
: const BorderSide(
color: Color(
0xFFA5DAF9,
),
),
),
color: const Color(0xFFE6F6FF),
),
child: Center(
child: Text(
headings[jj],
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14,
fontFamily:
"JakartaRegular",
color: AppColors.semi_black,
),
),
),
),
),
);
}),
),
),
// Right Column: Dynamic Input Fields
Expanded(
flex: 5,
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
if (selectedIndex == 0) ...[
...provider.leadStatusList.map((
status,
) {
return SizedBox(
height: 35,
child: CheckboxListTile(
activeColor:
AppColors.app_blue,
controlAffinity:
ListTileControlAffinity
.leading,
checkboxShape: CircleBorder(
side: BorderSide(
width: 0.5,
),
),
title: Text(
status!,
style: const TextStyle(
fontSize: 14,
),
),
value:
provider
.selectedLeadStatus ==
status,
onChanged: (bool? value) {
setState(() {
if (value == true) {
provider.selectedLeadStatus =
status;
} else {
provider.selectedLeadStatus =
null;
}
print(
provider
.selectedLeadStatus,
);
});
},
contentPadding:
EdgeInsets.zero,
),
);
}).toList(),
] else if (selectedIndex == 1) ...[
...provider.openStatusList.map((
status,
) {
return SizedBox(
height: 35,
child: CheckboxListTile(
activeColor:
AppColors.app_blue,
controlAffinity:
ListTileControlAffinity
.leading,
checkboxShape: CircleBorder(
side: BorderSide(
width: 0.5,
),
),
title: Text(
status!,
style: const TextStyle(
fontSize: 14,
),
),
value:
provider
.selectedOpenStatus ==
status,
onChanged: (bool? value) {
setState(() {
if (value == true) {
provider.selectedOpenStatus =
status;
} else {
provider.selectedOpenStatus =
null;
}
});
},
contentPadding:
EdgeInsets.zero,
),
);
}).toList(),
] else if (selectedIndex == 2) ...[
textControllerWidget(
context,
provider.mobileNumberController,
"Mobile Number",
"Enter Mobile Number",
provider.onChangedMobileNum,
TextInputType.number,
false,
FilteringTextInputFormatter
.digitsOnly,
),
] else if (selectedIndex == 3) ...[
textControllerWidget(
context,
provider.companyNameController,
"Company Name",
"Enter Company Name",
provider.onChangedCompanyName,
TextInputType.text,
false,
null,
),
] else if (selectedIndex == 4) ...[
...provider.sourcesList.map((
source,
) {
return SizedBox(
height: 35,
child: CheckboxListTile(
activeColor:
AppColors.app_blue,
controlAffinity:
ListTileControlAffinity
.leading,
checkboxShape: CircleBorder(
side: BorderSide(
width: 0.5,
),
),
title: Text(
source.name!,
style: const TextStyle(
fontSize: 14,
),
),
value:
provider.selectedSource ==
source,
onChanged: (bool? value) {
setState(() {
if (value == true) {
provider.selectedSource =
source!;
provider.selectedSourceId =
source.id!;
provider.selectedSourceValue =
source.name!;
} else {
provider.selectedSourceId =
null;
provider.selectedSourceValue =
null;
if (provider
.selectedReference !=
null) {
provider
.referencesList
.clear();
provider.selectedReferenceId =
null;
provider.selectedReferenceValue =
null;
}
}
// Call API if needed
provider
.crmLeadListSourceOnReferenceAPIFunction(
context,
widget.mode,
provider
.selectedSourceId,
);
});
},
contentPadding:
EdgeInsets.zero,
),
);
}).toList(),
] else if (selectedIndex == 5) ...[
if (provider
.referencesList
.isEmpty) ...[
errorWidget(
context,
"Please Select Source First",
),
] else ...[
...provider.referencesList.map((
reference,
) {
return SizedBox(
height: 35,
child: CheckboxListTile(
activeColor:
AppColors.app_blue,
controlAffinity:
ListTileControlAffinity
.leading,
checkboxShape: CircleBorder(
side: BorderSide(
width: 0.5,
),
),
title: Text(
reference.name!,
style: const TextStyle(
fontSize: 14,
),
),
value:
provider
.selectedReference ==
reference,
onChanged: (bool? value) {
setState(() {
if (value == true) {
provider.selectedReference =
reference;
provider.selectedReferenceId =
reference.id!;
provider.selectedReferenceValue =
reference.name!;
} else {
provider
.referencesList
.clear();
provider.selectedReferenceId =
null;
provider.selectedReferenceValue =
null;
}
});
},
contentPadding:
EdgeInsets.zero,
),
);
}).toList(),
],
] else if (selectedIndex == 6) ...[
...provider.teamsList.map((team) {
return SizedBox(
height: 35,
child: CheckboxListTile(
activeColor:
AppColors.app_blue,
title: Text(
team.name!,
style: const TextStyle(
fontSize: 14,
),
),
controlAffinity:
ListTileControlAffinity
.leading,
checkboxShape: CircleBorder(
side: BorderSide(
width: 0.5,
),
),
value:
provider.selectedTeam ==
team,
onChanged: (bool? value) {
setState(() {
if (value == true) {
provider.selectedTeam =
team;
provider.selectedTeamId =
team.id!;
provider.selectedTeamValue =
team.name!;
} else {
provider.selectedTeamId =
null;
provider.selectedTeamValue =
null;
if (provider
.selectedSegment !=
null) {
provider.segmentsList
.clear();
provider.selectedSegmentId =
null;
provider.selectedSegmentValue =
null;
}
}
provider
.crmLeadListSegmentOnTeamAPIFunction(
context,
widget.mode,
provider
.selectedTeamId,
);
});
},
contentPadding:
EdgeInsets.zero,
),
);
}).toList(),
] else if (selectedIndex == 7) ...[
if (provider
.segmentsList
.isEmpty) ...[
errorWidget(
context,
"Please Select Team ID First",
),
] else ...[
...provider.segmentsList.map((
segment,
) {
return SizedBox(
height: 35,
child: CheckboxListTile(
activeColor:
AppColors.app_blue,
controlAffinity:
ListTileControlAffinity
.leading,
checkboxShape: CircleBorder(
side: BorderSide(
width: 0.5,
),
),
title: Text(
segment.name!,
style: const TextStyle(
fontSize: 14,
),
),
value:
provider
.selectedSegment ==
segment,
onChanged: (bool? value) {
setState(() {
if (value == true) {
provider.selectedSegment =
segment;
provider.selectedSegmentId =
segment.id!;
provider.selectedSegmentValue =
segment.name!;
} else {
provider.segmentsList
.clear();
provider.selectedSegmentId =
null;
provider.selectedSegmentValue =
null;
}
});
},
contentPadding:
EdgeInsets.zero,
),
);
}).toList(),
],
] else if (widget.mode !=
"executive") ...[
...provider.employeesList.map((
employee,
) {
return SizedBox(
height: 35,
child: CheckboxListTile(
activeColor:
AppColors.app_blue,
controlAffinity:
ListTileControlAffinity
.leading,
checkboxShape: CircleBorder(
side: BorderSide(
width: 0.5,
),
),
title: Text(
employee.name!,
style: const TextStyle(
fontSize: 14,
),
),
value:
provider
.selectedEmployee ==
employee,
onChanged: (bool? value) {
setState(() {
if (value == true) {
provider.selectedEmployee =
employee;
provider.selectedEmployeeId =
employee.id!;
provider.selectedEmployeeValue =
employee.name!;
}
provider
.crmLeadListSourceOnReferenceAPIFunction(
context,
widget.mode,
provider
.selectedSourceId,
);
});
},
contentPadding:
EdgeInsets.zero,
),
);
}).toList(),
],
],
),
),
),
],
),
),
),
// Search Button
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 15,
vertical: 20,
),
child: InkResponse(
onTap: () {
provider.crmLeadListAPIFunction(
context,
widget.mode,
provider.selectedLeadStatus,
provider.selectedOpenStatus,
provider.selectedSourceId,
provider.selectedReferenceId,
provider.selectedTeamId,
provider.selectedSegmentId,
provider.selectedAlphabet,
);
Navigator.pop(context);
},
child: Container(
height: 45,
alignment: Alignment.center,
decoration: BoxDecoration(
color: AppColors.app_blue,
borderRadius: BorderRadius.circular(15),
),
child: const Text(
"Search",
style: TextStyle(
fontSize: 15,
fontFamily: "JakartaMedium",
color: Colors.white,
),
),
),
),
),
],
),
);
},
),
),
);
},
);
},
);
}
Future<void> _showFilterSheetNew(BuildContext context) {
List<bool> isSelected = List.generate(
......
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