Skip to content

Commit

Permalink
added notif pref
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunalpal216 committed Aug 7, 2023
1 parent 47f2ec6 commit e55295c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/globals/endpoints.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Endpoints {
static const String guestLogin = "/user/guest/login";
static const String userProfile = "/user";
static const String userDeviceTokens = "/user/device-tokens";
static const String userNotifPrefs = "user/notifs/prefs";
static const String userNotifPrefs = "/user/notifs/prefs";
//static const String userLogout = "/user/logout";
static getHeader() {
return {'Content-Type': 'application/json', 'security-key': Endpoints.apiSecurityKey};
Expand Down
12 changes: 6 additions & 6 deletions lib/pages/notifications/notification_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ class NotificationSettings extends StatefulWidget {
}

class _NotificationSettingsState extends State<NotificationSettings> {
bool lost = LoginStore.notifData["lost"]!;
bool found = LoginStore.notifData["found"]!;
bool cab= LoginStore.notifData["cab sharing"]!;
bool announcement = LoginStore.notifData["announcement"]!;
// bool lost = LoginStore.userData['notifPref'][NotificationCategories.lost]!;
// bool found = LoginStore.userData['notifPref'][NotificationCategories.found]!;
// bool cabSharing= LoginStore.userData['notifPref'][NotificationCategories.cabSharing]!;
// bool announcement = LoginStore.userData['notifPref'][NotificationCategories.announcement]!;
@override
Widget build(BuildContext context) {
print(LoginStore.userData['notifPref']);
return Scaffold(
appBar: AppBar(
backgroundColor: kAppBarGrey,
title: Text('Notification Settings',
style: MyFonts.w500,
),
),
body: Column(
body: ListView(
children: [
NotifToggle(text: NotificationCategories.announcement),
NotifToggle(text: NotificationCategories.cabSharing),
NotifToggle(text: NotificationCategories.lost),
NotifToggle(text: NotificationCategories.found),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/profile/edit_profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class _EditProfileState extends State<EditProfile> {
"Kameng",
"Barak",
"Lohit",
"Brahma",
"Brahmaputra",
"Disang",
"Manas",
"Dihing",
Expand Down
2 changes: 1 addition & 1 deletion lib/stores/login_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:firebase_messaging/firebase_messaging.dart';

class LoginStore {
static Map<String, dynamic> userData = {};
static Map<String, bool> notifData = {};
// static Map<String, bool> notifData = {};
final cookieManager = WebviewCookieManager();
static bool isGuest = false;
static bool isProfileComplete=false;
Expand Down
3 changes: 2 additions & 1 deletion lib/widgets/notifications/notif_toggle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ class _NotifToggleState extends State<NotifToggle> {
activeColor: lBlue2,
height: 32,
width: 52,
value: LoginStore.notifData[widget.text]!,
value: LoginStore.userData['notifPref'][widget.text]!,
onToggle: (val) async {
if(isLoading) {return;}
isLoading = true;
LoginStore.userData['notifPref'][widget.text] = val;
print(LoginStore.userData['notifPref']);
await APIService().updateUserNotifPref(LoginStore.userData['notifPref']);
// await LoginStore.updateNotifPref(widget.text);
setState((){});
Expand Down

0 comments on commit e55295c

Please sign in to comment.