Notificatio screen
This commit is contained in:
parent
bced613c1d
commit
d75170e314
@ -34,12 +34,15 @@ class ProductResponse {
|
||||
|
||||
class Product {
|
||||
final String id;
|
||||
// ignore: non_constant_identifier_names
|
||||
final String SKU;
|
||||
final String name;
|
||||
final Category category;
|
||||
final Brand brand;
|
||||
final double price;
|
||||
// ignore: non_constant_identifier_names
|
||||
final int GST;
|
||||
// ignore: non_constant_identifier_names
|
||||
final int HSNCode;
|
||||
final String description;
|
||||
final String productStatus;
|
||||
@ -53,12 +56,15 @@ class Product {
|
||||
|
||||
Product({
|
||||
required this.id,
|
||||
// ignore: non_constant_identifier_names
|
||||
required this.SKU,
|
||||
required this.name,
|
||||
required this.category,
|
||||
required this.brand,
|
||||
required this.price,
|
||||
// ignore: non_constant_identifier_names
|
||||
required this.GST,
|
||||
// ignore: non_constant_identifier_names
|
||||
required this.HSNCode,
|
||||
required this.description,
|
||||
required this.productStatus,
|
||||
|
@ -33,7 +33,10 @@ class SalesTaskResponse {
|
||||
|
||||
class SalesProduct {
|
||||
String? sId;
|
||||
// ignore: non_constant_identifier_names
|
||||
String? SKU;
|
||||
// ignore: non_constant_identifier_names
|
||||
// ignore: non_constant_identifier_names
|
||||
String? ProductName;
|
||||
Category? category;
|
||||
Brand? brand;
|
||||
@ -46,14 +49,19 @@ class SalesProduct {
|
||||
List<Null>? image;
|
||||
String? createdAt;
|
||||
String? updatedAt;
|
||||
// ignore: non_constant_identifier_names
|
||||
int? SalesAmount;
|
||||
// ignore: non_constant_identifier_names
|
||||
// ignore: non_constant_identifier_names
|
||||
int? QuantitySold;
|
||||
String? comments;
|
||||
int? iV;
|
||||
|
||||
SalesProduct(
|
||||
{this.sId,
|
||||
// ignore: non_constant_identifier_names
|
||||
this.SKU,
|
||||
// ignore: non_constant_identifier_names
|
||||
this.ProductName,
|
||||
this.category,
|
||||
this.brand,
|
||||
@ -66,8 +74,10 @@ class SalesProduct {
|
||||
this.image,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
// ignore: non_constant_identifier_names
|
||||
this.QuantitySold,
|
||||
this.comments,
|
||||
// ignore: non_constant_identifier_names
|
||||
this.SalesAmount,
|
||||
this.iV});
|
||||
|
||||
|
@ -35,8 +35,20 @@ class AddSalesProvider with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
} catch (e) {
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
setLoading(false);
|
||||
debugPrint("Error occurred while fetching sales tasks: $e");
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,7 +105,19 @@ class AddSalesProvider with ChangeNotifier {
|
||||
}
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
debugPrint("Error: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cheminova/constants/constant.dart';
|
||||
import 'package:cheminova/models/get_pd_response.dart';
|
||||
import 'package:cheminova/screens/data_submit_successfull.dart';
|
||||
import 'package:cheminova/services/api_client.dart';
|
||||
@ -133,10 +134,21 @@ class CollectKycProvider extends ChangeNotifier {
|
||||
pdList = (response.data as List)
|
||||
.map((e) => GetPdResponse.fromJson(e))
|
||||
.toList();
|
||||
|
||||
print('pd list length: ${pdList.length}');
|
||||
} else {}
|
||||
} catch (e) {
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
@ -286,9 +298,20 @@ class CollectKycProvider extends ChangeNotifier {
|
||||
}
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
if (e is DioException) {
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
'${e.response?.data['message'] ?? 'Something went wrong'}',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(SnackBar(content: Text('An error occurred: $e')));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Something went wrong.')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ class LoginProvider extends ChangeNotifier {
|
||||
await _storageService.write(
|
||||
key: 'access_token', value: response.data['token']);
|
||||
final fcmToken = await NotificationServices().getDeviceToken();
|
||||
print('fcmToken: $fcmToken');
|
||||
await _apiClient.post(ApiUrls.fcmUrl, data: {'fcmToken': fcmToken});
|
||||
return (true, response.data['message'].toString());
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
import 'package:cheminova/constants/constant.dart';
|
||||
import 'package:cheminova/models/announcement_model.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../models/notification_list_response.dart';
|
||||
import '../services/api_client.dart';
|
||||
@ -15,21 +16,40 @@ class NotificationProvider extends ChangeNotifier {
|
||||
final _apiClient = ApiClient();
|
||||
List<Notifications> notificationList = [];
|
||||
List<AnnouncementModel> _announcementList = [];
|
||||
int _totalAnnouncements = 0;
|
||||
String _selectedDate = DateFormat('dd/MM/yyyy').format(DateTime.now());
|
||||
|
||||
bool _isLoading = false;
|
||||
|
||||
bool get isLoading => _isLoading;
|
||||
int get totalAnnouncements => _totalAnnouncements;
|
||||
List<AnnouncementModel> get announcementList => _announcementList;
|
||||
String get selectedDate => _selectedDate;
|
||||
|
||||
void setLoading(bool loading) {
|
||||
_isLoading = loading;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void clearLists() {
|
||||
notificationList = [];
|
||||
_announcementList = [];
|
||||
_totalAnnouncements = 0;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setDate(String date) {
|
||||
_selectedDate = date;
|
||||
notifyListeners();
|
||||
getNotification();
|
||||
}
|
||||
|
||||
Future<void> getNotification() async {
|
||||
clearLists();
|
||||
setLoading(true);
|
||||
try {
|
||||
Response response = await _apiClient.get(ApiUrls.notificationUrl);
|
||||
Response response = await _apiClient
|
||||
.get('${ApiUrls.notificationUrl}?Date=$_selectedDate');
|
||||
setLoading(false);
|
||||
if (response.statusCode == 200) {
|
||||
final data = NotificationListResponse.fromJson(response.data);
|
||||
@ -41,19 +61,34 @@ class NotificationProvider extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getAnnouncement() async {
|
||||
Future<void> getAnnouncement(int page, int rowsPerPage) async {
|
||||
clearLists();
|
||||
setLoading(true);
|
||||
try {
|
||||
Response response = await _apiClient.get(ApiUrls.announcements);
|
||||
Response response = await _apiClient
|
||||
.get('${ApiUrls.announcements}?page=$page&rowsPerPage=$rowsPerPage');
|
||||
if (response.statusCode == 200) {
|
||||
_announcementList = (response.data as List)
|
||||
_announcementList = (response.data['announcements'] as List)
|
||||
.map((e) => AnnouncementModel.fromJson(e))
|
||||
.toList();
|
||||
notifyListeners();
|
||||
_totalAnnouncements = response.data['totalAnnouncements'];
|
||||
}
|
||||
setLoading(false);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:cheminova/constants/constant.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:cheminova/models/pd_rd_response_model.dart';
|
||||
@ -36,11 +37,21 @@ class PdRdProvider extends ChangeNotifier {
|
||||
.map((json) => PdRdResponseModel.fromJson(json))
|
||||
.toList();
|
||||
_pdList = data;
|
||||
} else {
|
||||
print("Failed to load data: ${response.statusCode}");
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error occurred: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -56,11 +67,21 @@ class PdRdProvider extends ChangeNotifier {
|
||||
.map((json) => PdRdResponseModel.fromJson(json))
|
||||
.toList();
|
||||
_rdList = data;
|
||||
} else {
|
||||
print("Failed to load data: ${response.statusCode}");
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error occurred: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:cheminova/constants/constant.dart';
|
||||
import 'package:cheminova/models/product_manual_model.dart';
|
||||
import 'package:cheminova/services/api_urls.dart';
|
||||
import 'package:cheminova/services/api_client.dart';
|
||||
@ -31,7 +32,19 @@ class ProductManualProvider extends ChangeNotifier {
|
||||
_productManualList = data;
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error occurred: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
import 'package:cheminova/constants/constant.dart';
|
||||
import 'package:cheminova/models/product_model.dart';
|
||||
import 'package:cheminova/services/api_client.dart';
|
||||
import 'package:cheminova/services/api_urls.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ProductProvider extends ChangeNotifier {
|
||||
ProductProvider() {
|
||||
@ -37,7 +38,19 @@ class ProductProvider extends ChangeNotifier {
|
||||
}
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
print("Error: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +82,19 @@ class ProductProvider extends ChangeNotifier {
|
||||
}
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
print("Error: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import 'package:cheminova/constants/constant.dart';
|
||||
import 'package:cheminova/models/rejected_applicaton_response.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../services/api_client.dart';
|
||||
import '../services/api_urls.dart';
|
||||
@ -34,6 +34,19 @@ class RejectedProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
} catch (e) {
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:cheminova/constants/constant.dart';
|
||||
import 'package:cheminova/models/pd_rd_response_model.dart';
|
||||
import 'package:cheminova/models/task_model.dart';
|
||||
import 'package:cheminova/screens/data_submit_successfull.dart';
|
||||
@ -78,11 +79,21 @@ class TaskProvider extends ChangeNotifier {
|
||||
.map((json) => PdRdResponseModel.fromJson(json))
|
||||
.toList();
|
||||
_salesCoordinators = data;
|
||||
} else {
|
||||
print("Failed to load data: ${response.statusCode}");
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error occurred: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
setLoading(false);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
@ -128,11 +139,21 @@ class TaskProvider extends ChangeNotifier {
|
||||
builder: (context) => const DataSubmitSuccessfull(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
print("Failed to assign task: ${response.statusCode}");
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error occurred: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -159,12 +180,21 @@ class TaskProvider extends ChangeNotifier {
|
||||
.map((json) => PdRdResponseModel.fromJson(json))
|
||||
.toList();
|
||||
_pdList = data;
|
||||
print("PDTradeName ${data[0].shippingAddress!.tradeName}");
|
||||
} else {
|
||||
print("Failed to load data: ${response.statusCode}");
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error occurred: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -180,12 +210,21 @@ class TaskProvider extends ChangeNotifier {
|
||||
.map((json) => PdRdResponseModel.fromJson(json))
|
||||
.toList();
|
||||
_rdList = data;
|
||||
print("RDTradeName ${data[0].kyc!.tradeName}");
|
||||
} else {
|
||||
print("Failed to load data: ${response.statusCode}");
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error occurred: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -203,7 +242,19 @@ class TaskProvider extends ChangeNotifier {
|
||||
_taskModelList = data;
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error occurred: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -221,7 +272,19 @@ class TaskProvider extends ChangeNotifier {
|
||||
_taskModelList = data;
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error occurred: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -240,7 +303,19 @@ class TaskProvider extends ChangeNotifier {
|
||||
_taskModelList = data;
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error occurred: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -260,7 +335,19 @@ class TaskProvider extends ChangeNotifier {
|
||||
_taskModelList = data;
|
||||
}
|
||||
} catch (e) {
|
||||
print("Error occurred: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:cheminova/constants/constant.dart';
|
||||
import 'package:cheminova/models/user_model.dart';
|
||||
import 'package:cheminova/services/api_client.dart';
|
||||
import 'package:cheminova/services/api_urls.dart';
|
||||
@ -32,12 +33,22 @@ class UserProvider extends ChangeNotifier {
|
||||
_user = UserModel.fromJson(data);
|
||||
|
||||
notifyListeners();
|
||||
} else {
|
||||
throw Exception('Failed to load user profile');
|
||||
}
|
||||
} catch (e) {
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
setLoading(false);
|
||||
throw Exception('Failed to load user profile: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,19 @@ class VisitPdRdProvider with ChangeNotifier {
|
||||
}
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
debugPrint("Error: $e");
|
||||
String error = "Something went wrong";
|
||||
if (e is DioException) {
|
||||
error = e.response!.data['message'] ?? "Something went wrong";
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
navigatorKey.currentContext!,
|
||||
).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
error,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ class ProductBlock extends StatefulWidget {
|
||||
const ProductBlock({super.key, required this.index});
|
||||
|
||||
@override
|
||||
_ProductBlockState createState() => _ProductBlockState();
|
||||
State<ProductBlock> createState() => _ProductBlockState();
|
||||
}
|
||||
|
||||
class _ProductBlockState extends State<ProductBlock> {
|
||||
|
@ -15,17 +15,41 @@ class AnnouncementScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AnnouncementScreenState extends State<AnnouncementScreen> {
|
||||
int currentPage = 1;
|
||||
final int announcementsPerPage = 10;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.read<NotificationProvider>().getAnnouncement();
|
||||
context
|
||||
.read<NotificationProvider>()
|
||||
.getAnnouncement(currentPage, announcementsPerPage);
|
||||
});
|
||||
}
|
||||
|
||||
void _changePage(int newPage) {
|
||||
setState(() {
|
||||
currentPage = newPage;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context
|
||||
.read<NotificationProvider>()
|
||||
.getAnnouncement(currentPage, announcementsPerPage);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final notificationProvider = context.watch<NotificationProvider>();
|
||||
final totalAnnouncements = notificationProvider.totalAnnouncements;
|
||||
final totalPages = (totalAnnouncements / announcementsPerPage).ceil();
|
||||
// final startIndex = (currentPage - 1) * announcementsPerPage;
|
||||
// final endIndex = startIndex + announcementsPerPage;
|
||||
// final announcementsToShow = notificationProvider.announcementList.sublist(
|
||||
// startIndex,
|
||||
// endIndex < totalAnnouncements ? endIndex : totalAnnouncements);
|
||||
|
||||
return CommonBackground(
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
@ -52,28 +76,29 @@ class _AnnouncementScreenState extends State<AnnouncementScreen> {
|
||||
body: Stack(
|
||||
children: [
|
||||
ListView.builder(
|
||||
itemCount: notificationProvider.announcementList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(
|
||||
bottom: 10,
|
||||
left: 10,
|
||||
right: 10,
|
||||
itemCount: notificationProvider.announcementList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(
|
||||
bottom: 10,
|
||||
left: 10,
|
||||
right: 10,
|
||||
),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||
child: ListTile(
|
||||
title: const Text('Message:'),
|
||||
subtitle: Text(
|
||||
'${notificationProvider.announcementList[index].message.capitalize()}\nDate: ${DateFormat("dd/MM/yyyy").format(
|
||||
DateTime.parse(
|
||||
notificationProvider.announcementList[index].date),
|
||||
)}',
|
||||
),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10))),
|
||||
child: ListTile(
|
||||
title: const Text('Message:'),
|
||||
subtitle: Text(
|
||||
'${notificationProvider.announcementList[index].message.capitalize()}\nDate: ${DateFormat("dd/MM/yyyy").format(
|
||||
DateTime.parse(notificationProvider
|
||||
.announcementList[index].date),
|
||||
)}',
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
if (notificationProvider.isLoading)
|
||||
Container(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
@ -85,6 +110,28 @@ class _AnnouncementScreenState extends State<AnnouncementScreen> {
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 16,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: List.generate(totalPages, (index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
child: ElevatedButton(
|
||||
onPressed: () => _changePage(index + 1),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: currentPage == index + 1
|
||||
? Colors.blue
|
||||
: Colors.grey,
|
||||
),
|
||||
child: Text('${index + 1}'),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -136,40 +136,4 @@ class _AssignTaskDashBoardScreenState extends State<AssignTaskDashBoardScreen> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _customCard({required String title, required String subtitle}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(8.0).copyWith(top: 15, bottom: 30),
|
||||
margin: const EdgeInsets.all(4).copyWith(bottom: 30),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.white),
|
||||
color: const Color(0xffB4D1E5).withOpacity(0.6),
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Anek',
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Text(
|
||||
subtitle,
|
||||
style: const TextStyle(
|
||||
fontSize: 34,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Anek',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -46,8 +46,11 @@ class CollectKycScreenState extends State<CollectKycScreen>
|
||||
final aadharcardController = TextEditingController();
|
||||
final pancardController = TextEditingController();
|
||||
|
||||
// ignore: unused_field
|
||||
File? _selfieImage;
|
||||
// ignore: unused_field
|
||||
File? _pesticideLicenseImage;
|
||||
// ignore: unused_field
|
||||
File? _fertilizerLicenseImage;
|
||||
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
@ -78,6 +81,7 @@ class CollectKycScreenState extends State<CollectKycScreen>
|
||||
});
|
||||
}
|
||||
|
||||
// ignore: unused_element
|
||||
void _showPicker(BuildContext context, bool isSelfie) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
@ -106,6 +110,7 @@ class CollectKycScreenState extends State<CollectKycScreen>
|
||||
});
|
||||
}
|
||||
|
||||
// ignore: unused_element
|
||||
void _showLicensePicker(BuildContext context, bool isPesticide) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:cheminova/screens/collect_kyc_screen.dart';
|
||||
import 'package:cheminova/screens/select_distributer_screen.dart';
|
||||
import 'package:cheminova/screens/display_sales_screen.dart';
|
||||
import 'package:cheminova/screens/visit_rd_pd_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cheminova/widgets/common_app_bar.dart';
|
||||
import 'package:cheminova/widgets/common_drawer.dart';
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:cheminova/notification_service.dart';
|
||||
import 'package:cheminova/provider/user_provider.dart';
|
||||
import 'package:cheminova/screens/announcement_screen.dart';
|
||||
import 'package:cheminova/screens/visit_rd_pd_screen.dart';
|
||||
import 'package:cheminova/screens/assign_task_dash_board_screen.dart';
|
||||
import 'package:cheminova/screens/calendar_screen.dart';
|
||||
import 'package:cheminova/screens/collect_kyc_screen.dart';
|
||||
@ -10,7 +9,6 @@ import 'package:cheminova/screens/notification_screen.dart';
|
||||
import 'package:cheminova/screens/products_manual_screen.dart';
|
||||
import 'package:cheminova/screens/rejected_application_screen.dart';
|
||||
import 'package:cheminova/screens/select_distributer_screen.dart';
|
||||
import 'package:cheminova/screens/display_sales_screen.dart';
|
||||
import 'package:cheminova/widgets/common_drawer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cheminova/widgets/common_background.dart';
|
||||
@ -34,9 +32,9 @@ class _HomePageState extends State<HomePage> {
|
||||
});
|
||||
notificationServices.requestNotificationPermission();
|
||||
|
||||
notificationServices.getDeviceToken().then((value) {
|
||||
print('Device Token: $value');
|
||||
});
|
||||
// notificationServices.getDeviceToken().then((value) {
|
||||
// print('Device Token: $value');
|
||||
// });
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -107,6 +107,8 @@ class _LoginPageState extends State<LoginPage> {
|
||||
builder: (context, value, child) =>
|
||||
CommonTextFormField(
|
||||
textCapitalization: TextCapitalization.none,
|
||||
maxLength: null,
|
||||
maxLines: 1,
|
||||
obscureText: true,
|
||||
controller: value.passwordController,
|
||||
validator: (value) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:cheminova/provider/attendance_provider.dart';
|
||||
import 'package:cheminova/screens/Attendance_success.dart';
|
||||
import 'package:cheminova/screens/attendance_success.dart';
|
||||
import 'package:cheminova/screens/on_leave_screen.dart';
|
||||
import 'package:cheminova/widgets/common_app_bar.dart';
|
||||
import 'package:cheminova/widgets/common_background.dart';
|
||||
|
@ -5,6 +5,7 @@ import 'package:cheminova/widgets/common_background.dart';
|
||||
import 'package:cheminova/widgets/common_drawer.dart';
|
||||
import 'package:cheminova/widgets/common_app_bar.dart';
|
||||
import 'package:cheminova/widgets/common_elevated_button.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@ -24,6 +25,19 @@ class NotificationScreenState extends State<NotificationScreen> {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> _selectDate(BuildContext context) async {
|
||||
final provider = context.read<NotificationProvider>();
|
||||
final dateSelected = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime(2000),
|
||||
lastDate: DateTime(2025),
|
||||
);
|
||||
if (dateSelected != null) {
|
||||
provider.setDate(DateFormat('dd/MM/yyyy').format(dateSelected));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChangeNotifierProvider(
|
||||
@ -54,7 +68,34 @@ class NotificationScreenState extends State<NotificationScreen> {
|
||||
body: Consumer<NotificationProvider>(
|
||||
builder: (context, value, child) => value.isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: MyListView(value: value),
|
||||
: Column(
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.all(10),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
value.selectedDate,
|
||||
),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
_selectDate(context);
|
||||
},
|
||||
icon: const Icon(Icons.calendar_month),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
MyListView(value: value),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -98,48 +139,59 @@ class MyListView extends StatelessWidget {
|
||||
groupedNotifications[date]!.add(notification);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
itemCount: groupedNotifications.length,
|
||||
itemBuilder: (context, index) {
|
||||
String date = groupedNotifications.keys.elementAt(index);
|
||||
List<Notifications> notificationsForDate = groupedNotifications[date]!;
|
||||
return Expanded(
|
||||
child: (groupedNotifications.isEmpty)
|
||||
? const Center(
|
||||
child: Text(
|
||||
'No notifications for selected date',
|
||||
style: TextStyle(fontSize: 20, color: Colors.white),
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
itemCount: groupedNotifications.length,
|
||||
itemBuilder: (context, index) {
|
||||
String date = groupedNotifications.keys.elementAt(index);
|
||||
List<Notifications> notificationsForDate =
|
||||
groupedNotifications[date]!;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10, left: 10, right: 10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Display the date once
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Text(
|
||||
date,
|
||||
style: const TextStyle(
|
||||
fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
// Display notifications for the date
|
||||
...notificationsForDate.map(
|
||||
(item) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: ExpansionTile(
|
||||
collapsedBackgroundColor: Colors.white,
|
||||
backgroundColor: Colors.white,
|
||||
trailing: const SizedBox.shrink(),
|
||||
title: Text(
|
||||
item.title ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 17, fontWeight: FontWeight.w500),
|
||||
),
|
||||
subtitle: Text(item.msg ?? ''),
|
||||
return Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(bottom: 10, left: 10, right: 10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Display the date once
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Text(
|
||||
date,
|
||||
style: const TextStyle(
|
||||
fontSize: 16, fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
// Display notifications for the date
|
||||
...notificationsForDate.map(
|
||||
(item) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: ExpansionTile(
|
||||
collapsedBackgroundColor: Colors.white,
|
||||
backgroundColor: Colors.white,
|
||||
trailing: const SizedBox.shrink(),
|
||||
title: Text(
|
||||
item.title ?? '',
|
||||
style: const TextStyle(
|
||||
fontSize: 17, fontWeight: FontWeight.w500),
|
||||
),
|
||||
subtitle: Text(item.msg ?? ''),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:cheminova/provider/mark_leave_provider.dart';
|
||||
import 'package:cheminova/screens/Attendance_success.dart';
|
||||
import 'package:cheminova/screens/attendance_success.dart';
|
||||
import 'package:cheminova/widgets/common_drawer.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cheminova/widgets/common_background.dart';
|
||||
|
@ -71,6 +71,8 @@ class RetailerDetailsScreenState extends State<RetailerDetailsScreen> {
|
||||
CommonTextFormField(
|
||||
// maxLength: 20,
|
||||
title: 'Email',
|
||||
keyboardType: TextInputType.emailAddress,
|
||||
textCapitalization: TextCapitalization.none,
|
||||
fillColor: Colors.white,
|
||||
inputFormatters: [
|
||||
NoSpaceFormatter(),
|
||||
|
@ -21,7 +21,7 @@ class SummaryScreenState extends State<SummaryScreen> {
|
||||
final timeController =
|
||||
TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now()));
|
||||
|
||||
final ProductController = TextEditingController();
|
||||
final productController = TextEditingController();
|
||||
final liquidationController = TextEditingController();
|
||||
final dealercontroller = TextEditingController();
|
||||
final inventoryController = TextEditingController();
|
||||
@ -97,7 +97,7 @@ class SummaryScreenState extends State<SummaryScreen> {
|
||||
CommonTextFormField(
|
||||
title: 'Product :',
|
||||
fillColor: Colors.white,
|
||||
controller: ProductController),
|
||||
controller: productController),
|
||||
const SizedBox(height: 15),
|
||||
Align(
|
||||
alignment: Alignment.center,
|
||||
|
@ -144,7 +144,7 @@ class _VerifyCodeScreenState extends State<VerifyCodeScreen> {
|
||||
onChanged: (pin) {
|
||||
_enteredOtp = pin;
|
||||
},
|
||||
onCompleted: (pin) => print(pin),
|
||||
// onCompleted: (pin) => print(pin),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Align(
|
||||
|
@ -93,7 +93,7 @@ class _VerifyPhoneScreenState extends State<VerifyPhoneScreen> {
|
||||
builder: (context) =>
|
||||
const VerifyCodeScreen()));
|
||||
// Handle OTP submission here
|
||||
print('OTP submitted');
|
||||
// print('OTP submitted');
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -48,7 +48,7 @@ class VisitRdPdScreenState extends State<VisitRdPdScreen> {
|
||||
if (image != null) {
|
||||
// Handle the picked image
|
||||
// For example, you could update a state variable or send it to your provider
|
||||
print('Image picked: ${image.path}');
|
||||
// print('Image picked: ${image.path}');
|
||||
// You might want to update your UI to show the selected image
|
||||
setState(() {
|
||||
notesController.text = image.path; // Just for demonstration
|
||||
|
@ -48,8 +48,8 @@ class CommonTextFormField extends StatelessWidget {
|
||||
controller: controller,
|
||||
textCapitalization: textCapitalization,
|
||||
readOnly: readOnly ?? false,
|
||||
// maxLines: maxLines,
|
||||
// maxLength: maxLength,
|
||||
maxLines: maxLines,
|
||||
maxLength: maxLength,
|
||||
onChanged: onChanged,
|
||||
onTapOutside: (event) => FocusScope.of(context).unfocus(),
|
||||
validator: validator,
|
||||
|
Loading…
Reference in New Issue
Block a user