diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 0000000..01ac02a --- /dev/null +++ b/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "cheminova-1fcf0" + } +} diff --git a/android/app/google-services.json b/android/app/google-services.json new file mode 100644 index 0000000..40ed628 --- /dev/null +++ b/android/app/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "242950171023", + "project_id": "cheminova-1fcf0", + "storage_bucket": "cheminova-1fcf0.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:242950171023:android:7fdc614b0429b52445c3fa", + "android_client_info": { + "package_name": "com.example.cheminova" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyDfgOZAwDgUnzQYnIHm8ObxrDtTutmAoAE" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..0dd5c0e --- /dev/null +++ b/firebase.json @@ -0,0 +1 @@ +{"remoteconfig":{"template":"remoteconfig.template.json"},"flutter":{"platforms":{"android":{"default":{"projectId":"cheminova-1fcf0","appId":"1:242950171023:android:7fdc614b0429b52445c3fa","fileOutput":"android/app/google-services.json"}},"dart":{"lib/firebase_options.dart":{"projectId":"cheminova-1fcf0","configurations":{"android":"1:242950171023:android:7fdc614b0429b52445c3fa","ios":"1:242950171023:ios:f4aba8c6c2d8f5ec45c3fa"}}}}}} \ No newline at end of file diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart new file mode 100644 index 0000000..daf3b9c --- /dev/null +++ b/lib/firebase_options.dart @@ -0,0 +1,68 @@ +// File generated by FlutterFire CLI. +// ignore_for_file: type=lint +import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; +import 'package:flutter/foundation.dart' + show defaultTargetPlatform, kIsWeb, TargetPlatform; + +/// Default [FirebaseOptions] for use with your Firebase apps. +/// +/// Example: +/// ```dart +/// import 'firebase_options.dart'; +/// // ... +/// await Firebase.initializeApp( +/// options: DefaultFirebaseOptions.currentPlatform, +/// ); +/// ``` +class DefaultFirebaseOptions { + static FirebaseOptions get currentPlatform { + if (kIsWeb) { + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for web - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + } + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return android; + case TargetPlatform.iOS: + return ios; + case TargetPlatform.macOS: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for macos - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.windows: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for windows - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + case TargetPlatform.linux: + throw UnsupportedError( + 'DefaultFirebaseOptions have not been configured for linux - ' + 'you can reconfigure this by running the FlutterFire CLI again.', + ); + default: + throw UnsupportedError( + 'DefaultFirebaseOptions are not supported for this platform.', + ); + } + } + + static const FirebaseOptions android = FirebaseOptions( + apiKey: 'AIzaSyDfgOZAwDgUnzQYnIHm8ObxrDtTutmAoAE', + appId: '1:242950171023:android:7fdc614b0429b52445c3fa', + messagingSenderId: '242950171023', + projectId: 'cheminova-1fcf0', + storageBucket: 'cheminova-1fcf0.appspot.com', + ); + + static const FirebaseOptions ios = FirebaseOptions( + apiKey: 'AIzaSyCukVtk1vpdHcO1ayiPMz1wLQGfRGzEXxk', + appId: '1:242950171023:ios:f4aba8c6c2d8f5ec45c3fa', + messagingSenderId: '242950171023', + projectId: 'cheminova-1fcf0', + storageBucket: 'cheminova-1fcf0.appspot.com', + iosBundleId: 'com.example.cheminova', + ); +} diff --git a/lib/models/notification_list_response.dart b/lib/models/notification_list_response.dart new file mode 100644 index 0000000..4db128d --- /dev/null +++ b/lib/models/notification_list_response.dart @@ -0,0 +1,67 @@ +class NotificationListResponse { + String? returnMessage; + List? notifications; + + NotificationListResponse({this.returnMessage, this.notifications}); + + NotificationListResponse.fromJson(Map json) { + returnMessage = json['return_message']; + if (json['notifications'] != null) { + notifications = []; + json['notifications'].forEach((v) { + notifications!.add(new Notifications.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['return_message'] = this.returnMessage; + if (this.notifications != null) { + data['notifications'] = + this.notifications!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class Notifications { + String? sId; + String? title; + String? msg; + String? addedFor; + String? createdAt; + String? updatedAt; + int? iV; + + Notifications( + {this.sId, + this.title, + this.msg, + this.addedFor, + this.createdAt, + this.updatedAt, + this.iV}); + + Notifications.fromJson(Map json) { + sId = json['_id']; + title = json['title']; + msg = json['msg']; + addedFor = json['added_for']; + createdAt = json['createdAt']; + updatedAt = json['updatedAt']; + iV = json['__v']; + } + + Map toJson() { + final Map data = new Map(); + data['_id'] = this.sId; + data['title'] = this.title; + data['msg'] = this.msg; + data['added_for'] = this.addedFor; + data['createdAt'] = this.createdAt; + data['updatedAt'] = this.updatedAt; + data['__v'] = this.iV; + return data; + } +} diff --git a/lib/provider/notification_provider.dart b/lib/provider/notification_provider.dart new file mode 100644 index 0000000..6dbcdbf --- /dev/null +++ b/lib/provider/notification_provider.dart @@ -0,0 +1,40 @@ +import 'package:dio/dio.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import '../models/notification_list_response.dart'; +import '../services/api_client.dart'; +import '../services/api_urls.dart'; + +class NotificationProvider extends ChangeNotifier { + NotificationProvider() { + getNotification(); + } + + final _apiClient = ApiClient(); + List notificationList = []; + + bool _isLoading = false; + + bool get isLoading => _isLoading; + + void setLoading(bool loading) { + _isLoading = loading; + notifyListeners(); + } + + Future getNotification() async { + setLoading(true); + try { + Response response = await _apiClient.get(ApiUrls.notificationUrl); + setLoading(false); + if (response.statusCode == 200) { + final data = NotificationListResponse.fromJson(response.data); + notificationList = data.notifications ?? []; + notifyListeners(); + } + } catch (e) { + setLoading(false); + } + } +} diff --git a/lib/screens/notification_screen.dart b/lib/screens/notification_screen.dart index fd8a550..84283df 100644 --- a/lib/screens/notification_screen.dart +++ b/lib/screens/notification_screen.dart @@ -1,4 +1,6 @@ +import 'package:cheminova/models/notification_list_response.dart'; import 'package:cheminova/models/rejected_applicaton_response.dart'; +import 'package:cheminova/provider/notification_provider.dart'; import 'package:flutter/material.dart'; import 'package:cheminova/widgets/common_background.dart'; import 'package:cheminova/widgets/common_drawer.dart'; @@ -6,7 +8,6 @@ import 'package:cheminova/widgets/common_app_bar.dart'; import 'package:cheminova/widgets/common_elevated_button.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; - import '../provider/rejected_provider.dart'; class NotificationScreen extends StatefulWidget { @@ -17,18 +18,18 @@ class NotificationScreen extends StatefulWidget { } class NotificationScreenState extends State { - late RejectedProvider _rejectedProvider; + late NotificationProvider _notificationProvider; @override void initState() { - _rejectedProvider = RejectedProvider(); + _notificationProvider = NotificationProvider(); super.initState(); } @override Widget build(BuildContext context) { return ChangeNotifierProvider( - create: (context) => _rejectedProvider, + create: (context) => _notificationProvider, child: CommonBackground( child: Scaffold( backgroundColor: Colors.transparent, @@ -52,7 +53,7 @@ class NotificationScreenState extends State { elevation: 0, ), drawer: const CommonDrawer(), - body: Consumer( + body: Consumer( builder: (context, value, child) => value.isLoading ? const Center(child: CircularProgressIndicator()) : MyListView(value: value), @@ -80,7 +81,7 @@ Widget buildProductButton(String productName) { } class MyListView extends StatelessWidget { - final RejectedProvider value; + final NotificationProvider value; const MyListView({super.key, required this.value}); @@ -88,25 +89,25 @@ class MyListView extends StatelessWidget { Widget build(BuildContext context) { return ListView.builder( padding: const EdgeInsets.only(top: 15), - itemCount: value.rejectedApplicationList.length, + itemCount: value.notificationList.length, itemBuilder: (context, index) { - RejectedApplicationResponse item = value.rejectedApplicationList[index]; + Notifications item = value.notificationList[index]; return Padding( padding: const EdgeInsets.only(bottom: 10, left: 10, right: 10), child: ExpansionTile( collapsedBackgroundColor: Colors.white, backgroundColor: Colors.white, + trailing: const SizedBox.shrink(), title: Text( - item.tradeName ?? '', + item.title ?? '', style: const TextStyle(fontSize: 17, fontWeight: FontWeight.w500), ), subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text((DateFormat("dd/MM/yyyy") + Text((DateFormat("dd/MMM/yyyy") .format(DateTime.parse(item.createdAt ?? '')))), - Text(item.sId ?? ''), - for (var note in item.notes!) Text(note.message ?? ''), + Text(item.msg ?? ''), ], ), ), diff --git a/lib/screens/rejected_application_screen.dart b/lib/screens/rejected_application_screen.dart index bdf1c33..abc96bb 100644 --- a/lib/screens/rejected_application_screen.dart +++ b/lib/screens/rejected_application_screen.dart @@ -104,7 +104,7 @@ class MyListView extends StatelessWidget { subtitle: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text((DateFormat("dd/MM/yyyy") + Text((DateFormat("dd/MMMM/yyyy") .format(DateTime.parse(item.createdAt ?? '')))), Text(item.sId ?? ''), for (var note in item.notes!) Text(note.message ?? ''), diff --git a/lib/services/api_urls.dart b/lib/services/api_urls.dart index bd6e6e5..cfe3377 100644 --- a/lib/services/api_urls.dart +++ b/lib/services/api_urls.dart @@ -11,6 +11,6 @@ class ApiUrls { static const String leaveAttendance = '${baseUrl}v1/markleave/salescoordinator'; static const String logOutUrl = '${baseUrl}salescoordinator/logout'; static const String rejectedApplication = '${baseUrl}kyc/getAllrejected'; - static const String notificationUrl = '$baseUrl/api/get-notification-sc'; + static const String notificationUrl = '${baseUrl}/get-notification-sc'; static const String fcmUrl = '${baseUrl}kyc/save-fcm-sc'; } diff --git a/remoteconfig.template.json b/remoteconfig.template.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/remoteconfig.template.json @@ -0,0 +1 @@ +{} \ No newline at end of file