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