integrate api for the notification and link with the push notifocation
This commit is contained in:
parent
d1bcdb7a7d
commit
510529d84d
@ -4,6 +4,8 @@ import 'package:cheminova/services/secure__storage_service.dart';
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../notification_services.dart';
|
||||||
|
|
||||||
class LoginProvider extends ChangeNotifier {
|
class LoginProvider extends ChangeNotifier {
|
||||||
final _storageService = SecureStorageService();
|
final _storageService = SecureStorageService();
|
||||||
|
|
||||||
@ -23,12 +25,17 @@ class LoginProvider extends ChangeNotifier {
|
|||||||
Future<(bool, String)> login() async {
|
Future<(bool, String)> login() async {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
Response response = await _apiClient.post(ApiUrls.loginUrl,
|
Response response = await _apiClient.post(ApiUrls.loginUrl, data: {
|
||||||
data: {'email': emailController.text.trim(), 'password': passwordController.text.trim()});
|
'email': emailController.text.trim(),
|
||||||
|
'password': passwordController.text.trim()
|
||||||
|
});
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
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();
|
||||||
|
print('fcmToken: $fcmToken');
|
||||||
|
await _apiClient.post(ApiUrls.fcmUrl, data: {'fcmToken': fcmToken});
|
||||||
return (true, response.data['message'].toString());
|
return (true, response.data['message'].toString());
|
||||||
} else {
|
} else {
|
||||||
return (false, response.data['message'].toString());
|
return (false, response.data['message'].toString());
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
import 'package:cheminova/widgets/common_background.dart';
|
import 'package:cheminova/models/rejected_applicaton_response.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../widgets/common_app_bar.dart';
|
import 'package:cheminova/widgets/common_background.dart';
|
||||||
import '../widgets/common_elevated_button.dart';
|
import 'package:cheminova/widgets/common_drawer.dart';
|
||||||
import '../widgets/common_text_form_field.dart';
|
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 {
|
class NotificationScreen extends StatefulWidget {
|
||||||
const NotificationScreen({super.key});
|
const NotificationScreen({super.key});
|
||||||
@ -12,10 +17,19 @@ class NotificationScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class NotificationScreenState extends State<NotificationScreen> {
|
class NotificationScreenState extends State<NotificationScreen> {
|
||||||
|
late RejectedProvider _rejectedProvider;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_rejectedProvider = RejectedProvider();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return ChangeNotifierProvider(
|
||||||
return CommonBackground(
|
create: (context) => _rejectedProvider,
|
||||||
|
child: CommonBackground(
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
appBar: CommonAppBar(
|
appBar: CommonAppBar(
|
||||||
@ -28,7 +42,7 @@ class NotificationScreenState extends State<NotificationScreen> {
|
|||||||
padding: const EdgeInsets.only(right: 20),
|
padding: const EdgeInsets.only(right: 20),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
title: const Text('Notifications',
|
title: const Text('Notification',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
@ -37,98 +51,67 @@ class NotificationScreenState extends State<NotificationScreen> {
|
|||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
drawer: const CommonDrawer(),
|
||||||
child: Column(
|
body: Consumer<RejectedProvider>(
|
||||||
|
builder: (context, value, child) => value.isLoading
|
||||||
|
? const Center(child: CircularProgressIndicator())
|
||||||
|
: MyListView(value: value),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildProductButton(String productName) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 15),
|
||||||
|
child: CommonElevatedButton(
|
||||||
|
borderRadius: 30,
|
||||||
|
width: double.infinity,
|
||||||
|
height: kToolbarHeight - 10,
|
||||||
|
text: productName,
|
||||||
|
backgroundColor: const Color(0xff004791),
|
||||||
|
onPressed: () {
|
||||||
|
// Handle product button press
|
||||||
|
debugPrint('$productName pressed');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyListView extends StatelessWidget {
|
||||||
|
final RejectedProvider value;
|
||||||
|
|
||||||
|
const MyListView({super.key, required this.value});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListView.builder(
|
||||||
|
padding: const EdgeInsets.only(top: 15),
|
||||||
|
itemCount: value.rejectedApplicationList.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
RejectedApplicationResponse item = value.rejectedApplicationList[index];
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 10, left: 10, right: 10),
|
||||||
|
child: ExpansionTile(
|
||||||
|
collapsedBackgroundColor: Colors.white,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
title: Text(
|
||||||
|
item.tradeName ?? '',
|
||||||
|
style: const TextStyle(fontSize: 17, fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
|
subtitle: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Text((DateFormat("dd/MM/yyyy")
|
||||||
padding: const EdgeInsets.all(20.0).copyWith(top: 20, bottom: 30),
|
.format(DateTime.parse(item.createdAt ?? '')))),
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 20.0),
|
Text(item.sId ?? ''),
|
||||||
decoration: BoxDecoration(
|
for (var note in item.notes!) Text(note.message ?? ''),
|
||||||
border: Border.all(color: Colors.white),
|
|
||||||
color: const Color(0xffB4D1E5).withOpacity(0.9),
|
|
||||||
borderRadius: BorderRadius.circular(26.0),
|
|
||||||
),
|
|
||||||
child: const Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
Text('Notifications',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 30,
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
fontFamily: 'Anek',
|
|
||||||
)),
|
|
||||||
SizedBox(
|
|
||||||
height: 10,
|
|
||||||
),
|
|
||||||
SizedBox(height:15 ),
|
|
||||||
CommonTextFormField(
|
|
||||||
title: ' Notification Type:Alert',
|
|
||||||
),
|
|
||||||
SizedBox(height: 20,),
|
|
||||||
|
|
||||||
])
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20,),
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(20.0).copyWith(top: 20, bottom: 30),
|
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 20.0),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(color: Colors.white),
|
|
||||||
color: const Color(0xffB4D1E5).withOpacity(0.9),
|
|
||||||
borderRadius: BorderRadius.circular(26.0),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
const Text('Notifications List',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 30,
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
fontFamily: 'Anek',
|
|
||||||
)),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
const CommonTextFormField(
|
|
||||||
title: 'Task: Review Sales Data by EOD\nDate: 10-06-2024',),
|
|
||||||
const SizedBox(height: 20,),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: CommonElevatedButton(
|
|
||||||
borderRadius: 30,
|
|
||||||
width: double.infinity,
|
|
||||||
height: kToolbarHeight - 10,
|
|
||||||
text: 'VIEW DETAILS',
|
|
||||||
backgroundColor: const Color(0xff004791),
|
|
||||||
onPressed: () {
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20,),
|
|
||||||
const CommonTextFormField(
|
|
||||||
title: 'Alert: New Dealer Assigned\nDate: 10-06-2024',),
|
|
||||||
const SizedBox(height: 15),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: CommonElevatedButton(
|
|
||||||
borderRadius: 30,
|
|
||||||
width: double.infinity,
|
|
||||||
height: kToolbarHeight - 10,
|
|
||||||
text: 'VIEW DETAILS',
|
|
||||||
backgroundColor: const Color(0xff004791),
|
|
||||||
onPressed: () {
|
|
||||||
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]),
|
);
|
||||||
)));
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,8 @@ class RejectedApplicationScreen extends StatefulWidget {
|
|||||||
const RejectedApplicationScreen({super.key});
|
const RejectedApplicationScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<RejectedApplicationScreen> createState() => _RejectedApplicationScreenState();
|
State<RejectedApplicationScreen> createState() =>
|
||||||
|
_RejectedApplicationScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _RejectedApplicationScreenState extends State<RejectedApplicationScreen> {
|
class _RejectedApplicationScreenState extends State<RejectedApplicationScreen> {
|
||||||
@ -56,47 +57,13 @@ class _RejectedApplicationScreenState extends State<RejectedApplicationScreen> {
|
|||||||
builder: (context, value, child) => value.isLoading
|
builder: (context, value, child) => value.isLoading
|
||||||
? const Center(child: CircularProgressIndicator())
|
? const Center(child: CircularProgressIndicator())
|
||||||
: MyListView(value: value),
|
: MyListView(value: value),
|
||||||
// child: Padding(
|
|
||||||
// padding: const EdgeInsets.all(16.0),
|
|
||||||
// child: SingleChildScrollView(
|
|
||||||
// physics: const BouncingScrollPhysics(),
|
|
||||||
// child: Column(
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
// children: <Widget>[
|
|
||||||
// const SizedBox(height: 16),
|
|
||||||
// Container(
|
|
||||||
// padding: const EdgeInsets.all(20.0).copyWith(
|
|
||||||
// top: 30, bottom: 30),
|
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// border: Border.all(color: Colors.white),
|
|
||||||
// color: const Color(0xffB4D1E5).withOpacity(0.9),
|
|
||||||
// borderRadius: BorderRadius.circular(26.0),
|
|
||||||
// ),
|
|
||||||
// child: Column(
|
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
// children: <Widget>[
|
|
||||||
// _buildProductButton('Trade Name 1'),
|
|
||||||
// _buildProductButton('Trade Name 2'),
|
|
||||||
// _buildProductButton('Trade Name 3'),
|
|
||||||
// // _buildProductButton('Product 4'),
|
|
||||||
// // _buildProductButton('Product 5'),
|
|
||||||
// // _buildProductButton('Product 6'),
|
|
||||||
// // _buildProductButton('Product 7'),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Widget _buildProductButton(String productName) {
|
|
||||||
|
Widget buildProductButton(String productName) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 15),
|
padding: const EdgeInsets.only(bottom: 15),
|
||||||
child: CommonElevatedButton(
|
child: CommonElevatedButton(
|
||||||
@ -111,11 +78,12 @@ class _RejectedApplicationScreenState extends State<RejectedApplicationScreen> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyListView extends StatelessWidget {
|
class MyListView extends StatelessWidget {
|
||||||
final RejectedProvider value;
|
final RejectedProvider value;
|
||||||
const MyListView( {super.key, required this.value});
|
|
||||||
|
const MyListView({super.key, required this.value});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -125,19 +93,21 @@ class MyListView extends StatelessWidget {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
RejectedApplicationResponse item = value.rejectedApplicationList[index];
|
RejectedApplicationResponse item = value.rejectedApplicationList[index];
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 10,left: 10,right: 10),
|
padding: const EdgeInsets.only(bottom: 10, left: 10, right: 10),
|
||||||
child: ExpansionTile(
|
child: ExpansionTile(
|
||||||
|
|
||||||
collapsedBackgroundColor: Colors.white,
|
collapsedBackgroundColor: Colors.white,
|
||||||
backgroundColor: Colors.white,
|
backgroundColor: Colors.white,
|
||||||
|
title: Text(
|
||||||
title: Text(item.tradeName ?? '',style: const TextStyle(fontSize: 17,fontWeight:FontWeight.w500),),
|
item.tradeName ?? '',
|
||||||
|
style: const TextStyle(fontSize: 17, fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
subtitle: Column(
|
subtitle: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text((DateFormat("dd/MM/yyyy")
|
Text((DateFormat("dd/MM/yyyy")
|
||||||
.format(DateTime.parse(item.createdAt ?? '')))),
|
.format(DateTime.parse(item.createdAt ?? '')))),
|
||||||
Text(item.sId ?? ''),
|
Text(item.sId ?? ''),
|
||||||
|
for (var note in item.notes!) Text(note.message ?? ''),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@ -160,31 +130,35 @@ class MyListView extends StatelessWidget {
|
|||||||
title: Text('Status: ${item.status ?? ''}'),
|
title: Text('Status: ${item.status ?? ''}'),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text('Principal Distributor: ${item.principalDistributer!.name ?? ''}'),
|
title: Text(
|
||||||
|
'Principal Distributor: ${item.principalDistributer!.name ?? ''}'),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text('PAN Number: ${item.panNumber ?? ''}'),
|
title: Text('PAN Number: ${item.panNumber ?? ''}'),
|
||||||
),
|
),
|
||||||
Image.network(item.panImg!.url ?? '',height: 250,width: 250),
|
Image.network(item.panImg!.url ?? '', height: 250, width: 250),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text('Aadhar Number: ${item.aadharNumber?? ''}'),
|
title: Text('Aadhar Number: ${item.aadharNumber ?? ''}'),
|
||||||
),
|
),
|
||||||
Image.network(item.aadharImg?.url ?? '',height: 250,width: 250),
|
Image.network(item.aadharImg?.url ?? '', height: 250, width: 250),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text('GST Number: ${item.gstNumber ?? ''}'),
|
title: Text('GST Number: ${item.gstNumber ?? ''}'),
|
||||||
),
|
),
|
||||||
Image.network(item.gstImg!.url ?? '',height: 250,width: 250),const ListTile(
|
Image.network(item.gstImg!.url ?? '', height: 250, width: 250),
|
||||||
|
const ListTile(
|
||||||
title: Text('Pesticide License: '),
|
title: Text('Pesticide License: '),
|
||||||
),
|
),
|
||||||
|
|
||||||
if (item.pesticideLicenseImg != null)
|
if (item.pesticideLicenseImg != null)
|
||||||
Image.network(item.pesticideLicenseImg!.url ?? '',height: 250,width: 250),
|
Image.network(item.pesticideLicenseImg!.url ?? '',
|
||||||
|
height: 250, width: 250),
|
||||||
// if (item['fertilizer_license_img'] != null)
|
// if (item['fertilizer_license_img'] != null)
|
||||||
// Image.network(item['fertilizer_license_img']['url'] ?? ''),
|
// Image.network(item['fertilizer_license_img']['url'] ?? ''),
|
||||||
const ListTile(
|
const ListTile(
|
||||||
title: Text('selfieEntranceImg: '),
|
title: Text('selfieEntranceImg: '),
|
||||||
),
|
),
|
||||||
Image.network(item.selfieEntranceImg!.url ?? '',height: 250,width: 250),
|
Image.network(item.selfieEntranceImg!.url ?? '',
|
||||||
|
height: 250, width: 250),
|
||||||
const ListTile(
|
const ListTile(
|
||||||
title: Text('Notes:'),
|
title: Text('Notes:'),
|
||||||
),
|
),
|
||||||
@ -194,7 +168,6 @@ class MyListView extends StatelessWidget {
|
|||||||
contentPadding: const EdgeInsets.only(left: 20),
|
contentPadding: const EdgeInsets.only(left: 20),
|
||||||
title: Text(note.message ?? ''),
|
title: Text(note.message ?? ''),
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -11,4 +11,6 @@ class ApiUrls {
|
|||||||
static const String leaveAttendance = '${baseUrl}v1/markleave/salescoordinator';
|
static const String leaveAttendance = '${baseUrl}v1/markleave/salescoordinator';
|
||||||
static const String logOutUrl = '${baseUrl}salescoordinator/logout';
|
static const String logOutUrl = '${baseUrl}salescoordinator/logout';
|
||||||
static const String rejectedApplication = '${baseUrl}kyc/getAllrejected';
|
static const String rejectedApplication = '${baseUrl}kyc/getAllrejected';
|
||||||
|
static const String notificationUrl = '$baseUrl/api/get-notification-sc';
|
||||||
|
static const String fcmUrl = '${baseUrl}kyc/save-fcm-sc';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user