diff --git a/lib/utilities/check_if_user_logged_in.dart b/lib/models/check_if_user_logged_in.dart similarity index 78% rename from lib/utilities/check_if_user_logged_in.dart rename to lib/models/check_if_user_logged_in.dart index 72f2fc0..5be08c9 100644 --- a/lib/utilities/check_if_user_logged_in.dart +++ b/lib/models/check_if_user_logged_in.dart @@ -3,6 +3,12 @@ import 'package:flutter/material.dart'; class CheckIfUserLoggedIn extends ChangeNotifier { bool _userLoggedIn = false; + FirebaseUser loggedInUser; + + String getCurrentUserEmail() { + loggedInUser = _auth.currentUser; + return loggedInUser.email; + } final _auth = FirebaseAuth.instance; bool getCurrentUser() { diff --git a/lib/models/reminder_db.dart b/lib/models/reminder_db.dart index a81c893..6e3e10c 100644 --- a/lib/models/reminder_db.dart +++ b/lib/models/reminder_db.dart @@ -1,8 +1,13 @@ import 'dart:collection'; +import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; +import 'check_if_user_logged_in.dart'; import 'reminder.dart'; class ReminderDB extends ChangeNotifier { + final _firestore = Firestore.instance; + CheckIfUserLoggedIn checkIfUserLoggedIn = CheckIfUserLoggedIn(); + List _reminderList = [ // Reminder( // title: 'Reminder Title', @@ -24,12 +29,28 @@ class ReminderDB extends ChangeNotifier { final reminder = Reminder( title: title, description: description, - // date: 'Today', date: date, time: time, ); _reminderList.add(reminder); + _firestore.collection('reminders').add({ + 'title': title, + 'description': description, + 'date': date, + 'time': time, + }); + + // if (checkIfUserLoggedIn.getCurrentUserEmail() != null) { + // _reminderList.add(reminder); + // _firestore.collection('reminders').add({ + // 'title': title, + // 'description': description, + // 'date': date, + // 'time': time, + // }); + // } + notifyListeners(); } @@ -40,6 +61,8 @@ class ReminderDB extends ChangeNotifier { void deleteReminder(Reminder reminder) { _reminderList.remove(reminder); + + // _firestore.collection('reminders').document('wgbhYkrUEKDMnsvYTiHZ') notifyListeners(); } } diff --git a/lib/views/account_view.dart b/lib/views/account_view.dart index 02a7bfd..d4b75c4 100644 --- a/lib/views/account_view.dart +++ b/lib/views/account_view.dart @@ -1,4 +1,4 @@ -import 'package:checklst/utilities/check_if_user_logged_in.dart'; +import 'package:checklst/models/check_if_user_logged_in.dart'; import 'package:checklst/views/body_widgets/auth_body.dart'; import 'package:checklst/views/body_widgets/profile_body.dart'; import "package:flutter/material.dart"; diff --git a/lib/views/body_widgets/auth_body.dart b/lib/views/body_widgets/auth_body.dart index 9bc9410..9cc1a33 100644 --- a/lib/views/body_widgets/auth_body.dart +++ b/lib/views/body_widgets/auth_body.dart @@ -1,4 +1,4 @@ -import 'package:checklst/utilities/check_if_user_logged_in.dart'; +import 'package:checklst/models/check_if_user_logged_in.dart'; import 'package:checklst/widgets/custom_text_form_field.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; diff --git a/lib/views/index.dart b/lib/views/index.dart index c847ed4..41524b9 100644 --- a/lib/views/index.dart +++ b/lib/views/index.dart @@ -1,5 +1,5 @@ -import 'package:checklst/utilities/check_if_user_logged_in.dart'; -import 'package:checklst/widgets/bottom_reminder_sheet.dart'; +import 'package:checklst/models/check_if_user_logged_in.dart'; +import 'package:checklst/widgets/bottom_reminder_modal_sheet.dart'; import 'package:checklst/widgets/fab_bottom_app_bar.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; diff --git a/lib/widgets/bottom_reminder_sheet.dart b/lib/widgets/bottom_reminder_modal_sheet.dart similarity index 100% rename from lib/widgets/bottom_reminder_sheet.dart rename to lib/widgets/bottom_reminder_modal_sheet.dart