Skip to content

Commit

Permalink
notification delete fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AryanSarafDev committed Aug 28, 2024
1 parent 7ad7aa4 commit dcbf7f3
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 196 deletions.
26 changes: 19 additions & 7 deletions lib/app/data/providers/firestore_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,14 @@ class FirestoreDb {
.doc(currentUserEmail)
.collection('sharedProfile')
.doc(currentProfileName)
.set(profileSet);
.set(profileSet)
.then((v) {
Get.snackbar('Notification', 'Item Shared!');
});
;
for (final email in emails) {
await _firebaseFirestore.collection('users').doc(email).update({
"receivedItems": FieldValue.arrayUnion([sharedItem])
'receivedItems': FieldValue.arrayUnion([sharedItem])
});
}
}
Expand All @@ -344,10 +348,13 @@ class FirestoreDb {
.doc(currentUserEmail)
.collection('sharedAlarms')
.doc(alarm.alarmID)
.set(AlarmModel.toMap(alarm));
.set(AlarmModel.toMap(alarm))
.then((v) {
Get.snackbar('Notification', 'Item Shared!');
});
for (final email in emails) {
await _firebaseFirestore.collection('users').doc(email).update({
"receivedItems": FieldValue.arrayUnion([sharedItem])
'receivedItems': FieldValue.arrayUnion([sharedItem])
});
}
}
Expand Down Expand Up @@ -515,9 +522,14 @@ class FirestoreDb {
yield* userNotifications;
}

static removeItem(String email, Map item) async {
await _firebaseFirestore.collection('users').doc(email).update({
"receivedItems": FieldValue.arrayRemove([item])
static removeItem(Map item) async {
print(item);

await _firebaseFirestore
.collection('users')
.doc(_firebaseAuthInstance.currentUser!.email)
.update({
'receivedItems': FieldValue.arrayRemove([item])
});
}
}
2 changes: 1 addition & 1 deletion lib/app/data/providers/isar_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class IsarDb {
static Future<bool> profileExists(String name) async {
final isarProvider = IsarDb();
final db = await isarProvider.db;
final a = db.profileModels.filter().profileNameEqualTo(name).findFirst();
final a = await db.profileModels.filter().profileNameEqualTo(name).findFirst();

return a != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class AddOrUpdateAlarmView extends GetView<AddOrUpdateAlarmController> {
),
),
appBar: PreferredSize(
preferredSize: Size.fromHeight(height / 8.9),
preferredSize: Size.fromHeight(height*0.08),
child: Obx(
() => AppBar(
backgroundColor: themeController.primaryBackgroundColor.value,
Expand Down
37 changes: 22 additions & 15 deletions lib/app/modules/notifications/views/notifications_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ class NotificationsView extends GetView<NotificationsController> {
TextButton(
onPressed: () async {
await FirestoreDb.removeItem(
controller.notifications[index]
['owner'],
controller
.notifications[index]);
Get.back();
controller.notifications[index],
);
Get.snackbar('Notification',
'Shared Item Removed',);
Navigator.of(context).pop();
},
child: const Text(
'Reject',
Expand All @@ -174,11 +174,13 @@ class NotificationsView extends GetView<NotificationsController> {
index]['AlarmName'],
);
await FirestoreDb.removeItem(
controller.notifications[index]
['owner'],
controller
.notifications[index]);
Get.back();


Navigator.of(context).pop();
Get.snackbar("Notification",
"Shared Item Added");
},
child: const Text('Add'),
),
Expand Down Expand Up @@ -210,7 +212,8 @@ class NotificationsView extends GetView<NotificationsController> {
}

Widget toAccept(Map notification) {
return SingleChildScrollView(scrollDirection: Axis.horizontal,
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
Container(
Expand All @@ -221,8 +224,8 @@ class NotificationsView extends GetView<NotificationsController> {
child: ClipRRect(
borderRadius: BorderRadius.circular(18),
child: Padding(
padding:
EdgeInsets.all(controller.homeController.scalingFactor * 10),
padding: EdgeInsets.all(
controller.homeController.scalingFactor * 10),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: notification['type'] == 'profile'
Expand Down Expand Up @@ -257,29 +260,33 @@ class NotificationsView extends GetView<NotificationsController> {
? Text(
'${notification['owner']} sent a profile.',
style: TextStyle(
fontSize: controller.homeController.scalingFactor * 14,
fontSize:
controller.homeController.scalingFactor * 14,
),
)
: Text(
'${notification['owner']} sent an alarm.',
style: TextStyle(
fontSize: controller.homeController.scalingFactor * 14,
fontSize:
controller.homeController.scalingFactor * 14,
),
),
notification['type'] == 'profile'
? Text(
notification['profileName'],
style: TextStyle(
color: kprimaryColor,
fontSize: controller.homeController.scalingFactor * 20,
fontSize:
controller.homeController.scalingFactor * 20,
fontWeight: FontWeight.w700,
),
)
: Text(
notification['alarmTime'],
style: TextStyle(
color: kprimaryColor,
fontSize: controller.homeController.scalingFactor * 20,
fontSize:
controller.homeController.scalingFactor * 20,
fontWeight: FontWeight.w700,
),
),
Expand Down
Loading

0 comments on commit dcbf7f3

Please sign in to comment.