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_urls.dart';
|
||||
import 'package:cheminova/services/secure__storage_service.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
class LoginProvider extends ChangeNotifier {
|
||||
final _storageService = SecureStorageService();
|
||||
|
||||
@ -31,26 +33,16 @@ class LoginProvider extends ChangeNotifier {
|
||||
if (response.statusCode == 200) {
|
||||
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());
|
||||
} else {
|
||||
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) {
|
||||
setLoading(false);
|
||||
return (false, 'something went wrong');
|
||||
return (false, 'Something want wrong');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,8 +139,8 @@ class CollectKycScreenState extends State<CollectKycScreen>
|
||||
return ChangeNotifierProvider(
|
||||
create: (context) => collectKycProvider,
|
||||
child: Consumer<CollectKycProvider>(
|
||||
builder: (BuildContext context, value, Widget? child) =>
|
||||
Stack(children: [
|
||||
builder: (BuildContext context, value, Widget? child) => Stack(
|
||||
children: [
|
||||
CommonBackground(
|
||||
child: DefaultTabController(
|
||||
length: 3,
|
||||
@ -154,8 +154,7 @@ class CollectKycScreenState extends State<CollectKycScreen>
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon:
|
||||
Image.asset('assets/Back_attendance.png'),
|
||||
icon: Image.asset('assets/Back_attendance.png'),
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
),
|
||||
],
|
||||
@ -169,8 +168,7 @@ class CollectKycScreenState extends State<CollectKycScreen>
|
||||
elevation: 0,
|
||||
bottom: TabBar(
|
||||
controller: value.tabController,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
dividerColor: Colors.transparent,
|
||||
indicatorColor: Colors.yellow,
|
||||
labelColor: Colors.white,
|
||||
@ -183,17 +181,24 @@ class CollectKycScreenState extends State<CollectKycScreen>
|
||||
Tab(text: 'Details'),
|
||||
Tab(text: 'Documents'),
|
||||
Tab(text: 'Verify')
|
||||
]))),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
drawer: const CommonDrawer(),
|
||||
body: TabBarView(
|
||||
controller: value.tabController,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: _pages)))),
|
||||
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) =>
|
||||
CommonTextFormField(
|
||||
controller: value.passwordController,
|
||||
obscureText: true,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Please enter your password';
|
||||
|
@ -86,25 +86,43 @@ class MyListView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return value.notificationList.isEmpty
|
||||
? const Center(
|
||||
child: Text(
|
||||
'No Notifications',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontFamily: 'Anek',
|
||||
),
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
// Group notifications by date
|
||||
Map<String, List<Notifications>> groupedNotifications = {};
|
||||
|
||||
for (var notification in value.notificationList) {
|
||||
String date = DateFormat("dd MMM yyyy")
|
||||
.format(DateTime.parse(notification.createdAt ?? ''));
|
||||
if (!groupedNotifications.containsKey(date)) {
|
||||
groupedNotifications[date] = [];
|
||||
}
|
||||
groupedNotifications[date]!.add(notification);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 15),
|
||||
itemCount: value.notificationList.length,
|
||||
itemCount: groupedNotifications.length,
|
||||
itemBuilder: (context, index) {
|
||||
Notifications item = value.notificationList[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(
|
||||
(item) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: ExpansionTile(
|
||||
collapsedBackgroundColor: Colors.white,
|
||||
backgroundColor: Colors.white,
|
||||
@ -114,18 +132,12 @@ class MyListView extends StatelessWidget {
|
||||
style: const TextStyle(
|
||||
fontSize: 17, fontWeight: FontWeight.w500),
|
||||
),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
(DateFormat("dd/MMM/yyyy").format(
|
||||
DateTime.parse(item.createdAt ?? ''),
|
||||
)),
|
||||
subtitle: Text(item.msg ?? ''),
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(item.msg ?? ''),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -104,7 +104,7 @@ class MyListView extends StatelessWidget {
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text((DateFormat("dd/MMMM/yyyy")
|
||||
Text((DateFormat("dd MMMM yyyy")
|
||||
.format(DateTime.parse(item.createdAt ?? '')))),
|
||||
Text(item.sId ?? ''),
|
||||
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 rejectedApplication = '${baseUrl}kyc/getAllrejected-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