diff --git a/README.md b/README.md index 451d649a..961fab14 100644 --- a/README.md +++ b/README.md @@ -1,132 +1,100 @@ -# get-flutter-fire +# PlanBuddy - ShreKhan Project + +Welcome to the Flutter Todo Task App - PlanBuddy + + +PlanBuddy is a productivity app designed to help users manage and organize their tasks effectively. It features a clean and intuitive interface where users can view and categorize tasks into "Pending" and "Completed" sections. Users can add new tasks, edit existing ones, and easily switch between different task views using a simple tab interface. The app integrates with Firebase for user authentication and data storage, ensuring seamless synchronization and security. +The main functionalities include: +1) Task Management: Add, edit, and categorize tasks as pending or completed. +2) User Authentication: Sign in and sign out securely using Firebase Authentication. +3) Real-time Data Sync: Store and manage tasks in real-time with Firebase Firestore. +4) PlanBuddy aims to streamline task management and enhance productivity with a user-friendly experience. + +============================================== + +# Steps + +1) . Add the Android Folder +If your existing Flutter project doesn’t have the Android folder, you can generate it with the following command: + + * Navigate to Your Project Directory: + `cd path/to/your/project` + * Generate the Android Folder: + `flutter create` . +This command will create the necessary Android folder and its configuration files if they are missing. + +2) Firebase Setup +Add Firebase to Your Flutter App: + 1. Go to the “Project settings” in the Firebase Console. + 2. Under “Your apps,” select the appropriate platform (iOS/Android) and follow the instructions to register your app. + 3. Download the google-services.json (for Android) or GoogleService-Info.plist (for iOS) and place them in the respective directories: + * For Android: Place google-services.json in the android/app directory. + * For iOS: Place GoogleService-Info.plist in the ios/Runner directory. +3) Configure Firebase for Flutter: + * Run the following command to generate firebase_options.dart: + `flutterfire configure` +This will create the firebase_options.dart file in your project. Ensure it is properly imported and used in your main.dart file. + +4) Update Firebase SDK Dependencies: + + * Ensure you have the correct Firebase dependencies in your pubspec.yaml file. Add or update the dependencies as needed: + ` dependencies:` + `firebase_core: ^3.4.0` + `firebase_auth: ^5.2.0` + `cloud_firestore: ^5.3.0` + `provider: ^6.1.2` + `intl: ^0.19.0` + `flutter_slidable: ^3.1.1` + `flutter_spinkit: ^5.2.1` + `get_storage: ^2.1.1` +5) Run the App + 1. Ensure Firebase Setup: + * Make sure all Firebase configurations are correctly set up, and dependencies are installed. + 2. Run the App: + * Use the following command to run the app on your emulator or physical device: + `flutter run` + +# Using the App + +Sign In: Use the authentication options provided to sign in or create a new user account. +Manage Tasks: Add, edit, and view tasks in the “Pending” and “Completed” sections. +Sign Out: Use the sign-out button in the app to log out of your account. +![alt text](image-1.png) ![alt text](image.png) ![alt text](image-4.png) + +# Key Features +1) User Authentication: + * Secure Sign-In/Sign-Out: Manage user accounts securely with Firebase Authentication. + * Sign-In Requirements: + + Email and Password: Users must provide a valid email address and a password that meets minimum complexity requirements (e.g., at least 6 characters). + * Display Messages: Inform users of any sign-in issues with clear error messages if fields are missing or if the password does not meet requirements. + + ![alt text](image-2.png) ![alt text](image-3.png) + +2) Task Management: + * Create Tasks: Add new tasks with details and due dates(+ icon for adding task). + ![alt text](image-6.png) ![alt text](image-7.png) + * Edit Tasks: Modify existing tasks with updated information. + ![alt text](image-10.png) ![alt text](image-11.png) + * Delete Tasks: Remove tasks with a swipe gesture. + +3) Task Interaction: + * Swipe Actions: + + Left Swipe: Reveal options to delete or edit tasks. + + Right Swipe: Mark tasks as completed. + ![alt text](image-8.png) ![alt text](image-9.png) + * Completion Handling: + + Move to Completed Tab: Tasks marked as completed are automatically moved to the "Completed" tab. + + Strike-Through Effect: Completed tasks are displayed with a strike-through to visually indicate completion. + ![alt text](image-12.png) ![alt text](image-13.png) + + +4) Real-Time Data Sync: + * Firestore Integration: Sync and manage tasks in real-time using Firebase Firestore. + ![alt text](image-14.png) ![alt text](image-15.png) +5) Responsive Design: + * Cross-Platform Compatibility: Ensure the app works well on phones, tablets, and desktops with adaptive layouts. +6) User Interaction Enhancements: + * Navigation: Easy navigation through tab-based views for pending and completed tasks. + * Floating Action Button (FAB): Add new tasks quickly using the FAB with an add icon. -This codebase provides a boilerplate code utilizing the following three technologies: -1. Flutter 3.0 - For UX and uses Dart languange. See [https://flutter.dev/] -2. GetX - State management for Flutter. See [https://github.com/jonataslaw/getx/tree/4.6.1] -3. Firebase - For Backend as a Service. See [https://firebase.google.com/] - 1. Easy Authentication flow - 2. Server side functions - 3. Remote Configurations which can be used for A/B testing - -This was created as part of my own learning process and you will find that git commits were made according to the Steps listed below. You can use the git version history to check each commit and learn step by step, as I did. - -I am also using this codebase as an experiment towards hiring people (freshers especially but not limited to them) for my development team. If you are in Mumbai and are interested to join my team, you can use this codebase in the following manner: - -* Fork the codebase -* Add your own firebase_options.dart (follow steps and see firebase_options.template) -* **Build your own application using this as a base (integrating any existing project of yours also works)**, or complete a TODO or fix a bug (only if you have no other ideas) -* Send me a Pull Request. Mention a way of connecting with you in the commit message along with details of commit. Also modify ReadMe to say what you have changed in detail. -* I will go through the request and then connect with you if I find the entry to be interesting and take an interview round. - -## The Steps - -Step 1: Use Get CLI [https://pub.dev/packages/get_cli] - -`get create project` - -Step 2: Copy code from [https://github.com/jonataslaw/getx/tree/4.6.1/example_nav2/lib] - -Step 3: Integrate FlutterFire Authentication - -- Tutorials [https://firebase.google.com/codelabs/firebase-auth-in-flutter-apps#0] for inspiration -- Firebase Documentation [https://firebase.google.com/docs/auth/flutter/start] -- Blog [www.medium.com/TBD] -- To compile the code ensure that you generate your own firebase_options.dart by running - - `flutterfire configure` - -Step 4: Add Google OAuth [https://firebase.google.com/codelabs/firebase-auth-in-flutter-apps#6]. Note ensure you do the steps for Android and iOS as the code for it is not in Github - -Step 5: Add Guest User/Anonymous login with a Cart and Checkout use case [https://firebase.google.com/docs/auth/flutter/anonymous-auth] - -* delete unlinked anonymous user post logout - -Step 6: Add ImagePicker and Firebase Storage for profile image - -* Create PopupMenu button for web [https://api.flutter.dev/flutter/material/PopupMenuButton-class.html] -* BottomSheet for phones and single file button for desktops -* GetX and Image Picker [https://stackoverflow.com/questions/66559553/flutter-imagepicker-with-getx] -* Add FilePicker [https://medium.com/@onuaugustine07/pick-any-file-file-picker-flutter-f82c0144e27c] -* Firebase Storage [https://mercyjemosop.medium.com/select-and-upload-images-to-firebase-storage-flutter-6fac855970a9] and [https://firebase.google.com/docs/storage/flutter/start] - - Modify the Firebase Rules - `service firebase.storage { match /b/{bucket}/o { match /{allPaths=**} { allow write: if request.auth.uid != null; allow read: if true; } } }` - - Fix CORS [https://stackoverflow.com/questions/37760695/firebase-storage-and-access-control-allow-origin] -* PList additions [https://medium.com/unitechie/flutter-tutorial-image-picker-from-camera-gallery-c27af5490b74] - -Step 7: Additional Auth flow items - -1. Add a Change Password Screen. The Flutter Fire package does not have this screen. -2. TODO: Add ReCaptcha to login flow for password authentication for Web only - * Phone Auth on Web has a ReCaptcha already [https://firebase.flutter.dev/docs/auth/phone/]. Tried to use that library but it is very cryptic. - * Use the following instead [https://stackoverflow.com/questions/60675575/how-to-implement-recaptcha-into-a-flutter-app] or [https://medium.com/cloudcraftz/securing-your-flutter-web-app-with-google-recaptcha-b556c567f409] or [https://pub.dev/packages/g_recaptcha_v3] -3. TODO: Ensure Reset Password has Email verification -4. TODO: Add Phone verification [https://firebase.google.com/docs/auth/flutter/phone-auth] - * See [https://github.com/firebase/flutterfire/issues/4189]. -5. TODO: Add 2FA with SMS Pin. This screen is available in the Flutter Fire package - -Step 8: Add Firebase Emulator to test on laptop instead of server so that we can use Functions without upgrading the plan to Blaze. See [https://firebase.google.com/docs/emulator-suite/install_and_configure] - -Step 9: Add User Roles using Custom Claims. This requires upgrade of plan as we need to use Firebase Functions. Instead using Emulator. - -1. In Emulator we can add user via http://127.0.0.1:4000/auth and add custom claim via UI as {"role":"admin"}. The effect is shown via Product page in Nav instead of Cart page for admin user. -2. Add Function to add the custom claim to make the first user the admin using the Admin SDK -3. Registeration form to collect some data post signUp and enforce email verification from Client side. - - * Note! for Emulator check the console to verify using the link provided as email is not sent. -4. Enforcing verify email using a button which appears when SignIn fails due to non verification. - - * Fixed the error handling message during login. - * Coverted server side to Typescript - * Enabled Resend verification mail button - * Approach 1 - Use Email Link Authentication and signIn, assuming it marks email as verified also. We cannot send the verification mail as is, since that can be sent only if signed in (which was allowed only for first login post signup) - * Refer https://firebase.google.com/docs/auth/flutter/email-link-auth - * TODO Enable Deep Linking: According to https://firebase.google.com/docs/dynamic-links/flutter/receive, the Flutter feature is being deprecated and we should use the AppLinks (Android), UniversalLinks(iOS) instead. Leaving this for future as adding complexity. - * We could use the server side handling instead of deep linking. See [https://firebase.google.com/docs/auth/custom-email-handler?hl=en&authuser=0#web]. However, this requires changing the email template for the URL which is not possible in Emulator. Using the continueURL instead does not work as oobCode is already expired. This handling also uses the web client sdk. Thus it is better to go with the below method instead. - * Approach 2 - (Hack) send a create request with suffix ".verify" added in email when button clicked. Use the server side beforeCreate to catch this and send verification mail - * Note that the Server side beforeCreate function can also bypass user creation till verification but the user record (esp password) needs to be stored anyways, so bypassing user creation is not a good idea. Instead, we should use the verified tag in subsequent processing - * Sending emails from server side is possible but by using the web client SDK. -5. TODO: Other Items - - * TODO: Using autocomplete for emails is throwing error log in terminal. No impact but need to fix when all is done. - * TODO: Add a job that removes all unverified users after a while automatically. This could be useful if you were victim of bot attacks, but adding the Recaptcha is better precaution. See [https://stackoverflow.com/questions/67148672/how-to-delete-unverified-e-mail-addresses-in-firebase-authentication-flutter/67150606#67150606] -6. Added Roles of Buyer and Seller. - - 1. Added Access level in increasing order of role order => Buyer then Seller then Admin - 2. Created Navigation for each of Admin, Buyer, Seller screens - 3. Allowed switch from lower role Navigation to Navigation view till the given role of the user - -Step 10: Firebase Remote Config for A/B testing. See [https://firebase.google.com/docs/remote-config] - -1. Complete the Screen enum based Navigation framework -2. Config useBottomSheetForProfileOptions for Navigation element to be one of the following - * False: Drawer for Account, Settings, Sign Out - * True: Hamburger that opens BottomSheet (Context Menu in larger screen) for the same options -3. TODO: Config for adding Search Bar at the Top vs a Bottom Navigation button - -Step 11: TODO: CRUD - -* Users request role upgrade -* Add this request data to Firebase Datastore -* Create ListView with slidable tiles for approvals -* Admin SDK used by admin user via workflow on this request data and is approved from app - * Allow a Plan attribute via Custome Claims (e.g. Premium user flag) for Buyer and Seller, to add features which are not Navigation linked. Add a button Upgrade to Plan in Drawer that leads to Payment screen. Also certain aspects of premium plan can be visible that leads to upgrade plan screen via middleware -* Nested Category, Sub-Category tree creation - -Step 12: TODO: Theming and Custom Settings - -* Add Persona (like that in Netflix) and create a Persona selection only for Buyer Role -* Add Minimal (Three Color Gradient Pallette) Material Theme. Align it with Persona Templates (like Kids Template in Netflix) -* Dark theme toggle setting based on each Persona of the logged in User - -Step 13: TODO: Large vs Small screen responsiveness - -* Drawer: Triggered by Top Left Icon (App Logo). For iOS this icon changes to back button when required. Contains allowed Role List, Screens specified as Drawer. Becomes Left Side Navigation for Horizontal Screens. Can have additional extreme left vertical Navigation Strip. Bottom Navigation Bar also folds into this strip in Horizontal Screens. -* Top Right Icon: used for Login and post Login triggers BottomSheet/Context Menu for Persona Change, Profile, Settings, Change Password, Logout -* Search Bar (Toggle Button for phones) on Top Center with Title -* Status Bottom Bar for desktops only instead of SnackBars -* FAB vs Main Menu - -Step 14: TODO: Make own login flow screens. Remove firebase library reference from all but auth_service diff --git a/analysis_options.yaml b/analysis_options.yaml index 72b295f6..d4a714ac 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,7 +1,28 @@ -analyzer: - errors: - constant_identifier_names: ignore -include: package:flutter_lints/flutter.yaml +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +# include: package:flutter_lints/flutter.yaml + linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. rules: - + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/android/app/google-services.json b/android/app/google-services.json new file mode 100644 index 00000000..ff5033ca --- /dev/null +++ b/android/app/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "595805963796", + "project_id": "todoapp-c66c4", + "storage_bucket": "todoapp-c66c4.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:595805963796:android:f84190cec3451b3c778901", + "android_client_info": { + "package_name": "com.todoapp.app" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyDN9dQSVEf2yXQ_O6WLEqWqkJzqwV2JTbE" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/android/app/src/main/kotlin/com/example/todoapp/MainActivity.kt b/android/app/src/main/kotlin/com/example/todoapp/MainActivity.kt new file mode 100644 index 00000000..43449522 --- /dev/null +++ b/android/app/src/main/kotlin/com/example/todoapp/MainActivity.kt @@ -0,0 +1,5 @@ +package com.todoapp.app; + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() diff --git a/assets/icons/logo.png b/assets/icons/logo.png deleted file mode 100644 index 77ffea42..00000000 Binary files a/assets/icons/logo.png and /dev/null differ diff --git a/assets/images/dash.png b/assets/images/dash.png deleted file mode 100644 index 6ccb3f39..00000000 Binary files a/assets/images/dash.png and /dev/null differ diff --git a/assets/images/flutterfire_300x.png b/assets/images/flutterfire_300x.png deleted file mode 100644 index 604593b8..00000000 Binary files a/assets/images/flutterfire_300x.png and /dev/null differ diff --git a/firebase.json b/firebase.json new file mode 100644 index 00000000..1ee58924 --- /dev/null +++ b/firebase.json @@ -0,0 +1 @@ +{"flutter":{"platforms":{"dart":{"lib/firebase_options.dart":{"projectId":"quizapps-5ab17","configurations":{"android":"1:549769041276:android:4269afe02da1569a40c0f9"}}}}}} \ No newline at end of file diff --git a/image-1.png b/image-1.png new file mode 100644 index 00000000..5a2c7cbf Binary files /dev/null and b/image-1.png differ diff --git a/image-10.png b/image-10.png new file mode 100644 index 00000000..bc4c17c5 Binary files /dev/null and b/image-10.png differ diff --git a/image-11.png b/image-11.png new file mode 100644 index 00000000..426723e0 Binary files /dev/null and b/image-11.png differ diff --git a/image-12.png b/image-12.png new file mode 100644 index 00000000..3e66ad69 Binary files /dev/null and b/image-12.png differ diff --git a/image-13.png b/image-13.png new file mode 100644 index 00000000..a3aed1af Binary files /dev/null and b/image-13.png differ diff --git a/image-14.png b/image-14.png new file mode 100644 index 00000000..a55d8923 Binary files /dev/null and b/image-14.png differ diff --git a/image-15.png b/image-15.png new file mode 100644 index 00000000..36398c85 Binary files /dev/null and b/image-15.png differ diff --git a/image-2.png b/image-2.png new file mode 100644 index 00000000..4745094a Binary files /dev/null and b/image-2.png differ diff --git a/image-3.png b/image-3.png new file mode 100644 index 00000000..0466485c Binary files /dev/null and b/image-3.png differ diff --git a/image-4.png b/image-4.png new file mode 100644 index 00000000..da396f2c Binary files /dev/null and b/image-4.png differ diff --git a/image-5.png b/image-5.png new file mode 100644 index 00000000..1b05467f Binary files /dev/null and b/image-5.png differ diff --git a/image-6.png b/image-6.png new file mode 100644 index 00000000..6dce0884 Binary files /dev/null and b/image-6.png differ diff --git a/image-7.png b/image-7.png new file mode 100644 index 00000000..c36493fa Binary files /dev/null and b/image-7.png differ diff --git a/image-8.png b/image-8.png new file mode 100644 index 00000000..8e2a20e7 Binary files /dev/null and b/image-8.png differ diff --git a/image-9.png b/image-9.png new file mode 100644 index 00000000..b551bab4 Binary files /dev/null and b/image-9.png differ diff --git a/image.png b/image.png new file mode 100644 index 00000000..d4345b3a Binary files /dev/null and b/image.png differ diff --git a/ios/Flutter/Generated.xcconfig b/ios/Flutter/Generated.xcconfig new file mode 100644 index 00000000..02036fb7 --- /dev/null +++ b/ios/Flutter/Generated.xcconfig @@ -0,0 +1,14 @@ +// This is a generated file; do not edit or check into version control. +FLUTTER_ROOT=C:\Users\priyal\flutter +FLUTTER_APPLICATION_PATH=C:\Users\priyal\get-flutter-fire +COCOAPODS_PARALLEL_CODE_SIGN=true +FLUTTER_TARGET=lib\main.dart +FLUTTER_BUILD_DIR=build +FLUTTER_BUILD_NAME=1.0.0 +FLUTTER_BUILD_NUMBER=1 +EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 +EXCLUDED_ARCHS[sdk=iphoneos*]=armv7 +DART_OBFUSCATION=false +TRACK_WIDGET_CREATION=true +TREE_SHAKE_ICONS=false +PACKAGE_CONFIG=.dart_tool/package_config.json diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh new file mode 100644 index 00000000..8994aca3 --- /dev/null +++ b/ios/Flutter/flutter_export_environment.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=C:\Users\priyal\flutter" +export "FLUTTER_APPLICATION_PATH=C:\Users\priyal\get-flutter-fire" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_TARGET=lib\main.dart" +export "FLUTTER_BUILD_DIR=build" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=true" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/ios/Runner/GeneratedPluginRegistrant.h b/ios/Runner/GeneratedPluginRegistrant.h new file mode 100644 index 00000000..7a890927 --- /dev/null +++ b/ios/Runner/GeneratedPluginRegistrant.h @@ -0,0 +1,19 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GeneratedPluginRegistrant_h +#define GeneratedPluginRegistrant_h + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface GeneratedPluginRegistrant : NSObject ++ (void)registerWithRegistry:(NSObject*)registry; +@end + +NS_ASSUME_NONNULL_END +#endif /* GeneratedPluginRegistrant_h */ diff --git a/ios/Runner/GeneratedPluginRegistrant.m b/ios/Runner/GeneratedPluginRegistrant.m new file mode 100644 index 00000000..62ff5c48 --- /dev/null +++ b/ios/Runner/GeneratedPluginRegistrant.m @@ -0,0 +1,42 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#import "GeneratedPluginRegistrant.h" + +#if __has_include() +#import +#else +@import cloud_firestore; +#endif + +#if __has_include() +#import +#else +@import firebase_auth; +#endif + +#if __has_include() +#import +#else +@import firebase_core; +#endif + +#if __has_include() +#import +#else +@import path_provider_foundation; +#endif + +@implementation GeneratedPluginRegistrant + ++ (void)registerWithRegistry:(NSObject*)registry { + [FLTFirebaseFirestorePlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTFirebaseFirestorePlugin"]]; + [FLTFirebaseAuthPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTFirebaseAuthPlugin"]]; + [FLTFirebaseCorePlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTFirebaseCorePlugin"]]; + [PathProviderPlugin registerWithRegistrar:[registry registrarForPlugin:@"PathProviderPlugin"]]; +} + +@end diff --git a/lib/app/middleware/auth_middleware.dart b/lib/app/middleware/auth_middleware.dart deleted file mode 100644 index 827dd96c..00000000 --- a/lib/app/middleware/auth_middleware.dart +++ /dev/null @@ -1,94 +0,0 @@ -// ignore_for_file: avoid_print -import 'package:get/get.dart'; -import 'package:get_flutter_fire/models/role.dart'; -import 'package:get_flutter_fire/services/auth_service.dart'; -import 'package:get_flutter_fire/app/routes/app_pages.dart'; - -Future loginVerify(bool check, GetNavConfig route, - Future Function(GetNavConfig) redirector) async { - final newRoute = route.location == Routes.LOGIN - ? Routes.LOGIN - : Routes.LOGIN_THEN(route.location); - if (check) { - return GetNavConfig.fromRoute(newRoute); - } - - // Below could be used if the login was happening without verification. - // This will never get reached if server is sending error in login due to non verification - // With customClaims status == "creating", it will reach here for SignUp case only - if (!AuthService.to.isEmailVerified && !AuthService.to.registered.value) { - return GetNavConfig.fromRoute(route.location == Routes.REGISTER - ? Routes.REGISTER - : Routes.REGISTER_THEN(route.location)); - } - - return await redirector(route); -} - -// class EnsureAuthMiddleware extends GetMiddleware { -// @override -// Future redirectDelegate(GetNavConfig route) async { -// // you can do whatever you want here -// // but it's preferable to make this method fast - -// return await loginVerify( -// !AuthService.to.isLoggedInValue, route, super.redirectDelegate); -// } -// } - -class EnsureNotAuthedOrGuestMiddleware extends GetMiddleware { - //AccessLevel.notAuthed - @override - Future redirectDelegate(GetNavConfig route) async { - if (AuthService.to.isLoggedInValue && !AuthService.to.isAnon) { - //NEVER navigate to auth screen, when user is already authed - return GetNavConfig.fromRoute( - AuthService.to.registered.value ? Routes.HOME : Routes.REGISTER); - } - return await super.redirectDelegate(route); - } -} - -class EnsureAuthedAndNotGuestMiddleware extends GetMiddleware { - //AccessLevel.authenticated - @override - Future redirectDelegate(GetNavConfig route) async { - return await loginVerify( - !AuthService.to.isLoggedInValue || AuthService.to.isAnon, - route, - super.redirectDelegate); - } -} - -class EnsureRoleMiddleware extends GetMiddleware { - //AccessLevel.roleBased - Role role; - EnsureRoleMiddleware(this.role); - - @override - Future redirectDelegate(GetNavConfig route) async { - if (!AuthService.to.isLoggedInValue || !AuthService.to.hasRole(role)) { - final newRoute = Routes.LOGIN_THEN(route.location); - return GetNavConfig.fromRoute(newRoute); - } - return await super.redirectDelegate(route); - } -} - -class EnsureAuthOrGuestMiddleware extends GetMiddleware { - //AccessLevel.guest - @override - Future redirectDelegate(GetNavConfig route) async { - // you can do whatever you want here - // but it's preferable to make this method fast - // In this case this is taking human input and is not fast - - if (!AuthService.to.isLoggedInValue) { - bool? value = await AuthService.to.guest(); - if (value != true) { - return GetNavConfig.fromRoute(Routes.LOGIN); - } - } - return await super.redirectDelegate(route); - } -} diff --git a/lib/app/modules/cart/bindings/cart_binding.dart b/lib/app/modules/cart/bindings/cart_binding.dart deleted file mode 100644 index 009c52ae..00000000 --- a/lib/app/modules/cart/bindings/cart_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/cart_controller.dart'; - -class CartBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => CartController(), - ); - } -} diff --git a/lib/app/modules/cart/controllers/cart_controller.dart b/lib/app/modules/cart/controllers/cart_controller.dart deleted file mode 100644 index c938ec4c..00000000 --- a/lib/app/modules/cart/controllers/cart_controller.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:get/get.dart'; - -class CartController extends GetxController { - //TODO: Implement CartController - - final count = 0.obs; - @override - void onInit() { - super.onInit(); - } - - @override - void onReady() { - super.onReady(); - } - - @override - void onClose() { - super.onClose(); - } - - void increment() => count.value++; -} diff --git a/lib/app/modules/cart/views/cart_view.dart b/lib/app/modules/cart/views/cart_view.dart deleted file mode 100644 index 3e048c79..00000000 --- a/lib/app/modules/cart/views/cart_view.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:get/get.dart'; -import 'package:get_flutter_fire/app/routes/app_pages.dart'; -import '../../../widgets/screen_widget.dart'; -import '../../../../services/auth_service.dart'; -import '../controllers/cart_controller.dart'; - -class CartView extends GetView { - const CartView({super.key}); - @override - Widget build(BuildContext context) { - return ScreenWidget( - appBar: AppBar( - title: Text('${AuthService.to.userName} Cart'), - centerTitle: true, - ), - body: const Center( - child: Text( - 'CartView is working', - style: TextStyle(fontSize: 20), - ), - ), - screen: screen!, - ); - } -} diff --git a/lib/app/modules/categories/bindings/categories_binding.dart b/lib/app/modules/categories/bindings/categories_binding.dart deleted file mode 100644 index 06e278c8..00000000 --- a/lib/app/modules/categories/bindings/categories_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/categories_controller.dart'; - -class CategoriesBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => CategoriesController(), - ); - } -} diff --git a/lib/app/modules/categories/controllers/categories_controller.dart b/lib/app/modules/categories/controllers/categories_controller.dart deleted file mode 100644 index 6612e511..00000000 --- a/lib/app/modules/categories/controllers/categories_controller.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:get/get.dart'; - -class CategoriesController extends GetxController { - //TODO: Implement CategoriesController - - final count = 0.obs; - @override - void onInit() { - super.onInit(); - } - - @override - void onReady() { - super.onReady(); - } - - @override - void onClose() { - super.onClose(); - } - - void increment() => count.value++; -} diff --git a/lib/app/modules/categories/views/categories_view.dart b/lib/app/modules/categories/views/categories_view.dart deleted file mode 100644 index 97bfef38..00000000 --- a/lib/app/modules/categories/views/categories_view.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:get/get.dart'; - -import '../controllers/categories_controller.dart'; - -class CategoriesView extends GetView { - const CategoriesView({super.key}); - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text('CategoriesView'), - centerTitle: true, - ), - body: const Center( - child: Text( - 'CategoriesView is working', - style: TextStyle(fontSize: 20), - ), - ), - ); - } -} diff --git a/lib/app/modules/checkout/bindings/checkout_binding.dart b/lib/app/modules/checkout/bindings/checkout_binding.dart deleted file mode 100644 index 42202b56..00000000 --- a/lib/app/modules/checkout/bindings/checkout_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/checkout_controller.dart'; - -class CheckoutBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => CheckoutController(), - ); - } -} diff --git a/lib/app/modules/checkout/controllers/checkout_controller.dart b/lib/app/modules/checkout/controllers/checkout_controller.dart deleted file mode 100644 index aa1265f6..00000000 --- a/lib/app/modules/checkout/controllers/checkout_controller.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:get/get.dart'; - -class CheckoutController extends GetxController { - //TODO: Implement CheckoutController - - final count = 0.obs; - @override - void onInit() { - super.onInit(); - } - - @override - void onReady() { - super.onReady(); - } - - @override - void onClose() { - super.onClose(); - } - - void increment() => count.value++; -} diff --git a/lib/app/modules/checkout/views/checkout_view.dart b/lib/app/modules/checkout/views/checkout_view.dart deleted file mode 100644 index b8b17072..00000000 --- a/lib/app/modules/checkout/views/checkout_view.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:get/get.dart'; - -import '../controllers/checkout_controller.dart'; - -class CheckoutView extends GetView { - const CheckoutView({super.key}); - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text('CheckoutView'), - centerTitle: true, - ), - body: const Center( - child: Text( - 'CheckoutView is working', - style: TextStyle(fontSize: 20), - ), - ), - ); - } -} diff --git a/lib/app/modules/dashboard/bindings/dashboard_binding.dart b/lib/app/modules/dashboard/bindings/dashboard_binding.dart deleted file mode 100644 index da48f13c..00000000 --- a/lib/app/modules/dashboard/bindings/dashboard_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/dashboard_controller.dart'; - -class DashboardBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => DashboardController(), - ); - } -} diff --git a/lib/app/modules/dashboard/controllers/dashboard_controller.dart b/lib/app/modules/dashboard/controllers/dashboard_controller.dart deleted file mode 100644 index 24d91a16..00000000 --- a/lib/app/modules/dashboard/controllers/dashboard_controller.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'dart:async'; - -import 'package:get/get.dart'; - -class DashboardController extends GetxController { - final now = DateTime.now().obs; - @override - void onReady() { - super.onReady(); - Timer.periodic( - const Duration(seconds: 1), - (timer) { - now.value = DateTime.now(); - }, - ); - } -} diff --git a/lib/app/modules/dashboard/views/dashboard_view.dart b/lib/app/modules/dashboard/views/dashboard_view.dart deleted file mode 100644 index f475030f..00000000 --- a/lib/app/modules/dashboard/views/dashboard_view.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../controllers/dashboard_controller.dart'; - -class DashboardView extends GetView { - const DashboardView({super.key}); - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Obx( - () => Column( - mainAxisSize: MainAxisSize.min, - children: [ - const Text( - 'DashboardView is working', - style: TextStyle(fontSize: 20), - ), - Text('Time: ${controller.now.value.toString()}'), - ], - ), - ), - ), - ); - } -} diff --git a/lib/app/modules/home/bindings/home_binding.dart b/lib/app/modules/home/bindings/home_binding.dart deleted file mode 100644 index d08a80d4..00000000 --- a/lib/app/modules/home/bindings/home_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/home_controller.dart'; - -class HomeBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => HomeController(), - ); - } -} diff --git a/lib/app/modules/home/controllers/home_controller.dart b/lib/app/modules/home/controllers/home_controller.dart deleted file mode 100644 index f058de2a..00000000 --- a/lib/app/modules/home/controllers/home_controller.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:get/get.dart'; - -import '../../../../models/role.dart'; -import '../../../../services/auth_service.dart'; - -class HomeController extends GetxController { - final Rx chosenRole = Rx(AuthService.to.maxRole); - - // Role get role => AuthService.to.maxRole; - - get isBuyer => chosenRole.value == Role.buyer; - - get isAdmin => chosenRole.value == Role.admin; -} diff --git a/lib/app/modules/home/views/home_view.dart b/lib/app/modules/home/views/home_view.dart deleted file mode 100644 index 0cfc040d..00000000 --- a/lib/app/modules/home/views/home_view.dart +++ /dev/null @@ -1,34 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import '../../../routes/app_pages.dart'; -import '../../../widgets/screen_widget.dart'; -import '../controllers/home_controller.dart'; - -class HomeView extends GetView { - const HomeView({super.key}); - - @override - Widget build(BuildContext context) { - return GetRouterOutlet.builder( - builder: (context, delegate, currentRoute) { - var arg = Get.rootDelegate.arguments(); - if (arg != null) { - controller.chosenRole.value = arg["role"]; - } - var route = controller.chosenRole.value.tabs[0].route; - //This router outlet handles the appbar and the bottom navigation bar - return ScreenWidget( - screen: screen!, - body: GetRouterOutlet( - initialRoute: route, - // anchorRoute: Routes.HOME, - key: Get.nestedKey(route), - ), - role: controller.chosenRole.value, - delegate: delegate, - currentRoute: currentRoute, - ); - }, - ); - } -} diff --git a/lib/app/modules/login/bindings/login_binding.dart b/lib/app/modules/login/bindings/login_binding.dart deleted file mode 100644 index ac119f4a..00000000 --- a/lib/app/modules/login/bindings/login_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/login_controller.dart'; - -class LoginBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => LoginController(), - ); - } -} diff --git a/lib/app/modules/login/controllers/login_controller.dart b/lib/app/modules/login/controllers/login_controller.dart deleted file mode 100644 index 5178fec9..00000000 --- a/lib/app/modules/login/controllers/login_controller.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:get/get.dart'; - -import '../../../../services/auth_service.dart'; - -class LoginController extends GetxController { - static AuthService get to => Get.find(); - - final Rx showReverificationButton = Rx(false); - - bool get isRobot => AuthService.to.robot.value == true; - - set robot(bool v) => AuthService.to.robot.value = v; - - bool get isLoggedIn => AuthService.to.isLoggedInValue; - - bool get isAnon => AuthService.to.isAnon; - - bool get isRegistered => - AuthService.to.registered.value || AuthService.to.isEmailVerified; -} diff --git a/lib/app/modules/login/views/login_view.dart b/lib/app/modules/login/views/login_view.dart deleted file mode 100644 index 00c3af3f..00000000 --- a/lib/app/modules/login/views/login_view.dart +++ /dev/null @@ -1,162 +0,0 @@ -// ignore_for_file: inference_failure_on_function_invocation - -import 'package:firebase_auth/firebase_auth.dart' as fba; -import 'package:firebase_ui_auth/firebase_ui_auth.dart'; -import 'package:firebase_ui_oauth_google/firebase_ui_oauth_google.dart'; -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import '../../../../firebase_options.dart'; - -import '../../../../models/screens.dart'; -import '../../../widgets/login_widgets.dart'; -import '../controllers/login_controller.dart'; - -class LoginView extends GetView { - void showReverificationButton( - bool show, fba.EmailAuthCredential? credential) { - // Below is very important. - // See [https://stackoverflow.com/questions/69351845/this-obx-widget-cannot-be-marked-as-needing-to-build-because-the-framework-is-al] - WidgetsBinding.instance.addPostFrameCallback((_) { - controller.showReverificationButton.value = show; - }); - //or Future.delayed(Duration.zero, () { - // We can get the email and password from the controllers either by making the whole screen from scratch - // or probably by add flutter_test find.byKey (hacky) - // tried using AuthStateChangeAction instead which is not getting called - // Finally Subclassed EmailAuthProvider to handle the same, but that also did not work - // So went for server side email sending option - //})); - } - - const LoginView({super.key}); - - @override - Widget build(BuildContext context) { - return Obx(() => loginScreen(context)); - } - - Widget subtitleBuilder(context, action) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 8.0), - child: action == AuthAction.signIn - ? const Text('Welcome to Get Flutter Fire, please sign in!') - : const Text('New to Get Flutter Fire, please sign up!'), - ); - } - - Widget footerBuilder(Rx show, Rxn credential) { - return LoginWidgets.footerBuilder(EmailLinkButton(show, credential)); - } - - Widget loginScreen(BuildContext context) { - Widget ui; - if (!controller.isLoggedIn) { - ui = !(GetPlatform.isAndroid || GetPlatform.isIOS) && controller.isRobot - ? recaptcha() - : SignInScreen( - providers: [ - GoogleProvider(clientId: DefaultFirebaseOptions.webClientId), - MyEmailAuthProvider(), - ], - showAuthActionSwitch: !controller.isRegistered, - showPasswordVisibilityToggle: true, - headerBuilder: LoginWidgets.headerBuilder, - subtitleBuilder: subtitleBuilder, - footerBuilder: (context, action) => footerBuilder( - controller.showReverificationButton, - LoginController.to.credential), - sideBuilder: LoginWidgets.sideBuilder, - actions: getActions(), - ); - } else if (controller.isAnon) { - ui = RegisterScreen( - providers: [ - MyEmailAuthProvider(), - ], - showAuthActionSwitch: !controller.isAnon, //if Anon only SignUp - showPasswordVisibilityToggle: true, - headerBuilder: LoginWidgets.headerBuilder, - subtitleBuilder: subtitleBuilder, - footerBuilder: (context, action) => footerBuilder( - controller.showReverificationButton, LoginController.to.credential), - sideBuilder: LoginWidgets.sideBuilder, - actions: getActions(), - ); - } else { - final thenTo = Get - .rootDelegate.currentConfiguration!.currentPage!.parameters?['then']; - Get.rootDelegate.offNamed(thenTo ?? - (controller.isRegistered ? Screen.HOME : Screen.REGISTER).route); - ui = const Scaffold(); - } - return ui; - } - - Widget recaptcha() { - //TODO: Add Recaptcha - return Scaffold( - body: TextButton( - onPressed: () => controller.robot = false, - child: const Text("Are you a Robot?"), - )); - } - - /// The following actions are useful here: - /// - [AuthStateChangeAction] - /// - [AuthCancelledAction] - /// - [EmailLinkSignInAction] - /// - [VerifyPhoneAction] - /// - [SMSCodeRequestedAction] - - List getActions() { - return [ - // AuthStateChangeAction((context, state) { - AuthStateChangeAction((context, state) => LoginController.to - .errorMessage(context, state, showReverificationButton)), - // AuthStateChangeAction((context, state) { - // // This is not required due to the AuthMiddleware - // }), - // EmailLinkSignInAction((context) { - // final thenTo = Get.rootDelegate.currentConfiguration!.currentPage! - // .parameters?['then']; - // Get.rootDelegate.offNamed(thenTo ?? Routes.PROFILE); - // }), - ]; - } -} - -class MyEmailAuthProvider extends EmailAuthProvider { - @override - void onCredentialReceived( - fba.EmailAuthCredential credential, - AuthAction action, - ) { - WidgetsBinding.instance.addPostFrameCallback((_) { - LoginController.to.credential.value = credential; - }); - super.onCredentialReceived(credential, action); - } -} - -class EmailLinkButton extends StatelessWidget { - final Rx show; - final Rxn credential; - - const EmailLinkButton( - this.show, - this.credential, { - super.key, - }); - - @override - Widget build(BuildContext context) { - return Obx(() => Visibility( - visible: show.value, - child: Padding( - padding: const EdgeInsets.only(top: 16), - child: ElevatedButton( - onPressed: () => LoginController.to - .sendVerificationMail(emailAuth: credential.value), - child: const Text('Resend Verification Mail'))))); - } -} diff --git a/lib/app/modules/my_products/bindings/my_products_binding.dart b/lib/app/modules/my_products/bindings/my_products_binding.dart deleted file mode 100644 index a537f047..00000000 --- a/lib/app/modules/my_products/bindings/my_products_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/my_products_controller.dart'; - -class MyProductsBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => MyProductsController(), - ); - } -} diff --git a/lib/app/modules/my_products/controllers/my_products_controller.dart b/lib/app/modules/my_products/controllers/my_products_controller.dart deleted file mode 100644 index 31696ea2..00000000 --- a/lib/app/modules/my_products/controllers/my_products_controller.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:get/get.dart'; - -class MyProductsController extends GetxController { - //TODO: Implement MyProductsController - - final count = 0.obs; - @override - void onInit() { - super.onInit(); - } - - @override - void onReady() { - super.onReady(); - } - - @override - void onClose() { - super.onClose(); - } - - void increment() => count.value++; -} diff --git a/lib/app/modules/my_products/views/my_products_view.dart b/lib/app/modules/my_products/views/my_products_view.dart deleted file mode 100644 index 43793ebb..00000000 --- a/lib/app/modules/my_products/views/my_products_view.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:get/get.dart'; - -import '../controllers/my_products_controller.dart'; - -class MyProductsView extends GetView { - const MyProductsView({super.key}); - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text('MyProductsView'), - centerTitle: true, - ), - body: const Center( - child: Text( - 'MyProductsView is working', - style: TextStyle(fontSize: 20), - ), - ), - ); - } -} diff --git a/lib/app/modules/product_details/bindings/product_details_binding.dart b/lib/app/modules/product_details/bindings/product_details_binding.dart deleted file mode 100644 index 624d55ac..00000000 --- a/lib/app/modules/product_details/bindings/product_details_binding.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/product_details_controller.dart'; - -class ProductDetailsBinding extends Bindings { - @override - void dependencies() { - Get.create( - () => ProductDetailsController( - Get.parameters['productId'] ?? '', - ), - ); - } -} diff --git a/lib/app/modules/product_details/controllers/product_details_controller.dart b/lib/app/modules/product_details/controllers/product_details_controller.dart deleted file mode 100644 index d894e10c..00000000 --- a/lib/app/modules/product_details/controllers/product_details_controller.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'package:get/get.dart'; - -class ProductDetailsController extends GetxController { - final String productId; - - ProductDetailsController(this.productId); - @override - void onInit() { - super.onInit(); - Get.log('ProductDetailsController created with id: $productId'); - } - - @override - void onClose() { - Get.log('ProductDetailsController close with id: $productId'); - super.onClose(); - } -} diff --git a/lib/app/modules/product_details/views/product_details_view.dart b/lib/app/modules/product_details/views/product_details_view.dart deleted file mode 100644 index c9290724..00000000 --- a/lib/app/modules/product_details/views/product_details_view.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:get/get.dart'; - -import '../controllers/product_details_controller.dart'; - -class ProductDetailsView extends GetWidget { - const ProductDetailsView({super.key}); - - @override - Widget build(BuildContext context) { - return Scaffold( - body: Center( - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - const Text( - 'ProductDetailsView is working', - style: TextStyle(fontSize: 20), - ), - Text('ProductId: ${controller.productId}') - ], - ), - ), - ); - } -} diff --git a/lib/app/modules/products/bindings/products_binding.dart b/lib/app/modules/products/bindings/products_binding.dart deleted file mode 100644 index e7c762db..00000000 --- a/lib/app/modules/products/bindings/products_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/products_controller.dart'; - -class ProductsBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => ProductsController(), - ); - } -} diff --git a/lib/app/modules/products/controllers/products_controller.dart b/lib/app/modules/products/controllers/products_controller.dart deleted file mode 100644 index 118c7dc8..00000000 --- a/lib/app/modules/products/controllers/products_controller.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:get/get.dart'; - -import '../../../../models/product.dart'; - -class ProductsController extends GetxController { - final products = [].obs; - - void loadDemoProductsFromSomeWhere() { - products.add( - Product( - name: 'Product added on: ${DateTime.now().toString()}', - id: DateTime.now().millisecondsSinceEpoch.toString(), - ), - ); - } - - @override - void onReady() { - super.onReady(); - loadDemoProductsFromSomeWhere(); - } - - @override - void onClose() { - Get.printInfo(info: 'Products: onClose'); - super.onClose(); - } -} diff --git a/lib/app/modules/products/views/products_view.dart b/lib/app/modules/products/views/products_view.dart deleted file mode 100644 index 5b190a6a..00000000 --- a/lib/app/modules/products/views/products_view.dart +++ /dev/null @@ -1,58 +0,0 @@ -// ignore_for_file: inference_failure_on_function_invocation - -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../../../../models/role.dart'; -import '../../../routes/app_pages.dart'; -import '../controllers/products_controller.dart'; - -class ProductsView extends GetView { - const ProductsView({super.key}); - - @override - Widget build(BuildContext context) { - var arg = Get.rootDelegate.arguments(); - return Scaffold( - floatingActionButton: - (arg != null && Get.rootDelegate.arguments()["role"] == Role.seller) - ? FloatingActionButton.extended( - onPressed: controller.loadDemoProductsFromSomeWhere, - label: const Text('Add'), - ) - : null, - body: Column( - children: [ - const Hero( - tag: 'heroLogo', - child: FlutterLogo(), - ), - Expanded( - child: Obx( - () => RefreshIndicator( - onRefresh: () async { - controller.products.clear(); - controller.loadDemoProductsFromSomeWhere(); - }, - child: ListView.builder( - itemCount: controller.products.length, - itemBuilder: (context, index) { - final item = controller.products[index]; - return ListTile( - onTap: () { - Get.rootDelegate.toNamed(Routes.PRODUCT_DETAILS( - item.id)); //we could use Get Parameters - }, - title: Text(item.name), - subtitle: Text(item.id), - ); - }, - ), - ), - ), - ), - ], - ), - ); - } -} diff --git a/lib/app/modules/profile/bindings/profile_binding.dart b/lib/app/modules/profile/bindings/profile_binding.dart deleted file mode 100644 index 5eb3b2bd..00000000 --- a/lib/app/modules/profile/bindings/profile_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/profile_controller.dart'; - -class ProfileBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => ProfileController(), - ); - } -} diff --git a/lib/app/modules/profile/controllers/profile_controller.dart b/lib/app/modules/profile/controllers/profile_controller.dart deleted file mode 100644 index 0c1e059e..00000000 --- a/lib/app/modules/profile/controllers/profile_controller.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'dart:io'; - -import 'package:firebase_auth/firebase_auth.dart'; -import 'package:firebase_storage/firebase_storage.dart'; -import 'package:get/get.dart'; -import 'package:get_storage/get_storage.dart'; - -import 'package:path/path.dart'; -import '../../../../services/auth_service.dart'; - -class ProfileController extends GetxController { - FirebaseStorage storage = FirebaseStorage.instance; - User? currentUser = AuthService.to.user; - final Rxn _photoURL = Rxn(); - - File? _photo; - - String? get photoURL => _photoURL.value; - - @override - onInit() { - super.onInit(); - _photoURL.value = currentUser!.photoURL; - _photoURL.bindStream(currentUser!.photoURL.obs.stream); - } - - Future uploadFile(String path) async { - try { - var byt = GetStorage().read(path); - if (byt != null) { - final fileName = path; - final destination = 'profilePics/${currentUser!.uid}'; - - final ref = storage.ref(destination).child(fileName); - await ref.putData(byt); - return "$destination/$fileName"; - } else { - _photo = File(path); - if (_photo == null) return null; - final fileName = basename(_photo!.path); - final destination = 'profilePics/${currentUser!.uid}'; - - final ref = storage.ref(destination).child(fileName); - await ref.putFile(_photo!); - return "$destination/$fileName"; - } - } catch (e) { - Get.snackbar('Error', 'Image Not Uploaded as ${e.toString()}'); - } - return null; - } - - void logout() { - AuthService.to.logout(); - } - - Future updatePhotoURL(String dest) async { - _photoURL.value = await storage.ref().child(dest).getDownloadURL(); - await currentUser?.updatePhotoURL(_photoURL.value); - Get.snackbar('Success', 'Picture stored and linked'); - } -} diff --git a/lib/app/modules/profile/views/profile_view.dart b/lib/app/modules/profile/views/profile_view.dart deleted file mode 100644 index c26d11c1..00000000 --- a/lib/app/modules/profile/views/profile_view.dart +++ /dev/null @@ -1,124 +0,0 @@ -// ignore_for_file: inference_failure_on_function_invocation - -import 'package:firebase_ui_auth/firebase_ui_auth.dart'; -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../../../../services/auth_service.dart'; -import '../../../../models/screens.dart'; -import '../../../widgets/change_password_dialog.dart'; -import '../../../widgets/image_picker_button.dart'; -import '../controllers/profile_controller.dart'; - -class ProfileView extends GetView { - const ProfileView({super.key}); - ShapeBorder get shape => const CircleBorder(); - double get size => 120; - Color get placeholderColor => Colors.grey; - - Widget _imageFrameBuilder( - BuildContext context, - Widget? child, - int? frame, - bool? _, - ) { - if (frame == null) { - return Container(color: placeholderColor); - } - - return child!; - } - - @override - Widget build(BuildContext context) { - return Obx(() => profileScreen()); - } - - Widget profileScreen() { - return AuthService.to.isLoggedInValue - ? ProfileScreen( - // We are using the Flutter Fire Profile Screen now but will change in subsequent steps. - // The issues are highlighted in comments here - - // appBar: AppBar( - // title: const Text('User Profile'), - // ), - avatar: SizedBox( - //null will give the profile image component but it does not refresh the pic when changed - height: size, - width: size, - child: ClipPath( - clipper: ShapeBorderClipper(shape: shape), - clipBehavior: Clip.hardEdge, - child: controller.photoURL != null - ? Image.network( - controller.photoURL!, - width: size, - height: size, - cacheWidth: size.toInt(), - cacheHeight: size.toInt(), - fit: BoxFit.contain, - frameBuilder: _imageFrameBuilder, - ) - : Center( - child: Image.asset( - 'assets/images/dash.png', - width: size, - fit: BoxFit.contain, - ), - ), - ), - ), - // showDeleteConfirmationDialog: true, //this does not work properly. Possibly a bug in FlutterFire - actions: [ - SignedOutAction((context) { - Get.back(); - controller.logout(); - Get.rootDelegate.toNamed(Screen.PROFILE.route); - // Navigator.of(context).pop(); - }), - AccountDeletedAction((context, user) { - //If we don't include this the button is still shown but no action gets done. Ideally the button should also not be shown. Its a bug in FlutterFire - Get.defaultDialog( - //this is only called after the delete is done and not useful for confirmation of the delete action - title: 'Deleted Account of ${user.displayName}', - barrierDismissible: true, - navigatorKey: Get.nestedKey(Screen.HOME.route), - ); - }) - ], - children: [ - //This is to show that we can add custom content here - const Divider(), - controller.currentUser?.email != null - ? TextButton.icon( - onPressed: callChangePwdDialog, - label: const Text('Change Password'), - icon: const Icon(Icons.password_rounded), - ) - : const SizedBox.shrink(), - ImagePickerButton(callback: (String? path) async { - if (path != null) { - //Upload to Store - String? dest = await controller.uploadFile(path); - //attach it to User imageUrl - if (dest != null) { - await controller.updatePhotoURL(dest); - } - } - }) - ], - ) - : const Scaffold(); - } - - void callChangePwdDialog() { - var dlg = ChangePasswordDialog(controller.currentUser!); - Get.defaultDialog( - title: "Change Password", - content: dlg, - textConfirm: "Submit", - textCancel: "Cancel", - onConfirm: dlg.onSubmit); - } -} diff --git a/lib/app/modules/register/bindings/register_binding.dart b/lib/app/modules/register/bindings/register_binding.dart deleted file mode 100644 index 1089ecbd..00000000 --- a/lib/app/modules/register/bindings/register_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/register_controller.dart'; - -class RegisterBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => RegisterController(), - ); - } -} diff --git a/lib/app/modules/register/controllers/register_controller.dart b/lib/app/modules/register/controllers/register_controller.dart deleted file mode 100644 index 96cb2cb0..00000000 --- a/lib/app/modules/register/controllers/register_controller.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:get/get.dart'; - -import '../../../../services/auth_service.dart'; - -class RegisterController extends GetxController { - @override - void onInit() { - super.onInit(); - // Send email verification and logout - AuthService.to - .sendVerificationMail(); //if we use the EmailVerificationScreen then no need to call this - } - - // @override - // void onReady() { - // super.onReady(); - // } - - // @override - // void onClose() { - // super.onClose(); - // } -} diff --git a/lib/app/modules/register/views/register_view.dart b/lib/app/modules/register/views/register_view.dart deleted file mode 100644 index 01f73e88..00000000 --- a/lib/app/modules/register/views/register_view.dart +++ /dev/null @@ -1,53 +0,0 @@ -// import 'package:firebase_ui_auth/firebase_ui_auth.dart'; -import 'package:flutter/material.dart'; - -import 'package:get/get.dart'; - -import '../../../../services/auth_service.dart'; -// import '../../../widgets/login_widgets.dart'; -import '../controllers/register_controller.dart'; - -//ALso add a form to take additional info such as display name of other customer details mapped with uid in Firestore -class RegisterView extends GetView { - const RegisterView({super.key}); - - @override - Widget build(BuildContext context) { - // Add pre verification Form if any. Mostly it can be post verification and can be the Profile or Setting screens - try { - // using this is causing an error when we send verification mail from server side - // if it was initiated once, even when no visible. So we need to dispose when not visible - var w = - // EmailVerificationScreen( - // headerBuilder: LoginWidgets.headerBuilder, - // sideBuilder: LoginWidgets.sideBuilder, - // actions: [ - // EmailVerifiedAction(() { - // AuthService.to.register(); - // }), - // ], - // ); - Scaffold( - appBar: AppBar( - title: const Text('Registeration'), - centerTitle: true, - ), - body: Center( - child: Column(children: [ - const Text( - 'Please verify your email (check SPAM folder), and then relogin', - style: TextStyle(fontSize: 20), - ), - TextButton( - onPressed: () => AuthService.to.register(), - child: const Text("Verification Done. Relogin"), - ) - ])), - ); - return w; - } catch (e) { - // TODO - } - return const Scaffold(); - } -} diff --git a/lib/app/modules/root/bindings/root_binding.dart b/lib/app/modules/root/bindings/root_binding.dart deleted file mode 100644 index e1e94d1d..00000000 --- a/lib/app/modules/root/bindings/root_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/root_controller.dart'; - -class RootBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => RootController(), - ); - } -} diff --git a/lib/app/modules/root/controllers/my_drawer_controller.dart b/lib/app/modules/root/controllers/my_drawer_controller.dart deleted file mode 100644 index f45ef122..00000000 --- a/lib/app/modules/root/controllers/my_drawer_controller.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:get/get.dart'; - -import '../../../../models/screens.dart'; - -class MyDrawerController extends GetxController { - MyDrawerController(Iterable iter) - : values = Rx>(iter); - - final Rx> values; -} diff --git a/lib/app/modules/root/controllers/root_controller.dart b/lib/app/modules/root/controllers/root_controller.dart deleted file mode 100644 index 7f160fc6..00000000 --- a/lib/app/modules/root/controllers/root_controller.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -class RootController extends GetxController { - GlobalKey scaffoldKey = GlobalKey(); - - void openDrawer() { - scaffoldKey.currentState!.openDrawer(); - } - - void closeDrawer() { - scaffoldKey.currentState!.openEndDrawer(); - } -} diff --git a/lib/app/modules/root/views/drawer.dart b/lib/app/modules/root/views/drawer.dart deleted file mode 100644 index 908d0223..00000000 --- a/lib/app/modules/root/views/drawer.dart +++ /dev/null @@ -1,118 +0,0 @@ -// ignore_for_file: inference_failure_on_function_invocation - -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../../../../models/role.dart'; -import '../../../../services/auth_service.dart'; - -import '../../../../models/screens.dart'; -import '../controllers/my_drawer_controller.dart'; - -class DrawerWidget extends StatelessWidget { - const DrawerWidget({ - super.key, - }); - - @override - Widget build(BuildContext context) { - MyDrawerController controller = Get.put(MyDrawerController([]), - permanent: true); //must make true else gives error - Screen.drawer().then((v) => {controller.values.value = v}); - return Obx(() => Drawer( - //changing the shape of the drawer - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topRight: Radius.circular(0), bottomRight: Radius.circular(20)), - ), - width: 200, - child: Column( - children: drawerItems(context, controller.values), - ), - )); - } - - List drawerItems(BuildContext context, Rx> values) { - List list = [ - Container( - height: 100, - color: Colors.red, - //adding content in the highlighted part of the drawer - child: Align( - alignment: Alignment.centerLeft, - child: Container( - margin: const EdgeInsets.only(left: 15), - child: const Text('User Name', //Profile Icon also - style: TextStyle(fontWeight: FontWeight.bold)))), - ) - ]; - - if (AuthService.to.maxRole.index > 1) { - for (var i = 0; i <= AuthService.to.maxRole.index; i++) { - Role role = Role.values[i]; - list.add(ListTile( - title: Text( - role.name, - style: const TextStyle( - color: Colors.blue, - ), - ), - onTap: () { - Get.rootDelegate - .toNamed(Screen.HOME.route, arguments: {'role': role}); - //to close the drawer - Navigator.of(context).pop(); - }, - )); - } - } - - for (Screen screen in values.value) { - list.add(ListTile( - title: Text(screen.label ?? ''), - onTap: () { - Get.rootDelegate.toNamed(screen.route); - //to close the drawer - - Navigator.of(context).pop(); - }, - )); - } - - if (AuthService.to.isLoggedInValue) { - list.add(ListTile( - title: const Text( - 'Logout', - style: TextStyle( - color: Colors.red, - ), - ), - onTap: () { - AuthService.to.logout(); - Get.rootDelegate.toNamed(Screen.LOGIN.route); - //to close the drawer - - Navigator.of(context).pop(); - }, - )); - } - if (!AuthService.to.isLoggedInValue) { - list.add(ListTile( - title: const Text( - 'Login', - style: TextStyle( - color: Colors.blue, - ), - ), - onTap: () { - Get.rootDelegate.toNamed(Screen.LOGIN.route); - //to close the drawer - - Navigator.of(context).pop(); - }, - )); - } - - return list; - } -} diff --git a/lib/app/modules/root/views/root_view.dart b/lib/app/modules/root/views/root_view.dart deleted file mode 100644 index 2bbf228c..00000000 --- a/lib/app/modules/root/views/root_view.dart +++ /dev/null @@ -1,64 +0,0 @@ -// ignore_for_file: inference_failure_on_function_invocation - -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import 'package:get_flutter_fire/services/auth_service.dart'; -import '../../../routes/app_pages.dart'; -import '../../../../models/screens.dart'; -import '../controllers/root_controller.dart'; -import 'drawer.dart'; - -class RootView extends GetView { - const RootView({super.key}); - - @override - Widget build(BuildContext context) { - return GetRouterOutlet.builder( - builder: (context, delegate, current) { - final title = current!.currentPage!.title; - return Scaffold( - key: controller.scaffoldKey, - drawer: const DrawerWidget(), - appBar: AppBar( - title: Text(title ?? ''), - centerTitle: true, - leading: GetPlatform.isIOS // Since Web and Android have back button - && - current.locationString.contains(RegExp(r'(\/[^\/]*){3,}')) - ? BackButton( - onPressed: () => - Get.rootDelegate.popRoute(), //Navigator.pop(context), - ) - : IconButton( - icon: ImageIcon( - const AssetImage("icons/logo.png"), - color: Colors.grey.shade800, - ), - onPressed: () => AuthService.to.isLoggedInValue - ? controller.openDrawer() - : {Screen.HOME.doAction()}, - ), - actions: topRightMenuButtons(current), - // automaticallyImplyLeading: false, //removes drawer icon - ), - body: GetRouterOutlet( - initialRoute: AppPages.INITIAL, - // anchorRoute: '/', - // filterPages: (afterAnchor) { - // return afterAnchor.take(1); - // }, - ), - ); - }, - ); - } - -//This could be used to add icon buttons in expanded web view instead of the context menu - List topRightMenuButtons(GetNavConfig current) { - return [ - Container( - margin: const EdgeInsets.only(right: 15), - child: Screen.LOGIN.widget(current)) - ]; //TODO add seach button - } -} diff --git a/lib/app/modules/settings/bindings/settings_binding.dart b/lib/app/modules/settings/bindings/settings_binding.dart deleted file mode 100644 index fb567f07..00000000 --- a/lib/app/modules/settings/bindings/settings_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/settings_controller.dart'; - -class SettingsBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => SettingsController(), - ); - } -} diff --git a/lib/app/modules/settings/controllers/settings_controller.dart b/lib/app/modules/settings/controllers/settings_controller.dart deleted file mode 100644 index 265e54b1..00000000 --- a/lib/app/modules/settings/controllers/settings_controller.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'package:get/get.dart'; - -class SettingsController extends GetxController { - //TODO: Implement SettingsController - - final count = 0.obs; - @override - void onInit() { - super.onInit(); - } - - @override - void onReady() { - super.onReady(); - } - - @override - void onClose() {} - void increment() => count.value++; -} diff --git a/lib/app/modules/settings/views/settings_view.dart b/lib/app/modules/settings/views/settings_view.dart deleted file mode 100644 index 2bb244b6..00000000 --- a/lib/app/modules/settings/views/settings_view.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:get/get.dart'; - -import '../controllers/settings_controller.dart'; - -class SettingsView extends GetView { - const SettingsView({super.key}); - - @override - Widget build(BuildContext context) { - return const Scaffold( - body: Center( - child: Text( - 'SettingsView is working', - style: TextStyle(fontSize: 20), - ), - ), - ); - } -} diff --git a/lib/app/modules/task_details/bindings/task_details_binding.dart b/lib/app/modules/task_details/bindings/task_details_binding.dart deleted file mode 100644 index 1e017283..00000000 --- a/lib/app/modules/task_details/bindings/task_details_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/task_details_controller.dart'; - -class TaskDetailsBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => TaskDetailsController(), - ); - } -} diff --git a/lib/app/modules/task_details/controllers/task_details_controller.dart b/lib/app/modules/task_details/controllers/task_details_controller.dart deleted file mode 100644 index e0a6a0d9..00000000 --- a/lib/app/modules/task_details/controllers/task_details_controller.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:get/get.dart'; - -class TaskDetailsController extends GetxController { - //TODO: Implement TaskDetailsController - - final count = 0.obs; - @override - void onInit() { - super.onInit(); - } - - @override - void onReady() { - super.onReady(); - } - - @override - void onClose() { - super.onClose(); - } - - void increment() => count.value++; -} diff --git a/lib/app/modules/task_details/views/task_details_view.dart b/lib/app/modules/task_details/views/task_details_view.dart deleted file mode 100644 index c21dbc0e..00000000 --- a/lib/app/modules/task_details/views/task_details_view.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:get/get.dart'; - -import '../controllers/task_details_controller.dart'; - -class TaskDetailsView extends GetView { - const TaskDetailsView({super.key}); - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text('TaskDetailsView'), - centerTitle: true, - ), - body: const Center( - child: Text( - 'TaskDetailsView is working', - style: TextStyle(fontSize: 20), - ), - ), - ); - } -} diff --git a/lib/app/modules/tasks/bindings/tasks_binding.dart b/lib/app/modules/tasks/bindings/tasks_binding.dart deleted file mode 100644 index 9d836c2b..00000000 --- a/lib/app/modules/tasks/bindings/tasks_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/tasks_controller.dart'; - -class TasksBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => TasksController(), - ); - } -} diff --git a/lib/app/modules/tasks/controllers/tasks_controller.dart b/lib/app/modules/tasks/controllers/tasks_controller.dart deleted file mode 100644 index 4d4196e4..00000000 --- a/lib/app/modules/tasks/controllers/tasks_controller.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:get/get.dart'; - -class TasksController extends GetxController { - //TODO: Implement TasksController - - final count = 0.obs; - @override - void onInit() { - super.onInit(); - } - - @override - void onReady() { - super.onReady(); - } - - @override - void onClose() { - super.onClose(); - } - - void increment() => count.value++; -} diff --git a/lib/app/modules/tasks/views/tasks_view.dart b/lib/app/modules/tasks/views/tasks_view.dart deleted file mode 100644 index 2103103b..00000000 --- a/lib/app/modules/tasks/views/tasks_view.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:get/get.dart'; - -import '../controllers/tasks_controller.dart'; - -class TasksView extends GetView { - const TasksView({super.key}); - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text('TasksView'), - centerTitle: true, - ), - body: const Center( - child: Text( - 'TasksView is working', - style: TextStyle(fontSize: 20), - ), - ), - ); - } -} diff --git a/lib/app/modules/users/bindings/users_binding.dart b/lib/app/modules/users/bindings/users_binding.dart deleted file mode 100644 index 7d8efdb0..00000000 --- a/lib/app/modules/users/bindings/users_binding.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:get/get.dart'; - -import '../controllers/users_controller.dart'; - -class UsersBinding extends Bindings { - @override - void dependencies() { - Get.lazyPut( - () => UsersController(), - ); - } -} diff --git a/lib/app/modules/users/controllers/users_controller.dart b/lib/app/modules/users/controllers/users_controller.dart deleted file mode 100644 index 871467c4..00000000 --- a/lib/app/modules/users/controllers/users_controller.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:get/get.dart'; - -class UsersController extends GetxController { - //TODO: Implement UsersController - - final count = 0.obs; - @override - void onInit() { - super.onInit(); - } - - @override - void onReady() { - super.onReady(); - } - - @override - void onClose() { - super.onClose(); - } - - void increment() => count.value++; -} diff --git a/lib/app/modules/users/views/users_view.dart b/lib/app/modules/users/views/users_view.dart deleted file mode 100644 index 702f32da..00000000 --- a/lib/app/modules/users/views/users_view.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'package:get/get.dart'; - -import '../controllers/users_controller.dart'; - -class UsersView extends GetView { - const UsersView({super.key}); - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: const Text('UsersView'), - centerTitle: true, - ), - body: const Center( - child: Text( - 'UsersView is working', - style: TextStyle(fontSize: 20), - ), - ), - ); - } -} diff --git a/lib/app/routes/app_pages.dart b/lib/app/routes/app_pages.dart deleted file mode 100644 index 7269755d..00000000 --- a/lib/app/routes/app_pages.dart +++ /dev/null @@ -1,154 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../../models/access_level.dart'; -import '../../models/role.dart'; -import '../middleware/auth_middleware.dart'; -import '../modules/cart/bindings/cart_binding.dart'; -import '../modules/cart/views/cart_view.dart'; -import '../modules/categories/bindings/categories_binding.dart'; -import '../modules/categories/views/categories_view.dart'; -import '../modules/checkout/bindings/checkout_binding.dart'; -import '../modules/checkout/views/checkout_view.dart'; -import '../modules/dashboard/bindings/dashboard_binding.dart'; -import '../modules/dashboard/views/dashboard_view.dart'; -import '../modules/home/bindings/home_binding.dart'; -import '../modules/home/views/home_view.dart'; -import '../modules/login/bindings/login_binding.dart'; -import '../modules/login/views/login_view.dart'; -import '../modules/my_products/bindings/my_products_binding.dart'; -import '../modules/my_products/views/my_products_view.dart'; -import '../modules/product_details/bindings/product_details_binding.dart'; -import '../modules/product_details/views/product_details_view.dart'; -import '../modules/products/bindings/products_binding.dart'; -import '../modules/products/views/products_view.dart'; -import '../modules/profile/bindings/profile_binding.dart'; -import '../modules/profile/views/profile_view.dart'; -import '../modules/register/bindings/register_binding.dart'; -import '../modules/register/views/register_view.dart'; -import '../modules/root/bindings/root_binding.dart'; -import '../modules/root/views/root_view.dart'; -import '../modules/settings/bindings/settings_binding.dart'; -import '../modules/settings/views/settings_view.dart'; -import '../modules/task_details/bindings/task_details_binding.dart'; -import '../modules/task_details/views/task_details_view.dart'; -import '../modules/tasks/bindings/tasks_binding.dart'; -import '../modules/tasks/views/tasks_view.dart'; -import '../modules/users/bindings/users_binding.dart'; -import '../modules/users/views/users_view.dart'; -import '../../models/screens.dart'; - -part 'app_routes.dart'; -part 'screen_extension.dart'; - -class AppPages { - AppPages._(); - - static const INITIAL = Routes.HOME; - - //TODO create this using the information from Screen and Role data - //can use https://pub.dev/packages/freezed - static final routes = [ - GetPage( - name: '/', - page: () => const RootView(), - binding: RootBinding(), - participatesInRootNavigator: true, - preventDuplicates: true, - children: [ - Screen.LOGIN.getPage( - page: () => const LoginView(), - binding: LoginBinding(), - ), - Screen.REGISTER.getPage( - page: () => const RegisterView(), - binding: RegisterBinding(), - ), - Screen.PROFILE.getPage( - page: () => const ProfileView(), - binding: ProfileBinding(), - ), - Screen.SETTINGS.getPage( - page: () => const SettingsView(), - binding: SettingsBinding(), - ), - Screen.HOME.getPage( - page: () => const HomeView(), - bindings: [ - HomeBinding(), - ], - children: [ - Screen.DASHBOARD.getPage( - page: () => const DashboardView(), - binding: DashboardBinding(), - ), - Screen.USERS.getPage( - role: Role.admin, - page: () => const UsersView(), - binding: UsersBinding(), - children: [ - Screen.USER_PROFILE.getPage( - page: () => const ProfileView(), - binding: ProfileBinding(), - ) - ], - ), - Screen.PRODUCTS.getPage( - page: () => const ProductsView(), - binding: ProductsBinding(), - children: [ - Screen.PRODUCT_DETAILS.getPages( - page: () => const ProductDetailsView(), - binding: ProductDetailsBinding(), - ), - ], - ), - Screen.CATEGORIES.getPage( - role: Role.admin, - page: () => const CategoriesView(), - binding: CategoriesBinding(), - ), - Screen.CART.getPage( - page: () => const CartView(), - binding: CartBinding(), - role: Role.buyer, - children: [ - Screen.CHECKOUT.getPage( - //if this is after cart details, it never gets reached - page: () => const CheckoutView(), - binding: CheckoutBinding(), - ), - Screen.CART_DETAILS.getPages( - page: () => const ProductDetailsView(), - binding: ProductDetailsBinding(), - ), - ], - ), - Screen.MY_PRODUCTS.getPage( - page: () => const MyProductsView(), - binding: MyProductsBinding(), - role: Role.seller, - children: [ - Screen.MY_PRODUCT_DETAILS.getPages( - page: () => const ProductDetailsView(), - binding: ProductDetailsBinding(), - ), - ], - ), - Screen.TASKS.getPage( - role: Role.admin, - page: () => const TasksView(), - binding: TasksBinding(), - children: [ - Screen.TASK_DETAILS.getPage( - page: () => const TaskDetailsView(), - binding: TaskDetailsBinding(), - ), - ], - ), - ], - ) - ], - ), - ]; -} diff --git a/lib/app/routes/app_routes.dart b/lib/app/routes/app_routes.dart deleted file mode 100644 index f3129d21..00000000 --- a/lib/app/routes/app_routes.dart +++ /dev/null @@ -1,54 +0,0 @@ -// ignore_for_file: non_constant_identifier_names, constant_identifier_names - -part of 'app_pages.dart'; -// DO NOT EDIT. This is code generated via package:get_cli/get_cli.dart - -abstract class Routes { - static const HOME = _Paths.HOME; - // static String PROFILE = Screen.PROFILE.fullPath; - // static String SETTINGS = Screen.SETTINGS.fullPath; - static String LOGIN = Screen.LOGIN.route; - static String REGISTER = Screen.REGISTER.route; - // static String DASHBOARD = Screen.DASHBOARD.fullPath; - // static String PRODUCTS = Screen.PRODUCTS.fullPath; - // static String CART = Screen.CART.fullPath; - // static String CHECKOUT = Screen.CHECKOUT.fullPath; - // static const CATEGORIES = _Paths.HOME + _Paths.CATEGORIES; - // static const TASKS = _Paths.HOME + _Paths.TASKS; - // static const USERS = _Paths.HOME + _Paths.USERS; - // static const MY_PRODUCTS = _Paths.HOME + _Paths.MY_PRODUCTS; - - static String PRODUCT_DETAILS(String productId) => - '${Screen.PRODUCTS.route}/$productId'; - static String CART_DETAILS(String productId) => - '${Screen.CART.route}/$productId'; - static String TASK_DETAILS(String taskId) => '${Screen.TASKS.route}/$taskId'; - static String USER_PROFILE(String uId) => '${Screen.USERS.route}/$uId'; - - Routes._(); - static String LOGIN_THEN(String afterSuccessfulLogin) => - '${Screen.LOGIN.route}?then=${Uri.encodeQueryComponent(afterSuccessfulLogin)}'; - static String REGISTER_THEN(String afterSuccessfulLogin) => - '${Screen.REGISTER.route}?then=${Uri.encodeQueryComponent(afterSuccessfulLogin)}'; -} - -// Keeping this as Get_Cli will require it. Any addition can later be added to Screen -abstract class _Paths { - static const String HOME = '/home'; - // static const DASHBOARD = '/dashboard'; - // static const PRODUCTS = '/products'; - // static const PROFILE = '/profile'; - // static const SETTINGS = '/settings'; - // static const PRODUCT_DETAILS = '/:productId'; - // static const CART_DETAILS = '/:productId'; - // static const LOGIN = '/login'; - // static const CART = '/cart'; - // static const CHECKOUT = '/checkout'; - // static const REGISTER = '/register'; - // static const CATEGORIES = '/categories'; - // static const TASKS = '/tasks'; - // static const TASK_DETAILS = '/:taskId'; - // static const USERS = '/users'; - // static const USER_PROFILE = '/:uId'; - // static const MY_PRODUCTS = '/my-products'; -} diff --git a/lib/app/routes/screen_extension.dart b/lib/app/routes/screen_extension.dart deleted file mode 100644 index aaf138b0..00000000 --- a/lib/app/routes/screen_extension.dart +++ /dev/null @@ -1,125 +0,0 @@ -part of 'app_pages.dart'; - -extension GetViewExtension on GetView { - static final _screens = Expando(); - - Screen? get screen => _screens[this]; - set screen(Screen? x) => _screens[this] = x; -} - -extension GetWidgetExtension on GetWidget { - static final _screens = Expando(); - - Screen? get screen => _screens[this]; - set screen(Screen? x) => _screens[this] = x; -} - -extension GetPageExtension on GetPage {} - -extension ScreenExtension on Screen { - GetPage getPage( - {required GetView Function() page, - Bindings? binding, - List bindings = const [], - List? middlewares, - List>? children, - bool preventDuplicates = true, - Role? role}) { - // we are injecting the Screen variable here - pageW() { - GetView p = page(); - p.screen = this; - return p; - } - - //check role and screen mapping for rolebased access - if (accessLevel == AccessLevel.roleBased) { - if (role == null && - (parent == null || parent!.accessLevel != AccessLevel.roleBased)) { - throw Exception("Role must be provided for RoleBased Screens"); - } - if (role != null && !role.permissions.contains(this)) { - throw Exception("Role must permit this Screen"); - } - } - - return _getPage(pageW, binding, bindings, middlewares, children, - preventDuplicates, role); - } - - GetPage getPages( - {required GetWidget Function() page, - Bindings? binding, - List bindings = const [], - List? middlewares, - List>? children, - bool preventDuplicates = false, - Role? role}) { - pageW() { - GetWidget p = page(); - p.screen = this; - return p; - } - - return _getPage(pageW, binding, bindings, middlewares, children, - preventDuplicates, role); - } - - GetPage _getPage( - Widget Function() pageW, - Bindings? binding, - List bindings, - List? middlewares, - List>? children, - bool preventDuplicates, - Role? role) { - return binding != null - ? GetPage( - preventDuplicates: preventDuplicates, - middlewares: middlewares ?? defaultMiddlewares(role), - name: path, - page: pageW, - title: label, - transition: Transition.fade, - binding: binding, - children: children ?? const []) - : GetPage( - preventDuplicates: preventDuplicates, - middlewares: middlewares, - name: path, - page: pageW, - title: label, - transition: Transition.fade, - bindings: bindings, - children: children ?? const []); - } - - List? defaultMiddlewares(Role? role) => (parent == null || - parent!.accessLevel.index < accessLevel.index) - ? switch (accessLevel) { - AccessLevel.public => null, - AccessLevel.guest => [EnsureAuthOrGuestMiddleware()], - AccessLevel.authenticated => [EnsureAuthedAndNotGuestMiddleware()], - AccessLevel.roleBased => [EnsureRoleMiddleware(role ?? Role.buyer)], - AccessLevel.masked => throw UnimplementedError(), //not for screens - AccessLevel.secret => throw UnimplementedError(), //not for screens - AccessLevel.notAuthed => [EnsureNotAuthedOrGuestMiddleware()], - } - : null; -} - -extension RoleExtension on Role { - int getCurrentIndexFromRoute(GetNavConfig? currentRoute) { - final String? currentLocation = currentRoute?.location; - int currentIndex = 0; - if (currentLocation != null) { - currentIndex = - tabs.indexWhere((tab) => currentLocation.startsWith(tab.path)); - } - return (currentIndex > 0) ? currentIndex : 0; - } - - void routeTo(int value, GetDelegate delegate) { - delegate.toNamed(tabs[value].route, arguments: {'role': this}); - } -} diff --git a/lib/app/widgets/change_password_dialog.dart b/lib/app/widgets/change_password_dialog.dart deleted file mode 100644 index 78c392e5..00000000 --- a/lib/app/widgets/change_password_dialog.dart +++ /dev/null @@ -1,139 +0,0 @@ -import 'package:firebase_auth/firebase_auth.dart'; -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../../constants.dart'; - -class ChangePasswordDialog extends StatefulWidget { - final User user; - - ChangePasswordDialog(this.user, {super.key}); - - final _formKey = GlobalKey(); - final _formValues = FormValues(); - - @override - State createState() => _ChangePasswordDialogState(); - - void onSubmit() async { - if (_formKey.currentState != null && _formKey.currentState!.validate()) { - _formKey.currentState?.save(); - try { - AuthCredential credential = EmailAuthProvider.credential( - email: user.email!, password: _formValues.old!); - await user.reauthenticateWithCredential(credential); - await user.updatePassword(_formValues.newP!); - Get.back(result: true); - } catch (e) { - _formValues.authError = "Incorrect Password"; - _formKey.currentState!.validate(); - // Get.snackbar("Error", e.toString()); - } - } - } - - void onReset() { - _formKey.currentState?.reset(); - } -} - -class FormValues { - String? old; - String? newP; - String? authError; -} - -class _ChangePasswordDialogState extends State { - @override - Widget build(BuildContext context) { - return Material( - child: Form( - key: widget._formKey, - child: Column( - children: [ - TextFormField( - textInputAction: TextInputAction.done, - autovalidateMode: AutovalidateMode.onUserInteraction, - obscureText: true, - cursorColor: kPrimaryColor, - decoration: const InputDecoration( - hintText: "Old Password", - prefixIcon: Padding( - padding: EdgeInsets.all(defaultPadding), - child: Icon(Icons.key), - ), - ), - validator: (String? value) { - return widget._formValues.authError ?? - ((value != null && value.length < 8) - ? 'Pwd cannot be less than 8 characters' - : null); - }, - onChanged: (value) { - setState(() { - widget._formValues.old = value; - widget._formValues.authError = null; - }); - }, - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: defaultPadding), - child: TextFormField( - textInputAction: TextInputAction.done, - autovalidateMode: AutovalidateMode.onUserInteraction, - obscureText: true, - cursorColor: kPrimaryColor, - decoration: const InputDecoration( - hintText: "New Password", - prefixIcon: Padding( - padding: EdgeInsets.all(defaultPadding), - child: Icon(Icons.lock), - ), - ), - validator: (String? value) { - return (value != null && value.length < 8) - ? 'Pwd cannot be less than 8 characters' - : (value != null && value == widget._formValues.old) - ? 'Pwd cannot be same as old Pwd' - : null; - }, - onChanged: (value) { - setState(() { - widget._formValues.newP = value; - }); - }, - ), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: defaultPadding), - child: TextFormField( - textInputAction: TextInputAction.done, - autovalidateMode: AutovalidateMode.onUserInteraction, - obscureText: true, - cursorColor: kPrimaryColor, - decoration: const InputDecoration( - hintText: "Confirm Password", - prefixIcon: Padding( - padding: EdgeInsets.all(defaultPadding), - child: Icon(Icons.confirmation_num), - ), - ), - validator: (String? value) { - return (value != null && value != widget._formValues.newP) - ? 'Pwd does not match' - : null; - }, - ), - ), - const SizedBox(height: defaultPadding), - ElevatedButton( - onPressed: widget.onReset, - child: const Text( - "Reset", - ), - ), - ], - ), - )); - } -} diff --git a/lib/app/widgets/image_picker_button.dart b/lib/app/widgets/image_picker_button.dart deleted file mode 100644 index d6e87ff4..00000000 --- a/lib/app/widgets/image_picker_button.dart +++ /dev/null @@ -1,91 +0,0 @@ -import 'package:file_picker/file_picker.dart'; -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import 'package:get_storage/get_storage.dart'; -import 'package:image_picker/image_picker.dart'; - -import '../../models/action_enum.dart'; -import 'menu_sheet_button.dart'; - -enum ImageSources implements ActionEnum { - camera(Icons.camera, 'Camera'), - gallery(Icons.photo_library, 'Gallery'), - file(Icons.file_upload, 'File'); - - const ImageSources(this.icon, this.label); - - @override - Future doAction() async { - switch (this) { - case ImageSources.camera: - return await getImage(ImageSource.camera); - case ImageSources.gallery: - return await getImage(ImageSource.gallery); - case ImageSources.file: - return await getFile(); - default: - } - return null; - } - - @override - final IconData? icon; - @override - final String? label; - - static Future getImage(ImageSource imageSource) async { - final pickedFile = await ImagePicker().pickImage(source: imageSource); - if (pickedFile != null) { - return pickedFile.path; - } else { - Get.snackbar('Error', 'Image Not Selected'); - return null; - } - } - - static Future getFile() async { - FilePickerResult? result = await FilePicker.platform - .pickFiles(type: FileType.image, allowMultiple: false); - - if (result != null && result.files.isNotEmpty) { - final fileBytes = result.files.first.bytes; - final fileName = result.files.first.name; - GetStorage().write(fileName, fileBytes); - - return fileName; - //result.files.single.path;//is causing issues for Web, see https://github.com/miguelpruivo/flutter_file_picker/wiki/FAQ - } else { - Get.snackbar('Error', 'Image Not Selected'); - return null; - } - } -} - -class ImagePickerButton extends MenuSheetButton { - final ValueSetter? callback; - - const ImagePickerButton( - {super.key, - super.icon = const Icon(Icons.image), - super.label = 'Pick an Image', - this.callback}); - - @override - Iterable get values => ImageSources.values; - - @override - void callbackFunc(act) { - if (callback != null) callback!(act); - } - - @override - Widget build(BuildContext context) { - return !(GetPlatform.isAndroid || GetPlatform.isIOS) - ? TextButton.icon( - onPressed: () async => callbackFunc(await ImageSources.getFile()), - icon: icon, - label: const Text('Pick an Image'), - ) - : builder(context); - } -} diff --git a/lib/app/widgets/login_widgets.dart b/lib/app/widgets/login_widgets.dart deleted file mode 100644 index b8f2d8c1..00000000 --- a/lib/app/widgets/login_widgets.dart +++ /dev/null @@ -1,95 +0,0 @@ -// ignore_for_file: inference_failure_on_function_invocation - -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../../services/auth_service.dart'; -import '../../models/screens.dart'; -import '../../services/remote_config.dart'; -import 'menu_sheet_button.dart'; - -class LoginWidgets { - static Widget headerBuilder(context, constraints, shrinkOffset) { - return Padding( - padding: const EdgeInsets.all(20), - child: AspectRatio( - aspectRatio: 1, - child: Image.asset('assets/images/flutterfire_300x.png'), - ), - ); - } - - static Widget footerBuilder(myWidget) { - return Column( - children: [ - myWidget, - const Padding( - padding: EdgeInsets.only(top: 16), - child: Text( - 'By signing in, you agree to our terms and conditions.', - style: TextStyle(color: Colors.grey), - )) - ], - ); - } - - static Widget sideBuilder(context, shrinkOffset) { - return Padding( - padding: const EdgeInsets.all(20), - child: AspectRatio( - aspectRatio: 1, - child: Image.asset('assets/images/flutterfire_300x.png'), - ), - ); - } -} - -class LoginBottomSheetToggle extends MenuSheetButton { - const LoginBottomSheetToggle(this.current, {super.key}); - final GetNavConfig current; - - @override - Iterable get values { - MenuItemsController controller = Get.find(); - return controller.values.value; - } - - @override - Icon? get icon => (AuthService.to.isLoggedInValue) - ? values.length == 1 - ? const Icon(Icons.logout) - : const Icon(Icons.menu) - : const Icon(Icons.login); - - @override - String? get label => (AuthService.to.isLoggedInValue) - ? values.length == 1 - ? 'Logout' - : 'Click for Options' - : 'Login'; - - @override - Widget build(BuildContext context) { - MenuItemsController controller = Get.put( - MenuItemsController([]), - permanent: true); //must make true else gives error - Screen.sheet(null).then((val) { - controller.values.value = val; - }); - RemoteConfig.instance.then((ins) => - ins.addUseBottomSheetForProfileOptionsListener((val) async => - {controller.values.value = await Screen.sheet(null)})); - return Obx(() => (AuthService.to.isLoggedInValue) - ? builder(context, vals: controller.values.value) - : !(current.currentPage!.name == Screen.LOGIN.path) - ? IconButton( - onPressed: () async { - await Screen.LOGIN.doAction(); - // controller.toggle(Screen.LOGIN); - }, - icon: Icon(Screen.LOGIN.icon), - tooltip: Screen.LOGIN.label, - ) - : const SizedBox.shrink()); //should be only for loggedin case - } -} diff --git a/lib/app/widgets/menu_sheet_button.dart b/lib/app/widgets/menu_sheet_button.dart deleted file mode 100644 index abd3873e..00000000 --- a/lib/app/widgets/menu_sheet_button.dart +++ /dev/null @@ -1,94 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../../models/action_enum.dart'; - -class MenuItemsController extends GetxController { - MenuItemsController(Iterable iter) : values = Rx>(iter); - - final Rx> values; -} - -class MenuSheetButton extends StatelessWidget { - final Iterable? values_; - final Icon? icon; - final String? label; - - const MenuSheetButton( - {super.key, - this.values_, - this.icon, - this.label}); //passing scaffoldKey means that bottomSheet is added to it - - Iterable get values => values_!; - - static Widget bottomSheet( - Iterable values, ValueSetter? callback) { - return SizedBox( - height: 180, - width: Get.mediaQuery.size.width, - child: ListView( - // mainAxisAlignment: MainAxisAlignment.center, - children: values - .map( - (ActionEnum value) => ListTile( - leading: Icon(value.icon), - title: Text( - value.label!, - ), - onTap: () async { - Get.back(); - callback != null - ? callback(await value.doAction()) - : await value.doAction(); - }), - ) - .toList(), - ), - ); - } - - List> getItems(BuildContext context, Iterable values) { - return values.map>(createPopupMenuItem).toList(); - } - - PopupMenuEntry createPopupMenuItem(dynamic value) => PopupMenuItem( - value: value, - child: Text(value.label ?? ''), //TODO add Icon - ); - - @override - Widget build(BuildContext context) { - return builder(context); - } - -//This should be a modal bottom sheet if on Mobile (See https://mercyjemosop.medium.com/select-and-upload-images-to-firebase-storage-flutter-6fac855970a9) - Widget builder(BuildContext context, {Iterable? vals}) { - Iterable values = vals ?? values_!; - return values.length == 1 || - Get.mediaQuery.orientation == Orientation.portrait - // : Get.context!.isPortrait - ? (icon != null - ? IconButton( - onPressed: () => buttonPressed(values), - icon: icon!, - tooltip: label, - ) - : TextButton( - onPressed: () => buttonPressed(values), - child: Text(label ?? 'Need Label'))) - : PopupMenuButton( - itemBuilder: (context_) => getItems(context_, values), - icon: icon, - tooltip: label, - onSelected: (T value) async => - callbackFunc(await value.doAction())); - } - - void buttonPressed(Iterable values) async => values.length == 1 - ? callbackFunc(await values.first.doAction()) - : Get.bottomSheet(MenuSheetButton.bottomSheet(values, callbackFunc), - backgroundColor: Colors.white); - - void callbackFunc(act) {} -} diff --git a/lib/app/widgets/screen_widget.dart b/lib/app/widgets/screen_widget.dart deleted file mode 100644 index d80c9275..00000000 --- a/lib/app/widgets/screen_widget.dart +++ /dev/null @@ -1,75 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import '../routes/app_pages.dart'; -import '../../models/role.dart'; -import '../../models/screens.dart'; - -class ScreenWidget extends StatelessWidget { - final Widget body; - final Role? role; - - final GetDelegate? delegate; - - final GetNavConfig? currentRoute; - - final Screen screen; - final AppBar? appBar; - - const ScreenWidget({ - super.key, - required this.body, - required this.screen, - this.role = Role.buyer, - this.delegate, - this.currentRoute, - this.appBar, - }); - - @override - Widget build(BuildContext context) { - int currentIndex = - role != null ? role!.getCurrentIndexFromRoute(currentRoute) : 0; - Iterable fabs = screen.fabs; - return Scaffold( - body: body, - appBar: appBar, - bottomNavigationBar: (screen.navTabs.isNotEmpty) - ? BottomNavigationBar( - currentIndex: currentIndex, - onTap: (value) { - if (delegate != null) { - role!.routeTo(value, delegate!); - } - }, - items: - role!.tabs //screen may have more navTabs but we need by role - .map((Screen tab) => BottomNavigationBarItem( - icon: Icon(tab.icon), - label: tab.label, - )) - .toList(), - ) - : null, - floatingActionButton: fabs.isNotEmpty ? getFAB(fabs) : null, - // bottomSheet: //this is used for persistent bar like status bar - ); - } - - FloatingActionButton? getFAB(Iterable fabs) { - if (fabs.length == 1) { - var screen = fabs.firstOrNull!; - return FloatingActionButton.extended( - backgroundColor: Colors.blue, - onPressed: () => Get.rootDelegate.toNamed(screen.route), - label: Text(screen.label ?? ''), - icon: screen.icon == null - ? null - : Icon( - screen.icon, - color: Colors.white, - ), - ); - } - return null; //TODO multi fab button on press - } -} diff --git a/lib/constants.dart b/lib/constants.dart deleted file mode 100644 index dd5d17ce..00000000 --- a/lib/constants.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:flutter/material.dart'; -// import 'package:get/get_utils/src/platform/platform.dart'; - -const kPrimaryColor = Color(0xFF6F35A5); -const kPrimaryLightColor = Color(0xFFF1E6FF); - -const double defaultPadding = 16.0; - -const useEmulator = false; - -const useRecaptcha = false; - -const sendMailFromClient = - true; // set this true if in server using custom claim status - -const emulatorHost = - "127.0.0.1"; // GetPlatform.isAndroid ? "10.0.2.2" : "127.0.0.1"; //This is not required due to automaticHostMapping - -const baseUrl = useEmulator ? "http://127.0.0.1" : "your domain"; - -const bundleID = "com.example"; diff --git a/lib/home_screen.dart b/lib/home_screen.dart new file mode 100644 index 00000000..442d6506 --- /dev/null +++ b/lib/home_screen.dart @@ -0,0 +1,188 @@ +import 'package:flutter/material.dart'; +import '../login_screen.dart'; +import '../models/todo_model.dart'; +import '../services/auth_services.dart'; +import '../services/database_services.dart'; +import '../widgets/completed_widget.dart'; +import '../widgets/pending_widget.dart'; + +class HomeScreen extends StatefulWidget { + const HomeScreen({super.key}); + + @override + State createState() => _HomeScreenState(); +} + +class _HomeScreenState extends State { + int _buttonIndex = 0; + final _widgets = [ + // Pending Task Widget + PendingWidget(), + CompletedWidget(), + ]; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0xFF1d2630), + appBar: AppBar( + backgroundColor: Color(0xFF1d2630), + foregroundColor: Colors.white, + title: Text('PlanBuddy'), + actions: [ + IconButton( + onPressed: () async { + await AuthService().signout(); + Navigator.pushReplacement( + context, + MaterialPageRoute(builder: (context) => LoginScreen()), + ); + }, + icon: Icon(Icons.exit_to_app), + ), + ], + ), + body: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height: 20), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + InkWell( + borderRadius: BorderRadius.circular(10), + onTap: () { + setState(() { + _buttonIndex = 0; + }); + }, + child: Container( + height: 50, + width: MediaQuery.of(context).size.width / 2.2, + decoration: BoxDecoration( + color: _buttonIndex == 0 ? Colors.indigo : Colors.white, + borderRadius: BorderRadius.circular(10), + ), + child: Center( + child: Text( + 'Pending Tasks', + style: TextStyle( + fontSize: _buttonIndex == 0 ? 16 : 14, + fontWeight: FontWeight.w500, + color: _buttonIndex == 0 ? Colors.white : Colors.black38, + ), + ), + ), + ), + ), + InkWell( + borderRadius: BorderRadius.circular(10), + onTap: () { + setState(() { + _buttonIndex = 1; + }); + }, + child: Container( + height: 50, + width: MediaQuery.of(context).size.width / 2.2, + decoration: BoxDecoration( + color: _buttonIndex == 1 ? Colors.indigo : Colors.white, + borderRadius: BorderRadius.circular(10), + ), + child: Center( + child: Text( + 'Completed Tasks', + style: TextStyle( + fontSize: _buttonIndex == 1 ? 16 : 14, + fontWeight: FontWeight.w500, + color: _buttonIndex == 1 ? Colors.white : Colors.black38, + ), + ), + ), + ), + ), + ], + ), + SizedBox(height: 30.0), + _widgets[_buttonIndex], + ], + ), + ), + floatingActionButton: FloatingActionButton( + backgroundColor: Colors.white, + child: Icon(Icons.add), + onPressed: () { + _showTaskDialog(context); + }, + ), + ); + } + + void _showTaskDialog(BuildContext context, {Todo? todo}) { + final TextEditingController _titleController = TextEditingController(text: todo?.title); + final TextEditingController _descriptionController = TextEditingController(text: todo?.description); + final DatabaseService _databaseService = DatabaseService(); + + showDialog( + context: context, + builder: (context) { + return AlertDialog( + backgroundColor: Colors.white, + title: Text( + todo == null ? 'Add Task' : "Edit Task", + style: TextStyle( + fontWeight: FontWeight.w500, + ), + ), + content: SingleChildScrollView( + child: Column( + children: [ + TextField( + controller: _titleController, + decoration: InputDecoration( + labelText: 'Title', + border: OutlineInputBorder(), + ), + ), + SizedBox(height: 10.0), + TextField( + controller: _descriptionController, + decoration: InputDecoration( + labelText: 'Description', + border: OutlineInputBorder(), + ), + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text("Cancel"), + ), + ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.indigo, + foregroundColor: Colors.white, + ), + onPressed: () async { + if (todo == null) { + await _databaseService.addTodoTask(_titleController.text, + _descriptionController.text); + } else { + await _databaseService.updateTodo(todo.description, + _titleController.text, _descriptionController.text); + } + Navigator.pop(context); + }, + child: Text(todo == null ? "Add" : "Update"), + ), + ], + ); + }, + ); + } +} diff --git a/lib/login_screen.dart b/lib/login_screen.dart new file mode 100644 index 00000000..2a981f8b --- /dev/null +++ b/lib/login_screen.dart @@ -0,0 +1,186 @@ +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:flutter/material.dart'; +import '../home_screen.dart'; +import '../services/auth_services.dart'; +import '../signup_screen.dart'; + +class LoginScreen extends StatelessWidget { + final AuthService _auth = AuthService(); + final TextEditingController _emailController = TextEditingController(); + final TextEditingController _passwordController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0xFF1d2630), + appBar: AppBar( + backgroundColor: Color(0xFF1d2630), + foregroundColor: Colors.white, + title: Text('Sign In'), + ), + body: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(20.0), + child: Column(children: [ + SizedBox(height: 50), + Text( + "Welcome Back!", + style: TextStyle( + fontSize: 30.0, + color: Colors.white, + fontWeight: FontWeight.w500, + ), + ), + SizedBox(height: 10.0), + Text( + "Login Here!", + style: TextStyle( + fontSize: 16.0, + color: Colors.white, + ), + ), + SizedBox(height: 40.0), + TextField( + controller: _emailController, + style: TextStyle(color: Colors.white), + decoration: InputDecoration( + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide(color: Colors.white60), + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + ), + labelText: 'Email', + labelStyle: TextStyle(color: Colors.white60), + ), + ), + SizedBox(height: 20), + TextField( + controller: _passwordController, + style: TextStyle(color: Colors.white), + obscureText: true, + decoration: InputDecoration( + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide(color: Colors.white60), + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + ), + labelText: 'Password', + labelStyle: TextStyle(color: Colors.white60), + ), + ), + SizedBox(height: 50), + SizedBox( + height: 55, + width: MediaQuery.of(context).size.width / 1.5, + child: ElevatedButton( + onPressed: () async { + final email = _emailController.text.trim(); + final password = _passwordController.text.trim(); + + if (email.isEmpty) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Email is required."), + backgroundColor: Colors.red, + ), + ); + return; + } + + if (password.isEmpty) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Password is required."), + backgroundColor: Colors.red, + ), + ); + return; + } + + try { + User? user = await _auth.signInWithEmailAndPassword(email, password); + if (user != null) { + Navigator.push(context, MaterialPageRoute(builder: (context) => HomeScreen())); + } + } catch (e) { + if (e is FirebaseAuthException) { + print('FirebaseAuthException code: ${e.code}'); // Debug log + switch (e.code) { + case 'user-not-found': + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("No user found with this email."), + backgroundColor: Colors.red, + ), + ); + break; + case 'wrong-password': + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Incorrect password."), + backgroundColor: Colors.red, + ), + ); + break; + case 'invalid-email': + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Invalid email address."), + backgroundColor: Colors.red, + ), + ); + break; + default: + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("An error occurred. Please try again."), + backgroundColor: Colors.red, + ), + ); + break; + } + } else { + // Handle any other exceptions + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("An unexpected error occurred. Please try again."), + backgroundColor: Colors.red, + ), + ); + } + } + }, + child: Text( + "Log In", + style: TextStyle( + color: Colors.indigo, + fontSize: 18.0, + ), + ), + ), + ), + SizedBox(height: 20.0), + Text( + "OR", + style: TextStyle(color: Colors.white), + ), + SizedBox(height: 20.0), + TextButton( + onPressed: () { + Navigator.push(context, MaterialPageRoute(builder: (context) => SignupScreen())); + }, + child: Text( + "Create Account", + style: TextStyle(fontSize: 25.0), + ), + ), + ]), + ), + ), + ); + } +} diff --git a/lib/main.dart b/lib/main.dart index 30c258f2..a5aaa583 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,43 +2,34 @@ import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import 'package:get_storage/get_storage.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter/foundation.dart'; +import '../home_screen.dart'; +import '../login_screen.dart'; +import 'package:firebase_auth/firebase_auth.dart'; -import 'app/routes/app_pages.dart'; -import 'firebase_options.dart'; -import 'services/auth_service.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); - await GetStorage.init(); - await Firebase.initializeApp( - options: DefaultFirebaseOptions.currentPlatform, - ); + await Firebase.initializeApp(); + runApp(MyApp()); +} - runApp( - GetMaterialApp.router( - debugShowCheckedModeBanner: - false, //the debug banner will automatically disappear in prod build - title: 'Application', - initialBinding: BindingsBuilder( - () { - Get.put(AuthService()); - }, - ), - getPages: AppPages.routes, - // routeInformationParser: GetInformationParser( - // // initialRoute: Routes.HOME, - // ), - // routerDelegate: GetDelegate( - // backButtonPopMode: PopMode.History, - // preventDuplicateHandlingMode: - // PreventDuplicateHandlingMode.ReorderRoutes, - // ), + class MyApp extends StatelessWidget { + final FirebaseAuth _auth = FirebaseAuth.instance; + // This widget is the root of your application. + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + title: "PlanBuddy", theme: ThemeData( - highlightColor: Colors.black.withOpacity(0.5), - bottomSheetTheme: - const BottomSheetThemeData(surfaceTintColor: Colors.blue)), - ), - ); + primarySwatch: Colors.blue, + primaryColor: Colors.indigo, + ), + home: _auth.currentUser != null ? HomeScreen( ) : LoginScreen(), + + ); + } } + diff --git a/lib/models/access_level.dart b/lib/models/access_level.dart deleted file mode 100644 index a7b89742..00000000 --- a/lib/models/access_level.dart +++ /dev/null @@ -1,9 +0,0 @@ -enum AccessLevel { - public, //available without any login - guest, //available with guest login - notAuthed, // used for login screens - authenticated, //available on login - roleBased, //available on login and with allowed roles - masked, //available in a partly masked manner based on role - secret //never visible -} diff --git a/lib/models/action_enum.dart b/lib/models/action_enum.dart deleted file mode 100644 index 023adba5..00000000 --- a/lib/models/action_enum.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'package:flutter/material.dart'; - -abstract class ActionEnum { - Future doAction(); - IconData? get icon; - String? get label; -} diff --git a/lib/models/product.dart b/lib/models/product.dart deleted file mode 100644 index 003d5785..00000000 --- a/lib/models/product.dart +++ /dev/null @@ -1,9 +0,0 @@ -class Product { - final String name; - final String id; - - Product({ - required this.name, - required this.id, - }); -} diff --git a/lib/models/role.dart b/lib/models/role.dart deleted file mode 100644 index 50ee31b4..00000000 --- a/lib/models/role.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'screens.dart'; - -// First tab for all except Admin is Home/Dashboard which is diferrent for each role -// Admin is User List By Roles with slide to Change Role or Disable -// Second tab for -// Guest & Buyer is Public Product List by Category with Slide to Add to Cart -// Seller is Product List by Category with Add Product FAB leading to Product Form -// Admin is Category List with Add Category FAB -// Third tab for -// Guest is Cart with Guest Auth -// Buyer is Cart with own Auth -// Seller is MyProducts -// Admin is Tasks/Approvals -// Profile and Settings is in Drawer - -enum Role { - buyer([Screen.DASHBOARD, Screen.PRODUCTS, Screen.CART]), - seller([Screen.DASHBOARD, Screen.PRODUCTS, Screen.MY_PRODUCTS]), - admin([Screen.USERS, Screen.CATEGORIES, Screen.TASKS]); -//higher role can assume a lower role - - const Role(this.permissions); - final List - permissions; //list of screens, with accessLevel = roleBased, visible for the role - - static Role fromString(String? name) => (name != null - ? Role.values.firstWhere((role) => role.name == name) - : Role.buyer); - bool hasAccess(Role role) => index >= role.index; - bool hasAccessOf(String role) => index >= fromString(role).index; - - List get tabs => permissions - .where((screen) => screen.accessor_ == AccessedVia.navigator) - .toList(); //the ones in tab -} diff --git a/lib/models/screens.dart b/lib/models/screens.dart deleted file mode 100644 index 24dee39f..00000000 --- a/lib/models/screens.dart +++ /dev/null @@ -1,177 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import '../app/widgets/login_widgets.dart'; -import '../services/remote_config.dart'; -import 'action_enum.dart'; -import 'access_level.dart'; -import '../../services/auth_service.dart'; - -enum AccessedVia { - auto, - widget, //example: top right button - navigator, //bottom nav. can be linked to drawer items //handled in ScreenWidget - drawer, //creates nav tree //handled in RootView - bottomSheet, //context menu for web handled via the Button that calls the sheet - fab, //handled in ScreenWidget - singleTap, //when an item of a list is clicked - longTap //or double click -} - -enum Screen implements ActionEnum { - HOME('/home', - icon: Icons.home, - label: "Home", - accessor_: AccessedVia.drawer, - accessLevel: AccessLevel.public), //first screen is default screen - DASHBOARD('/dashboard', - icon: Icons.home, - label: "Home", - accessor_: AccessedVia.navigator, - accessLevel: AccessLevel.public, - parent: HOME), - PRODUCTS('/products', - icon: Icons.dataset, - label: "Products", - accessor_: AccessedVia.navigator, - accessLevel: AccessLevel.public, - parent: HOME), - PRODUCT_DETAILS('/:productId', - accessLevel: AccessLevel.public, parent: PRODUCTS), - LOGIN('/login', - icon: Icons.login, - accessor_: AccessedVia.widget, - accessLevel: AccessLevel.notAuthed), - PROFILE('/profile', - icon: Icons.account_box_rounded, - label: "Profile", - accessor_: AccessedVia.drawer, - accessLevel: AccessLevel.authenticated, - remoteConfig: true), - SETTINGS('/settings', - icon: Icons.settings, - label: "Settings", - accessor_: AccessedVia.drawer, - accessLevel: AccessLevel.authenticated, - remoteConfig: true), - CART('/cart', - icon: Icons.trolley, - label: "Cart", - parent: HOME, - accessor_: AccessedVia.navigator, - accessLevel: AccessLevel.guest), - CART_DETAILS('/:productId', parent: CART, accessLevel: AccessLevel.guest), - CHECKOUT('/checkout', - icon: Icons.check_outlined, - label: "Checkout", - accessor_: AccessedVia.fab, //fab appears in parent - parent: CART, - accessLevel: AccessLevel.authenticated), - REGISTER('/register', - accessor_: AccessedVia.auto, accessLevel: AccessLevel.authenticated), - CATEGORIES('/categories', - icon: Icons.category, - label: "Categories", - parent: HOME, - accessor_: AccessedVia.navigator, - accessLevel: AccessLevel.roleBased), - TASKS('/tasks', - icon: Icons.task, - label: "Tasks", - parent: HOME, - accessor_: AccessedVia.navigator, - accessLevel: AccessLevel.roleBased), - TASK_DETAILS('/:taskId', parent: TASKS, accessLevel: AccessLevel.roleBased), - USERS('/users', - icon: Icons.verified_user, - label: "Users", - parent: HOME, - accessor_: AccessedVia.navigator, - accessLevel: AccessLevel.roleBased), - USER_PROFILE('/:uId', parent: USERS, accessLevel: AccessLevel.roleBased), - MY_PRODUCTS('/my-products', - parent: HOME, - icon: Icons.inventory, - accessor_: AccessedVia.navigator, - label: "Inventory", - accessLevel: AccessLevel.roleBased), - MY_PRODUCT_DETAILS('/:productId', - parent: MY_PRODUCTS, accessLevel: AccessLevel.roleBased), - LOGOUT('/login', - icon: Icons.logout, - label: "Logout", - accessor_: AccessedVia.bottomSheet, - accessLevel: AccessLevel.authenticated), - ; - - const Screen(this.path, - {this.icon, - this.label, - this.parent, - this.accessor_ = AccessedVia.singleTap, - this.accessLevel = AccessLevel.authenticated, - this.remoteConfig = false}); - - @override - final IconData? icon; - @override - final String? label; - - final String path; - final AccessedVia accessor_; - final Screen? parent; - final AccessLevel - accessLevel; //if false it is role based. true means allowed for all - final bool remoteConfig; - - Future get accessor async { - if (remoteConfig && - (await RemoteConfig.instance).useBottomSheetForProfileOptions()) { - return AccessedVia.bottomSheet; - } - return accessor_; - } - - Iterable get children => - Screen.values.where((Screen screen) => screen.parent == this); - - Iterable get fabs => Screen.values.where((Screen screen) => - screen.parent == this && screen.accessor_ == AccessedVia.fab); - - Iterable get navTabs => Screen.values.where((Screen screen) => - screen.parent == this && screen.accessor_ == AccessedVia.navigator); - - String get route => (parent != null ? parent?.route : '')! + path; - - static Future> sheet(Screen? parent) async { - List list = []; - await Future.forEach(Screen.values, (Screen screen) async { - if (screen.parent == parent && - (await screen.accessor) == AccessedVia.bottomSheet) { - list.add(screen); - } - }); - return list; - } - - static Future> drawer() async { - //drawer is not parent linked - List list = []; - await Future.forEach(Screen.values, (Screen screen) async { - if ((await screen.accessor) == AccessedVia.drawer) { - list.add(screen); - } - }); - return list; - } - - @override - Future doAction() async { - if (this == LOGOUT) { - AuthService.to.logout(); - } - Get.rootDelegate.toNamed(route); - } - - Widget? widget(GetNavConfig current) => - (this == LOGIN) ? LoginBottomSheetToggle(current) : null; -} diff --git a/lib/models/todo_model.dart b/lib/models/todo_model.dart new file mode 100644 index 00000000..1da046e2 --- /dev/null +++ b/lib/models/todo_model.dart @@ -0,0 +1,16 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +class Todo +{ + final String id; + final String title; + final String description; + final bool completed; + final Timestamp timeStamp; + + Todo( + {required this.id, + required this.title, + required this.description, + required this.completed, + required this.timeStamp}); +} diff --git a/lib/services/auth_service.dart b/lib/services/auth_service.dart deleted file mode 100644 index 8bf72aaa..00000000 --- a/lib/services/auth_service.dart +++ /dev/null @@ -1,201 +0,0 @@ -// ignore_for_file: avoid_print - -import 'package:firebase_auth/firebase_auth.dart'; -import 'package:firebase_ui_auth/firebase_ui_auth.dart' as fbui; -import 'package:firebase_ui_localizations/firebase_ui_localizations.dart'; -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; - -import '../models/screens.dart'; -import '../constants.dart'; -import '../models/role.dart'; - -class AuthService extends GetxService { - static AuthService get to => Get.find(); - - final FirebaseAuth _auth = FirebaseAuth.instance; - late Rxn credential = Rxn(); - final Rxn _firebaseUser = Rxn(); - final Rx _userRole = Rx(Role.buyer); - final Rx robot = RxBool(useRecaptcha); - final RxBool registered = false.obs; - - User? get user => _firebaseUser.value; - Role get maxRole => _userRole.value; - - @override - onInit() { - super.onInit(); - if (useEmulator) _auth.useAuthEmulator(emulatorHost, 9099); - _firebaseUser.bindStream(_auth.authStateChanges()); - _auth.authStateChanges().listen((User? user) { - if (user != null) { - user.getIdTokenResult().then((token) { - _userRole.value = Role.fromString(token.claims?["role"]); - }); - } - }); - } - - bool get isEmailVerified => - user != null && (user!.email == null || user!.emailVerified); - - bool get isLoggedInValue => user != null; - - bool get isAdmin => user != null && _userRole.value == Role.admin; - - bool hasRole(Role role) => user != null && _userRole.value == role; - - bool get isAnon => user != null && user!.isAnonymous; - - String? get userName => (user != null && !user!.isAnonymous) - ? (user!.displayName ?? user!.email) - : 'Guest'; - - void login() { - // this is not needed as we are using Firebase UI for the login part - } - - void sendVerificationMail({EmailAuthCredential? emailAuth}) async { - if (sendMailFromClient) { - if (_auth.currentUser != null) { - await _auth.currentUser?.sendEmailVerification(); - } else if (emailAuth != null) { - // Approach 1: sending email auth link requires deep linking which is - // a TODO as the current Flutter methods are deprecated - // sendSingInLink(emailAuth); - - // Approach 2: This is a hack. - // We are using createUser to send the verification link from the server side by adding suffix .verify in the email - // if the user already exists and the password is also same and sign in occurs via custom token on server side - try { - await _auth.createUserWithEmailAndPassword( - email: "${credential.value!.email}.verify", - password: credential.value!.password!); - } on FirebaseAuthException catch (e) { - int i = e.message!.indexOf("message") + 10; - int j = e.message!.indexOf('"', i); - Get.snackbar( - e.message!.substring(i, j), - 'Please verify your email by clicking the link on the Email sent', - ); - } - } - } - } - - void sendSingInLink(EmailAuthCredential emailAuth) { - var acs = ActionCodeSettings( - // URL you want to redirect back to. The domain (www.example.com) for this - // URL must be whitelisted in the Firebase Console. - url: - '$baseUrl:5001/flutterfast-92c25/us-central1/handleEmailLinkVerification', - // // This must be true if deep linking. - // // If deeplinking. See [https://firebase.google.com/docs/dynamic-links/flutter/receive] - handleCodeInApp: true, - // iOSBundleId: '$bundleID.ios', - // androidPackageName: '$bundleID.android', - // // installIfNotAvailable - // androidInstallApp: true, - // // minimumVersion - // androidMinimumVersion: '12' - ); - _auth - .sendSignInLinkToEmail(email: emailAuth.email, actionCodeSettings: acs) - .catchError( - (onError) => print('Error sending email verification $onError')) - .then((value) => print('Successfully sent email verification')); - } - - void register() { - registered.value = true; - // logout(); // Uncomment if we need to enforce relogin - final thenTo = - Get.rootDelegate.currentConfiguration!.currentPage!.parameters?['then']; - Get.rootDelegate - .offAndToNamed(thenTo ?? Screen.PROFILE.route); //Profile has the forms - } - - void logout() { - _auth.signOut(); - if (isAnon) _auth.currentUser?.delete(); - _firebaseUser.value = null; - } - - Future guest() async { - return await Get.defaultDialog( - middleText: 'Sign in as Guest', - barrierDismissible: true, - onConfirm: loginAsGuest, - onCancel: () => Get.back(result: false), - textConfirm: 'Yes, will SignUp later', - textCancel: 'No, will SignIn now'); - } - - void loginAsGuest() async { - try { - await FirebaseAuth.instance.signInAnonymously(); - Get.back(result: true); - Get.snackbar( - 'Alert!', - 'Signed in with temporary account.', - ); - } on FirebaseAuthException catch (e) { - switch (e.code) { - case "operation-not-allowed": - print("Anonymous auth hasn't been enabled for this project."); - break; - default: - print("Unknown error."); - } - Get.back(result: false); - } - } - - void errorMessage(BuildContext context, fbui.AuthFailed state, - Function(bool, EmailAuthCredential?) callback) { - fbui.ErrorText.localizeError = - (BuildContext context, FirebaseAuthException e) { - final defaultLabels = FirebaseUILocalizations.labelsOf(context); - - // for verification error, also set a boolean flag to trigger button visibility to resend verification mail - String? verification; - if (e.code == "internal-error" && - e.message!.contains('"status":"UNAUTHENTICATED"')) { - // Note that (possibly in Emulator only) the e.email is always coming as null - // String? email = e.email ?? parseEmail(e.message!); - callback(true, credential.value); - verification = - "Please verify email id by clicking the link on the email sent"; - } else { - callback(false, credential.value); - } - - return switch (e.code) { - 'invalid-credential' => 'User ID or Password incorrect', - 'user-not-found' => 'Please create an account first.', - 'credential-already-in-use' => 'This email is already in use.', - _ => fbui.localizedErrorText(e.code, defaultLabels) ?? - verification ?? - 'Oh no! Something went wrong.', - }; - }; - } -} - -class MyCredential extends AuthCredential { - final EmailAuthCredential cred; - MyCredential(this.cred) - : super(providerId: "custom", signInMethod: cred.signInMethod); - - @override - Map asMap() { - return cred.asMap(); - } -} - -parseEmail(String message) { - int i = message.indexOf('"message":') + 13; - int j = message.indexOf('"', i); - return message.substring(i, j - 1); -} diff --git a/lib/services/auth_services.dart b/lib/services/auth_services.dart new file mode 100644 index 00000000..486037ff --- /dev/null +++ b/lib/services/auth_services.dart @@ -0,0 +1,47 @@ +import 'package:firebase_auth/firebase_auth.dart'; +class AuthService{ + final FirebaseAuth _auth = FirebaseAuth.instance; + + // sign in + + Future signInWithEmailAndPassword(String email, String password) async + { + try { + UserCredential result = await _auth.signInWithEmailAndPassword(email: email, password: password); + User? user = result.user; + return user; + } + catch(e) + { + print(e.toString()); + return null; + } + } + // sign up + + Future registerWithEmailAndPassword(String email, String password) async + { + try { + UserCredential result = await _auth.createUserWithEmailAndPassword(email: email, password: password); + User? user = result.user; + return user; + } + catch(e) + { + print(e.toString()); + return null; + } + } + // sign out + Future signout() async{ + try{ + return await _auth.signOut(); + } + catch(e) + { + print(e.toString()); + return null; + } + } + +} \ No newline at end of file diff --git a/lib/services/database_services.dart b/lib/services/database_services.dart new file mode 100644 index 00000000..5d4bb09a --- /dev/null +++ b/lib/services/database_services.dart @@ -0,0 +1,72 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import '../models/todo_model.dart'; + +class DatabaseService { + final CollectionReference todoCollection = FirebaseFirestore.instance.collection("todos"); + + User? user = FirebaseAuth.instance.currentUser; + + // Add todo task + Future addTodoTask + (String title, String description) async + { + return await todoCollection.add({ + 'uid' : user!.uid, + 'title' : title, + 'description' : description, + 'completed' : false, + 'createdAt' : FieldValue.serverTimestamp(), + }); + } + + // Update Todo Task + Future updateTodo(String id,String title,String description) async + { + final updatetodoCollection = FirebaseFirestore.instance.collection("todos").doc(id); + return await updatetodoCollection.update({ + 'title' : title, + 'description' : description, + }); + } + // update todo status + Future updateTodoStatus(String id, bool completed) async + { + return await todoCollection.doc(id).update({ + 'completed' : completed + }); + } + + // delete todo task + Future deleteTodoTask(String id, bool bool) async + { + return await todoCollection.doc(id).delete(); + } + // get pending tasks + Stream > get todos + { + return todoCollection.where('uid', isEqualTo: user!.uid). + where('completed',isEqualTo: false) + .snapshots().map(_todoListFromSnapshot); + } + // get completed tasks + Stream > get completedtodos + { + return todoCollection.where('uid', isEqualTo: user!.uid). + where('completed',isEqualTo: true) + .snapshots().map(_todoListFromSnapshot); + } + List _todoListFromSnapshot(QuerySnapshot snapshot) + { + return snapshot.docs.map((doc) + { + return Todo(id : doc.id, + title: doc['title'] ?? '', + description: doc['description'] ?? '', + completed: doc['completed'] ?? false, + timeStamp: doc['createdAt']); + }).toList(); + } + + +} \ No newline at end of file diff --git a/lib/services/remote_config.dart b/lib/services/remote_config.dart deleted file mode 100644 index 5d1145a5..00000000 --- a/lib/services/remote_config.dart +++ /dev/null @@ -1,78 +0,0 @@ -import 'package:firebase_remote_config/firebase_remote_config.dart'; -import 'package:get/get_utils/src/platform/platform.dart'; - -enum Typer { integer, boolean, double, string } - -class RemoteConfig { - static RemoteConfig? _instance; - - static Future get instance async { - _instance = _instance ?? RemoteConfig(); - await _instance!.init(); - return _instance!; - } - - final FirebaseRemoteConfig _remoteConfig = FirebaseRemoteConfig.instance; - final List listeners = []; - - Future init() async { - await _remoteConfig.setConfigSettings(RemoteConfigSettings( - fetchTimeout: const Duration(minutes: 1), - minimumFetchInterval: //const Duration(hours: 1), //use for prod - const Duration(minutes: 5), //use for testing only - )); - - await _remoteConfig.setDefaults(const { - "useBottomSheetForProfileOptions": false, - "showSearchBarOnTop": true, - }); - - await fetch(); - } - - Future fetch() async { - return await _remoteConfig.fetchAndActivate(); - } - -//can be used to change config without restart - void addListener(String key, Typer typ, Function listener) async { - if (!GetPlatform.isWeb) { - _remoteConfig.onConfigUpdated. //not supported in web - listen((event) async { - await _remoteConfig.activate(); - if (event.updatedKeys.contains(key)) { - _remoteConfig.fetch(); - var val = _remoteConfig.getValue(key); - switch (typ) { - case Typer.integer: - listener(val.asInt()); - break; - case Typer.boolean: - listener(val.asInt()); - break; - case Typer.double: - listener(val.asDouble()); - break; - default: - listener(val.asString()); - } - } - }); - } - } - - bool useBottomSheetForProfileOptions() { - return _remoteConfig.getBool("useBottomSheetForProfileOptions"); - } - - bool showSearchBarOnTop() { - return _remoteConfig.getBool("showSearchBarOnTop"); - } - - void addUseBottomSheetForProfileOptionsListener(listener) { - addListener("useBottomSheetForProfileOptions", Typer.boolean, listener); - if (!listeners.contains(listener)) { - listeners.add(listener); - } - } -} diff --git a/lib/signup_screen.dart b/lib/signup_screen.dart new file mode 100644 index 00000000..abac74e4 --- /dev/null +++ b/lib/signup_screen.dart @@ -0,0 +1,196 @@ +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:flutter/material.dart'; +import '../home_screen.dart'; +import '../login_screen.dart'; +import '../services/auth_services.dart'; + +class SignupScreen extends StatelessWidget { + final AuthService _auth = AuthService(); + final TextEditingController _emailController = TextEditingController(); + final TextEditingController _passwordController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0xFF1d2630), + appBar: AppBar( + backgroundColor: Color(0xFF1d2630), + foregroundColor: Colors.white, + title: Text('Create Account'), + ), + body: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(20.0), + child: Column(children: [ + SizedBox(height: 50), + Text( + "Welcome!", + style: TextStyle( + fontSize: 30.0, + color: Colors.white, + fontWeight: FontWeight.w500, + ), + ), + SizedBox(height: 10.0), + Text( + "Register Here!", + style: TextStyle( + fontSize: 16.0, + color: Colors.white, + ), + ), + SizedBox(height: 40.0), + TextField( + controller: _emailController, + style: TextStyle(color: Colors.white), + decoration: InputDecoration( + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide(color: Colors.white60), + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + ), + labelText: 'Email', + labelStyle: TextStyle(color: Colors.white60), + ), + ), + SizedBox(height: 20), + TextField( + controller: _passwordController, + style: TextStyle(color: Colors.white), + obscureText: true, + decoration: InputDecoration( + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + borderSide: BorderSide(color: Colors.white60), + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10), + ), + labelText: 'Password', + labelStyle: TextStyle(color: Colors.white60), + ), + ), + SizedBox(height: 50), + SizedBox( + height: 55, + width: MediaQuery.of(context).size.width / 1.5, + child: ElevatedButton( + onPressed: () async { + final email = _emailController.text.trim(); + final password = _passwordController.text.trim(); + + if (email.isEmpty) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Email is required."), + backgroundColor: Colors.red, + ), + ); + return; + } + + if (password.isEmpty) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Password is required."), + backgroundColor: Colors.red, + ), + ); + return; + } + + if (password.length < 6) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Password must be at least 6 characters long."), + backgroundColor: Colors.red, + ), + ); + return; + } + + try { + User? user = await _auth.registerWithEmailAndPassword(email, password); + if (user != null) { + Navigator.push(context, MaterialPageRoute(builder: (context) => HomeScreen())); + } + } catch (e) { + if (e is FirebaseAuthException) { + print('FirebaseAuthException code: ${e.code}'); // Debug log + switch (e.code) { + case 'email-already-in-use': + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Email is already in use."), + backgroundColor: Colors.red, + ), + ); + break; + case 'weak-password': + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Password is too weak."), + backgroundColor: Colors.red, + ), + ); + break; + case 'invalid-email': + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("Invalid email address."), + backgroundColor: Colors.red, + ), + ); + break; + default: + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("An error occurred. Please try again."), + backgroundColor: Colors.red, + ), + ); + break; + } + } else { + // Handle any other exceptions + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text("An unexpected error occurred. Please try again."), + backgroundColor: Colors.red, + ), + ); + } + } + }, + child: Text( + "Register", + style: TextStyle( + color: Colors.indigo, + fontSize: 18.0, + ), + ), + ), + ), + SizedBox(height: 20.0), + Text( + "OR", + style: TextStyle(color: Colors.white), + ), + SizedBox(height: 20.0), + TextButton( + onPressed: () { + Navigator.push(context, MaterialPageRoute(builder: (context) => LoginScreen())); + }, + child: Text( + "Log In", + style: TextStyle(fontSize: 25.0), + ), + ), + ]), + ), + ), + ); + } +} diff --git a/lib/widgets/completed_widget.dart b/lib/widgets/completed_widget.dart new file mode 100644 index 00000000..9ec426a8 --- /dev/null +++ b/lib/widgets/completed_widget.dart @@ -0,0 +1,89 @@ +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; +import '../models/todo_model.dart'; +import '../services/database_services.dart'; + +class CompletedWidget extends StatefulWidget { + const CompletedWidget({super.key}); + + @override + State createState() => _CompletedWidgetState(); +} + +class _CompletedWidgetState extends State { + User? user = FirebaseAuth.instance.currentUser; + late String uid; + final DatabaseService _databaseService = DatabaseService(); + + @override + void initState() { + super.initState(); + uid = FirebaseAuth.instance.currentUser!.uid; + } + + @override + Widget build(BuildContext context) { + return StreamBuilder>( + stream: _databaseService.completedtodos, + builder: (context, snapshot) { + if (snapshot.hasData) { + List todos = snapshot.data!; + return ListView.builder( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemCount: todos.length, + itemBuilder: (context, index) { + Todo todo = todos[index]; + final DateTime dt = todo.timeStamp.toDate(); + return Container( + margin: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.white54, + borderRadius: BorderRadius.circular(10), + ), + child: Slidable( + key: ValueKey(todo.id), + endActionPane: ActionPane( + motion: DrawerMotion(), + children: [ + SlidableAction( + backgroundColor: Colors.red, + foregroundColor: Colors.white, + icon: Icons.delete, + label: "Delete", + onPressed: (context) async { + await _databaseService.deleteTodoTask(todo.id, true); + }, + ) + ], + ), + child: ListTile( + title: Text( + todo.title, + style: TextStyle(fontWeight: FontWeight.w500, + decoration:TextDecoration.lineThrough ), + ), + subtitle: Text( + todo.description, + style: TextStyle( + decoration:TextDecoration.lineThrough), + ), + trailing: Text( + '${dt.day}/${dt.month}/${dt.year}', + style: TextStyle(fontWeight: FontWeight.bold), + ), + ), + ), + ); + }, + ); + } else { + return Center(child: CircularProgressIndicator(color: Colors.white)); + } + }, + ); + } + +} diff --git a/lib/widgets/pending_widget.dart b/lib/widgets/pending_widget.dart new file mode 100644 index 00000000..4f4472c4 --- /dev/null +++ b/lib/widgets/pending_widget.dart @@ -0,0 +1,180 @@ +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; +import '../models/todo_model.dart'; +import '../services/database_services.dart'; + +class PendingWidget extends StatefulWidget { + const PendingWidget({super.key}); + + @override + State createState() => _PendingWidgetState(); +} + +class _PendingWidgetState extends State { + User? user = FirebaseAuth.instance.currentUser; + late String uid; + final DatabaseService _databaseService = DatabaseService(); + + @override + void initState() { + super.initState(); + uid = FirebaseAuth.instance.currentUser!.uid; + } + + @override + Widget build(BuildContext context) { + return StreamBuilder>( + stream: _databaseService.todos, + builder: (context, snapshot) { + if (snapshot.hasData) { + List todos = snapshot.data!; + return ListView.builder( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemCount: todos.length, + itemBuilder: (context, index) { + Todo todo = todos[index]; + final DateTime dt = todo.timeStamp.toDate(); + return Container( + margin: EdgeInsets.all(10), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(10), + ), + child: Slidable( + key: ValueKey(todo.id), + endActionPane: ActionPane( + motion: DrawerMotion(), + children: [ + SlidableAction( + backgroundColor: Colors.green, + foregroundColor: Colors.white, + icon: Icons.done, + label: "Mark", + onPressed: (context) { + _databaseService.updateTodoStatus(todo.id, true); + }, + ) + ], + ), + startActionPane: ActionPane( + motion: DrawerMotion(), + children: [ + SlidableAction( + backgroundColor: Colors.amber, + foregroundColor: Colors.white, + icon: Icons.edit, + label: "Edit", + onPressed: (context) { + _showTaskDialog(context, todo: todo); + }, + ), + SlidableAction( + backgroundColor: Colors.red, + foregroundColor: Colors.white, + icon: Icons.delete, + label: "Delete", + onPressed: (context) async { + await _databaseService.deleteTodoTask(todo.id, true); + }, + ) + ], + ), + child: ListTile( + title: Text( + todo.title, + style: TextStyle(fontWeight: FontWeight.w500), + ), + subtitle: Text( + todo.description, + ), + trailing: Text( + '${dt.day}/${dt.month}/${dt.year}', + style: TextStyle(fontWeight: FontWeight.bold), + ), + ), + ), + ); + }, + ); + } else { + return Center(child: CircularProgressIndicator(color: Colors.white)); + } + }, + ); + } + + void _showTaskDialog(BuildContext context, {Todo? todo}) { + final TextEditingController _titleController = TextEditingController(text: todo?.title); + final TextEditingController _descriptionController = TextEditingController(text: todo?.description); + final DatabaseService _databaseService = DatabaseService(); + + showDialog( + context: context, + builder: (context) { + return AlertDialog( + backgroundColor: Colors.white, + title: Text( + todo == null ? 'Add Task' : "Edit Task", + style: TextStyle( + fontWeight: FontWeight.w500, + ), + ), + content: SingleChildScrollView( + child: Column( + children: [ + TextField( + controller: _titleController, + decoration: InputDecoration( + labelText: 'Title', + border: OutlineInputBorder(), + ), + ), + SizedBox(height: 10.0), + TextField( + controller: _descriptionController, + decoration: InputDecoration( + labelText: 'Description', + border: OutlineInputBorder(), + ), + ), + ], + ), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text("Cancel"), + ), + ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: Colors.indigo, + foregroundColor: Colors.white, + ), + onPressed: () async { + if (todo == null) { + await _databaseService.addTodoTask( + _titleController.text, + _descriptionController.text + ); + } else { + await _databaseService.updateTodo( + todo.id, // Use ID for update + _titleController.text, + _descriptionController.text + ); + } + Navigator.pop(context); + }, + child: Text(todo == null ? "Add" : "Update"), + ), + ], + ); + }, + ); + } +} diff --git a/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/macos/Flutter/ephemeral/Flutter-Generated.xcconfig new file mode 100644 index 00000000..808e1459 --- /dev/null +++ b/macos/Flutter/ephemeral/Flutter-Generated.xcconfig @@ -0,0 +1,11 @@ +// This is a generated file; do not edit or check into version control. +FLUTTER_ROOT=C:\Users\priyal\flutter +FLUTTER_APPLICATION_PATH=C:\Users\priyal\get-flutter-fire +COCOAPODS_PARALLEL_CODE_SIGN=true +FLUTTER_BUILD_DIR=build +FLUTTER_BUILD_NAME=1.0.0 +FLUTTER_BUILD_NUMBER=1 +DART_OBFUSCATION=false +TRACK_WIDGET_CREATION=true +TREE_SHAKE_ICONS=false +PACKAGE_CONFIG=.dart_tool/package_config.json diff --git a/macos/Flutter/ephemeral/flutter_export_environment.sh b/macos/Flutter/ephemeral/flutter_export_environment.sh new file mode 100644 index 00000000..3f63dd45 --- /dev/null +++ b/macos/Flutter/ephemeral/flutter_export_environment.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# This is a generated file; do not edit or check into version control. +export "FLUTTER_ROOT=C:\Users\priyal\flutter" +export "FLUTTER_APPLICATION_PATH=C:\Users\priyal\get-flutter-fire" +export "COCOAPODS_PARALLEL_CODE_SIGN=true" +export "FLUTTER_BUILD_DIR=build" +export "FLUTTER_BUILD_NAME=1.0.0" +export "FLUTTER_BUILD_NUMBER=1" +export "DART_OBFUSCATION=false" +export "TRACK_WIDGET_CREATION=true" +export "TREE_SHAKE_ICONS=false" +export "PACKAGE_CONFIG=.dart_tool/package_config.json" diff --git a/pubspec.lock b/pubspec.lock index 877fc75e..a511f1c9 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,18 +5,10 @@ packages: dependency: transitive description: name: _flutterfire_internals - sha256: "37a42d06068e2fe3deddb2da079a8c4d105f241225ba27b7122b37e9865fd8f7" + sha256: "9371d13b8ee442e3bfc08a24e3a1b3742c839abbfaf5eef11b79c4b862c89bf7" url: "https://pub.dev" source: hosted - version: "1.3.35" - args: - dependency: transitive - description: - name: args - sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a" - url: "https://pub.dev" - source: hosted - version: "2.5.0" + version: "1.3.41" async: dependency: transitive description: @@ -49,30 +41,38 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" - collection: + cloud_firestore: + dependency: "direct main" + description: + name: cloud_firestore + sha256: "77ac40d66a0fd585ca1e80ef3cbfd9df34462103bd4c1cf5950cb7d1f4c2e188" + url: "https://pub.dev" + source: hosted + version: "5.3.0" + cloud_firestore_platform_interface: dependency: transitive description: - name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + name: cloud_firestore_platform_interface + sha256: da0fa07284bc845b4a517449365eac0346a084676b3ed399f75a0ed25c3ec4c8 url: "https://pub.dev" source: hosted - version: "1.18.0" - cross_file: + version: "6.3.2" + cloud_firestore_web: dependency: transitive description: - name: cross_file - sha256: "55d7b444feb71301ef6b8838dbc1ae02e63dd48c8773f3810ff53bb1e2945b32" + name: cloud_firestore_web + sha256: "98dca6f864141cd3f79cf42a036f45233b8e2a3940b0011e6a370dd2283c45db" url: "https://pub.dev" source: hosted - version: "0.3.4+1" - crypto: + version: "4.1.2" + collection: dependency: transitive description: - name: crypto - sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + name: collection + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "3.0.3" + version: "1.18.0" cupertino_icons: dependency: "direct main" description: @@ -81,22 +81,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.8" - desktop_webview_auth: - dependency: transitive - description: - name: desktop_webview_auth - sha256: c4dce73346a7be7243c90ac3b1a68586d9f0e2c2710e81e07d758e80a6ebd920 - url: "https://pub.dev" - source: hosted - version: "0.0.15" - email_validator: - dependency: transitive - description: - name: email_validator - sha256: e9a90f27ab2b915a27d7f9c2a7ddda5dd752d6942616ee83529b686fc086221b - url: "https://pub.dev" - source: hosted - version: "2.1.17" fake_async: dependency: transitive description: @@ -109,226 +93,58 @@ packages: dependency: transitive description: name: ffi - sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" - url: "https://pub.dev" - source: hosted - version: "2.1.2" - file_picker: - dependency: "direct main" - description: - name: file_picker - sha256: "29c90806ac5f5fb896547720b73b17ee9aed9bba540dc5d91fe29f8c5745b10a" - url: "https://pub.dev" - source: hosted - version: "8.0.3" - file_selector_linux: - dependency: transitive - description: - name: file_selector_linux - sha256: "045d372bf19b02aeb69cacf8b4009555fb5f6f0b7ad8016e5f46dd1387ddd492" - url: "https://pub.dev" - source: hosted - version: "0.9.2+1" - file_selector_macos: - dependency: transitive - description: - name: file_selector_macos - sha256: f42eacb83b318e183b1ae24eead1373ab1334084404c8c16e0354f9a3e55d385 - url: "https://pub.dev" - source: hosted - version: "0.9.4" - file_selector_platform_interface: - dependency: transitive - description: - name: file_selector_platform_interface - sha256: a3994c26f10378a039faa11de174d7b78eb8f79e4dd0af2a451410c1a5c3f66b - url: "https://pub.dev" - source: hosted - version: "2.6.2" - file_selector_windows: - dependency: transitive - description: - name: file_selector_windows - sha256: d3547240c20cabf205c7c7f01a50ecdbc413755814d6677f3cb366f04abcead0 - url: "https://pub.dev" - source: hosted - version: "0.9.3+1" - firebase_analytics: - dependency: "direct main" - description: - name: firebase_analytics - sha256: dbf1e7ab22cfb1f4a4adb103b46a26276b4edc593d4a78ef6fb942bafc92e035 - url: "https://pub.dev" - source: hosted - version: "10.10.7" - firebase_analytics_platform_interface: - dependency: transitive - description: - name: firebase_analytics_platform_interface - sha256: "3729b74f8cf1d974a27ba70332ecb55ff5ff560edc8164a6469f4a055b429c37" - url: "https://pub.dev" - source: hosted - version: "3.10.8" - firebase_analytics_web: - dependency: transitive - description: - name: firebase_analytics_web - sha256: "019cd7eee74254d33fbd2e29229367ce33063516bf6b3258a341d89e3b0f1655" + sha256: "16ed7b077ef01ad6170a3d0c57caa4a112a38d7a2ed5602e0aca9ca6f3d98da6" url: "https://pub.dev" source: hosted - version: "0.5.7+7" + version: "2.1.3" firebase_auth: dependency: "direct main" description: name: firebase_auth - sha256: f0a75f61992d036e4c46ad0e9febd364d98aa2c092690a5475cb1421a8243cfe + sha256: "6f5792bdc208416bfdfbfe3363b78ce01667b6ebc4c5cb47cfa891f2fca45ab7" url: "https://pub.dev" source: hosted - version: "4.19.5" + version: "5.2.0" firebase_auth_platform_interface: dependency: transitive description: name: firebase_auth_platform_interface - sha256: feb77258404309ffc7761c78e1c0ad2ed5e4fdc378e035619e2cc13be4397b62 + sha256: "80237bb8a92bb0a5e3b40de1c8dbc80254e49ac9e3907b4b47b8e95ac3dd3fad" url: "https://pub.dev" source: hosted - version: "7.2.6" + version: "7.4.4" firebase_auth_web: dependency: transitive description: name: firebase_auth_web - sha256: "6d527f357da2bf93a67a42b423aa92943104a0c290d1d72ad9a42c779d501cd2" + sha256: "9d315491a6be65ea83511cb0e078544a309c39dd54c0ee355c51dbd6d8c03cc8" url: "https://pub.dev" source: hosted - version: "5.11.5" + version: "5.12.6" firebase_core: dependency: "direct main" description: name: firebase_core - sha256: "26de145bb9688a90962faec6f838247377b0b0d32cc0abecd9a4e43525fc856c" + sha256: "06537da27db981947fa535bb91ca120b4e9cb59cb87278dbdde718558cafc9ff" url: "https://pub.dev" source: hosted - version: "2.32.0" + version: "3.4.0" firebase_core_platform_interface: dependency: transitive description: name: firebase_core_platform_interface - sha256: c437ae5d17e6b5cc7981cf6fd458a5db4d12979905f9aafd1fea930428a9fe63 + sha256: f7d7180c7f99babd4b4c517754d41a09a4943a0f7a69b65c894ca5c68ba66315 url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "5.2.1" firebase_core_web: dependency: transitive description: name: firebase_core_web - sha256: "43d9e951ac52b87ae9cc38ecdcca1e8fa7b52a1dd26a96085ba41ce5108db8e9" - url: "https://pub.dev" - source: hosted - version: "2.17.0" - firebase_dynamic_links: - dependency: transitive - description: - name: firebase_dynamic_links - sha256: f704859abc17d99e74b47eaf47455b45a88ab7e2973f03e6130ff666b45fe11f - url: "https://pub.dev" - source: hosted - version: "5.5.5" - firebase_dynamic_links_platform_interface: - dependency: transitive - description: - name: firebase_dynamic_links_platform_interface - sha256: f86992605b50e2f0ce6c24993430affc98021da8d8a74d5596b7a2c84196c110 - url: "https://pub.dev" - source: hosted - version: "0.2.6+33" - firebase_remote_config: - dependency: "direct main" - description: - name: firebase_remote_config - sha256: "653bd94b68e2c4e89eca10db90576101f1024151f39f2d4e7c64ae6a90a5f9c5" - url: "https://pub.dev" - source: hosted - version: "4.4.7" - firebase_remote_config_platform_interface: - dependency: transitive - description: - name: firebase_remote_config_platform_interface - sha256: "24a2c445b15de3af7e4582ebceb2aa9a1e3731d0202cb3e7a1e03012440fa07d" - url: "https://pub.dev" - source: hosted - version: "1.4.35" - firebase_remote_config_web: - dependency: transitive - description: - name: firebase_remote_config_web - sha256: "525aa3000fd27cd023841c802010a06515e564aab2f147aa964b35f54abbf449" - url: "https://pub.dev" - source: hosted - version: "1.6.7" - firebase_storage: - dependency: "direct main" - description: - name: firebase_storage - sha256: da76ca9c11d795c4bae1bd13b31d54bb9eb9ccbee7eb5f6b86b8294370e9d488 - url: "https://pub.dev" - source: hosted - version: "11.7.5" - firebase_storage_platform_interface: - dependency: transitive - description: - name: firebase_storage_platform_interface - sha256: be17bfa9110a6429b40dd3760c755034079fd734aa1dd2476d5638ab780cc508 - url: "https://pub.dev" - source: hosted - version: "5.1.20" - firebase_storage_web: - dependency: transitive - description: - name: firebase_storage_web - sha256: "5219c20c0768a8e2ffedf0a116b7bc80ab32fcc6e2cbd50cbde14f8c4575c3f4" - url: "https://pub.dev" - source: hosted - version: "3.9.5" - firebase_ui_auth: - dependency: "direct main" - description: - name: firebase_ui_auth - sha256: "62c3ce9c8da134e0780bf8ed7d7ed91dd2308596ee3cb56fab03eb79f8323479" - url: "https://pub.dev" - source: hosted - version: "1.14.0" - firebase_ui_localizations: - dependency: "direct main" - description: - name: firebase_ui_localizations - sha256: a7faa62e2d56cb38aae270a8f05c1a8518b04b06dd0f0cc2d4974e4b4782de1c + sha256: "362e52457ed2b7b180964769c1e04d1e0ea0259fdf7025fdfedd019d4ae2bd88" url: "https://pub.dev" source: hosted - version: "1.12.0" - firebase_ui_oauth: - dependency: transitive - description: - name: firebase_ui_oauth - sha256: b86458b7d403d48d335c2502004bf88f2145d2f0be58b29fba8de28944f7fa91 - url: "https://pub.dev" - source: hosted - version: "1.5.2" - firebase_ui_oauth_google: - dependency: "direct main" - description: - name: firebase_ui_oauth_google - sha256: "101c13ba7ac04f6b70e1d73ab6d063b82801b794394914655356eb2a6f18bbcb" - url: "https://pub.dev" - source: hosted - version: "1.3.2" - firebase_ui_shared: - dependency: transitive - description: - name: firebase_ui_shared - sha256: f1d07c130a39104d32fba1dab274b7bcb13be2bf4e652624a4ccabb58f9781f1 - url: "https://pub.dev" - source: hosted - version: "1.4.1" + version: "2.17.5" flutter: dependency: "direct main" description: flutter @@ -342,27 +158,22 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" - flutter_localizations: - dependency: transitive - description: flutter - source: sdk - version: "0.0.0" - flutter_plugin_android_lifecycle: - dependency: transitive + flutter_slidable: + dependency: "direct main" description: - name: flutter_plugin_android_lifecycle - sha256: "8cf40eebf5dec866a6d1956ad7b4f7016e6c0cc69847ab946833b7d43743809f" + name: flutter_slidable + sha256: "2c5611c0b44e20d180e4342318e1bbc28b0a44ad2c442f5df16962606fd3e8e3" url: "https://pub.dev" source: hosted - version: "2.0.19" - flutter_svg: - dependency: transitive + version: "3.1.1" + flutter_spinkit: + dependency: "direct main" description: - name: flutter_svg - sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2" + name: flutter_spinkit + sha256: d2696eed13732831414595b98863260e33e8882fc069ee80ec35d4ac9ddb0472 url: "https://pub.dev" source: hosted - version: "2.0.10+1" + version: "5.2.1" flutter_test: dependency: "direct dev" description: flutter @@ -389,70 +200,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" - google_fonts: - dependency: "direct main" - description: - name: google_fonts - sha256: b1ac0fe2832c9cc95e5e88b57d627c5e68c223b9657f4b96e1487aa9098c7b82 - url: "https://pub.dev" - source: hosted - version: "6.2.1" - google_identity_services_web: - dependency: transitive - description: - name: google_identity_services_web - sha256: "9482364c9f8b7bd36902572ebc3a7c2b5c8ee57a9c93e6eb5099c1a9ec5265d8" - url: "https://pub.dev" - source: hosted - version: "0.3.1+1" - google_sign_in: - dependency: "direct main" - description: - name: google_sign_in - sha256: "0b8787cb9c1a68ad398e8010e8c8766bfa33556d2ab97c439fb4137756d7308f" - url: "https://pub.dev" - source: hosted - version: "6.2.1" - google_sign_in_android: - dependency: transitive - description: - name: google_sign_in_android - sha256: "7647893c65e6720973f0e579051c8f84b877b486614d9f70a404259c41a4632e" - url: "https://pub.dev" - source: hosted - version: "6.1.23" - google_sign_in_ios: - dependency: transitive - description: - name: google_sign_in_ios - sha256: a058c9880be456f21e2e8571c1126eaacd570bdc5b6c6d9d15aea4bdf22ca9fe - url: "https://pub.dev" - source: hosted - version: "5.7.6" - google_sign_in_platform_interface: - dependency: transitive - description: - name: google_sign_in_platform_interface - sha256: "1f6e5787d7a120cc0359ddf315c92309069171306242e181c09472d1b00a2971" - url: "https://pub.dev" - source: hosted - version: "2.4.5" - google_sign_in_web: - dependency: transitive - description: - name: google_sign_in_web - sha256: fc0f14ed45ea616a6cfb4d1c7534c2221b7092cc4f29a709f0c3053cc3e821bd - url: "https://pub.dev" - source: hosted - version: "0.12.4" - http: - dependency: transitive - description: - name: http - sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" - url: "https://pub.dev" - source: hosted - version: "1.2.1" http_parser: dependency: transitive description: @@ -461,72 +208,8 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" - image_picker: - dependency: "direct main" - description: - name: image_picker - sha256: "33974eca2e87e8b4e3727f1b94fa3abcb25afe80b6bc2c4d449a0e150aedf720" - url: "https://pub.dev" - source: hosted - version: "1.1.1" - image_picker_android: - dependency: transitive - description: - name: image_picker_android - sha256: "79455f6cff4cbef583b2b524bbf0d4ec424e5959f4d464e36ef5323715b98370" - url: "https://pub.dev" - source: hosted - version: "0.8.12" - image_picker_for_web: - dependency: transitive - description: - name: image_picker_for_web - sha256: "5d6eb13048cd47b60dbf1a5495424dea226c5faf3950e20bf8120a58efb5b5f3" - url: "https://pub.dev" - source: hosted - version: "3.0.4" - image_picker_ios: - dependency: transitive - description: - name: image_picker_ios - sha256: cb0db0ec0d3e2cd49674f2e6053be25ccdb959832607c1cbd215dd6cf10fb0dd - url: "https://pub.dev" - source: hosted - version: "0.8.11" - image_picker_linux: - dependency: transitive - description: - name: image_picker_linux - sha256: "4ed1d9bb36f7cd60aa6e6cd479779cc56a4cb4e4de8f49d487b1aaad831300fa" - url: "https://pub.dev" - source: hosted - version: "0.2.1+1" - image_picker_macos: - dependency: transitive - description: - name: image_picker_macos - sha256: "3f5ad1e8112a9a6111c46d0b57a7be2286a9a07fc6e1976fdf5be2bd31d4ff62" - url: "https://pub.dev" - source: hosted - version: "0.2.1+1" - image_picker_platform_interface: - dependency: transitive - description: - name: image_picker_platform_interface - sha256: "9ec26d410ff46f483c5519c29c02ef0e02e13a543f882b152d4bfd2f06802f80" - url: "https://pub.dev" - source: hosted - version: "2.10.0" - image_picker_windows: - dependency: transitive - description: - name: image_picker_windows - sha256: "6ad07afc4eb1bc25f3a01084d28520496c4a3bb0cb13685435838167c9dcedeb" - url: "https://pub.dev" - source: hosted - version: "0.2.1+1" intl: - dependency: transitive + dependency: "direct main" description: name: intl sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf @@ -537,18 +220,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a" + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" url: "https://pub.dev" source: hosted - version: "10.0.4" + version: "10.0.5" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8" + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" url: "https://pub.dev" source: hosted - version: "3.0.3" + version: "3.0.5" leak_tracker_testing: dependency: transitive description: @@ -577,58 +260,50 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.11.1" meta: dependency: transitive description: name: meta - sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.12.0" - mime: + version: "1.15.0" + nested: dependency: transitive description: - name: mime - sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" + name: nested + sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20" url: "https://pub.dev" source: hosted - version: "1.0.5" + version: "1.0.0" path: - dependency: "direct main" + dependency: transitive description: name: path sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted version: "1.9.0" - path_parsing: - dependency: transitive - description: - name: path_parsing - sha256: e3e67b1629e6f7e8100b367d3db6ba6af4b1f0bb80f64db18ef1fbabd2fa9ccf - url: "https://pub.dev" - source: hosted - version: "1.0.1" path_provider: dependency: transitive description: name: path_provider - sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161 + sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378 url: "https://pub.dev" source: hosted - version: "2.1.3" + version: "2.1.4" path_provider_android: dependency: transitive description: name: path_provider_android - sha256: a248d8146ee5983446bf03ed5ea8f6533129a12b11f12057ad1b4a67a2b3b41d + sha256: "6f01f8e37ec30b07bc424b4deabac37cacb1bc7e2e515ad74486039918a37eb7" url: "https://pub.dev" source: hosted - version: "2.2.4" + version: "2.2.10" path_provider_foundation: dependency: transitive description: @@ -657,26 +332,18 @@ packages: dependency: transitive description: name: path_provider_windows - sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170" - url: "https://pub.dev" - source: hosted - version: "2.2.1" - petitparser: - dependency: transitive - description: - name: petitparser - sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27 + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 url: "https://pub.dev" source: hosted - version: "6.0.2" + version: "2.3.0" platform: dependency: transitive description: name: platform - sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec" + sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65" url: "https://pub.dev" source: hosted - version: "3.1.4" + version: "3.1.5" plugin_platform_interface: dependency: transitive description: @@ -685,6 +352,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.8" + provider: + dependency: "direct main" + description: + name: provider + sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c + url: "https://pub.dev" + source: hosted + version: "6.1.2" sky_engine: dependency: transitive description: flutter @@ -734,10 +409,10 @@ packages: dependency: transitive description: name: test_api - sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.7.0" + version: "0.7.2" typed_data: dependency: transitive description: @@ -746,30 +421,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" - vector_graphics: - dependency: transitive - description: - name: vector_graphics - sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3" - url: "https://pub.dev" - source: hosted - version: "1.1.11+1" - vector_graphics_codec: - dependency: transitive - description: - name: vector_graphics_codec - sha256: c86987475f162fadff579e7320c7ddda04cd2fdeffbe1129227a85d9ac9e03da - url: "https://pub.dev" - source: hosted - version: "1.1.11+1" - vector_graphics_compiler: - dependency: transitive - description: - name: vector_graphics_compiler - sha256: "12faff3f73b1741a36ca7e31b292ddeb629af819ca9efe9953b70bd63fc8cd81" - url: "https://pub.dev" - source: hosted - version: "1.1.11+1" vector_math: dependency: transitive description: @@ -782,10 +433,10 @@ packages: dependency: transitive description: name: vm_service - sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec" + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "14.2.1" + version: "14.2.5" web: dependency: transitive description: @@ -794,14 +445,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.1" - win32: - dependency: transitive - description: - name: win32 - sha256: "0eaf06e3446824099858367950a813472af675116bf63f008a4c2a75ae13e9cb" - url: "https://pub.dev" - source: hosted - version: "5.5.0" xdg_directories: dependency: transitive description: @@ -810,14 +453,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.4" - xml: - dependency: transitive - description: - name: xml - sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226 - url: "https://pub.dev" - source: hosted - version: "6.5.0" sdks: - dart: ">=3.3.4 <4.0.0" - flutter: ">=3.19.2" + dart: ">=3.4.0 <4.0.0" + flutter: ">=3.22.0" diff --git a/pubspec.yaml b/pubspec.yaml index 2909a374..b3d2ca22 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,34 +10,21 @@ dependencies: get: 4.6.6 flutter: sdk: flutter - firebase_core: ^2.31.0 - firebase_ui_auth: ^1.14.0 - firebase_auth: ^4.19.5 - google_sign_in: ^6.2.1 - firebase_ui_oauth_google: ^1.3.2 - google_fonts: ^6.2.1 - firebase_storage: ^11.7.5 - image_picker: ^1.1.1 - file_picker: ^8.0.3 - path: ^1.9.0 + firebase_core: ^3.4.0 + firebase_auth: ^5.2.0 + cloud_firestore: ^5.3.0 + provider: ^6.1.2 + intl: ^0.19.0 + flutter_slidable: ^3.1.1 + flutter_spinkit: ^5.2.1 get_storage: ^2.1.1 - firebase_ui_localizations: ^1.12.0 - firebase_remote_config: ^4.4.7 - firebase_analytics: ^10.10.7 + dev_dependencies: flutter_lints: 3.0.2 flutter_test: sdk: flutter -flutter: - fonts: - - family: SocialIcons - fonts: - - asset: packages/firebase_ui_auth/fonts/SocialIcons.ttf - assets: - - assets/images/flutterfire_300x.png - - assets/images/dash.png - - assets/icons/logo.png - uses-material-design: true +flutter: + uses-material-design: true \ No newline at end of file