notification screeen upgrade
This commit is contained in:
parent
3e0e46d2b9
commit
a41f500aee
@ -1,9 +1,11 @@
|
|||||||
|
import 'package:cheminova/notification_service.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:cheminova/services/secure__storage_service.dart';
|
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';
|
||||||
|
|
||||||
|
|
||||||
class LoginProvider extends ChangeNotifier {
|
class LoginProvider extends ChangeNotifier {
|
||||||
final _storageService = SecureStorageService();
|
final _storageService = SecureStorageService();
|
||||||
|
|
||||||
@ -31,26 +33,16 @@ class LoginProvider extends ChangeNotifier {
|
|||||||
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());
|
||||||
}
|
}
|
||||||
} on DioException catch (e) {
|
|
||||||
setLoading(false);
|
|
||||||
|
|
||||||
if (e.response?.data is Map<String, dynamic>) {
|
|
||||||
return (
|
|
||||||
false,
|
|
||||||
e.response?.data['message'].toString() ?? 'something went wrong'
|
|
||||||
);
|
|
||||||
} else if (e.response?.data is String) {
|
|
||||||
return (false, e.response?.data.toString() ?? 'something went wrong');
|
|
||||||
} else {
|
|
||||||
return (false, 'something went wrong');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return (false, 'something went wrong');
|
return (false, 'Something want wrong');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,61 +139,66 @@ class CollectKycScreenState extends State<CollectKycScreen>
|
|||||||
return ChangeNotifierProvider(
|
return ChangeNotifierProvider(
|
||||||
create: (context) => collectKycProvider,
|
create: (context) => collectKycProvider,
|
||||||
child: Consumer<CollectKycProvider>(
|
child: Consumer<CollectKycProvider>(
|
||||||
builder: (BuildContext context, value, Widget? child) =>
|
builder: (BuildContext context, value, Widget? child) => Stack(
|
||||||
Stack(children: [
|
children: [
|
||||||
CommonBackground(
|
CommonBackground(
|
||||||
child: DefaultTabController(
|
child: DefaultTabController(
|
||||||
length: 3,
|
length: 3,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
appBar: PreferredSize(
|
||||||
|
preferredSize: const Size.fromHeight(100),
|
||||||
|
child: CommonAppBar(
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
icon: Image.asset('assets/Back_attendance.png'),
|
||||||
|
padding: const EdgeInsets.only(right: 20),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
title: const Text('Collect KYC Data',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
color: Colors.black,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
fontFamily: 'Anek')),
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
appBar: PreferredSize(
|
elevation: 0,
|
||||||
preferredSize: const Size.fromHeight(100),
|
bottom: TabBar(
|
||||||
child: CommonAppBar(
|
controller: value.tabController,
|
||||||
actions: [
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||||
IconButton(
|
dividerColor: Colors.transparent,
|
||||||
onPressed: () {
|
indicatorColor: Colors.yellow,
|
||||||
Navigator.pop(context);
|
labelColor: Colors.white,
|
||||||
},
|
unselectedLabelColor: Colors.black,
|
||||||
icon:
|
indicatorSize: TabBarIndicatorSize.tab,
|
||||||
Image.asset('assets/Back_attendance.png'),
|
indicator: BoxDecoration(
|
||||||
padding: const EdgeInsets.only(right: 20),
|
color: Colors.blue,
|
||||||
),
|
borderRadius: BorderRadius.circular(10)),
|
||||||
],
|
tabs: const [
|
||||||
title: const Text('Collect KYC Data',
|
Tab(text: 'Details'),
|
||||||
style: TextStyle(
|
Tab(text: 'Documents'),
|
||||||
fontSize: 20,
|
Tab(text: 'Verify')
|
||||||
color: Colors.black,
|
],
|
||||||
fontWeight: FontWeight.w400,
|
),
|
||||||
fontFamily: 'Anek')),
|
),
|
||||||
backgroundColor: Colors.transparent,
|
),
|
||||||
elevation: 0,
|
drawer: const CommonDrawer(),
|
||||||
bottom: TabBar(
|
body: TabBarView(
|
||||||
controller: value.tabController,
|
controller: value.tabController,
|
||||||
padding: const EdgeInsets.symmetric(
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
horizontal: 10),
|
children: _pages),
|
||||||
dividerColor: Colors.transparent,
|
),
|
||||||
indicatorColor: Colors.yellow,
|
),
|
||||||
labelColor: Colors.white,
|
),
|
||||||
unselectedLabelColor: Colors.black,
|
if (value.isLoading)
|
||||||
indicatorSize: TabBarIndicatorSize.tab,
|
Container(
|
||||||
indicator: BoxDecoration(
|
color: Colors.black.withOpacity(0.5),
|
||||||
color: Colors.blue,
|
child: const Center(child: CircularProgressIndicator()))
|
||||||
borderRadius: BorderRadius.circular(10)),
|
],
|
||||||
tabs: const [
|
),
|
||||||
Tab(text: 'Details'),
|
|
||||||
Tab(text: 'Documents'),
|
|
||||||
Tab(text: 'Verify')
|
|
||||||
]))),
|
|
||||||
drawer: const CommonDrawer(),
|
|
||||||
body: TabBarView(
|
|
||||||
controller: value.tabController,
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
children: _pages)))),
|
|
||||||
if (value.isLoading)
|
|
||||||
Container(
|
|
||||||
color: Colors.black.withOpacity(0.5),
|
|
||||||
child: const Center(child: CircularProgressIndicator()))
|
|
||||||
]),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,6 @@ class _LoginPageState extends State<LoginPage> {
|
|||||||
builder: (context, value, child) =>
|
builder: (context, value, child) =>
|
||||||
CommonTextFormField(
|
CommonTextFormField(
|
||||||
controller: value.passwordController,
|
controller: value.passwordController,
|
||||||
obscureText: true,
|
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value == null || value.isEmpty) {
|
if (value == null || value.isEmpty) {
|
||||||
return 'Please enter your password';
|
return 'Please enter your password';
|
||||||
|
@ -86,48 +86,60 @@ class MyListView extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return value.notificationList.isEmpty
|
// Group notifications by date
|
||||||
? const Center(
|
Map<String, List<Notifications>> groupedNotifications = {};
|
||||||
child: Text(
|
|
||||||
'No Notifications',
|
for (var notification in value.notificationList) {
|
||||||
style: TextStyle(
|
String date = DateFormat("dd MMM yyyy")
|
||||||
fontSize: 20,
|
.format(DateTime.parse(notification.createdAt ?? ''));
|
||||||
color: Colors.white,
|
if (!groupedNotifications.containsKey(date)) {
|
||||||
fontWeight: FontWeight.w500,
|
groupedNotifications[date] = [];
|
||||||
fontFamily: 'Anek',
|
}
|
||||||
|
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<Notifications> 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(
|
||||||
: ListView.builder(
|
(item) => Padding(
|
||||||
padding: const EdgeInsets.only(top: 15),
|
padding: const EdgeInsets.only(bottom: 10),
|
||||||
itemCount: value.notificationList.length,
|
child: ExpansionTile(
|
||||||
itemBuilder: (context, index) {
|
collapsedBackgroundColor: Colors.white,
|
||||||
Notifications item = value.notificationList[index];
|
backgroundColor: Colors.white,
|
||||||
return Padding(
|
trailing: const SizedBox.shrink(),
|
||||||
padding: const EdgeInsets.only(bottom: 10, left: 10, right: 10),
|
title: Text(
|
||||||
child: ExpansionTile(
|
item.title ?? '',
|
||||||
collapsedBackgroundColor: Colors.white,
|
style: const TextStyle(
|
||||||
backgroundColor: Colors.white,
|
fontSize: 17, fontWeight: FontWeight.w500),
|
||||||
trailing: const SizedBox.shrink(),
|
),
|
||||||
title: Text(
|
subtitle: Text(item.msg ?? ''),
|
||||||
item.title ?? '',
|
|
||||||
style: const TextStyle(
|
|
||||||
fontSize: 17, fontWeight: FontWeight.w500),
|
|
||||||
),
|
|
||||||
subtitle: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
(DateFormat("dd/MMM/yyyy").format(
|
|
||||||
DateTime.parse(item.createdAt ?? ''),
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
Text(item.msg ?? ''),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
],
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ class MyListView extends StatelessWidget {
|
|||||||
subtitle: Column(
|
subtitle: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text((DateFormat("dd/MMMM/yyyy")
|
Text((DateFormat("dd MMMM 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 ?? ''),
|
for (var note in item.notes!) Text(note.message ?? ''),
|
||||||
|
@ -10,4 +10,5 @@ class ApiUrls {
|
|||||||
static const String getPdUrl = 'kyc/get-pd-tm';
|
static const String getPdUrl = 'kyc/get-pd-tm';
|
||||||
static const String rejectedApplication = '${baseUrl}kyc/getAllrejected-tm';
|
static const String rejectedApplication = '${baseUrl}kyc/getAllrejected-tm';
|
||||||
static const String notificationUrl = '$baseUrl/get-notification-tm';
|
static const String notificationUrl = '$baseUrl/get-notification-tm';
|
||||||
|
static const String fcmUrl = '${baseUrl}kyc/save-fcm-tm';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user