├── .firebaserc ├── .github └── ISSUE_TEMPLATE │ ├── bug-report.md │ ├── feature-request.md │ └── questions.md ├── .gitignore ├── LICENSE ├── README.md ├── firebase.json ├── firestore.indexes.json ├── firestore.rules ├── flutter_app ├── .gitignore ├── .metadata ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── wisetap │ │ │ │ │ └── flutter_chat_app_with_mysql │ │ │ │ │ └── flutter_chat_app_with_mysql │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── launcher_icon.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── launcher_icon.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── launcher_icon.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── launcher_icon.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── launcher_icon.png │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── assets │ ├── fonts │ │ └── RedHatDisplay │ │ │ ├── OFL.txt │ │ │ ├── README.txt │ │ │ ├── RedHatDisplay-Black.ttf │ │ │ ├── RedHatDisplay-BlackItalic.ttf │ │ │ ├── RedHatDisplay-Bold.ttf │ │ │ ├── RedHatDisplay-BoldItalic.ttf │ │ │ ├── RedHatDisplay-ExtraBold.ttf │ │ │ ├── RedHatDisplay-ExtraBoldItalic.ttf │ │ │ ├── RedHatDisplay-Italic-VariableFont_wght.ttf │ │ │ ├── RedHatDisplay-Italic.ttf │ │ │ ├── RedHatDisplay-Light.ttf │ │ │ ├── RedHatDisplay-LightItalic.ttf │ │ │ ├── RedHatDisplay-Medium.ttf │ │ │ ├── RedHatDisplay-MediumItalic.ttf │ │ │ ├── RedHatDisplay-Regular.ttf │ │ │ ├── RedHatDisplay-SemiBold.ttf │ │ │ ├── RedHatDisplay-SemiBoldItalic.ttf │ │ │ └── RedHatDisplay-VariableFont_wght.ttf │ └── imgs │ │ └── 370075_send_chat_communication_email_letter_icon │ │ ├── attribution-credit.txt │ │ └── icon.png ├── flutter_launcher_icons.yaml ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-50x50@1x.png │ │ │ │ ├── Icon-App-50x50@2x.png │ │ │ │ ├── Icon-App-57x57@1x.png │ │ │ │ ├── Icon-App-57x57@2x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-72x72@1x.png │ │ │ │ ├── Icon-App-72x72@2x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h │ └── RunnerTests │ │ └── RunnerTests.swift ├── lib │ ├── core │ │ ├── data │ │ │ ├── data_sources │ │ │ │ ├── auth_ds.dart │ │ │ │ └── users_ds.dart │ │ │ └── models │ │ │ │ ├── user_full_model.dart │ │ │ │ └── user_public_model.dart │ │ ├── domain │ │ │ ├── entities │ │ │ │ ├── failures │ │ │ │ │ └── failure.dart │ │ │ │ ├── user_full.dart │ │ │ │ └── user_public.dart │ │ │ └── services │ │ │ │ ├── auth_service.dart │ │ │ │ ├── notifications_service.dart │ │ │ │ └── users_service.dart │ │ ├── presentation │ │ │ ├── confirmation_modal.dart │ │ │ ├── snackbar.dart │ │ │ └── widgets │ │ │ │ ├── button_widget.dart │ │ │ │ ├── center_content_widget.dart │ │ │ │ ├── circular_person.dart │ │ │ │ ├── expanded_section_widget.dart │ │ │ │ ├── info_widget.dart │ │ │ │ ├── my_appbar_widget.dart │ │ │ │ ├── my_custom_text_form_field.dart │ │ │ │ ├── my_multiline_text_field.dart │ │ │ │ ├── my_scaffold.dart │ │ │ │ ├── person_icon.dart │ │ │ │ ├── stopwatch │ │ │ │ ├── stopwatch_controller.dart │ │ │ │ └── stopwatch_widget.dart │ │ │ │ └── waves_background │ │ │ │ ├── clipper │ │ │ │ └── waves_background_clipper.dart │ │ │ │ └── waves_background.dart │ │ └── utils │ │ │ ├── dartz_utils.dart │ │ │ ├── model_utils.dart │ │ │ └── validators.dart │ ├── environment.dart │ ├── features │ │ ├── call │ │ │ ├── data │ │ │ │ └── data_sources │ │ │ │ │ └── call_ds.dart │ │ │ ├── domain │ │ │ │ ├── entities │ │ │ │ │ └── call_credentials.dart │ │ │ │ └── services │ │ │ │ │ └── call_service.dart │ │ │ └── presentation │ │ │ │ └── screens │ │ │ │ └── call_screen.dart │ │ ├── chat │ │ │ ├── data │ │ │ │ ├── data_sources │ │ │ │ │ ├── messages_ds.dart │ │ │ │ │ └── typing_ds.dart │ │ │ │ ├── models │ │ │ │ │ ├── conversation_model.dart │ │ │ │ │ └── message_firestore_model.dart │ │ │ │ └── utils.dart │ │ │ ├── domain │ │ │ │ ├── chat_utils.dart │ │ │ │ ├── entities │ │ │ │ │ ├── chat_list_item_entity.dart │ │ │ │ │ ├── conversation.dart │ │ │ │ │ ├── detailed_conversation.dart │ │ │ │ │ ├── message.dart │ │ │ │ │ ├── pending_request_to_api_telling_message_was_read.dart │ │ │ │ │ └── sending_text_message_entity.dart │ │ │ │ └── services │ │ │ │ │ └── messages_service.dart │ │ │ └── presentation │ │ │ │ ├── controllers │ │ │ │ ├── detailed_conversation_controller.dart │ │ │ │ ├── detailed_conversation_list_controller.dart │ │ │ │ ├── message_input_controller.dart │ │ │ │ ├── realtime_chat_page_controller.dart │ │ │ │ ├── signout_controller.dart │ │ │ │ └── users_to_talk_to_controller.dart │ │ │ │ ├── screens │ │ │ │ ├── realtime_chat_screen │ │ │ │ │ └── realtime_chat_screen.dart │ │ │ │ └── realtime_conversations_screen │ │ │ │ │ └── realtime_conversations_screen.dart │ │ │ │ └── widgets │ │ │ │ ├── balloon_widget.dart │ │ │ │ ├── chat_item_widget.dart │ │ │ │ ├── conversation_item.dart │ │ │ │ ├── delay_animate_switcher.dart │ │ │ │ ├── load_more_messages_button.dart │ │ │ │ ├── logout_button_widget.dart │ │ │ │ ├── message_status_widget.dart │ │ │ │ ├── message_widget.dart │ │ │ │ ├── separator_date_for_messages_widget.dart │ │ │ │ └── typing_indicator_widget.dart │ │ ├── groups │ │ │ ├── data │ │ │ │ └── datasources │ │ │ │ │ └── groups_ds.dart │ │ │ ├── domain │ │ │ │ └── services │ │ │ │ │ └── groups_service.dart │ │ │ └── presentation │ │ │ │ ├── controllers │ │ │ │ ├── add_participants_controller.dart │ │ │ │ ├── create_group_or_edit_title_controller.dart │ │ │ │ └── manage_group_participants_controller.dart │ │ │ │ └── screens │ │ │ │ ├── add_participants_screen.dart │ │ │ │ ├── create_group_or_edit_title_screen.dart │ │ │ │ └── manage_group_participants_screen.dart │ │ ├── loading │ │ │ └── screens │ │ │ │ └── loading_screen.dart │ │ └── login_and_registration │ │ │ ├── domain │ │ │ └── entities │ │ │ │ ├── failures │ │ │ │ ├── email_already_exists_failure.dart │ │ │ │ ├── invalid_credentials_failure.dart │ │ │ │ ├── invalid_email_failure.dart │ │ │ │ └── invalid_password_failure.dart │ │ │ │ └── tokens_entity.dart │ │ │ └── presentation │ │ │ ├── screens │ │ │ ├── content │ │ │ │ ├── login_content.dart │ │ │ │ └── register_content.dart │ │ │ ├── login_and_registration_screen.dart │ │ │ └── widgets │ │ │ │ └── animated_icon.dart │ │ │ └── widgets │ │ │ └── separator.dart │ ├── injection_container.dart │ ├── main.dart │ └── screen_routes.dart ├── linux │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ │ ├── CMakeLists.txt │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ └── generated_plugins.cmake │ ├── main.cc │ ├── my_application.cc │ └── my_application.h ├── macos │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── app_icon_1024.png │ │ │ │ ├── app_icon_128.png │ │ │ │ ├── app_icon_16.png │ │ │ │ ├── app_icon_256.png │ │ │ │ ├── app_icon_32.png │ │ │ │ ├── app_icon_512.png │ │ │ │ └── app_icon_64.png │ │ ├── Base.lproj │ │ │ └── MainMenu.xib │ │ ├── Configs │ │ │ ├── AppInfo.xcconfig │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ └── Warnings.xcconfig │ │ ├── DebugProfile.entitlements │ │ ├── Info.plist │ │ ├── MainFlutterWindow.swift │ │ └── Release.entitlements │ └── RunnerTests │ │ └── RunnerTests.swift ├── pubspec.lock ├── pubspec.yaml ├── web │ ├── environment.js │ ├── favicon.png │ ├── firebase-messaging-sw.js │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── index.html │ └── manifest.json └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake │ └── runner │ ├── CMakeLists.txt │ ├── Runner.rc │ ├── flutter_window.cpp │ ├── flutter_window.h │ ├── main.cpp │ ├── resource.h │ ├── resources │ └── app_icon.ico │ ├── runner.exe.manifest │ ├── utils.cpp │ ├── utils.h │ ├── win32_window.cpp │ └── win32_window.h ├── functions ├── .gitignore ├── package-lock.json ├── package.json ├── src │ ├── data │ │ ├── datasource │ │ │ ├── db.ts │ │ │ ├── messages-datasource.ts │ │ │ └── users-datasource.ts │ │ └── models │ │ │ ├── agora-uid-mutex-model.ts │ │ │ ├── conversation-group-model.ts │ │ │ ├── conversation-model.ts │ │ │ ├── message-model.ts │ │ │ ├── mutex-model.ts │ │ │ ├── user-full-model.ts │ │ │ └── user-public-model.ts │ ├── domain │ │ ├── entities │ │ │ ├── conversation-group.ts │ │ │ ├── conversation.ts │ │ │ ├── message.ts │ │ │ ├── mutex.ts │ │ │ ├── user-full.ts │ │ │ └── user-public.ts │ │ └── services │ │ │ ├── get-agora-uid-mutex-service.ts │ │ │ ├── messages-service.ts │ │ │ ├── mutex-service.ts │ │ │ ├── notifications-service.ts │ │ │ └── users-service.ts │ ├── environment.ts │ ├── index.ts │ ├── middlewares │ │ ├── calls │ │ │ └── calls.ts │ │ └── oncall-wrapper.ts │ └── utils.ts └── tsconfig.json └── readme-image.png /.firebaserc: -------------------------------------------------------------------------------- 1 | { 2 | "projects": {}, 3 | "targets": {}, 4 | "etags": {} 5 | } 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior. 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Additional context** 20 | Add any other context about the problem here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/questions.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Questions 3 | about: Ask a question 4 | title: '' 5 | labels: question 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | firebase-debug.log 2 | *.cache 3 | .idea 4 | functions/src/environment.ts -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Rodrigo João Bertotti 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /firebase.json: -------------------------------------------------------------------------------- 1 | { 2 | "functions": [ 3 | { 4 | "source": "functions", 5 | "codebase": "default", 6 | "ignore": [ 7 | "node_modules", 8 | ".git", 9 | "firebase-debug.log", 10 | "firebase-debug.*.log" 11 | ], 12 | "predeploy": [ 13 | "npm --prefix \"$RESOURCE_DIR\" run build" 14 | ] 15 | } 16 | ], 17 | "firestore": { 18 | "rules": "firestore.rules", 19 | "indexes": "firestore.indexes.json" 20 | }, 21 | "hosting": { 22 | "public": "flutter_app/build/web", 23 | "ignore": [ 24 | "firebase.json", 25 | "**/.*", 26 | "**/node_modules/**" 27 | ], 28 | "predeploy": [ 29 | "cd flutter_app && flutter build web --web-renderer canvaskit" 30 | ], 31 | "rewrites": [ 32 | { 33 | "source": "**", 34 | "destination": "/index.html" 35 | } 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /firestore.indexes.json: -------------------------------------------------------------------------------- 1 | { 2 | "indexes": [ 3 | { 4 | "collectionGroup": "messages", 5 | "queryScope": "COLLECTION", 6 | "fields": [ 7 | { 8 | "fieldPath": "participants", 9 | "arrayConfig": "CONTAINS" 10 | }, 11 | { 12 | "fieldPath": "sentAt", 13 | "order": "ASCENDING" 14 | } 15 | ] 16 | }, 17 | { 18 | "collectionGroup": "messages", 19 | "queryScope": "COLLECTION", 20 | "fields": [ 21 | { 22 | "fieldPath": "participants", 23 | "arrayConfig": "CONTAINS" 24 | }, 25 | { 26 | "fieldPath": "sentAt", 27 | "order": "DESCENDING" 28 | } 29 | ] 30 | } 31 | ], 32 | "fieldOverrides": [] 33 | } 34 | -------------------------------------------------------------------------------- /flutter_app/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | #**/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | -------------------------------------------------------------------------------- /flutter_app/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled. 5 | 6 | version: 7 | revision: 796c8ef79279f9c774545b3771238c3098dbefab 8 | channel: stable 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 796c8ef79279f9c774545b3771238c3098dbefab 17 | base_revision: 796c8ef79279f9c774545b3771238c3098dbefab 18 | - platform: android 19 | create_revision: 796c8ef79279f9c774545b3771238c3098dbefab 20 | base_revision: 796c8ef79279f9c774545b3771238c3098dbefab 21 | - platform: ios 22 | create_revision: 796c8ef79279f9c774545b3771238c3098dbefab 23 | base_revision: 796c8ef79279f9c774545b3771238c3098dbefab 24 | - platform: linux 25 | create_revision: 796c8ef79279f9c774545b3771238c3098dbefab 26 | base_revision: 796c8ef79279f9c774545b3771238c3098dbefab 27 | - platform: macos 28 | create_revision: 796c8ef79279f9c774545b3771238c3098dbefab 29 | base_revision: 796c8ef79279f9c774545b3771238c3098dbefab 30 | - platform: web 31 | create_revision: 796c8ef79279f9c774545b3771238c3098dbefab 32 | base_revision: 796c8ef79279f9c774545b3771238c3098dbefab 33 | - platform: windows 34 | create_revision: 796c8ef79279f9c774545b3771238c3098dbefab 35 | base_revision: 796c8ef79279f9c774545b3771238c3098dbefab 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /flutter_app/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /flutter_app/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /flutter_app/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | // START: FlutterFire Configuration 26 | apply plugin: 'com.google.gms.google-services' 27 | // END: FlutterFire Configuration 28 | apply plugin: 'kotlin-android' 29 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 30 | 31 | android { 32 | namespace "com.example.fluttergroupchatappwithfirebase" 33 | compileSdkVersion 34 34 | ndkVersion flutter.ndkVersion 35 | 36 | compileOptions { 37 | sourceCompatibility JavaVersion.VERSION_1_8 38 | targetCompatibility JavaVersion.VERSION_1_8 39 | } 40 | 41 | kotlinOptions { 42 | jvmTarget = '1.8' 43 | } 44 | 45 | sourceSets { 46 | main.java.srcDirs += 'src/main/kotlin' 47 | } 48 | 49 | defaultConfig { 50 | applicationId "com.example.fluttergroupchatappwithfirebase" 51 | // You can update the following values to match your application needs. 52 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 53 | minSdkVersion 23 54 | targetSdkVersion 34 55 | versionCode flutterVersionCode.toInteger() 56 | versionName flutterVersionName 57 | } 58 | 59 | buildTypes { 60 | release { 61 | // Signing with the debug keys for now, so `flutter run --release` works. 62 | signingConfig signingConfigs.debug 63 | } 64 | } 65 | } 66 | 67 | flutter { 68 | source '../..' 69 | } 70 | 71 | dependencies { 72 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 73 | } 74 | -------------------------------------------------------------------------------- /flutter_app/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 21 | 29 | 33 | 37 | 38 | 39 | 40 | 41 | 42 | 44 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/kotlin/com/wisetap/flutter_chat_app_with_mysql/flutter_chat_app_with_mysql/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.fluttergroupchatappwithfirebase 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/res/mipmap-hdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/android/app/src/main/res/mipmap-hdpi/launcher_icon.png -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/res/mipmap-mdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/android/app/src/main/res/mipmap-mdpi/launcher_icon.png -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/res/mipmap-xhdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/android/app/src/main/res/mipmap-xhdpi/launcher_icon.png -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/android/app/src/main/res/mipmap-xxhdpi/launcher_icon.png -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/android/app/src/main/res/mipmap-xxxhdpi/launcher_icon.png -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /flutter_app/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /flutter_app/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /flutter_app/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | maven { url 'https://jitpack.io' } 7 | } 8 | 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:7.3.1' 11 | // START: FlutterFire Configuration 12 | classpath 'com.google.gms:google-services:4.3.15' 13 | // END: FlutterFire Configuration 14 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | google() 21 | mavenCentral() 22 | maven { url 'https://jitpack.io' } 23 | } 24 | } 25 | 26 | rootProject.buildDir = '../build' 27 | subprojects { 28 | project.buildDir = "${rootProject.buildDir}/${project.name}" 29 | } 30 | subprojects { 31 | project.evaluationDependsOn(':app') 32 | } 33 | 34 | tasks.register("clean", Delete) { 35 | delete rootProject.buildDir 36 | } 37 | -------------------------------------------------------------------------------- /flutter_app/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M \ 2 | --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \ 3 | --add-opens=java.base/java.lang=ALL-UNNAMED \ 4 | --add-opens=java.base/java.lang.reflect=ALL-UNNAMED \ 5 | --add-opens=java.base/java.io=ALL-UNNAMED \ 6 | --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED 7 | android.useAndroidX=true 8 | android.enableJetifier=true 9 | android.defaults.buildfeatures.buildconfig=true 10 | -------------------------------------------------------------------------------- /flutter_app/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip 6 | -------------------------------------------------------------------------------- /flutter_app/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/README.txt: -------------------------------------------------------------------------------- 1 | Red Hat Display Variable Font 2 | ============================= 3 | 4 | This download contains Red Hat Display as both variable fonts and static fonts. 5 | 6 | Red Hat Display is a variable font with this axis: 7 | wght 8 | 9 | This means all the styles are contained in these files: 10 | RedHatDisplay-VariableFont_wght.ttf 11 | RedHatDisplay-Italic-VariableFont_wght.ttf 12 | 13 | If your app fully supports variable fonts, you can now pick intermediate styles 14 | that aren’t available as static fonts. Not all apps support variable fonts, and 15 | in those cases you can use the static font files for Red Hat Display: 16 | static/RedHatDisplay-Light.ttf 17 | static/RedHatDisplay-Regular.ttf 18 | static/RedHatDisplay-Medium.ttf 19 | static/RedHatDisplay-SemiBold.ttf 20 | static/RedHatDisplay-Bold.ttf 21 | static/RedHatDisplay-ExtraBold.ttf 22 | static/RedHatDisplay-Black.ttf 23 | static/RedHatDisplay-LightItalic.ttf 24 | static/RedHatDisplay-Italic.ttf 25 | static/RedHatDisplay-MediumItalic.ttf 26 | static/RedHatDisplay-SemiBoldItalic.ttf 27 | static/RedHatDisplay-BoldItalic.ttf 28 | static/RedHatDisplay-ExtraBoldItalic.ttf 29 | static/RedHatDisplay-BlackItalic.ttf 30 | 31 | Get started 32 | ----------- 33 | 34 | 1. Install the font files you want to use 35 | 36 | 2. Use your app's font picker to view the font family and all the 37 | available styles 38 | 39 | Learn more about variable fonts 40 | ------------------------------- 41 | 42 | https://developers.google.com/web/fundamentals/design-and-ux/typography/variable-fonts 43 | https://variablefonts.typenetwork.com 44 | https://medium.com/variable-fonts 45 | 46 | In desktop apps 47 | 48 | https://theblog.adobe.com/can-variable-fonts-illustrator-cc 49 | https://helpx.adobe.com/nz/photoshop/using/fonts.html#variable_fonts 50 | 51 | Online 52 | 53 | https://developers.google.com/fonts/docs/getting_started 54 | https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide 55 | https://developer.microsoft.com/en-us/microsoft-edge/testdrive/demos/variable-fonts 56 | 57 | Installing fonts 58 | 59 | MacOS: https://support.apple.com/en-us/HT201749 60 | Linux: https://www.google.com/search?q=how+to+install+a+font+on+gnu%2Blinux 61 | Windows: https://support.microsoft.com/en-us/help/314960/how-to-install-or-remove-a-font-in-windows 62 | 63 | Android Apps 64 | 65 | https://developers.google.com/fonts/docs/android 66 | https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts 67 | 68 | License 69 | ------- 70 | Please read the full license text (OFL.txt) to understand the permissions, 71 | restrictions and requirements for usage, redistribution, and modification. 72 | 73 | You can use them in your products & projects – print or digital, 74 | commercial or otherwise. 75 | 76 | This isn't legal advice, please consider consulting a lawyer and see the full 77 | license for all details. 78 | -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-Black.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-BlackItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-BlackItalic.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-Bold.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-BoldItalic.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-ExtraBold.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-ExtraBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-ExtraBoldItalic.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-Italic-VariableFont_wght.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-Italic-VariableFont_wght.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-Italic.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-Light.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-LightItalic.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-Medium.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-MediumItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-MediumItalic.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-Regular.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-SemiBold.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-SemiBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-SemiBoldItalic.ttf -------------------------------------------------------------------------------- /flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-VariableFont_wght.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/fonts/RedHatDisplay/RedHatDisplay-VariableFont_wght.ttf -------------------------------------------------------------------------------- /flutter_app/assets/imgs/370075_send_chat_communication_email_letter_icon/attribution-credit.txt: -------------------------------------------------------------------------------- 1 | Image imported from: https://www.iconfinder.com/icons/370075/send_chat_communication_email_letter_mail_message_icon 2 | Created by: https://www.iconfinder.com/setu 3 | Licensed under: http://creativecommons.org/licenses/by/3.0/ -------------------------------------------------------------------------------- /flutter_app/assets/imgs/370075_send_chat_communication_email_letter_icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/assets/imgs/370075_send_chat_communication_email_letter_icon/icon.png -------------------------------------------------------------------------------- /flutter_app/flutter_launcher_icons.yaml: -------------------------------------------------------------------------------- 1 | flutter_launcher_icons: 2 | android: "launcher_icon" 3 | ios: true 4 | image_path: "assets/imgs/370075_send_chat_communication_email_letter_icon/icon.png" 5 | min_sdk_android: 31 6 | web: 7 | generate: true 8 | background_color: "#hexcode" 9 | theme_color: "#hexcode" 10 | windows: 11 | generate: true 12 | icon_size: 48 # min:48, max:256, default: 48 13 | macos: 14 | generate: true -------------------------------------------------------------------------------- /flutter_app/ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /flutter_app/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /flutter_app/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /flutter_app/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /flutter_app/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '11.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | target 'RunnerTests' do 36 | inherit! :search_paths 37 | end 38 | end 39 | 40 | post_install do |installer| 41 | installer.pods_project.targets.each do |target| 42 | flutter_additional_ios_build_settings(target) 43 | target.build_configurations.each do |config| 44 | # Workaround for https://github.com/flutter/flutter/issues/64502 45 | config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES' # <= this line 46 | end 47 | end 48 | end -------------------------------------------------------------------------------- /flutter_app/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /flutter_app/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter_app/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter_app/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /flutter_app/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter_app/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter_app/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | import Firebase 4 | 5 | @UIApplicationMain 6 | @objc class AppDelegate: FlutterAppDelegate { 7 | override func application( 8 | _ application: UIApplication, 9 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 10 | ) -> Bool { 11 | FirebaseApp.configure() 12 | GeneratedPluginRegistrant.register(with: self) 13 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CADisableMinimumFrameDurationOnPhone 6 | 7 | CFBundleDevelopmentRegion 8 | $(DEVELOPMENT_LANGUAGE) 9 | CFBundleDisplayName 10 | Flutter Group Chat App with Firebase 11 | CFBundleExecutable 12 | $(EXECUTABLE_NAME) 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | flutter_group_chat_app_with_firebase 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | $(FLUTTER_BUILD_NAME) 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | $(FLUTTER_BUILD_NUMBER) 27 | LSRequiresIPhoneOS 28 | 29 | NSCameraUsageDescription 30 | $(PRODUCT_NAME)Camera permission is required for making calls 31 | NSMicrophoneUsageDescription 32 | $(PRODUCT_NAME)Microphone permission is required for making calls 33 | UIApplicationSupportsIndirectInputEvents 34 | 35 | UIBackgroundModes 36 | 37 | fetch 38 | remote-notification 39 | 40 | UILaunchStoryboardName 41 | LaunchScreen 42 | UIMainStoryboardFile 43 | Main 44 | UISupportedInterfaceOrientations 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | UISupportedInterfaceOrientations~ipad 51 | 52 | UIInterfaceOrientationPortrait 53 | UIInterfaceOrientationPortraitUpsideDown 54 | UIInterfaceOrientationLandscapeLeft 55 | UIInterfaceOrientationLandscapeRight 56 | 57 | UIViewControllerBasedStatusBarAppearance 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /flutter_app/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /flutter_app/ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /flutter_app/lib/core/data/data_sources/auth_ds.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:firebase_auth/firebase_auth.dart'; 3 | import 'package:flutter_group_chat_app_with_firebase/features/login_and_registration/domain/entities/failures/invalid_email_failure.dart'; 4 | import 'package:flutter_group_chat_app_with_firebase/features/login_and_registration/domain/entities/failures/invalid_password_failure.dart'; 5 | import '../../../features/login_and_registration/domain/entities/failures/invalid_credentials_failure.dart'; 6 | 7 | class AuthDS { 8 | final FirebaseAuth firebaseAuth; 9 | final List _onSignOutListeners = []; 10 | 11 | AuthDS({required this.firebaseAuth}); 12 | 13 | String? get loggedUid => firebaseAuth.currentUser?.uid; 14 | 15 | bool get isAuthenticated { 16 | return firebaseAuth.currentUser != null; 17 | } 18 | 19 | void addOnSignInListener(void Function() listener) { 20 | firebaseAuth.authStateChanges().listen((user) { 21 | if (user != null) { 22 | listener(); 23 | } 24 | }); 25 | } 26 | 27 | void addOnSignOutListener(void Function() listener) { 28 | _onSignOutListeners.add(listener); 29 | } 30 | 31 | void removeOnSignOutListener(void Function() listener) { 32 | _onSignOutListeners.remove(listener); 33 | } 34 | 35 | Future signOut() async { 36 | for (final listener in List.from(_onSignOutListeners)) { 37 | listener(); 38 | } 39 | await Future.delayed(const Duration(milliseconds: 100)); 40 | return firebaseAuth.signOut(); 41 | } 42 | 43 | /// throws [InvalidEmailFailure] or [InvalidPasswordFailure] 44 | Future signInWithEmailAndPassword ({required String email, required String password}) async { 45 | try { 46 | await firebaseAuth.signInWithEmailAndPassword(email: email, password: password); 47 | } catch (e) { 48 | if (e is FirebaseAuthException) { 49 | switch (e.code) { 50 | case 'INVALID_LOGIN_CREDENTIALS': 51 | case 'auth/invalid-credential': 52 | case 'user-not-found': 53 | case 'invalid-email': 54 | case 'user-disabled': 55 | throw InvalidEmailFailure(); 56 | case 'wrong-password': 57 | throw InvalidPasswordFailure(); 58 | default: 59 | print("FirebaseAuthException: ${e.code}: ${e.message}"); 60 | throw InvalidCredentialsFailure(); 61 | } 62 | } 63 | rethrow; 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /flutter_app/lib/core/data/models/user_full_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_group_chat_app_with_firebase/core/data/models/user_public_model.dart'; 2 | import 'package:flutter_group_chat_app_with_firebase/core/domain/entities/user_full.dart'; 3 | 4 | 5 | class UserFullModel extends UserFull { 6 | /// Field names: 7 | static const String kUid = "uid"; 8 | static const String kFcmToken = "fcmToken"; 9 | 10 | UserFullModel({required String uid, required String firstName, required String lastName, required String? fcmToken}) 11 | : super(uid: uid, firstName: firstName, lastName: lastName, fcmToken: fcmToken,); 12 | 13 | static UserFullModel? fromMap({required Map? userFull}) { 14 | if (userFull == null) { 15 | return null; 16 | } 17 | return UserFullModel( 18 | uid: userFull[kUid], 19 | fcmToken: userFull[kFcmToken], 20 | firstName: userFull[UserPublicModel.kFirstName], 21 | lastName: userFull[UserPublicModel.kLastName], 22 | ); 23 | } 24 | 25 | Map toMap() => { 26 | kUid: uid, 27 | kFcmToken: fcmToken, 28 | UserPublicModel.kFirstName: firstName, 29 | UserPublicModel.kLastName: lastName, 30 | }; 31 | 32 | } -------------------------------------------------------------------------------- /flutter_app/lib/core/data/models/user_public_model.dart: -------------------------------------------------------------------------------- 1 | import '../../domain/entities/user_public.dart'; 2 | 3 | 4 | class UserPublicModel extends UserPublic { 5 | /// Field names: 6 | static const String kUid = "uid"; 7 | static const String kFirstName = "firstName"; 8 | static const String kLastName = "lastName"; 9 | 10 | 11 | UserPublicModel({required String uid, required String firstName, required String lastName}) 12 | : super(uid: uid, firstName: firstName, lastName: lastName,); 13 | 14 | static UserPublicModel fromMap(map) { 15 | return UserPublicModel( 16 | uid: map[kUid], 17 | firstName: map[kFirstName], 18 | lastName: map[kLastName], 19 | ); 20 | } 21 | 22 | static List fromList(List list) { 23 | return list.map((data) => UserPublicModel.fromMap(data)).toList(); 24 | } 25 | 26 | Map toMap() => { 27 | kUid: uid, 28 | kFirstName: firstName, 29 | kLastName: lastName 30 | }; 31 | 32 | } -------------------------------------------------------------------------------- /flutter_app/lib/core/domain/entities/failures/failure.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | class Failure extends Error { 5 | dynamic _err; 6 | 7 | Failure([dynamic err]) { 8 | _err = err; 9 | } 10 | 11 | String get error => _err ?? "An error occurred, please try again later"; 12 | 13 | @override 14 | String toString() { 15 | return "Failure: $error"; 16 | } 17 | } -------------------------------------------------------------------------------- /flutter_app/lib/core/domain/entities/user_full.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_group_chat_app_with_firebase/core/domain/entities/user_public.dart'; 2 | 3 | class UserFull extends UserPublic { 4 | final String? fcmToken; 5 | 6 | UserFull ({required String uid, required this.fcmToken, required String firstName, required String lastName}) 7 | : super(uid: uid, firstName: firstName, lastName: lastName); 8 | } -------------------------------------------------------------------------------- /flutter_app/lib/core/domain/entities/user_public.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_group_chat_app_with_firebase/core/domain/services/auth_service.dart'; 2 | import 'package:flutter_group_chat_app_with_firebase/injection_container.dart'; 3 | import '../../../features/chat/domain/chat_utils.dart' as chatUtils; 4 | 5 | class UserPublic { 6 | final String uid; 7 | final String firstName; 8 | final String lastName; 9 | 10 | UserPublic({required this.uid, required this.firstName, required this.lastName}); 11 | 12 | String get fullName => "$firstName $lastName"; 13 | 14 | String get conversationId { 15 | return chatUtils.getDirectConversationId([uid, getIt.get().loggedUid!]); 16 | } 17 | 18 | static UserPublic empty() => UserPublic(uid: '', firstName: '', lastName: ''); 19 | } -------------------------------------------------------------------------------- /flutter_app/lib/core/domain/services/auth_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | import 'package:flutter_group_chat_app_with_firebase/core/domain/services/notifications_service.dart'; 3 | import '../../data/data_sources/auth_ds.dart'; 4 | import '../entities/failures/failure.dart'; 5 | import '../../data/data_sources/users_ds.dart'; 6 | 7 | 8 | class AuthService { 9 | final AuthDS authDS; 10 | final UsersDS usersDS; 11 | final NotificationsService notificationsController; 12 | 13 | AuthService({required this.authDS, required this.usersDS, required this.notificationsController}); 14 | 15 | bool get isAuthenticated { 16 | return authDS.isAuthenticated; 17 | } 18 | 19 | void addOnSignInListener(void Function() listener) => authDS.addOnSignInListener(listener); 20 | 21 | void addOnSignOutListener(void Function() listener) => authDS.addOnSignOutListener(listener); 22 | 23 | Future signOut() async { 24 | await notificationsController.removeTokenFromLoggedUser(); 25 | return authDS.signOut(); 26 | } 27 | 28 | Future> signInWithEmailAndPassword({required String email, required String password}) async { 29 | try { 30 | await authDS.signInWithEmailAndPassword(email: email, password: password); 31 | return right(null); 32 | } catch (e) { 33 | if (e is Failure) { 34 | return left(e); 35 | } 36 | print(e); 37 | return left(Failure('Ops! An unknown error occurred when trying to sign with with email and password')); 38 | } 39 | } 40 | 41 | String? get loggedUid => authDS.loggedUid; 42 | 43 | void removeOnSignOutListener(void Function() listener) { 44 | authDS.removeOnSignOutListener(listener); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /flutter_app/lib/core/domain/services/users_service.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:dartz/dartz.dart'; 3 | import 'package:flutter_group_chat_app_with_firebase/features/login_and_registration/domain/entities/failures/email_already_exists_failure.dart'; 4 | import '../entities/user_public.dart'; 5 | import 'package:flutter_group_chat_app_with_firebase/core/domain/entities/failures/failure.dart'; 6 | import '../../data/data_sources/users_ds.dart'; 7 | 8 | class UsersService { 9 | final UsersDS usersRemoteDataSource; 10 | 11 | UsersService({required this.usersRemoteDataSource}); 12 | 13 | /// Creates a new user 14 | /// 15 | /// left can only be an instance of: 16 | /// - [EmailAlreadyExistsFailure] 17 | /// - [Failure] 18 | Future> createUser({required String firstName, required String lastName, required String email, required String password}) async { 19 | try { 20 | await usersRemoteDataSource.createUser(firstName: firstName, lastName: lastName, email: email, password: password,); 21 | return right(null); 22 | } catch (e) { 23 | if(e is Failure){ 24 | return left(e); 25 | } 26 | print(e.toString()); 27 | return left(Failure("An error occurred when trying to create the user")); 28 | } 29 | } 30 | 31 | 32 | Stream> streamAllUsersExceptLogged() { 33 | return usersRemoteDataSource.streamAllUsersExceptLogged(); 34 | } 35 | 36 | /// Reads all users the current user can talk to 37 | Future> getAllUsersExceptLogged() { 38 | return usersRemoteDataSource.getAllUsersExceptLogged(); 39 | } 40 | 41 | 42 | Future getUser({required String uid}) { 43 | return usersRemoteDataSource.getPublicUser(uid: uid); 44 | } 45 | 46 | Stream streamPublicUser({required String uid}) { 47 | return usersRemoteDataSource.streamPublicUser(uid: uid); 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/confirmation_modal.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_group_chat_app_with_firebase/core/presentation/widgets/button_widget.dart'; 3 | 4 | 5 | 6 | 7 | Future showConfirmationModal ({required BuildContext context, String title = "Are you sure?", String? message, String confirmButtonText = 'CONFIRM'}) async { 8 | const kConfirmedResult = '_confirmed_'; 9 | const radius = Radius.circular(20); 10 | return (await showModalBottomSheet( 11 | shape: RoundedRectangleBorder( 12 | borderRadius: BorderRadius.only(topLeft: radius, topRight: radius) 13 | ), 14 | context: context, 15 | builder: (context) { 16 | return Padding( 17 | padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 10), 18 | child: Column( 19 | mainAxisSize: MainAxisSize.min, 20 | children: [ 21 | Text(title, style: TextStyle(color: Colors.indigo[900], fontSize: 18, fontWeight: FontWeight.w700),), 22 | if (message != null) 23 | ...[ 24 | const SizedBox(height: 8,), 25 | Text(message, style: TextStyle(color: Colors.indigo[600], fontSize: 16, fontWeight: FontWeight.w500),), 26 | ], 27 | const SizedBox(height: 14,), 28 | Row( 29 | mainAxisAlignment: MainAxisAlignment.center, 30 | crossAxisAlignment: CrossAxisAlignment.center, 31 | children: [ 32 | ButtonWidget(text: 'CANCEL', isSmall: true, onPressed: () => Navigator.of(context).pop()), 33 | const SizedBox(width: 30,), 34 | ButtonWidget( 35 | text: confirmButtonText, 36 | isSmall: true, 37 | backgroundColor: Colors.red, 38 | onPressed: () { 39 | Navigator.of(context).pop(kConfirmedResult); 40 | }, 41 | ), 42 | ], 43 | ) 44 | ], 45 | ), 46 | ); 47 | })) == kConfirmedResult; 48 | } -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/snackbar.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_group_chat_app_with_firebase/main.dart'; 6 | 7 | void showSnackBarWarning ({required String message, Color? backgroundColor}) { 8 | return showSnackBar( 9 | message: message, 10 | backgroundColor: Colors.indigo[900], 11 | icon: Icons.warning, 12 | iconColor: Colors.yellow, 13 | ); 14 | } 15 | 16 | void showSnackBar ({required String message, Color? backgroundColor, IconData? icon, Color? iconColor}) { 17 | final radius = Radius.circular(15); 18 | ScaffoldMessenger.of(navigatorKey.currentContext!).showSnackBar(SnackBar( 19 | backgroundColor: backgroundColor ?? Colors.indigo[900], 20 | duration: const Duration(seconds: 4), 21 | shape: RoundedRectangleBorder( 22 | borderRadius: BorderRadius.only(topLeft: radius, topRight: radius) 23 | ), 24 | content: Row( 25 | children: [ 26 | Icon(icon ?? Icons.info, size: 24, color: iconColor ?? Colors.white,), 27 | const SizedBox(width: 6,), 28 | Flexible(child: Text(message, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.w600, fontSize: 16),)) 29 | ], 30 | ), 31 | )); 32 | } -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/widgets/button_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | 4 | class ButtonWidget extends StatelessWidget { 5 | final String text; 6 | final void Function()? onPressed; 7 | final bool isLoading; 8 | final bool isSmall; 9 | final IconData? icon; 10 | final Color? backgroundColor; 11 | final double? width; 12 | 13 | const ButtonWidget({Key? key, this.isSmall = false, this.width, this.backgroundColor, this.icon, required this.text, this.onPressed, this.isLoading = false}) : super(key: key); 14 | 15 | @override 16 | Widget build(BuildContext context) { 17 | return SizedBox( 18 | width: width ?? (!isSmall ? double.infinity : null), 19 | height: isSmall ? 30 : 42, 20 | child: ElevatedButton( 21 | style: ButtonStyle( 22 | elevation: MaterialStateProperty.all(0), 23 | backgroundColor: backgroundColor != null ? MaterialStateProperty.all(backgroundColor) : MaterialStateProperty.all(Colors.indigo[900]), 24 | shape: MaterialStateProperty.all( 25 | RoundedRectangleBorder( 26 | borderRadius: BorderRadius.circular(18.0), 27 | ) 28 | ) 29 | ), 30 | onPressed: isLoading ? null : onPressed, 31 | child: isLoading 32 | ? Center(child: SizedBox(width: 20, height: 20, child: CircularProgressIndicator(color: Colors.white),),) 33 | : Row( 34 | mainAxisSize: MainAxisSize.min, 35 | children: [ 36 | if (icon != null) 37 | ...[ 38 | Icon(icon!, color: Colors.white), 39 | const SizedBox(width: 6,), 40 | ], 41 | Flexible(child: FittedBox(child: Text(text, style: TextStyle(color: Colors.white, fontSize: isSmall ? 12 : 15, letterSpacing: 2, fontWeight: FontWeight.w700)),)) 42 | ], 43 | ), 44 | ), 45 | ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/widgets/center_content_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'dart:math' as math; 3 | 4 | import 'package:flutter_group_chat_app_with_firebase/main.dart'; 5 | 6 | 7 | /// Centers the `child` without a delimited container, 8 | /// so we are able to create animations outside this widget, 9 | /// like adding items to a list coming from the left or right 10 | class CenterContentWidget extends StatelessWidget { 11 | final Widget child; 12 | final BoxDecoration? decoration; 13 | 14 | const CenterContentWidget({required this.child, this.decoration, Key? key}) : super(key: key); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | double horizontalMarginSide () { 19 | return math.max(0, (MediaQuery.of(context).size.width - kPageContentWidth) / 2); 20 | } 21 | return Container( 22 | clipBehavior: Clip.none, 23 | decoration: decoration, 24 | child: Align( 25 | alignment: Alignment.topCenter, 26 | child: Builder( 27 | builder: (context) { 28 | return Padding( 29 | padding: EdgeInsets.only( 30 | left: horizontalMarginSide(), 31 | right: horizontalMarginSide(), 32 | ), 33 | child: SafeArea(child: child,), 34 | ); 35 | }) 36 | ) 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/widgets/circular_person.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | 4 | class CircularPerson extends StatelessWidget { 5 | final double size; 6 | const CircularPerson({this.size = 80, super.key}); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return Container( 11 | decoration: BoxDecoration( 12 | borderRadius: BorderRadius.circular(100), 13 | color: Colors.white.withOpacity(.95) 14 | ), 15 | padding: EdgeInsets.all(size * 0.2), 16 | child: Icon(Icons.person, size: size, color: Colors.blue), 17 | ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/widgets/expanded_section_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// Source: https://stackoverflow.com/a/54173729/4508758 4 | class ExpandedSection extends StatefulWidget { 5 | final Widget child; 6 | final bool expand; 7 | 8 | const ExpandedSection({super.key, required this.expand, required this.child}); 9 | 10 | @override 11 | _ExpandedSectionState createState() => _ExpandedSectionState(); 12 | } 13 | 14 | class _ExpandedSectionState extends State with SingleTickerProviderStateMixin { 15 | late AnimationController expandController; 16 | late Animation animation; 17 | 18 | @override 19 | void initState() { 20 | super.initState(); 21 | prepareAnimations(); 22 | _runExpandCheck(); 23 | } 24 | 25 | ///Setting up the animation 26 | void prepareAnimations() { 27 | expandController = AnimationController( 28 | vsync: this, 29 | duration: Duration(milliseconds: 500) 30 | ); 31 | animation = CurvedAnimation( 32 | parent: expandController, 33 | curve: Curves.fastOutSlowIn, 34 | ); 35 | } 36 | 37 | void _runExpandCheck() { 38 | if(widget.expand) { 39 | expandController.forward(); 40 | } 41 | else { 42 | expandController.reverse(); 43 | } 44 | } 45 | 46 | @override 47 | void didUpdateWidget(ExpandedSection oldWidget) { 48 | super.didUpdateWidget(oldWidget); 49 | _runExpandCheck(); 50 | } 51 | 52 | @override 53 | void dispose() { 54 | expandController.dispose(); 55 | super.dispose(); 56 | } 57 | 58 | @override 59 | Widget build(BuildContext context) { 60 | return SizeTransition( 61 | axisAlignment: 1.0, 62 | sizeFactor: animation, 63 | child: widget.child 64 | ); 65 | } 66 | } -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/widgets/info_widget.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | import 'package:flutter/material.dart'; 5 | 6 | class InfoWidget extends StatelessWidget { 7 | final String text; 8 | final EdgeInsetsGeometry margin; 9 | 10 | const InfoWidget({required this.text, super.key, this.margin = const EdgeInsets.only()}); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return Container( 15 | margin: margin, 16 | decoration: BoxDecoration( 17 | color: Colors.blue[200], 18 | borderRadius: BorderRadius.circular(15) 19 | ), 20 | child: Padding( 21 | padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 5), 22 | child: Row( 23 | mainAxisSize: MainAxisSize.min, 24 | children: [ 25 | Icon(Icons.info_outline, color: Colors.indigo[900],), 26 | const SizedBox(width: 5,), 27 | Text(text, style: TextStyle(color: Colors.indigo[900], fontSize: 15, letterSpacing: .8, fontWeight: FontWeight.w600)), 28 | ], 29 | ), 30 | ) 31 | ); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/widgets/my_appbar_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_group_chat_app_with_firebase/main.dart'; 3 | 4 | import 'center_content_widget.dart'; 5 | 6 | const double _height = 50; 7 | const double _leftIconSize = 28; 8 | const double _leftIconPaddingSide = 2; 9 | 10 | class MyAppBarWidget extends PreferredSize{ 11 | 12 | MyAppBarWidget({super.key, required BuildContext context, Widget? child, bool withBackground = true}) : super( 13 | preferredSize: const Size(double.infinity, _height), 14 | child: Container( 15 | color: Colors.blue[800]!, 16 | child: SafeArea( 17 | child: Container( 18 | decoration: !withBackground ? null : BoxDecoration( 19 | gradient: LinearGradient( 20 | colors: [ 21 | Colors.blue[900]!, 22 | Colors.blue[800]!, 23 | Colors.blue[900]!, 24 | ] 25 | ), 26 | boxShadow: [ 27 | BoxShadow(color: Colors.blue[900]!, offset: const Offset(0,0), spreadRadius: 2, blurRadius: 1) 28 | ] 29 | ), 30 | child: CenterContentWidget( 31 | decoration: BoxDecoration(color: Colors.blue[900]), 32 | child: Padding( 33 | padding: const EdgeInsets.only(left: 15, right: 15), 34 | child: Row( 35 | children: [ 36 | //on left 37 | FutureBuilder( 38 | future: Future.delayed(const Duration(milliseconds: 250)), 39 | builder: (context, _) { 40 | if(Navigator.of(context).canPop()) { 41 | return InkWell( 42 | child: Ink( 43 | child: const Icon(Icons.keyboard_arrow_left_rounded, color: Colors.white, size: _leftIconSize), 44 | ), 45 | onTap: () { 46 | Navigator.of(navigatorKey.currentContext!).pop(); 47 | }, 48 | ); 49 | } 50 | return Container(); 51 | }, 52 | ), 53 | 54 | // on center 55 | Expanded( 56 | child: SizedBox( 57 | height: _height, 58 | child: Center( 59 | child: child, 60 | ), 61 | ), 62 | ), 63 | ], 64 | ), 65 | ) 66 | ) 67 | ), 68 | ), 69 | ) 70 | ); 71 | } 72 | 73 | -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/widgets/my_multiline_text_field.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_group_chat_app_with_firebase/main.dart'; 5 | 6 | class MyMultilineTextField extends StatelessWidget { 7 | final ValueChanged? onSubmitted; 8 | final Widget? prefixIcon; 9 | final Widget? suffixIcon; 10 | final TextEditingController controller; 11 | final String hintText; 12 | final Color? fillColor; 13 | final int maxLines; 14 | final int? maxLength; 15 | 16 | const MyMultilineTextField({Key? key, this.maxLength, this.fillColor, this.maxLines = 20, this.onSubmitted, required this.hintText, this.prefixIcon, this.suffixIcon, required this.controller,}) : super(key: key); 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | const inputStyle = TextStyle(color: Colors.white, fontSize: 17, fontWeight: FontWeight.w600); 21 | final border = OutlineInputBorder( 22 | borderRadius: const BorderRadius.all(Radius.circular(15)), 23 | borderSide: BorderSide.none, 24 | ); 25 | 26 | return TextField( 27 | textInputAction: TextInputAction.go, 28 | controller: controller, 29 | onSubmitted: onSubmitted, 30 | keyboardType: TextInputType.multiline, 31 | minLines: 1, 32 | maxLines: maxLines, 33 | maxLength: maxLength, 34 | textAlignVertical: TextAlignVertical.center, 35 | clipBehavior: Clip.none, 36 | decoration: InputDecoration( 37 | prefixText: ' ', 38 | suffixIconConstraints: const BoxConstraints( 39 | maxHeight: kIconSize 40 | ), 41 | isCollapsed: true, 42 | contentPadding: const EdgeInsets.symmetric(vertical: 10,), 43 | isDense: true, 44 | hintStyle: TextStyle(color: Colors.white, fontWeight: FontWeight.w600), 45 | hintText: hintText, 46 | fillColor: fillColor ?? Colors.indigo[700], 47 | focusedBorder: border, 48 | enabledBorder: border, 49 | errorBorder: border, 50 | disabledBorder: border, 51 | border: border, 52 | focusedErrorBorder: border, 53 | prefixIcon: prefixIcon, 54 | suffixIcon: suffixIcon, 55 | filled: true, 56 | ), 57 | style: inputStyle, 58 | ); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/widgets/my_scaffold.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_group_chat_app_with_firebase/core/presentation/widgets/center_content_widget.dart'; 3 | import '../../../main.dart'; 4 | 5 | final noBackground = Container(); 6 | final defaultBackground = Container( 7 | decoration: BoxDecoration( 8 | gradient: LinearGradient( 9 | colors: [ 10 | Colors.blue[600]!, 11 | Colors.blue[400]!, 12 | Colors.blue[600]!, 13 | ] 14 | ) 15 | ), 16 | ); 17 | final background2Colors = Container( 18 | decoration: const BoxDecoration( 19 | gradient: LinearGradient( 20 | colors: [ 21 | Color(0xff4984f2), 22 | Color(0xff87b3ff), 23 | ] 24 | ) 25 | ), 26 | ); 27 | 28 | class MyScaffold extends StatelessWidget { 29 | final PreferredSizeWidget? appBar; 30 | final Widget body; 31 | final Widget? floatingActionButton; 32 | final Widget? background; 33 | final EdgeInsets padding; 34 | 35 | const MyScaffold({this.appBar, this.padding = const EdgeInsets.symmetric(horizontal: kMargin, vertical: kMargin), required this.body, this.floatingActionButton, this.background, super.key}); 36 | 37 | @override 38 | Widget build(BuildContext context) { 39 | 40 | return Stack( 41 | children: [ 42 | Container(child: background ?? defaultBackground), 43 | Scaffold( 44 | appBar: appBar, 45 | backgroundColor: Colors.transparent, 46 | body: CenterContentWidget( 47 | child: Padding( 48 | padding: padding, 49 | child: body, 50 | ), 51 | ), 52 | floatingActionButton: floatingActionButton, 53 | ), 54 | ], 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/widgets/person_icon.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | 4 | class PersonIcon extends StatelessWidget { 5 | final bool isGroup; 6 | final double iconSize; 7 | final double borderWidth; 8 | final EdgeInsets? iconInternalPadding; 9 | 10 | const PersonIcon({required this.isGroup, this.iconSize = 26, this.borderWidth = 0, this.iconInternalPadding, super.key}); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return Container( 15 | decoration: BoxDecoration( 16 | borderRadius: BorderRadius.circular(40), 17 | color: isGroup ? Colors.indigo[800] : Colors.blue, 18 | border: borderWidth > 0 ? Border.all(color: Colors.white, width: borderWidth) : null, 19 | ), 20 | padding: iconInternalPadding ?? const EdgeInsets.all(7), 21 | child: Icon(isGroup ? Icons.group : Icons.person, size: iconSize, color: Colors.white), 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/widgets/stopwatch/stopwatch_controller.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math' as math; 2 | 3 | 4 | class StopwatchController { 5 | final List _listeners = []; 6 | bool _paused = true; 7 | late int _seconds; 8 | late int _stoppedSeconds; 9 | Duration? _reverseDuration; 10 | 11 | int get seconds { 12 | if (_reverseDuration != null) { 13 | return math.min(_stoppedSeconds, math.min(_seconds, _reverseDuration!.inSeconds)); 14 | } 15 | return math.max(_stoppedSeconds, math.max(_seconds, 0)); 16 | } 17 | 18 | StopwatchController({Duration? reverseDuration}) { 19 | _init(reverseDuration); 20 | } 21 | 22 | String get text { 23 | final minutesStr = seconds ~/ 60; 24 | final secondsStr = seconds % 60; 25 | return "${minutesStr < 10 ? '0' : ''}$minutesStr:${secondsStr < 10 ? '0' : ''}$secondsStr"; 26 | } 27 | 28 | Duration? get reverseDuration => _reverseDuration; 29 | 30 | void start({Duration? customReverseDuration}) { 31 | if (!_paused) { 32 | return; 33 | } 34 | _init(customReverseDuration); 35 | _paused = false; 36 | 37 | 38 | (() async { 39 | while(!_paused){ 40 | if (_reverseDuration != null) { 41 | _seconds--; 42 | } else { 43 | _seconds++; 44 | } 45 | for (final listener in _listeners) { 46 | listener(_seconds); 47 | } 48 | if (_seconds == 0 && _reverseDuration != null) { 49 | stop(); 50 | } else { 51 | await Future.delayed(const Duration(seconds: 1)); 52 | } 53 | } 54 | })(); 55 | } 56 | 57 | void addOnChangedListener ({required void Function(int seconds) listener}) { _listeners.add(listener); } 58 | void removeOnChangedListener ({required void Function(int seconds) listener}) { _listeners.remove(listener); } 59 | 60 | void dispose() { 61 | stop(); 62 | } 63 | void pause () { 64 | _paused = true; 65 | } 66 | void stop () { 67 | pause(); 68 | _stoppedSeconds = _seconds; 69 | if (_reverseDuration != null) { 70 | _seconds = _reverseDuration!.inSeconds + 1; 71 | } else { 72 | _seconds = -1; 73 | } 74 | } 75 | 76 | void _init(Duration? reverseDuration) { 77 | if (reverseDuration != null) { 78 | _reverseDuration = reverseDuration; 79 | } 80 | 81 | if (_reverseDuration != null) { 82 | _stoppedSeconds = _seconds = _reverseDuration!.inSeconds + 1; 83 | } else { 84 | _stoppedSeconds = _seconds = -1; 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/widgets/stopwatch/stopwatch_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'stopwatch_controller.dart'; 4 | 5 | 6 | class StopwatchWidget extends StatefulWidget { 7 | final StopwatchController controller; 8 | final Color color; 9 | final double fontSize; 10 | 11 | const StopwatchWidget({this.color = Colors.white, required this.controller, this.fontSize = 22, super.key}); 12 | 13 | @override 14 | State createState() => _StopwatchWidgetState(); 15 | } 16 | 17 | class _StopwatchWidgetState extends State { 18 | @override 19 | void initState() { 20 | super.initState(); 21 | widget.controller.addOnChangedListener(listener: refresh); 22 | } 23 | 24 | @override 25 | Widget build(BuildContext context) { 26 | return Text(widget.controller.text, style: TextStyle(color: widget.color, fontWeight: FontWeight.w700, fontSize: widget.fontSize), ); 27 | } 28 | 29 | @override 30 | void dispose() { 31 | widget.controller.removeOnChangedListener(listener: refresh); 32 | super.dispose(); 33 | } 34 | 35 | void refresh(_) { 36 | setState(() {}); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/widgets/waves_background/clipper/waves_background_clipper.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// Source: https://stackoverflow.com/a/61274521/4508758 4 | class WavesBackgroundClipper extends CustomClipper { 5 | @override 6 | Path getClip(Size size) { 7 | Path path = Path(); 8 | path.lineTo(0, size.height); 9 | path.quadraticBezierTo(size.width / 4, size.height - 40, size.width / 2, size.height - 20); 10 | path.quadraticBezierTo(3 / 4 * size.width, size.height, size.width, size.height - 30); 11 | path.lineTo(size.width, 0); 12 | 13 | return path; 14 | } 15 | 16 | @override 17 | bool shouldReclip(WavesBackgroundClipper oldClipper) => false; 18 | } 19 | -------------------------------------------------------------------------------- /flutter_app/lib/core/presentation/widgets/waves_background/waves_background.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'clipper/waves_background_clipper.dart'; 4 | 5 | 6 | class WavesBackground extends StatelessWidget { 7 | final bool waveOnTop; 8 | const WavesBackground({Key? key, this.waveOnTop = false}) : super(key: key); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return Stack( 13 | children: [ 14 | Container( 15 | width: MediaQuery.of(context).size.width, 16 | height: MediaQuery.of(context).size.height, 17 | decoration: BoxDecoration( 18 | gradient: LinearGradient( 19 | colors: [ 20 | Colors.blue[900]!, 21 | Colors.blue[800]!, 22 | Colors.blue[900]!, 23 | ] 24 | ) 25 | ), 26 | ), 27 | SizedBox( 28 | height: waveOnTop ? (MediaQuery.of(context).size.height * .38) : (MediaQuery.of(context).size.height * .43), 29 | child: ClipPath( 30 | clipper: WavesBackgroundClipper(), 31 | child: Container( 32 | width: MediaQuery.of(context).size.width, 33 | height: MediaQuery.of(context).size.height, 34 | decoration: BoxDecoration( 35 | gradient: LinearGradient( 36 | colors: [ 37 | Colors.blue[400]!, 38 | Colors.blue[300]!, 39 | Colors.blue[400]!, 40 | ] 41 | ) 42 | ), 43 | ), 44 | ), 45 | ), 46 | ], 47 | ); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /flutter_app/lib/core/utils/dartz_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:dartz/dartz.dart'; 2 | 3 | R asRight (Either either) { 4 | if(either.isLeft()){ 5 | throw "asRight failed, because is left"; 6 | } 7 | return (either as Right).value; 8 | } -------------------------------------------------------------------------------- /flutter_app/lib/core/utils/model_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:cloud_firestore/cloud_firestore.dart'; 2 | 3 | Map? fromMapOfTimestamp (Map? map) { 4 | if (map == null) { 5 | return null; 6 | } 7 | final Map res = {}; 8 | for (final entry in Map.from(map).entries) { 9 | if (entry.value != null) { 10 | res[entry.key] = (entry.value as Timestamp).toDate(); 11 | } else { 12 | // if key exists, but value is null, it's a case where you created 13 | // receivedAt with FieldValue.serverTimestamp(); 14 | // "receivedAt":{ 15 | // "OGdLCtfMJ3cveXu3qhOvxTPtU0C2": null 16 | // } 17 | res[entry.key] = DateTime.now(); 18 | } 19 | } 20 | return res; 21 | } -------------------------------------------------------------------------------- /flutter_app/lib/core/utils/validators.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | /// Adapted from https://stackoverflow.com/a/63292899/4508758 5 | String? validateEmail (String? value) { 6 | final requiredError = validateRequired(value); 7 | if(requiredError != null){ 8 | return requiredError; 9 | } 10 | 11 | const pattern = r"(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'" 12 | r'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-' 13 | r'\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*' 14 | r'[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4]' 15 | r'[0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9]' 16 | r'[0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\' 17 | r'x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])'; 18 | final regex = RegExp(pattern); 19 | 20 | return !regex.hasMatch(value!) ? 'Invalid email address' : null; 21 | } 22 | 23 | String? validateRequired (String? value) { 24 | return value?.isNotEmpty == true ? null : 'This field is required'; 25 | } 26 | 27 | String? validateCreatePassword(String? value) { 28 | final requiredError = validateRequired(value); 29 | if(requiredError != null){ 30 | return requiredError; 31 | } 32 | if(value!.length < 6){ 33 | return "The password should contain at least 6 characters"; 34 | } 35 | return null; 36 | } -------------------------------------------------------------------------------- /flutter_app/lib/environment.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | class Environment { 5 | static const String agoraAppId = ""; // TODO (optional): replace with your Agora APP ID to make video calls work 6 | } 7 | -------------------------------------------------------------------------------- /flutter_app/lib/features/call/data/data_sources/call_ds.dart: -------------------------------------------------------------------------------- 1 | 2 | import 'package:cloud_functions/cloud_functions.dart'; 3 | import 'package:dartz/dartz.dart'; 4 | import 'package:flutter_group_chat_app_with_firebase/features/call/domain/entities/call_credentials.dart'; 5 | 6 | class CallDS { 7 | final FirebaseFunctions firebaseFunctions; 8 | CallDS ({required this.firebaseFunctions}); 9 | 10 | Future getCallCredentials({required String conversationId}) async { 11 | try { 12 | final res = await FirebaseFunctions 13 | .instance 14 | .httpsCallable("getCallCredentials") 15 | .call({ 16 | "conversationId": conversationId, 17 | }); 18 | 19 | if (res.data != null && res.data["rtcToken"] != null) { 20 | return CallCredentials(data: CallCredentialsData( 21 | agoraUid: res.data["agoraUid"], 22 | rtcToken: res.data["rtcToken"], 23 | )); 24 | } 25 | print ("getCallCredentials: An error occurred"); 26 | return CallCredentials(); 27 | } catch (e){ 28 | print ("getCallCredentials: An error occurred: ${e.toString()}"); 29 | return CallCredentials(); 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /flutter_app/lib/features/call/domain/entities/call_credentials.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | class CallCredentials { 5 | final CallCredentialsData? data; 6 | 7 | bool get success => data != null; 8 | 9 | CallCredentials({this.data}); 10 | } 11 | 12 | class CallCredentialsData { 13 | final int agoraUid; 14 | final String rtcToken; 15 | 16 | CallCredentialsData({required this.agoraUid, required this.rtcToken}); 17 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/call/domain/services/call_service.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | import '../../data/data_sources/call_ds.dart'; 5 | import '../entities/call_credentials.dart'; 6 | 7 | class CallService { 8 | final CallDS callDS; 9 | 10 | CallService({required this.callDS}); 11 | 12 | Future getCallCredentials({required String conversationId}) async { 13 | return callDS.getCallCredentials(conversationId: conversationId); 14 | } 15 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/data/models/conversation_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:cloud_firestore/cloud_firestore.dart'; 2 | import 'package:flutter_group_chat_app_with_firebase/features/chat/domain/entities/conversation.dart'; 3 | 4 | 5 | class ConversationModel extends Conversation { 6 | static const kConversationId = "conversationId"; 7 | static const kParticipants = "participants"; 8 | static const kGroup = "group"; 9 | 10 | ConversationModel({required super.conversationId, required super.participants, required super.typingUids, super.group}); 11 | 12 | static Conversation? fromDocument(DocumentSnapshot snapshot, List typingUids) { 13 | final data = snapshot.data() as dynamic; 14 | if (data == null) { 15 | return null; 16 | } 17 | return fromData(snapshot, typingUids); 18 | } 19 | 20 | toMap() => { 21 | ConversationModel.kConversationId: conversationId, 22 | ConversationModel.kParticipants: participants, 23 | ConversationModel.kGroup: group == null ? null : ConversationGroupModel.fromEntity(group!).toMap(), 24 | }; 25 | 26 | static Conversation? fromData(data, [List? typingUids]) { 27 | return Conversation( 28 | conversationId: data[kConversationId], 29 | participants: List.from(data[kParticipants]), 30 | group: data[kGroup] == null ? null : ConversationGroupModel.fromData(data[kGroup]), 31 | typingUids: typingUids ?? [], 32 | ); 33 | } 34 | } 35 | 36 | class ConversationGroupModel extends ConversationGroup { 37 | static const kCreatedBy = "createdBy"; 38 | static const kTitle = "title"; 39 | static const kAdminUids = "adminUids"; 40 | static const kJoinedAt = "joinedAt"; 41 | 42 | ConversationGroupModel({required super.title, required super.joinedAt, required super.adminUids, required super.createdBy}); 43 | 44 | ConversationGroupModel.fromEntity(ConversationGroup conversation): super(title: conversation.title, adminUids: conversation.adminUids, createdBy: conversation.createdBy, joinedAt: conversation.joinedAt,); 45 | 46 | static fromData(data) { 47 | if (data == null) { 48 | return null; 49 | } 50 | return ConversationGroupModel( 51 | title: data[kTitle], 52 | adminUids: List.from(data[kAdminUids]), 53 | createdBy: data[kCreatedBy], 54 | joinedAt: Map.fromEntries(Map.from(data[kJoinedAt]).entries.map((e) => MapEntry(e.key, (e.value is Timestamp ? (e.value as Timestamp) : Timestamp.now()).toDate()))), 55 | ); 56 | } 57 | 58 | toMap() => { 59 | kTitle: title, 60 | kAdminUids: adminUids, 61 | kCreatedBy: createdBy, 62 | kJoinedAt: joinedAt, 63 | }; 64 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/data/utils.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | bool isDifferentDay (DateTime d1, DateTime d2) => DateTime(d1.year, d1.month, d1.day).difference(DateTime(d2.year, d2.month, d2.day)).inDays != 0; 5 | -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/domain/chat_utils.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | String getDirectConversationId (List uids) { 5 | final aux = uids..sort((a,b) => a.compareTo(b)); 6 | return "direct_${aux.first.substring(0, 14)}${aux.last.substring(0, 14)}"; 7 | } 8 | 9 | bool isDirectConversation(String? conversationId) { 10 | return conversationId?.startsWith("direct_") == true; 11 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/domain/entities/chat_list_item_entity.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | import 'package:flutter_group_chat_app_with_firebase/core/domain/entities/user_public.dart'; 6 | import 'package:flutter_group_chat_app_with_firebase/features/chat/domain/entities/message.dart'; 7 | 8 | class ChatListItemEntity { 9 | 10 | } 11 | 12 | class SeparatorDateForMessages extends ChatListItemEntity { 13 | DateTime date; 14 | 15 | SeparatorDateForMessages({required this.date}); 16 | 17 | } 18 | 19 | class MessageChatListItemEntity extends ChatListItemEntity { 20 | final Message message; 21 | 22 | MessageChatListItemEntity({required this.message}); 23 | 24 | } 25 | 26 | class TypingIndicatorChatListItemEntity extends ChatListItemEntity { 27 | UserPublic user; 28 | 29 | TypingIndicatorChatListItemEntity({required this.user}); 30 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/domain/entities/conversation.dart: -------------------------------------------------------------------------------- 1 | 2 | class Conversation { 3 | late final String conversationId; 4 | 5 | /// ID's of the members of the conversation 6 | final List participants; 7 | 8 | /// User IDS of the users who are typing at the same time 9 | List typingUids; 10 | 11 | bool get isGroup => group != null; 12 | 13 | final ConversationGroup? group; 14 | 15 | Conversation({ 16 | required this.conversationId, 17 | required this.participants, 18 | required this.typingUids, 19 | this.group, 20 | }); 21 | 22 | } 23 | 24 | class ConversationGroup { 25 | String title; 26 | final List adminUids; 27 | final String createdBy; 28 | Map joinedAt; 29 | 30 | ConversationGroup({required this.title, required this.joinedAt, required this.adminUids, required this.createdBy}); 31 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/domain/entities/detailed_conversation.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_group_chat_app_with_firebase/features/chat/domain/entities/conversation.dart'; 2 | import 'package:flutter_group_chat_app_with_firebase/core/domain/entities/user_public.dart'; 3 | import 'package:flutter_group_chat_app_with_firebase/injection_container.dart'; 4 | import '../../../../core/domain/services/auth_service.dart'; 5 | import 'message.dart'; 6 | import 'package:collection/collection.dart'; 7 | 8 | class DetailedConversation { 9 | final List users; 10 | final List messages; 11 | late final Conversation _conversation; 12 | 13 | bool get isGroup => _conversation.isGroup; 14 | 15 | DetailedConversation({required this.users, required this.messages, required Conversation conversation}) { 16 | _conversation = conversation; 17 | } 18 | 19 | List get notMeUsers { 20 | return users.where((element) => element.uid != getIt.get().loggedUid).toList(); 21 | } 22 | 23 | String? get uidForDirectConversation { 24 | if (_conversation.isGroup) { 25 | return null; 26 | } 27 | return notMeUsers.firstOrNull?.uid; 28 | } 29 | 30 | List get typingUsers => users 31 | .where((user) => _conversation.typingUids.contains(user.uid)) 32 | .toList(); 33 | 34 | String get conversationId => _conversation.conversationId; 35 | 36 | String get title => _conversation.group?.title ?? notMeUsers.firstOrNull?.fullName ?? 'Loading...'; 37 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/domain/entities/pending_request_to_api_telling_message_was_read.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | class PendingRequestToApiTellingMessagesWasRead { 4 | final String senderUid; 5 | final DateTime dateTime; 6 | 7 | PendingRequestToApiTellingMessagesWasRead({required this.dateTime, required this.senderUid}); 8 | 9 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/domain/entities/sending_text_message_entity.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | class SendingMessageEntity { 4 | final String conversationId; 5 | final String text; 6 | final List participants; 7 | 8 | SendingMessageEntity({ 9 | required this.conversationId, 10 | required this.text, 11 | required this.participants, 12 | }){ 13 | assert(participants.isNotEmpty); 14 | } 15 | 16 | 17 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/domain/services/messages_service.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:flutter_group_chat_app_with_firebase/core/domain/services/auth_service.dart'; 3 | import 'package:flutter_group_chat_app_with_firebase/core/domain/services/users_service.dart'; 4 | import 'package:flutter_group_chat_app_with_firebase/features/chat/domain/entities/message.dart'; 5 | import 'package:flutter_group_chat_app_with_firebase/features/chat/domain/entities/sending_text_message_entity.dart'; 6 | import 'package:flutter_group_chat_app_with_firebase/features/chat/domain/entities/conversation.dart'; 7 | import '../../data/data_sources/messages_ds.dart'; 8 | 9 | class MessagesService { 10 | final MessagesDS messagesDatasource; 11 | final UsersService usersService; 12 | final AuthService authService; 13 | 14 | MessagesService({required this.messagesDatasource, required this.authService, required this.usersService}); 15 | 16 | Stream conversationStream({required String conversationId}) { 17 | return messagesDatasource.conversationStream(conversationId: conversationId); 18 | } 19 | 20 | Stream> conversationListStream() { 21 | return messagesDatasource.conversationListStream(); 22 | } 23 | 24 | Future updateImTyping({required String conversationId}) { 25 | return messagesDatasource.updateImTyping(conversationId: conversationId); 26 | } 27 | 28 | Future updateMessageToRead({required String conversationId, required String messageId}) { 29 | return messagesDatasource.updateMessageToRead(conversationId: conversationId, messageId: messageId); 30 | } 31 | 32 | void newMessage({required SendingMessageEntity message}) { 33 | messagesDatasource.addMessage(message: message); 34 | } 35 | 36 | Stream> messagesStream({required String conversationId, int? limitToLast, void Function(List newReceivedMessageList)? onNewReceivedMessage}) { 37 | return messagesDatasource.messagesStream(conversationId: conversationId, limit: limitToLast, onNewReceivedMessage: onNewReceivedMessage); 38 | } 39 | 40 | Stream pendingReadMessagesAmount({required String conversationId}) { 41 | return messagesDatasource.pendingReadMessagesAmount(conversationId: conversationId); 42 | } 43 | 44 | Future createConversationIfDoesntExists({required String uidForDirectConversation}) { 45 | return messagesDatasource.createConversationIfDoesntExists(uidForDirectConversation: uidForDirectConversation); 46 | } 47 | 48 | Future getConversationById({required String conversationId}) { 49 | return messagesDatasource.getConversationById(conversationId: conversationId); 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/presentation/controllers/message_input_controller.dart: -------------------------------------------------------------------------------- 1 | import 'dart:developer'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_group_chat_app_with_firebase/features/chat/domain/entities/sending_text_message_entity.dart'; 4 | import 'package:flutter_group_chat_app_with_firebase/features/chat/domain/services/messages_service.dart'; 5 | import 'package:flutter_group_chat_app_with_firebase/injection_container.dart'; 6 | 7 | class MessageInputController extends TextEditingController { 8 | final hasTextToSendNotifier = ValueNotifier(false); 9 | final showTextSentIconNotifier = ValueNotifier(false); 10 | final String conversationId; 11 | final List Function() getParticipants; 12 | final void Function() scrollToBottom; 13 | 14 | String _previousText = ""; 15 | 16 | MessageInputController({String? text, required this.conversationId, required this.scrollToBottom, required this.getParticipants}) : super(text: text) { 17 | addListener(() { 18 | if (_previousText != this.text && this.text.isNotEmpty) { 19 | getIt().updateImTyping(conversationId: conversationId); 20 | } 21 | hasTextToSendNotifier.value = this.text.isNotEmpty; 22 | _previousText = this.text; 23 | }); 24 | } 25 | 26 | void addMessageToQueue() { 27 | if (text.isEmpty) { 28 | log('No text to send'); 29 | return; 30 | } 31 | 32 | getIt.get().newMessage(message: SendingMessageEntity( 33 | conversationId: conversationId, 34 | text: text, 35 | participants: getParticipants() 36 | )); 37 | 38 | clear(); 39 | showTextSentIconNotifier.value = true; 40 | scrollToBottom(); 41 | Future.delayed(const Duration(seconds: 1), () { 42 | showTextSentIconNotifier.value = false; 43 | }); 44 | } 45 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/presentation/controllers/signout_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_group_chat_app_with_firebase/screen_routes.dart'; 3 | import '../../../../core/domain/services/auth_service.dart'; 4 | import '../../../../injection_container.dart'; 5 | 6 | class SignOutController { 7 | 8 | void signOut(BuildContext context) { 9 | Future.delayed(const Duration(milliseconds: 200), getIt.get().signOut); 10 | Navigator.of(context).pushNamedAndRemoveUntil(ScreenRoutes.login, (route) => false); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/presentation/controllers/users_to_talk_to_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_group_chat_app_with_firebase/core/domain/entities/user_public.dart'; 2 | import 'package:flutter_group_chat_app_with_firebase/core/domain/services/users_service.dart'; 3 | import 'package:flutter_group_chat_app_with_firebase/injection_container.dart'; 4 | 5 | 6 | 7 | 8 | class UsersToTalkToController { 9 | 10 | Stream> stream() { 11 | return getIt.get().streamAllUsersExceptLogged(); 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/presentation/widgets/chat_item_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_group_chat_app_with_firebase/features/chat/domain/entities/chat_list_item_entity.dart'; 3 | import 'package:flutter_group_chat_app_with_firebase/features/chat/presentation/widgets/message_widget.dart'; 4 | import 'package:flutter_group_chat_app_with_firebase/features/chat/presentation/widgets/typing_indicator_widget.dart'; 5 | import 'package:flutter_group_chat_app_with_firebase/injection_container.dart'; 6 | import '../../../../core/domain/services/auth_service.dart'; 7 | import '../../../../core/presentation/widgets/circular_person.dart'; 8 | import 'separator_date_for_messages_widget.dart'; 9 | 10 | class ChatItemWidget extends StatelessWidget { 11 | final ChatListItemEntity chatItem; 12 | final bool showSenderInfo; 13 | final bool extraMarginBeforeSenderInfo; 14 | final bool isGroup; 15 | 16 | const ChatItemWidget( 17 | {required this.chatItem, 18 | Key? key, 19 | required this.isGroup, 20 | required this.showSenderInfo, 21 | required this.extraMarginBeforeSenderInfo}) 22 | : super(key: key); 23 | 24 | String get loggedUid => getIt.get().loggedUid!; 25 | 26 | @override 27 | Widget build(BuildContext context) { 28 | if (chatItem is SeparatorDateForMessages) { 29 | return SeparatorDateForMessagesWidget( 30 | dateTime: (chatItem as SeparatorDateForMessages).date, 31 | ); 32 | } 33 | if (chatItem is! MessageChatListItemEntity && 34 | chatItem is! TypingIndicatorChatListItemEntity) { 35 | throw "TODO: ${chatItem.toString()}"; 36 | } 37 | return Padding( 38 | padding: extraMarginBeforeSenderInfo 39 | ? const EdgeInsets.only(top: 8) 40 | : EdgeInsets.zero, 41 | child: Row( 42 | mainAxisSize: MainAxisSize.min, 43 | crossAxisAlignment: CrossAxisAlignment.start, 44 | children: [ 45 | if (isGroup) 46 | Padding( 47 | padding: const EdgeInsets.only(top: 5), 48 | child: Opacity( 49 | opacity: showSenderInfo ? 1 : 0, 50 | child: const CircularPerson(size: 23), 51 | ), 52 | ), 53 | if (chatItem is MessageChatListItemEntity) 54 | Expanded(child: MessageSideWidget( 55 | showSenderInfo: showSenderInfo, 56 | message: (chatItem as MessageChatListItemEntity).message, 57 | key: ValueKey((chatItem as MessageChatListItemEntity).message.messageId), 58 | )), 59 | if (chatItem is TypingIndicatorChatListItemEntity) 60 | TypingIndicatorWidget( 61 | margin: showSenderInfo ? const EdgeInsets.only(top: 7) : EdgeInsets.zero, 62 | showUserInfo: showSenderInfo ? (chatItem as TypingIndicatorChatListItemEntity).user : null, 63 | ), 64 | ] 65 | ), 66 | ); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/presentation/widgets/delay_animate_switcher.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'dart:math' as math; 3 | 4 | class DelayAnimateSwitcher extends StatefulWidget { 5 | final bool animate; 6 | final Duration delay; 7 | final Duration animationDuration; 8 | final Widget secondChild; 9 | final Widget? firstChild; 10 | final Widget Function(Widget child, Animation animation)? transitionBuilder; 11 | 12 | const DelayAnimateSwitcher({Key? key, 13 | required this.secondChild, 14 | this.firstChild, 15 | this.animate = true, 16 | this.delay = const Duration(milliseconds: 1), 17 | this.transitionBuilder, 18 | this.animationDuration = const Duration(milliseconds: 150)}) : super(key: key); 19 | 20 | @override 21 | State createState() => _DelayAnimateSwitcherState(); 22 | } 23 | 24 | class _DelayAnimateSwitcherState extends State { 25 | bool showChild2 = false; 26 | 27 | @override 28 | void initState() { 29 | super.initState(); 30 | 31 | if (widget.animate && widget.animationDuration.inMilliseconds > 0) { 32 | Future.delayed( 33 | Duration(milliseconds: math.max(widget.delay.inMilliseconds, 10))) 34 | .then((_) { 35 | setState(() { 36 | showChild2 = true; 37 | }); 38 | }); 39 | } else { 40 | showChild2 = true; 41 | } 42 | } 43 | 44 | @override 45 | Widget build(BuildContext context) { 46 | if (!widget.animate || widget.animationDuration.inMilliseconds == 0) { 47 | return widget.secondChild; 48 | } 49 | 50 | return AnimatedSwitcher( 51 | duration: widget.animationDuration, 52 | transitionBuilder: widget.transitionBuilder ?? (Widget child, Animation animation) { 53 | return ScaleTransition(scale: animation, child: child); 54 | }, 55 | child: showChild2 56 | ? widget.secondChild 57 | : (widget.firstChild ?? Container()), 58 | ); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/presentation/widgets/load_more_messages_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class LoadMoreMessagesButton extends StatelessWidget { 4 | final void Function() onTap; 5 | 6 | const LoadMoreMessagesButton({required this.onTap, Key? key}) : super(key: key); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return Align( 11 | alignment: Alignment.center, 12 | child: InkWell( 13 | onTap: onTap, 14 | child: Ink( 15 | child: Container( 16 | margin: const EdgeInsets.only(top: 17, bottom: 12), 17 | padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 5), 18 | decoration: BoxDecoration( 19 | color: Colors.lightBlue[50], 20 | borderRadius: const BorderRadius.all(Radius.circular(50)), 21 | ), 22 | child: const Text("Load more messages", style: TextStyle(color: Colors.indigo, fontSize: 14)), 23 | ), 24 | ), 25 | ) 26 | ); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/presentation/widgets/logout_button_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import '../controllers/signout_controller.dart'; 3 | 4 | class SignOutButtonWidget extends StatelessWidget { 5 | final signOutController = SignOutController(); 6 | 7 | SignOutButtonWidget({Key? key}) : super(key: key); 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return InkWell( 12 | onTap: () { 13 | signOutController.signOut(context); 14 | }, 15 | child: Ink( 16 | child: Container( 17 | decoration: BoxDecoration( 18 | color: Colors.blue[800], 19 | borderRadius: BorderRadius.circular(10) 20 | ), 21 | padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 5), 22 | child: Icon(Icons.logout_outlined, color: Colors.blue[50]!,), 23 | ), 24 | ), 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/presentation/widgets/message_status_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_group_chat_app_with_firebase/features/chat/domain/entities/message.dart'; 3 | import '../../../../core/domain/services/auth_service.dart'; 4 | import '../../../../injection_container.dart'; 5 | import 'delay_animate_switcher.dart'; 6 | 7 | class MessageStatusWidget extends StatelessWidget { 8 | final Message message; 9 | get checkIcon => Icon(Icons.check, size: 16, color: message.read ? Colors.blue[300] : Colors.green[50]); 10 | 11 | String get loggedUid => getIt.get().loggedUid!; 12 | bool get isLeftSide => message.senderUid != loggedUid; 13 | 14 | const MessageStatusWidget({Key? key, required this.message}) : super(key: key); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return Row( 19 | mainAxisSize: MainAxisSize.min, 20 | crossAxisAlignment: CrossAxisAlignment.end, 21 | children: [ 22 | if (!isLeftSide && message.hasPendingWrites) 23 | Icon(Icons.access_time_outlined, color: Colors.green[50], size: 17), 24 | if(!isLeftSide && (!message.hasPendingWrites || message.received || message.read)) 25 | SizedBox( 26 | width: message.received || message.read ? 25 : null, 27 | child: Stack( 28 | children: [ 29 | DelayAnimateSwitcher( 30 | firstChild: Container(width: 18,), 31 | secondChild: checkIcon, 32 | animate: !message.received ? false : (DateTime.now().millisecondsSinceEpoch - 1000 < message.lastReceivedAt!.millisecondsSinceEpoch), 33 | ), 34 | if (message.received || message.read) 35 | Align( 36 | alignment: const Alignment(.85,0), 37 | child: DelayAnimateSwitcher( 38 | firstChild: Container(width: 18,), 39 | secondChild: checkIcon, 40 | animate: DateTime.now().millisecondsSinceEpoch - 1000 < message.sentAt.millisecondsSinceEpoch, 41 | delay: const Duration(milliseconds: 320) 42 | ), 43 | ) 44 | ], 45 | ), 46 | ) 47 | ], 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /flutter_app/lib/features/chat/presentation/widgets/separator_date_for_messages_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:intl/intl.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | class SeparatorDateForMessagesWidget extends StatelessWidget { 5 | final DateTime dateTime; 6 | 7 | const SeparatorDateForMessagesWidget({required this.dateTime, Key? key}) : super(key: key); 8 | 9 | String get text { 10 | DateTime now = DateTime.now(); 11 | final int differenceInDays = DateTime(dateTime.year, dateTime.month, dateTime.day).difference(DateTime(now.year, now.month, now.day)).inDays; 12 | if(differenceInDays == 0){ 13 | return 'Today'; 14 | } 15 | if(differenceInDays == -1){ 16 | return 'Yesterday'; 17 | } 18 | if(differenceInDays > -7){ 19 | return [ 20 | 'Monday', 21 | 'Tuesday', 22 | 'Wednesday', 23 | 'Thursday', 24 | 'Friday', 25 | 'Saturday', 26 | 'Sunday', 27 | ][dateTime.weekday-1]; 28 | } 29 | if(differenceInDays > -365){ 30 | return '${[ 31 | 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' 32 | ][dateTime.month-1]} ${dateTime.day}'; 33 | } 34 | return DateFormat('yyyy/MM/dd').format(dateTime); 35 | } 36 | 37 | @override 38 | Widget build(BuildContext context) { 39 | return Align( 40 | alignment: Alignment.center, 41 | child: Container( 42 | margin: const EdgeInsets.only(top: 17, bottom: 12), 43 | padding: const EdgeInsets.symmetric(horizontal: 25, vertical: 5), 44 | decoration: BoxDecoration( 45 | color: Color(0xffebf5fc), 46 | borderRadius: const BorderRadius.all(Radius.circular(50)), 47 | ), 48 | child: Text(text, style: const TextStyle(color: Colors.indigo, fontSize: 14)), 49 | ) 50 | ); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /flutter_app/lib/features/groups/domain/services/groups_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_group_chat_app_with_firebase/core/domain/services/auth_service.dart'; 2 | import '../../../chat/domain/entities/conversation.dart'; 3 | import '../../data/datasources/groups_ds.dart'; 4 | 5 | 6 | class GroupsService { 7 | final GroupsDS groupsDS; 8 | final AuthService authService; 9 | 10 | GroupsService({required this.groupsDS, required this.authService}); 11 | 12 | Future createGroup({required String groupTitle}) { 13 | return groupsDS.createGroup(groupTitle: groupTitle, uids: [authService.loggedUid!], groupAdminUids: [authService.loggedUid!]); 14 | } 15 | 16 | Future addParticipant({required String conversationId, required String uid, bool isAdmin = false}) { 17 | return groupsDS.addParticipant(conversationId: conversationId, uid: uid, isAdmin: isAdmin); 18 | } 19 | 20 | Future removeParticipant({required String conversationId, required String uid}) { 21 | return groupsDS.removeParticipant(conversationId: conversationId, uid: uid); 22 | } 23 | 24 | Future editGroupsTitle({required String conversationId, required String groupTitle}) { 25 | return groupsDS.editGroupsTitle(conversationId: conversationId, groupTitle: groupTitle); 26 | } 27 | 28 | Stream readGroupStream({required String conversationId}) { 29 | return groupsDS.readGroupStream(conversationId: conversationId); 30 | } 31 | 32 | Future addAdminPrivilege({required String conversationId, required String uid}) { 33 | return groupsDS.addAdminPrivilege(conversationId: conversationId, uid: uid); 34 | } 35 | 36 | Future removeAdminPrivilege({required String conversationId, required String uid}) { 37 | return groupsDS.removeAdminPrivilege(conversationId: conversationId, uid: uid); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/groups/presentation/controllers/manage_group_participants_controller.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:flutter_group_chat_app_with_firebase/core/domain/entities/user_public.dart'; 3 | import 'package:flutter_group_chat_app_with_firebase/core/domain/services/auth_service.dart'; 4 | import 'package:flutter_group_chat_app_with_firebase/core/domain/services/users_service.dart'; 5 | import 'package:stream_d/stream_d.dart'; 6 | import '../../../../injection_container.dart'; 7 | import '../../../chat/domain/entities/conversation.dart'; 8 | import '../../domain/services/groups_service.dart'; 9 | 10 | class ManageGroupParticipantsController { 11 | late final String _conversationId; 12 | bool _initialized = false; 13 | final Map _usersCache = {}; 14 | final StreamController _streamController = StreamController(); 15 | Conversation? _conversation; 16 | 17 | Conversation? get conversation => _conversation; 18 | 19 | ManageGroupParticipantsController(); 20 | 21 | String get conversationId => _conversationId; 22 | 23 | bool get iAmAdmin => _conversation!.group!.adminUids.contains(getIt.get().loggedUid); 24 | 25 | init ({required String conversationId}) { 26 | assert(!_initialized); 27 | _initialized = true; 28 | _conversationId = conversationId; 29 | final subscription = StreamD(getIt.get().readGroupStream(conversationId: conversationId)) 30 | .listenD((event) { 31 | _conversation = event; 32 | Future.wait( 33 | event.participants.map((uid) => Future(() async { 34 | _usersCache[uid] ??= (await getIt.get().getUser(uid: uid))!; 35 | })).toList()).then((_) { 36 | _streamController.add(event); 37 | }); 38 | }); 39 | _streamController.onCancel = subscription.cancel; 40 | subscription.addOnDone(() { 41 | print("manage group participants is done!"); 42 | _streamController.close(); 43 | }); 44 | } 45 | 46 | void dispose () => _streamController.close(); 47 | 48 | List get admins => _conversation!.group!.adminUids.map((uid) => _usersCache[uid]!).toList(); 49 | List get participants { 50 | final loggedUid = getIt.get().loggedUid; 51 | return _conversation!.participants.where((uid) => uid != loggedUid).map((uid) => _usersCache[uid]!).toList(); 52 | } 53 | 54 | Future removeParticipant({required String uid}) { 55 | return getIt.get().removeParticipant(conversationId: conversationId, uid: uid); 56 | } 57 | 58 | bool get initialized => _initialized; 59 | 60 | UserPublic user(String uid) => _usersCache[uid]!; 61 | 62 | Stream readGroupStream () { 63 | return _streamController.stream; 64 | } 65 | 66 | isAdmin(String uid) => _conversation!.group!.adminUids.contains(uid); 67 | 68 | Future addAdminPrivilege(String uid) { 69 | return getIt.get().addAdminPrivilege(conversationId: conversationId, uid: uid); 70 | } 71 | 72 | Future removeAdminPrivilege(String uid) { 73 | return getIt.get().removeAdminPrivilege(conversationId: conversationId, uid: uid); 74 | } 75 | 76 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/loading/screens/loading_screen.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_group_chat_app_with_firebase/core/domain/services/notifications_service.dart'; 3 | import '../../../core/domain/services/auth_service.dart'; 4 | import '../../../core/presentation/widgets/my_scaffold.dart'; 5 | import '../../../core/presentation/widgets/waves_background/waves_background.dart'; 6 | import '../../../injection_container.dart'; 7 | import '../../../screen_routes.dart'; 8 | 9 | 10 | class LoadingScreen extends StatelessWidget { 11 | static const String route = '/'; 12 | 13 | const LoadingScreen({Key? key}) : super(key: key); 14 | 15 | @override 16 | Widget build(BuildContext context) { 17 | WidgetsBinding.instance.addPostFrameCallback((_) { 18 | _start(context); 19 | }); 20 | 21 | return const MyScaffold( 22 | background: WavesBackground(), 23 | body: Center( 24 | child: Column( 25 | crossAxisAlignment: CrossAxisAlignment.center, 26 | mainAxisAlignment: MainAxisAlignment.center, 27 | children: [ 28 | CircularProgressIndicator(color: Colors.white,), 29 | SizedBox(height: 15,), 30 | Text("Loading...", style: TextStyle(fontSize: 18, color: Colors.white, fontWeight: FontWeight.w600, letterSpacing: 1)), 31 | ], 32 | ), 33 | ), 34 | ); 35 | } 36 | 37 | void _start(BuildContext context) { 38 | if (getIt.get().isAuthenticated) { 39 | Navigator.of(context).pushNamedAndRemoveUntil(ScreenRoutes.conversations, (_) => false); 40 | getIt.get().start(); 41 | } else { 42 | Navigator.of(context).pushNamedAndRemoveUntil(ScreenRoutes.login, (_) => false); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /flutter_app/lib/features/login_and_registration/domain/entities/failures/email_already_exists_failure.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_group_chat_app_with_firebase/core/domain/entities/failures/failure.dart'; 2 | 3 | 4 | class EmailAlreadyExistsFailure extends Failure { 5 | 6 | EmailAlreadyExistsFailure() : super ("Email is already in use, please, try to login into your account"); 7 | 8 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/login_and_registration/domain/entities/failures/invalid_credentials_failure.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_group_chat_app_with_firebase/core/domain/entities/failures/failure.dart'; 2 | 3 | 4 | class InvalidCredentialsFailure extends Failure { 5 | 6 | InvalidCredentialsFailure() : super("Ops! Incorrect email and/or password"); 7 | 8 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/login_and_registration/domain/entities/failures/invalid_email_failure.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | import 'package:flutter_group_chat_app_with_firebase/core/domain/entities/failures/failure.dart'; 4 | 5 | class InvalidEmailFailure extends Failure { 6 | 7 | InvalidEmailFailure() : super("Oops! This email is not registered yet"); 8 | 9 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/login_and_registration/domain/entities/failures/invalid_password_failure.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | import '../../../../../core/domain/entities/failures/failure.dart'; 5 | 6 | class InvalidPasswordFailure extends Failure { 7 | 8 | InvalidPasswordFailure() : super("Oops! This is not the correct password"); 9 | 10 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/login_and_registration/domain/entities/tokens_entity.dart: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | class TokensEntity { 5 | final String accessToken; 6 | final String refreshToken; 7 | final String uid; 8 | final DateTime accessTokenExpiration; 9 | 10 | TokensEntity({ 11 | required this.accessToken, 12 | required this.refreshToken, 13 | required this.uid, 14 | required this.accessTokenExpiration 15 | }); 16 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/login_and_registration/presentation/screens/widgets/animated_icon.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class MyAnimatedIcon extends StatefulWidget { 4 | final IconData icon; 5 | final ValueNotifier? notifySuccess; 6 | final ValueNotifier? notifyError; 7 | 8 | const MyAnimatedIcon( 9 | { required this.icon, 10 | this.notifySuccess, 11 | this.notifyError, 12 | Key? key} 13 | ) : super(key: key); 14 | 15 | @override 16 | State createState() => _MyAnimatedIconState(); 17 | } 18 | 19 | class _MyAnimatedIconState extends State { 20 | ValueNotifier? internalNotifySuccess; 21 | ValueNotifier? internalNotifyError; 22 | 23 | @override 24 | Widget build(BuildContext context) { 25 | return ValueListenableBuilder( 26 | valueListenable: (widget.notifySuccess ?? internalNotifySuccess)!, 27 | builder: (context, showSuccess, _) { 28 | return ValueListenableBuilder( 29 | valueListenable: (widget.notifyError ?? internalNotifyError)!, 30 | builder: (context, showError, __) { 31 | return AnimatedSwitcher( 32 | duration: const Duration(milliseconds: 300), 33 | transitionBuilder: (Widget child, Animation animation) { 34 | return ScaleTransition(scale: animation, child: child); 35 | }, 36 | child: () { 37 | const double kIconSize = 27.0; 38 | if (showSuccess) { 39 | return const Icon( 40 | key: ValueKey(0), 41 | Icons.check, 42 | color: Colors.indigo, 43 | size: kIconSize, 44 | ); 45 | } 46 | if (showError?.isNotEmpty == true) { 47 | return Icon( 48 | key: ValueKey(1), 49 | Icons.error_outline_rounded, 50 | color: Colors.red[300]!, 51 | size: kIconSize, 52 | ); 53 | } 54 | return Icon( 55 | key: const ValueKey(2), 56 | widget.icon, 57 | color: Colors.indigo, 58 | size: kIconSize, 59 | ); 60 | }(), 61 | ); 62 | } 63 | ); 64 | } 65 | ); 66 | } 67 | 68 | @override 69 | void initState() { 70 | super.initState(); 71 | 72 | if (widget.notifySuccess == null) { 73 | internalNotifySuccess = ValueNotifier(false); 74 | } 75 | if (widget.notifyError == null) { 76 | internalNotifyError = ValueNotifier(null); 77 | } 78 | } 79 | 80 | @override 81 | void dispose() { 82 | internalNotifySuccess?.dispose(); 83 | internalNotifyError?.dispose(); 84 | super.dispose(); 85 | } 86 | } -------------------------------------------------------------------------------- /flutter_app/lib/features/login_and_registration/presentation/widgets/separator.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | const separator = SizedBox(height: 15,); -------------------------------------------------------------------------------- /flutter_app/lib/screen_routes.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_group_chat_app_with_firebase/features/call/presentation/screens/call_screen.dart'; 3 | import 'package:flutter_group_chat_app_with_firebase/features/groups/presentation/screens/add_participants_screen.dart'; 4 | import 'package:flutter_group_chat_app_with_firebase/features/groups/presentation/screens/manage_group_participants_screen.dart'; 5 | import 'features/chat/presentation/screens/realtime_chat_screen/realtime_chat_screen.dart'; 6 | import 'features/chat/presentation/screens/realtime_conversations_screen/realtime_conversations_screen.dart'; 7 | import 'features/groups/presentation/screens/create_group_or_edit_title_screen.dart'; 8 | import 'features/loading/screens/loading_screen.dart'; 9 | import 'features/login_and_registration/presentation/screens/login_and_registration_screen.dart'; 10 | 11 | 12 | class ScreenRoutes { 13 | /// home route 14 | static const loading = LoadingScreen.route; 15 | static const login = LoginAndRegistrationScreen.route; 16 | static const conversations = RealtimeConversationsScreen.route; 17 | static const chat = RealtimeChatScreen.route; 18 | static const createGroupOrEditTitle = CreateGroupOrEditTitleScreen.route; 19 | static const addGroupParticipants = AddGroupParticipantsScreen.route; 20 | static const manageGroupParticipants = ManageGroupParticipantsScreen.route; 21 | static const call = CallScreen.route; 22 | } 23 | 24 | Map screenRoutes = { 25 | ScreenRoutes.loading: (context) => const LoadingScreen(), 26 | ScreenRoutes.login: (context) => const LoginAndRegistrationScreen(), 27 | ScreenRoutes.chat: (context) => const RealtimeChatScreen(), 28 | ScreenRoutes.conversations: (context) => const RealtimeConversationsScreen(), 29 | ScreenRoutes.createGroupOrEditTitle: (context) => const CreateGroupOrEditTitleScreen(), 30 | ScreenRoutes.addGroupParticipants: (context) => const AddGroupParticipantsScreen(), 31 | ScreenRoutes.manageGroupParticipants: (context) => const ManageGroupParticipantsScreen(), 32 | ScreenRoutes.call: (context) => const CallScreen(), 33 | }; -------------------------------------------------------------------------------- /flutter_app/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /flutter_app/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /flutter_app/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /flutter_app/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /flutter_app/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /flutter_app/linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /flutter_app/linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /flutter_app/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /flutter_app/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /flutter_app/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /flutter_app/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import agora_rtc_engine 9 | import cloud_firestore 10 | import cloud_functions 11 | import firebase_auth 12 | import firebase_core 13 | import firebase_messaging 14 | import iris_method_channel 15 | import path_provider_foundation 16 | 17 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 18 | AgoraRtcNgPlugin.register(with: registry.registrar(forPlugin: "AgoraRtcNgPlugin")) 19 | FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin")) 20 | FLTFirebaseFunctionsPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFunctionsPlugin")) 21 | FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) 22 | FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) 23 | FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin")) 24 | IrisMethodChannelPlugin.register(with: registry.registrar(forPlugin: "IrisMethodChannelPlugin")) 25 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 26 | } 27 | -------------------------------------------------------------------------------- /flutter_app/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | target 'RunnerTests' do 35 | inherit! :search_paths 36 | end 37 | end 38 | 39 | post_install do |installer| 40 | installer.pods_project.targets.each do |target| 41 | flutter_additional_macos_build_settings(target) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /flutter_app/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter_app/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /flutter_app/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter_app/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "version": 1, 4 | "author": "xcode" 5 | }, 6 | "images": [ 7 | { 8 | "size": "16x16", 9 | "idiom": "mac", 10 | "filename": "app_icon_16.png", 11 | "scale": "1x" 12 | }, 13 | { 14 | "size": "16x16", 15 | "idiom": "mac", 16 | "filename": "app_icon_32.png", 17 | "scale": "2x" 18 | }, 19 | { 20 | "size": "32x32", 21 | "idiom": "mac", 22 | "filename": "app_icon_32.png", 23 | "scale": "1x" 24 | }, 25 | { 26 | "size": "32x32", 27 | "idiom": "mac", 28 | "filename": "app_icon_64.png", 29 | "scale": "2x" 30 | }, 31 | { 32 | "size": "128x128", 33 | "idiom": "mac", 34 | "filename": "app_icon_128.png", 35 | "scale": "1x" 36 | }, 37 | { 38 | "size": "128x128", 39 | "idiom": "mac", 40 | "filename": "app_icon_256.png", 41 | "scale": "2x" 42 | }, 43 | { 44 | "size": "256x256", 45 | "idiom": "mac", 46 | "filename": "app_icon_256.png", 47 | "scale": "1x" 48 | }, 49 | { 50 | "size": "256x256", 51 | "idiom": "mac", 52 | "filename": "app_icon_512.png", 53 | "scale": "2x" 54 | }, 55 | { 56 | "size": "512x512", 57 | "idiom": "mac", 58 | "filename": "app_icon_512.png", 59 | "scale": "1x" 60 | }, 61 | { 62 | "size": "512x512", 63 | "idiom": "mac", 64 | "filename": "app_icon_1024.png", 65 | "scale": "2x" 66 | } 67 | ] 68 | } -------------------------------------------------------------------------------- /flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /flutter_app/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = flutter_group_chat_app_with_firebase 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.fluttergroupchatappwithfirebase 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2023 com.example.fluttergroupchatappwithfirebase. All rights reserved. 15 | -------------------------------------------------------------------------------- /flutter_app/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /flutter_app/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /flutter_app/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /flutter_app/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /flutter_app/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /flutter_app/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /flutter_app/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /flutter_app/macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import FlutterMacOS 2 | import Cocoa 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /flutter_app/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_group_chat_app_with_firebase 2 | description: A Flutter Group Chat App with Firebase 3 | 4 | publish_to: 'none' 5 | version: 1.0.0+1 6 | environment: 7 | sdk: '>=3.0.5 <4.0.0' 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | msh_checkbox: ^2.0.1 13 | cupertino_icons: ^1.0.6 14 | intl: ^0.18.1 15 | dartz: ^0.10.1 16 | get_it: ^7.6.4 17 | firebase_core: ^2.16.0 18 | cloud_firestore: ^4.9.2 19 | firebase_auth: ^4.10.0 20 | collection: ^1.17.2 21 | cloud_functions: ^4.4.2 22 | synchronized: ^3.1.0 23 | firebase_messaging: ^14.7.3 24 | stream_d: ^0.3.0 25 | agora_rtc_engine: ^6.2.4 26 | agora_uikit: ^1.3.7 27 | sliding_up_panel: ^2.0.0+1 28 | 29 | dev_dependencies: 30 | flutter_test: 31 | sdk: flutter 32 | flutter_lints: ^2.0.3 33 | flutter_launcher_icons: "^0.13.1" 34 | 35 | flutter: 36 | uses-material-design: true 37 | 38 | assets: 39 | - assets/ 40 | - assets/fonts/RedHatDisplay/ 41 | 42 | fonts: 43 | - family: RedHatDisplay 44 | fonts: 45 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-Light.ttf 46 | weight: 100 47 | style: normal 48 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-LightItalic.ttf 49 | weight: 100 50 | style: italic 51 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-Light.ttf 52 | weight: 200 53 | style: normal 54 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-LightItalic.ttf 55 | weight: 200 56 | style: italic 57 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-Regular.ttf 58 | weight: 300 59 | style: normal 60 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-Italic.ttf 61 | weight: 300 62 | style: normal 63 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-Medium.ttf 64 | weight: 400 65 | style: normal 66 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-MediumItalic.ttf 67 | weight: 400 68 | style: italic 69 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-SemiBold.ttf 70 | weight: 500 71 | style: normal 72 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-SemiBoldItalic.ttf 73 | weight: 500 74 | style: italic 75 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-Bold.ttf 76 | weight: 600 77 | style: normal 78 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-BoldItalic.ttf 79 | weight: 600 80 | style: italic 81 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-ExtraBold.ttf 82 | weight: 700 83 | style: normal 84 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-ExtraBoldItalic.ttf 85 | weight: 700 86 | style: italic 87 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-BlackItalic.ttf 88 | weight: 800 89 | style: italic 90 | - asset: assets/fonts/RedHatDisplay/RedHatDisplay-BlackItalic.ttf 91 | weight: 800 92 | style: italic 93 | -------------------------------------------------------------------------------- /flutter_app/web/environment.js: -------------------------------------------------------------------------------- 1 | // TODO: copy the values from "web" field in the "flutter_app/lib/firebase_options.dart" file 2 | 3 | const environment = { 4 | "firebase": { 5 | "apiKey": "", 6 | "appId": "", 7 | "messagingSenderId": "", 8 | "projectId": "", 9 | "authDomain": "", 10 | "storageBucket": "" 11 | } 12 | }; -------------------------------------------------------------------------------- /flutter_app/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/web/favicon.png -------------------------------------------------------------------------------- /flutter_app/web/firebase-messaging-sw.js: -------------------------------------------------------------------------------- 1 | importScripts('https://www.gstatic.com/firebasejs/10.5.2/firebase-app-compat.js') 2 | importScripts('https://www.gstatic.com/firebasejs/10.5.2/firebase-messaging-compat.js') 3 | 4 | // my custom environment file for firebase 5 | importScripts('environment.js') 6 | 7 | if (!environment.firebase?.apiKey?.length) { 8 | console.error("Missing environment values for web, push notifications won't work") 9 | console.error("1. Copy the values from copy the values from the \"web\" field in the \"flutter_app/lib/firebase_options.dart\" file ") 10 | console.error("2. Paste the values in the `flutter_app/web/environment.js` file") 11 | } else { 12 | const app = firebase.initializeApp(environment.firebase); 13 | firebase.messaging().onBackgroundMessage((payload) => { 14 | console.log("onBackgroundMessage"); 15 | console.log(payload); 16 | return self.registration.showNotification(payload.notification.title, {body: payload.notification.body}); 17 | }) 18 | } 19 | -------------------------------------------------------------------------------- /flutter_app/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/web/icons/Icon-192.png -------------------------------------------------------------------------------- /flutter_app/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/web/icons/Icon-512.png -------------------------------------------------------------------------------- /flutter_app/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /flutter_app/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /flutter_app/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | flutter_group_chat_app_with_firebase 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /flutter_app/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "flutter_group_chat_app_with_firebase", 3 | "short_name": "flutter_group_chat_app_with_firebase", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#hexcode", 7 | "theme_color": "#hexcode", 8 | "description": "A Flutter Group Chat App with Firebase", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } -------------------------------------------------------------------------------- /flutter_app/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /flutter_app/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | void RegisterPlugins(flutter::PluginRegistry* registry) { 17 | AgoraRtcEnginePluginRegisterWithRegistrar( 18 | registry->GetRegistrarForPlugin("AgoraRtcEnginePlugin")); 19 | CloudFirestorePluginCApiRegisterWithRegistrar( 20 | registry->GetRegistrarForPlugin("CloudFirestorePluginCApi")); 21 | FirebaseAuthPluginCApiRegisterWithRegistrar( 22 | registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi")); 23 | FirebaseCorePluginCApiRegisterWithRegistrar( 24 | registry->GetRegistrarForPlugin("FirebaseCorePluginCApi")); 25 | IrisMethodChannelPluginCApiRegisterWithRegistrar( 26 | registry->GetRegistrarForPlugin("IrisMethodChannelPluginCApi")); 27 | PermissionHandlerWindowsPluginRegisterWithRegistrar( 28 | registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); 29 | } 30 | -------------------------------------------------------------------------------- /flutter_app/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /flutter_app/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | agora_rtc_engine 7 | cloud_firestore 8 | firebase_auth 9 | firebase_core 10 | iris_method_channel 11 | permission_handler_windows 12 | ) 13 | 14 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 15 | ) 16 | 17 | set(PLUGIN_BUNDLED_LIBRARIES) 18 | 19 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 20 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 21 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 24 | endforeach(plugin) 25 | 26 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 27 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 28 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 29 | endforeach(ffi_plugin) 30 | -------------------------------------------------------------------------------- /flutter_app/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /flutter_app/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | return true; 35 | } 36 | 37 | void FlutterWindow::OnDestroy() { 38 | if (flutter_controller_) { 39 | flutter_controller_ = nullptr; 40 | } 41 | 42 | Win32Window::OnDestroy(); 43 | } 44 | 45 | LRESULT 46 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 47 | WPARAM const wparam, 48 | LPARAM const lparam) noexcept { 49 | // Give Flutter, including plugins, an opportunity to handle window messages. 50 | if (flutter_controller_) { 51 | std::optional result = 52 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 53 | lparam); 54 | if (result) { 55 | return *result; 56 | } 57 | } 58 | 59 | switch (message) { 60 | case WM_FONTCHANGE: 61 | flutter_controller_->engine()->ReloadSystemFonts(); 62 | break; 63 | } 64 | 65 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 66 | } 67 | -------------------------------------------------------------------------------- /flutter_app/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /flutter_app/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"flutter_group_chat_app_with_firebase", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /flutter_app/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /flutter_app/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/flutter_app/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /flutter_app/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /flutter_app/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length <= 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /flutter_app/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /functions/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled JavaScript files 2 | dist/**/*.js 3 | dist/**/*.js.map 4 | 5 | # TypeScript v1 declaration files 6 | typings/ 7 | 8 | # Node.js dependency directory 9 | node_modules/ 10 | -------------------------------------------------------------------------------- /functions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "functions", 3 | "scripts": { 4 | "build": "tsc", 5 | "build:watch": "tsc --watch", 6 | "serve": "npm run build && firebase emulators:start --only functions", 7 | "shell": "npm run build && firebase functions:shell", 8 | "start": "npm run shell", 9 | "deploy": "firebase deploy --only functions", 10 | "logs": "firebase functions:log" 11 | }, 12 | "engines": { 13 | "node": "16" 14 | }, 15 | "main": "dist/index.js", 16 | "dependencies": { 17 | "agora-token": "^2.0.3", 18 | "body-parser": "^1.20.2", 19 | "express": "^4.18.2", 20 | "firebase-admin": "^11.11.0", 21 | "firebase-functions": "^4.5.0" 22 | }, 23 | "devDependencies": { 24 | "@types/express": "^4.17.17", 25 | "@types/node": "^18.17.18", 26 | "firebase-functions-test": "^3.1.0", 27 | "typescript": "^4.9.0" 28 | }, 29 | "private": true 30 | } 31 | -------------------------------------------------------------------------------- /functions/src/data/datasource/db.ts: -------------------------------------------------------------------------------- 1 | import {firestore} from "firebase-admin"; 2 | 3 | export function db () { 4 | return firestore(); 5 | } 6 | -------------------------------------------------------------------------------- /functions/src/data/datasource/messages-datasource.ts: -------------------------------------------------------------------------------- 1 | import {Conversation} from "../../domain/entities/conversation"; 2 | import {db} from "./db"; 3 | import {ConversationModel} from "../models/conversation-model"; 4 | import {MessageModel} from "../models/message-model"; 5 | import * as admin from "firebase-admin" 6 | 7 | class MessagesDatasource { 8 | 9 | async getConversation (conversationId: string): Promise { 10 | const data = ( 11 | await db() 12 | .collection("conversations") 13 | .doc(conversationId) 14 | .get() 15 | ).data(); 16 | 17 | return ConversationModel.fromData(data); 18 | } 19 | 20 | async removeParticipantsInMessages (conversationId:string, participantsUids: string[]): Promise { 21 | console.log("removeParticipantsInMessages: "+" " + conversationId + " " +participantsUids + " " + Array.isArray(participantsUids)); 22 | const snapshot = await db() 23 | .collection("conversations") 24 | .doc(conversationId) 25 | .collection("messages") 26 | .where(MessageModel.kParticipants, "array-contains-any", participantsUids) 27 | .get(); 28 | 29 | for (const message of snapshot.docs) { 30 | console.log("snapshot.docs: "+" " + snapshot.docs.length); 31 | 32 | if (message.data()[MessageModel.kParticipants].length) { 33 | await message.ref.update({ 34 | [MessageModel.kParticipants]: admin.firestore.FieldValue.arrayRemove(...participantsUids), 35 | [MessageModel.kPendingRead]: admin.firestore.FieldValue.arrayRemove(...participantsUids), 36 | [MessageModel.kPendingReceivement]: admin.firestore.FieldValue.arrayRemove(...participantsUids), 37 | }); 38 | } else { 39 | await message.ref.delete(); 40 | } 41 | } 42 | } 43 | 44 | async deleteAllMessages(conversationId: string): Promise { 45 | const snapshot = await db() 46 | .collection("conversations") 47 | .doc(conversationId) 48 | .collection("messages") 49 | .get(); 50 | for (const message of snapshot.docs) { 51 | message.ref.delete(); 52 | } 53 | } 54 | } 55 | 56 | export const messagesDatasource = new MessagesDatasource(); 57 | -------------------------------------------------------------------------------- /functions/src/data/datasource/users-datasource.ts: -------------------------------------------------------------------------------- 1 | import {UserPublic} from "../../domain/entities/user-public"; 2 | import {UserFull} from "../../domain/entities/user-full"; 3 | import {db} from "./db"; 4 | import {UserPublicModel} from "../models/user-public-model"; 5 | import {UserFullModel} from "../models/user-full-model"; 6 | 7 | 8 | class UsersDatasource { 9 | 10 | async getPublicUser (uid:string) : Promise { 11 | const user = await this.publicUserRef(uid).get(); 12 | 13 | return UserPublicModel.fromData(user.data()); 14 | } 15 | 16 | private publicUserRef(uid: string) { 17 | return db() 18 | .collection("users") 19 | .doc(uid); 20 | } 21 | private fullUserRef(uid: string) { 22 | return db() 23 | .collection("users") 24 | .doc(uid) 25 | .collection("fullUser") 26 | .doc("data"); 27 | } 28 | 29 | async getFullUser (uid:string) : Promise { 30 | const user = await this.fullUserRef(uid).get(); 31 | 32 | return UserFullModel.fromData(user.data()); 33 | } 34 | 35 | async updateUser(uid: string, data: {[p: string]: any} & FirebaseFirestore.AddPrefixToKeys, visibility:'public'|'private'): Promise { 36 | if (visibility == "public") { 37 | await this.publicUserRef(uid).update(data); 38 | } 39 | await this.fullUserRef(uid).update(data); 40 | } 41 | } 42 | 43 | export const usersDatasource = new UsersDatasource(); 44 | -------------------------------------------------------------------------------- /functions/src/data/models/agora-uid-mutex-model.ts: -------------------------------------------------------------------------------- 1 | import {MutexModel} from "./mutex-model"; 2 | 3 | 4 | export class AgoraUidMutexModel extends MutexModel { 5 | static kNextAgoraUid = "nextAgoraUid"; 6 | constructor( 7 | locksQueue: string[], 8 | public readonly nextAgoraUid: number, 9 | ) { 10 | super(locksQueue); 11 | } 12 | 13 | toData() { 14 | const res = super.toData(); 15 | res[AgoraUidMutexModel.kNextAgoraUid] = this.nextAgoraUid; 16 | return res; 17 | } 18 | 19 | static fromData(data:any) : AgoraUidMutexModel { 20 | return new AgoraUidMutexModel( 21 | data[MutexModel.kLocksQueue], 22 | data[AgoraUidMutexModel.kNextAgoraUid], 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /functions/src/data/models/conversation-group-model.ts: -------------------------------------------------------------------------------- 1 | import {firestore} from "firebase-admin"; 2 | import Timestamp = firestore.Timestamp; 3 | import {Conversation} from "../../domain/entities/conversation"; 4 | import {ConversationGroup} from "../../domain/entities/conversation-group"; 5 | 6 | 7 | export class ConversationGroupModel extends ConversationGroup { 8 | static readonly kTitle = "title"; 9 | static readonly kCreatedBy = "createdBy"; 10 | static readonly kAdminUids = "adminUids"; 11 | static readonly kJoinedAt = "joinedAt"; 12 | 13 | constructor( 14 | title: string, 15 | createdBy: string, 16 | adminUids: string[], 17 | joinedAt: {[p: string]: Date}, 18 | ){ 19 | super(title, createdBy, adminUids, joinedAt); 20 | } 21 | 22 | static fromData(data:any) : ConversationGroupModel | undefined { 23 | if (data == null) { 24 | return undefined; 25 | } 26 | 27 | return new ConversationGroupModel( 28 | data[ConversationGroupModel.kTitle], 29 | data[ConversationGroupModel.kCreatedBy], 30 | data[ConversationGroupModel.kAdminUids], 31 | Object.fromEntries(Object.entries(data[ConversationGroupModel.kJoinedAt]).map(([key, value]) => [key, (value as Timestamp).toDate()])), 32 | ); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /functions/src/data/models/conversation-model.ts: -------------------------------------------------------------------------------- 1 | import {firestore} from "firebase-admin"; 2 | import Timestamp = firestore.Timestamp; 3 | import {Conversation} from "../../domain/entities/conversation"; 4 | import {ConversationGroup} from "../../domain/entities/conversation-group"; 5 | import {ConversationGroupModel} from "./conversation-group-model"; 6 | 7 | 8 | export class ConversationModel extends Conversation { 9 | static readonly kConversationId = "conversationId"; 10 | static readonly kParticipants = "participants"; 11 | static readonly kTyping = "typing"; 12 | static readonly kGroup = "group"; 13 | 14 | constructor( 15 | conversationId: string, 16 | participants: string[], 17 | group?: ConversationGroup, 18 | ){ 19 | super(conversationId, participants, group); 20 | } 21 | 22 | static fromData(data:any) : ConversationModel | null { 23 | if (!data) { 24 | return null; 25 | } 26 | 27 | return new ConversationModel( 28 | data[ConversationModel.kConversationId], 29 | data[ConversationModel.kParticipants], 30 | ConversationGroupModel.fromData(data[ConversationModel.kGroup]) 31 | ); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /functions/src/data/models/message-model.ts: -------------------------------------------------------------------------------- 1 | import {Message} from "../../domain/entities/message"; 2 | import * as admin from "firebase-admin" 3 | import {fromMapOfTimestamp} from "../../utils"; 4 | 5 | export class MessageModel extends Message { 6 | static readonly kConversationId = "conversationId"; 7 | static readonly kMessageId = "messageId"; 8 | static readonly kText = "text"; 9 | static readonly kSenderUid = "senderUid"; 10 | static readonly kParticipants = "participants"; 11 | static readonly kReceivedAt = "receivedAt"; 12 | static readonly kReadAt = "readAt"; 13 | static readonly kSentAt = "sentAt"; 14 | static readonly kPendingRead = "pendingRead"; 15 | static readonly kPendingReceivement = "pendingReceivement"; 16 | 17 | constructor( 18 | messageId: string, 19 | conversationId: string, 20 | text: string, 21 | senderUid: string, 22 | participants: string[], 23 | sentAt: Date, 24 | pendingRead: string[], 25 | pendingReceivement: string[], 26 | receivedAt: Map, 27 | readAt: Map, 28 | ) { 29 | super(messageId, conversationId, text, senderUid, participants, sentAt, pendingRead, pendingReceivement, receivedAt, readAt,); 30 | } 31 | 32 | static fromData(data: any) : MessageModel { 33 | return new MessageModel( 34 | data[MessageModel.kMessageId], 35 | data[MessageModel.kConversationId], 36 | data[MessageModel.kText], 37 | data[MessageModel.kSenderUid], 38 | data[MessageModel.kParticipants], 39 | (data[MessageModel.kSentAt] as admin.firestore.Timestamp).toDate(), 40 | data[MessageModel.kPendingRead], 41 | data[MessageModel.kPendingReceivement], 42 | fromMapOfTimestamp(data[MessageModel.kReceivedAt]), 43 | fromMapOfTimestamp(data[MessageModel.kReadAt]), 44 | ); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /functions/src/data/models/mutex-model.ts: -------------------------------------------------------------------------------- 1 | import {Mutex} from "../../domain/entities/mutex"; 2 | 3 | 4 | export class MutexModel extends Mutex { 5 | static kLocksQueue = "locksQueue"; 6 | locksQueue: string[]; 7 | 8 | constructor(locksQueue: string[]) { 9 | super(locksQueue); 10 | } 11 | 12 | toData() { 13 | return { 14 | [MutexModel.kLocksQueue]: this.locksQueue, 15 | } as {[p:string]: any} 16 | } 17 | 18 | static fromData(data:any) : MutexModel { 19 | return new MutexModel(data[MutexModel.kLocksQueue]); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /functions/src/data/models/user-full-model.ts: -------------------------------------------------------------------------------- 1 | import {UserFull} from "../../domain/entities/user-full"; 2 | import {UserPublicModel} from "./user-public-model"; 3 | 4 | 5 | export class UserFullModel extends UserFull { 6 | static readonly kFcmToken = "fcmToken"; 7 | constructor( 8 | uid: string, 9 | firstName: string, 10 | lastName: string, 11 | agoraUid: number, 12 | fcmToken: string, 13 | ) { 14 | super(uid, firstName, lastName, agoraUid, fcmToken); 15 | } 16 | 17 | static fromData(data:any) : UserFullModel | undefined { 18 | if (!data) { 19 | return undefined; 20 | } 21 | return new UserFullModel( 22 | data[UserPublicModel.kUid], 23 | data[UserPublicModel.kFirstName], 24 | data[UserPublicModel.kLastName], 25 | data[UserPublicModel.kAgoraUid], 26 | data[UserFullModel.kFcmToken], 27 | ) 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /functions/src/data/models/user-public-model.ts: -------------------------------------------------------------------------------- 1 | import {UserPublic} from "../../domain/entities/user-public"; 2 | import {firestore} from "firebase-admin"; 3 | import DocumentData = firestore.DocumentData; 4 | 5 | 6 | export class UserPublicModel extends UserPublic { 7 | static readonly kUid = "uid"; 8 | static readonly kFirstName = "firstName"; 9 | static readonly kLastName = "lastName"; 10 | static readonly kAgoraUid = "agoraUid"; 11 | 12 | constructor( 13 | uid: string, 14 | firstName: string, 15 | lastName: string, 16 | agoraUid: number, 17 | ) { 18 | super(uid, firstName, lastName, agoraUid); 19 | } 20 | 21 | static fromData(data:DocumentData | undefined) : UserPublicModel | null { 22 | if (!data) { 23 | return null; 24 | } 25 | return new UserPublicModel( 26 | data[UserPublicModel.kUid], 27 | data[UserPublicModel.kFirstName], 28 | data[UserPublicModel.kLastName], 29 | data[UserPublicModel.kAgoraUid], 30 | ) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /functions/src/domain/entities/conversation-group.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | export class ConversationGroup { 5 | 6 | constructor( 7 | public readonly title: string, 8 | public readonly createdBy: string, 9 | public readonly adminUids: string[], 10 | public readonly joinedAt: {[p: string]: Date}, 11 | ) {} 12 | 13 | } 14 | -------------------------------------------------------------------------------- /functions/src/domain/entities/conversation.ts: -------------------------------------------------------------------------------- 1 | import {ConversationGroup} from "./conversation-group"; 2 | 3 | 4 | export class Conversation { 5 | 6 | constructor( 7 | public readonly conversationId: string, 8 | public readonly participants: string[], 9 | public readonly group?: ConversationGroup, 10 | ) {} 11 | 12 | get isGroup () : boolean { 13 | return this.group != null; 14 | } 15 | 16 | removedParticipants(conversationBeforeUpdate:Conversation) : Array { 17 | return conversationBeforeUpdate.participants 18 | .filter((uid) => conversationBeforeUpdate.participants.includes(uid)) 19 | .filter((uid) => !this.participants.includes(uid)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /functions/src/domain/entities/message.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | export class Message { 6 | constructor( 7 | public readonly messageId: string, 8 | public readonly conversationId: string, 9 | public readonly text: string, 10 | public readonly senderUid: string, 11 | public readonly participants: string[], 12 | public readonly sentAt: Date, 13 | public readonly pendingRead: string[], 14 | public readonly pendingReceivement: string[], 15 | public readonly receivedAt: Map, 16 | public readonly readAt : Map, 17 | ) {} 18 | 19 | get isGroup(): boolean { 20 | return this.conversationId.startsWith('group_'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /functions/src/domain/entities/mutex.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | export class Mutex { 5 | 6 | constructor( 7 | public readonly locksQueue: string[], 8 | ) {} 9 | 10 | } 11 | -------------------------------------------------------------------------------- /functions/src/domain/entities/user-full.ts: -------------------------------------------------------------------------------- 1 | import {UserPublic} from "./user-public"; 2 | 3 | 4 | export class UserFull extends UserPublic{ 5 | 6 | constructor( 7 | uid: string, 8 | firstName: string, 9 | lastName: string, 10 | agoraUid: number, 11 | public readonly fcmToken: string, 12 | ) { 13 | super(uid, firstName, lastName, agoraUid); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /functions/src/domain/entities/user-public.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | export class UserPublic { 6 | 7 | constructor( 8 | public readonly uid: string, 9 | public readonly firstName: string, 10 | public readonly lastName: string, 11 | public agoraUid: number, 12 | ) {} 13 | 14 | get fullName () : string { 15 | return `${this.firstName} ${this.lastName}`; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /functions/src/domain/services/get-agora-uid-mutex-service.ts: -------------------------------------------------------------------------------- 1 | import {MutexService} from "./mutex-service"; 2 | import {usersService} from "./users-service"; 3 | import {firestore} from "firebase-admin"; 4 | 5 | 6 | class GetAgoraUidMutexService extends MutexService<{agoraUid: number}, {uid: string}> { 7 | 8 | constructor() { 9 | super("get-agora-uid-mutex", "administrative"); 10 | } 11 | 12 | protected createDocumentForTheFirstTime(): FirebaseFirestore.WithFieldValue { 13 | return { "nextAgoraUid": 1 }; 14 | } 15 | 16 | protected getMutexId(input: { uid: string }): string { 17 | return input.uid; 18 | } 19 | 20 | protected async synchronized(input: {uid: string}, data: firestore.DocumentData, ref:firestore.DocumentReference): Promise<{ agoraUid: number }> { 21 | const agoraUid:number = data["nextAgoraUid"]; 22 | await ref.update({ "nextAgoraUid": firestore.FieldValue.increment(1) }); 23 | await usersService.updateUser(input.uid, { "agoraUid": agoraUid }, 'public'); 24 | return { agoraUid: agoraUid }; 25 | } 26 | 27 | 28 | } 29 | 30 | export const getAgoraUidMutexService = new GetAgoraUidMutexService(); 31 | -------------------------------------------------------------------------------- /functions/src/domain/services/messages-service.ts: -------------------------------------------------------------------------------- 1 | import {Conversation} from "../entities/conversation"; 2 | import {messagesDatasource} from "../../data/datasource/messages-datasource"; 3 | 4 | 5 | class MessagesService { 6 | 7 | getConversation (conversationId:string) : Promise { 8 | return messagesDatasource.getConversation(conversationId); 9 | } 10 | 11 | removeParticipantsInConversationMessages (conversationId:string, participantsUids: string[]) : Promise { 12 | return messagesDatasource.removeParticipantsInMessages(conversationId, participantsUids); 13 | } 14 | 15 | deleteAllMessages(conversationId: string) : Promise { 16 | return messagesDatasource.deleteAllMessages(conversationId); 17 | } 18 | } 19 | 20 | export const messagesService = new MessagesService(); 21 | -------------------------------------------------------------------------------- /functions/src/domain/services/notifications-service.ts: -------------------------------------------------------------------------------- 1 | import {usersDatasource} from "../../data/datasource/users-datasource"; 2 | import * as admin from "firebase-admin"; 3 | import {UserFull} from "../entities/user-full"; 4 | 5 | class NotificationsService { 6 | async sendPushNotificationToDevice(params:{uid?:string, user?:UserFull, title:string, body:string, data?:object}): Promise { 7 | if (params.user == null && params.uid == null) { 8 | throw Error("You must inform either user or uid"); 9 | } 10 | params.user ??= await usersDatasource.getFullUser(params.uid!); 11 | if (params.user?.fcmToken?.length) { 12 | try { 13 | const data = { 14 | click_action: "FLUTTER_NOTIFICATION_CLICK", 15 | ...params.data, 16 | }; 17 | 18 | await admin.messaging().send({ 19 | notification: { 20 | title: params.title, 21 | body: params.body, 22 | }, 23 | android: { 24 | notification: { 25 | title: params.title, 26 | body: params.body, 27 | color: "#1A237E", 28 | }, 29 | priority: "high", 30 | ttl: 24 * 60 * 60, 31 | }, 32 | webpush: { 33 | notification: { 34 | title: params.title, 35 | body: params.body, 36 | data: data, 37 | } 38 | }, 39 | token: params.user.fcmToken, 40 | data: data 41 | }); 42 | console.log(`Push notification sent to ${params.user.fullName} (${params.user.uid}).`); 43 | } catch (e:any) { 44 | console.error(`An error ocurred when sending the push notification to ${params.user.fullName} (${params.user.uid}): \"${e.stack.split("\n", 1).join("")}\"`); 45 | } 46 | } else { 47 | console.log(`Push notification NOT sent to ${(params.user?.fullName ?? 'unknown')} (${(params.user?.uid ?? 'unknown')}).`); 48 | } 49 | } 50 | } 51 | 52 | export const notificationsService = new NotificationsService(); 53 | -------------------------------------------------------------------------------- /functions/src/domain/services/users-service.ts: -------------------------------------------------------------------------------- 1 | import {usersDatasource} from "../../data/datasource/users-datasource"; 2 | import {UserFull} from "../entities/user-full"; 3 | import {UserPublic} from "../entities/user-public"; 4 | import {getAgoraUidMutexService} from "./get-agora-uid-mutex-service"; 5 | 6 | 7 | class UsersService { 8 | 9 | getFullUser (uid:string) : Promise { 10 | return usersDatasource.getFullUser(uid); 11 | } 12 | getPublicUser (uid:string) : Promise { 13 | return usersDatasource.getPublicUser(uid); 14 | } 15 | 16 | updateUser(uid: string, data:any, visibility:'public'|'private') : Promise { 17 | return usersDatasource.updateUser(uid, data, visibility); 18 | } 19 | 20 | async getAgoraUid(uid: string, cache?:UserFull) : Promise { 21 | cache ??= await usersService.getFullUser(uid); 22 | if (cache.agoraUid == null) { 23 | cache.agoraUid = (await getAgoraUidMutexService.call({uid: uid})).agoraUid; 24 | } 25 | return cache.agoraUid; 26 | } 27 | 28 | } 29 | 30 | export const usersService = new UsersService(); 31 | -------------------------------------------------------------------------------- /functions/src/environment.ts: -------------------------------------------------------------------------------- 1 | 2 | /** Keep this file local, do not commit */ 3 | export const environment = { 4 | agora: { 5 | appID: "", 6 | appCertificate: "", 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /functions/src/middlewares/calls/calls.ts: -------------------------------------------------------------------------------- 1 | import * as functions from "firebase-functions"; 2 | import * as agora from "agora-token"; 3 | import {usersService} from "../../domain/services/users-service"; 4 | import {environment} from "../../environment"; 5 | import {notificationsService} from "../../domain/services/notifications-service"; 6 | import {messagesService} from "../../domain/services/messages-service"; 7 | import {UserFull} from "../../domain/entities/user-full"; 8 | import {Conversation} from "../../domain/entities/conversation"; 9 | 10 | function getNotificationTitle(user:UserFull, conversation:Conversation) { 11 | if (conversation.isGroup) { 12 | return `Meeting is underway in ${conversation.group.title}`; 13 | } 14 | return `${user.fullName} is calling you`; 15 | } 16 | function getNotificationBody(user:UserFull, conversation:Conversation) { 17 | if (conversation.isGroup) { 18 | return `${user.fullName} joined the meeting, click here to join too`; 19 | } 20 | return `Click here to join`; 21 | } 22 | 23 | export const getCallCredentials = async (data: any, context: functions.https.CallableContext) : Promise => { 24 | if (!context.auth?.uid) { 25 | throw new Error("getCallToken: user must be authenticated"); 26 | } 27 | const conversationId = data["conversationId"]; 28 | if (!conversationId?.length) throw new Error("getCallToken: conversationId must not be null"); 29 | 30 | const conversation = await messagesService.getConversation(conversationId); 31 | const user = await usersService.getFullUser(context.auth.uid); 32 | for (let uid of conversation.participants) { 33 | if (uid != context.auth.uid) { 34 | await notificationsService.sendPushNotificationToDevice({ 35 | uid: uid, 36 | data: {"conversationId": conversationId, "joinCall": 'true'}, 37 | title: getNotificationTitle(user, conversation), 38 | body: getNotificationBody(user, conversation), 39 | }) 40 | } 41 | } 42 | 43 | const agoraUid = await usersService.getAgoraUid(context.auth.uid, user); 44 | const rtcToken = agora.RtcTokenBuilder.buildTokenWithUid( 45 | environment.agora.appID, 46 | environment.agora.appCertificate, 47 | conversationId, 48 | agoraUid, 49 | agora.RtcRole.PUBLISHER, 50 | 86400, 51 | 86400, 52 | ); 53 | return { rtcToken: rtcToken, agoraUid: agoraUid, }; 54 | } 55 | -------------------------------------------------------------------------------- /functions/src/middlewares/oncall-wrapper.ts: -------------------------------------------------------------------------------- 1 | import * as functions from "firebase-functions"; 2 | 3 | export const onCallWrapper = async (handler: () => any | Promise) : Promise => { 4 | try { 5 | return (await handler()); 6 | } catch (e) { 7 | console.error(e.toString()); 8 | throw new functions.https.HttpsError("unknown", "An internal error occurred"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /functions/src/utils.ts: -------------------------------------------------------------------------------- 1 | import * as admin from "firebase-admin" 2 | 3 | 4 | export function fromMapOfTimestamp (map:any): Map { 5 | const res: Map = new Map(); 6 | for (const key of Object.keys(map)) { 7 | if (map.hasOwnProperty(key)) { 8 | res[key] = (map[key] as admin.firestore.Timestamp)?.toDate(); 9 | } 10 | } 11 | return res; 12 | } 13 | -------------------------------------------------------------------------------- /functions/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "noImplicitReturns": true, 5 | "noUnusedLocals": false, 6 | "outDir": "dist", 7 | "strictNullChecks": false, 8 | "sourceMap": true, 9 | "strict": true, 10 | "target": "es2017", 11 | "allowSyntheticDefaultImports": true, 12 | "suppressImplicitAnyIndexErrors": true, 13 | }, 14 | "compileOnSave": true, 15 | "include": [ 16 | "src" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /readme-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RodrigoBertotti/flutter_group_chat_app_with_firebase/9bbcb190cfa3229504d29b269d1e79e4842369f8/readme-image.png --------------------------------------------------------------------------------