From d75170e31423b1750eb8cfeb9588c1fba0a17107 Mon Sep 17 00:00:00 2001 From: kratikpal Date: Thu, 17 Oct 2024 13:39:27 +0530 Subject: [PATCH] Notificatio screen --- lib/models/product_model.dart | 6 + lib/models/sales_task_response.dart | 10 ++ lib/provider/add_sales_provider.dart | 28 +++- lib/provider/collect_kyc_provider.dart | 31 +++- lib/provider/login_provider.dart | 1 - lib/provider/notification_provider.dart | 47 +++++- lib/provider/pd_rd_provider.dart | 33 ++++- lib/provider/product_manual_provider.dart | 15 +- lib/provider/product_provider.dart | 31 +++- lib/provider/rejected_provider.dart | 15 +- lib/provider/task_provider.dart | 123 +++++++++++++--- lib/provider/user_provider.dart | 17 ++- lib/provider/visit_pdrd_provider.dart | 14 +- lib/screens/add_products_screen.dart | 2 +- lib/screens/announcement_screen.dart | 91 +++++++++--- .../assign_task_dash_board_screen.dart | 36 ----- lib/screens/collect_kyc_screen.dart | 5 + lib/screens/daily_tasks_screen.dart | 1 - lib/screens/home_screen.dart | 8 +- lib/screens/login_screen.dart | 2 + lib/screens/mark_attendence_screen.dart | 2 +- lib/screens/notification_screen.dart | 134 ++++++++++++------ lib/screens/on_leave_screen.dart | 2 +- lib/screens/retailer_details_screen.dart | 2 + lib/screens/summary_screen.dart | 4 +- lib/screens/verify_code_screen.dart | 2 +- lib/screens/verify_phone_screen.dart | 2 +- lib/screens/visit_rd_pd_screen.dart | 2 +- lib/widgets/common_text_form_field.dart | 4 +- 29 files changed, 509 insertions(+), 161 deletions(-) diff --git a/lib/models/product_model.dart b/lib/models/product_model.dart index 7ea9986..20bfa54 100644 --- a/lib/models/product_model.dart +++ b/lib/models/product_model.dart @@ -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, diff --git a/lib/models/sales_task_response.dart b/lib/models/sales_task_response.dart index 95748f1..faf04eb 100644 --- a/lib/models/sales_task_response.dart +++ b/lib/models/sales_task_response.dart @@ -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? 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}); diff --git a/lib/provider/add_sales_provider.dart b/lib/provider/add_sales_provider.dart index 379a5f4..e2ed403 100644 --- a/lib/provider/add_sales_provider.dart +++ b/lib/provider/add_sales_provider.dart @@ -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, + ), + ), + ); } } diff --git a/lib/provider/collect_kyc_provider.dart b/lib/provider/collect_kyc_provider.dart index a750205..0e8d075 100644 --- a/lib/provider/collect_kyc_provider.dart +++ b/lib/provider/collect_kyc_provider.dart @@ -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.'))); } } } diff --git a/lib/provider/login_provider.dart b/lib/provider/login_provider.dart index 405804a..d6b7d00 100644 --- a/lib/provider/login_provider.dart +++ b/lib/provider/login_provider.dart @@ -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()); } diff --git a/lib/provider/notification_provider.dart b/lib/provider/notification_provider.dart index 571499c..8bbcbfa 100644 --- a/lib/provider/notification_provider.dart +++ b/lib/provider/notification_provider.dart @@ -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 notificationList = []; List _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 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 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 getAnnouncement() async { + Future 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); } } diff --git a/lib/provider/pd_rd_provider.dart b/lib/provider/pd_rd_provider.dart index 1854814..f21cc88 100644 --- a/lib/provider/pd_rd_provider.dart +++ b/lib/provider/pd_rd_provider.dart @@ -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); } diff --git a/lib/provider/product_manual_provider.dart b/lib/provider/product_manual_provider.dart index d0e83f3..9241442 100644 --- a/lib/provider/product_manual_provider.dart +++ b/lib/provider/product_manual_provider.dart @@ -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); } diff --git a/lib/provider/product_provider.dart b/lib/provider/product_provider.dart index b8bf3ad..dbdfe4a 100644 --- a/lib/provider/product_provider.dart +++ b/lib/provider/product_provider.dart @@ -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; } } diff --git a/lib/provider/rejected_provider.dart b/lib/provider/rejected_provider.dart index c0d6402..1ab0685 100644 --- a/lib/provider/rejected_provider.dart +++ b/lib/provider/rejected_provider.dart @@ -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); } } diff --git a/lib/provider/task_provider.dart b/lib/provider/task_provider.dart index 3523e1a..247448e 100644 --- a/lib/provider/task_provider.dart +++ b/lib/provider/task_provider.dart @@ -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); } diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 190dbe7..fd0e0ca 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -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'); } } diff --git a/lib/provider/visit_pdrd_provider.dart b/lib/provider/visit_pdrd_provider.dart index e7532f0..c541e84 100644 --- a/lib/provider/visit_pdrd_provider.dart +++ b/lib/provider/visit_pdrd_provider.dart @@ -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, + ), + ), + ); } } } diff --git a/lib/screens/add_products_screen.dart b/lib/screens/add_products_screen.dart index 30b9a89..1b29c8f 100644 --- a/lib/screens/add_products_screen.dart +++ b/lib/screens/add_products_screen.dart @@ -267,7 +267,7 @@ class ProductBlock extends StatefulWidget { const ProductBlock({super.key, required this.index}); @override - _ProductBlockState createState() => _ProductBlockState(); + State createState() => _ProductBlockState(); } class _ProductBlockState extends State { diff --git a/lib/screens/announcement_screen.dart b/lib/screens/announcement_screen.dart index e909af3..42b2250 100644 --- a/lib/screens/announcement_screen.dart +++ b/lib/screens/announcement_screen.dart @@ -15,17 +15,41 @@ class AnnouncementScreen extends StatefulWidget { } class _AnnouncementScreenState extends State { + int currentPage = 1; + final int announcementsPerPage = 10; + @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { - context.read().getAnnouncement(); + context + .read() + .getAnnouncement(currentPage, announcementsPerPage); + }); + } + + void _changePage(int newPage) { + setState(() { + currentPage = newPage; + WidgetsBinding.instance.addPostFrameCallback((_) { + context + .read() + .getAnnouncement(currentPage, announcementsPerPage); + }); }); } @override Widget build(BuildContext context) { final notificationProvider = context.watch(); + 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 { 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 { 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}'), + ), + ); + }), + ), + ), ], ), ), diff --git a/lib/screens/assign_task_dash_board_screen.dart b/lib/screens/assign_task_dash_board_screen.dart index 990e696..fe2c61d 100644 --- a/lib/screens/assign_task_dash_board_screen.dart +++ b/lib/screens/assign_task_dash_board_screen.dart @@ -136,40 +136,4 @@ class _AssignTaskDashBoardScreenState extends State { ), ); } - - 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', - ), - ), - ], - ), - ); - } } diff --git a/lib/screens/collect_kyc_screen.dart b/lib/screens/collect_kyc_screen.dart index f8f2515..2fccd9e 100644 --- a/lib/screens/collect_kyc_screen.dart +++ b/lib/screens/collect_kyc_screen.dart @@ -46,8 +46,11 @@ class CollectKycScreenState extends State 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 }); } + // ignore: unused_element void _showPicker(BuildContext context, bool isSelfie) { showModalBottomSheet( context: context, @@ -106,6 +110,7 @@ class CollectKycScreenState extends State }); } + // ignore: unused_element void _showLicensePicker(BuildContext context, bool isPesticide) { showModalBottomSheet( context: context, diff --git a/lib/screens/daily_tasks_screen.dart b/lib/screens/daily_tasks_screen.dart index 13078b9..d12a2a9 100644 --- a/lib/screens/daily_tasks_screen.dart +++ b/lib/screens/daily_tasks_screen.dart @@ -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'; diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index 394daf3..532363b 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.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 { }); notificationServices.requestNotificationPermission(); - notificationServices.getDeviceToken().then((value) { - print('Device Token: $value'); - }); + // notificationServices.getDeviceToken().then((value) { + // print('Device Token: $value'); + // }); } @override diff --git a/lib/screens/login_screen.dart b/lib/screens/login_screen.dart index 8bb0a08..571c778 100644 --- a/lib/screens/login_screen.dart +++ b/lib/screens/login_screen.dart @@ -107,6 +107,8 @@ class _LoginPageState extends State { builder: (context, value, child) => CommonTextFormField( textCapitalization: TextCapitalization.none, + maxLength: null, + maxLines: 1, obscureText: true, controller: value.passwordController, validator: (value) { diff --git a/lib/screens/mark_attendence_screen.dart b/lib/screens/mark_attendence_screen.dart index a1893f0..6cfd5e5 100644 --- a/lib/screens/mark_attendence_screen.dart +++ b/lib/screens/mark_attendence_screen.dart @@ -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'; diff --git a/lib/screens/notification_screen.dart b/lib/screens/notification_screen.dart index 2219bd7..fa5086b 100644 --- a/lib/screens/notification_screen.dart +++ b/lib/screens/notification_screen.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 { super.initState(); } + Future _selectDate(BuildContext context) async { + final provider = context.read(); + 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 { body: Consumer( 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 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 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 ?? ''), + ), + ), + ), + ], ), - ), - ), - ], - ), - ); - }, + ); + }, + ), ); } } diff --git a/lib/screens/on_leave_screen.dart b/lib/screens/on_leave_screen.dart index 8c97ca4..8307bb8 100644 --- a/lib/screens/on_leave_screen.dart +++ b/lib/screens/on_leave_screen.dart @@ -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'; diff --git a/lib/screens/retailer_details_screen.dart b/lib/screens/retailer_details_screen.dart index 703aa88..ac40df4 100644 --- a/lib/screens/retailer_details_screen.dart +++ b/lib/screens/retailer_details_screen.dart @@ -71,6 +71,8 @@ class RetailerDetailsScreenState extends State { CommonTextFormField( // maxLength: 20, title: 'Email', + keyboardType: TextInputType.emailAddress, + textCapitalization: TextCapitalization.none, fillColor: Colors.white, inputFormatters: [ NoSpaceFormatter(), diff --git a/lib/screens/summary_screen.dart b/lib/screens/summary_screen.dart index 352a236..43659c5 100644 --- a/lib/screens/summary_screen.dart +++ b/lib/screens/summary_screen.dart @@ -21,7 +21,7 @@ class SummaryScreenState extends State { 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 { CommonTextFormField( title: 'Product :', fillColor: Colors.white, - controller: ProductController), + controller: productController), const SizedBox(height: 15), Align( alignment: Alignment.center, diff --git a/lib/screens/verify_code_screen.dart b/lib/screens/verify_code_screen.dart index b942feb..3187ac9 100644 --- a/lib/screens/verify_code_screen.dart +++ b/lib/screens/verify_code_screen.dart @@ -144,7 +144,7 @@ class _VerifyCodeScreenState extends State { onChanged: (pin) { _enteredOtp = pin; }, - onCompleted: (pin) => print(pin), + // onCompleted: (pin) => print(pin), ), const SizedBox(height: 20), Align( diff --git a/lib/screens/verify_phone_screen.dart b/lib/screens/verify_phone_screen.dart index cf958ff..361d32c 100644 --- a/lib/screens/verify_phone_screen.dart +++ b/lib/screens/verify_phone_screen.dart @@ -93,7 +93,7 @@ class _VerifyPhoneScreenState extends State { builder: (context) => const VerifyCodeScreen())); // Handle OTP submission here - print('OTP submitted'); + // print('OTP submitted'); }, ), ), diff --git a/lib/screens/visit_rd_pd_screen.dart b/lib/screens/visit_rd_pd_screen.dart index a23d901..5c99480 100644 --- a/lib/screens/visit_rd_pd_screen.dart +++ b/lib/screens/visit_rd_pd_screen.dart @@ -48,7 +48,7 @@ class VisitRdPdScreenState extends State { 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 diff --git a/lib/widgets/common_text_form_field.dart b/lib/widgets/common_text_form_field.dart index 3546486..1fad71b 100644 --- a/lib/widgets/common_text_form_field.dart +++ b/lib/widgets/common_text_form_field.dart @@ -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,