integrate notification api list
This commit is contained in:
parent
510529d84d
commit
65b97c4f73
5
.firebaserc
Normal file
5
.firebaserc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"projects": {
|
||||
"default": "cheminova-1fcf0"
|
||||
}
|
||||
}
|
29
android/app/google-services.json
Normal file
29
android/app/google-services.json
Normal file
@ -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"
|
||||
}
|
1
firebase.json
Normal file
1
firebase.json
Normal file
@ -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"}}}}}}
|
68
lib/firebase_options.dart
Normal file
68
lib/firebase_options.dart
Normal file
@ -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',
|
||||
);
|
||||
}
|
67
lib/models/notification_list_response.dart
Normal file
67
lib/models/notification_list_response.dart
Normal file
@ -0,0 +1,67 @@
|
||||
class NotificationListResponse {
|
||||
String? returnMessage;
|
||||
List<Notifications>? notifications;
|
||||
|
||||
NotificationListResponse({this.returnMessage, this.notifications});
|
||||
|
||||
NotificationListResponse.fromJson(Map<String, dynamic> json) {
|
||||
returnMessage = json['return_message'];
|
||||
if (json['notifications'] != null) {
|
||||
notifications = <Notifications>[];
|
||||
json['notifications'].forEach((v) {
|
||||
notifications!.add(new Notifications.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
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<String, dynamic> json) {
|
||||
sId = json['_id'];
|
||||
title = json['title'];
|
||||
msg = json['msg'];
|
||||
addedFor = json['added_for'];
|
||||
createdAt = json['createdAt'];
|
||||
updatedAt = json['updatedAt'];
|
||||
iV = json['__v'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
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;
|
||||
}
|
||||
}
|
40
lib/provider/notification_provider.dart
Normal file
40
lib/provider/notification_provider.dart
Normal file
@ -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<Notifications> notificationList = [];
|
||||
|
||||
bool _isLoading = false;
|
||||
|
||||
bool get isLoading => _isLoading;
|
||||
|
||||
void setLoading(bool loading) {
|
||||
_isLoading = loading;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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<NotificationScreen> {
|
||||
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<NotificationScreen> {
|
||||
elevation: 0,
|
||||
),
|
||||
drawer: const CommonDrawer(),
|
||||
body: Consumer<RejectedProvider>(
|
||||
body: Consumer<NotificationProvider>(
|
||||
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 ?? ''),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -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 ?? ''),
|
||||
|
@ -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';
|
||||
}
|
||||
|
1
remoteconfig.template.json
Normal file
1
remoteconfig.template.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
Loading…
Reference in New Issue
Block a user