diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..d60b2e2 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "chat", + "request": "launch", + "type": "dart" + } + ] +} \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index d48950c..cb9f0dd 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -24,6 +24,7 @@ if (flutterVersionName == null) { apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" +apply plugin: 'com.google.gms.google-services' android { compileSdkVersion rootProject.ext.compileSdkVersion @@ -35,7 +36,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "br.com.lucasgabriel.chat.chat" + applicationId "br.com.lucasgabriel.chat" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode flutterVersionCode.toInteger() @@ -57,4 +58,5 @@ flutter { dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation platform('com.google.firebase:firebase-bom:27.0.0') } diff --git a/android/app/google-services.json b/android/app/google-services.json new file mode 100644 index 0000000..58e65ed --- /dev/null +++ b/android/app/google-services.json @@ -0,0 +1,47 @@ +{ + "project_info": { + "project_number": "778715077891", + "project_id": "chat-flutter-4b882", + "storage_bucket": "chat-flutter-4b882.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:778715077891:android:412992c89d51e6389a5d36", + "android_client_info": { + "package_name": "br.com.lucasgabriel.chat" + } + }, + "oauth_client": [ + { + "client_id": "778715077891-8cv2tokv7al69c8ldsjnoasmsss7dsri.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "br.com.lucasgabriel.chat", + "certificate_hash": "cf92da8cda5bb3d00b5db8f4f0928682a7e4b2e0" + } + }, + { + "client_id": "778715077891-9g4hol2rhrqbl0ss1trhnjoorv3fce7g.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyCR46JXpr2WfdgJU6N_rPcJ3WWhYPcoduc" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "778715077891-9g4hol2rhrqbl0ss1trhnjoorv3fce7g.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index 16ecf4a..50cc583 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="br.com.lucasgabriel.chat"> diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index f23b03f..b21b59e 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,8 +1,9 @@ + package="br.com.lucasgabriel.chat"> + android:icon="@mipmap/ic_launcher" + android:requestLegacyExternalStorage="true"> + package="br.com.lucasgabriel.chat"> diff --git a/android/build.gradle b/android/build.gradle index dab0e2a..23831dd 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -2,7 +2,7 @@ buildscript { ext.kotlin_version = '1.3.50' ext { // buildToolsVersion = "29.0.2" - minSdkVersion = 16 + minSdkVersion = 21 compileSdkVersion = 30 targetSdkVersion = 30 ndkVersion = "23.0.7196353" @@ -16,6 +16,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'com.google.gms:google-services:4.3.5' } } diff --git a/ios/Flutter/Debug.xcconfig b/ios/Flutter/Debug.xcconfig index 592ceee..ec97fc6 100644 --- a/ios/Flutter/Debug.xcconfig +++ b/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/ios/Flutter/Release.xcconfig b/ios/Flutter/Release.xcconfig index 592ceee..c4855bf 100644 --- a/ios/Flutter/Release.xcconfig +++ b/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/ios/Podfile b/ios/Podfile new file mode 100644 index 0000000..9411102 --- /dev/null +++ b/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +platform :ios, '10.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/ios/Podfile.lock b/ios/Podfile.lock new file mode 100644 index 0000000..6d526b2 --- /dev/null +++ b/ios/Podfile.lock @@ -0,0 +1,421 @@ +PODS: + - abseil/algorithm (0.20200225.0): + - abseil/algorithm/algorithm (= 0.20200225.0) + - abseil/algorithm/container (= 0.20200225.0) + - abseil/algorithm/algorithm (0.20200225.0): + - abseil/base/config + - abseil/algorithm/container (0.20200225.0): + - abseil/algorithm/algorithm + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/base (0.20200225.0): + - abseil/base/atomic_hook (= 0.20200225.0) + - abseil/base/base (= 0.20200225.0) + - abseil/base/base_internal (= 0.20200225.0) + - abseil/base/bits (= 0.20200225.0) + - abseil/base/config (= 0.20200225.0) + - abseil/base/core_headers (= 0.20200225.0) + - abseil/base/dynamic_annotations (= 0.20200225.0) + - abseil/base/endian (= 0.20200225.0) + - abseil/base/errno_saver (= 0.20200225.0) + - abseil/base/exponential_biased (= 0.20200225.0) + - abseil/base/log_severity (= 0.20200225.0) + - abseil/base/malloc_internal (= 0.20200225.0) + - abseil/base/periodic_sampler (= 0.20200225.0) + - abseil/base/pretty_function (= 0.20200225.0) + - abseil/base/raw_logging_internal (= 0.20200225.0) + - abseil/base/spinlock_wait (= 0.20200225.0) + - abseil/base/throw_delegate (= 0.20200225.0) + - abseil/base/atomic_hook (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/base (0.20200225.0): + - abseil/base/atomic_hook + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/log_severity + - abseil/base/raw_logging_internal + - abseil/base/spinlock_wait + - abseil/meta/type_traits + - abseil/base/base_internal (0.20200225.0): + - abseil/base/config + - abseil/meta/type_traits + - abseil/base/bits (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/config (0.20200225.0) + - abseil/base/core_headers (0.20200225.0): + - abseil/base/config + - abseil/base/dynamic_annotations (0.20200225.0) + - abseil/base/endian (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/errno_saver (0.20200225.0): + - abseil/base/config + - abseil/base/exponential_biased (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/log_severity (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/malloc_internal (0.20200225.0): + - abseil/base/base + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/base/dynamic_annotations + - abseil/base/raw_logging_internal + - abseil/base/periodic_sampler (0.20200225.0): + - abseil/base/core_headers + - abseil/base/exponential_biased + - abseil/base/pretty_function (0.20200225.0) + - abseil/base/raw_logging_internal (0.20200225.0): + - abseil/base/atomic_hook + - abseil/base/config + - abseil/base/core_headers + - abseil/base/log_severity + - abseil/base/spinlock_wait (0.20200225.0): + - abseil/base/base_internal + - abseil/base/core_headers + - abseil/base/errno_saver + - abseil/base/throw_delegate (0.20200225.0): + - abseil/base/config + - abseil/base/raw_logging_internal + - abseil/container/compressed_tuple (0.20200225.0): + - abseil/utility/utility + - abseil/container/inlined_vector (0.20200225.0): + - abseil/algorithm/algorithm + - abseil/base/core_headers + - abseil/base/throw_delegate + - abseil/container/inlined_vector_internal + - abseil/memory/memory + - abseil/container/inlined_vector_internal (0.20200225.0): + - abseil/base/core_headers + - abseil/container/compressed_tuple + - abseil/memory/memory + - abseil/meta/type_traits + - abseil/types/span + - abseil/memory (0.20200225.0): + - abseil/memory/memory (= 0.20200225.0) + - abseil/memory/memory (0.20200225.0): + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/meta (0.20200225.0): + - abseil/meta/type_traits (= 0.20200225.0) + - abseil/meta/type_traits (0.20200225.0): + - abseil/base/config + - abseil/numeric/int128 (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/strings/internal (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/base/endian + - abseil/base/raw_logging_internal + - abseil/meta/type_traits + - abseil/strings/str_format (0.20200225.0): + - abseil/strings/str_format_internal + - abseil/strings/str_format_internal (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/numeric/int128 + - abseil/strings/strings + - abseil/types/span + - abseil/strings/strings (0.20200225.0): + - abseil/base/base + - abseil/base/bits + - abseil/base/config + - abseil/base/core_headers + - abseil/base/endian + - abseil/base/raw_logging_internal + - abseil/base/throw_delegate + - abseil/memory/memory + - abseil/meta/type_traits + - abseil/numeric/int128 + - abseil/strings/internal + - abseil/time (0.20200225.0): + - abseil/time/internal (= 0.20200225.0) + - abseil/time/time (= 0.20200225.0) + - abseil/time/internal (0.20200225.0): + - abseil/time/internal/cctz (= 0.20200225.0) + - abseil/time/internal/cctz (0.20200225.0): + - abseil/time/internal/cctz/civil_time (= 0.20200225.0) + - abseil/time/internal/cctz/time_zone (= 0.20200225.0) + - abseil/time/internal/cctz/civil_time (0.20200225.0): + - abseil/base/config + - abseil/time/internal/cctz/time_zone (0.20200225.0): + - abseil/base/config + - abseil/time/internal/cctz/civil_time + - abseil/time/time (0.20200225.0): + - abseil/base/base + - abseil/base/core_headers + - abseil/base/raw_logging_internal + - abseil/numeric/int128 + - abseil/strings/strings + - abseil/time/internal/cctz/civil_time + - abseil/time/internal/cctz/time_zone + - abseil/types (0.20200225.0): + - abseil/types/any (= 0.20200225.0) + - abseil/types/bad_any_cast (= 0.20200225.0) + - abseil/types/bad_any_cast_impl (= 0.20200225.0) + - abseil/types/bad_optional_access (= 0.20200225.0) + - abseil/types/bad_variant_access (= 0.20200225.0) + - abseil/types/compare (= 0.20200225.0) + - abseil/types/optional (= 0.20200225.0) + - abseil/types/span (= 0.20200225.0) + - abseil/types/variant (= 0.20200225.0) + - abseil/types/any (0.20200225.0): + - abseil/base/config + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/types/bad_any_cast + - abseil/utility/utility + - abseil/types/bad_any_cast (0.20200225.0): + - abseil/base/config + - abseil/types/bad_any_cast_impl + - abseil/types/bad_any_cast_impl (0.20200225.0): + - abseil/base/config + - abseil/base/raw_logging_internal + - abseil/types/bad_optional_access (0.20200225.0): + - abseil/base/config + - abseil/base/raw_logging_internal + - abseil/types/bad_variant_access (0.20200225.0): + - abseil/base/config + - abseil/base/raw_logging_internal + - abseil/types/compare (0.20200225.0): + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/types/optional (0.20200225.0): + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/memory/memory + - abseil/meta/type_traits + - abseil/types/bad_optional_access + - abseil/utility/utility + - abseil/types/span (0.20200225.0): + - abseil/algorithm/algorithm + - abseil/base/core_headers + - abseil/base/throw_delegate + - abseil/meta/type_traits + - abseil/types/variant (0.20200225.0): + - abseil/base/base_internal + - abseil/base/config + - abseil/base/core_headers + - abseil/meta/type_traits + - abseil/types/bad_variant_access + - abseil/utility/utility + - abseil/utility/utility (0.20200225.0): + - abseil/base/base_internal + - abseil/base/config + - abseil/meta/type_traits + - AppAuth (1.4.0): + - AppAuth/Core (= 1.4.0) + - AppAuth/ExternalUserAgent (= 1.4.0) + - AppAuth/Core (1.4.0) + - AppAuth/ExternalUserAgent (1.4.0) + - BoringSSL-GRPC (0.0.7): + - BoringSSL-GRPC/Implementation (= 0.0.7) + - BoringSSL-GRPC/Interface (= 0.0.7) + - BoringSSL-GRPC/Implementation (0.0.7): + - BoringSSL-GRPC/Interface (= 0.0.7) + - BoringSSL-GRPC/Interface (0.0.7) + - cloud_firestore (1.0.5): + - Firebase/Firestore (= 7.3.0) + - firebase_core + - Flutter + - Firebase/Auth (7.3.0): + - Firebase/CoreOnly + - FirebaseAuth (~> 7.3.0) + - Firebase/CoreOnly (7.3.0): + - FirebaseCore (= 7.3.0) + - Firebase/Firestore (7.3.0): + - Firebase/CoreOnly + - FirebaseFirestore (~> 7.3.0) + - Firebase/Storage (7.3.0): + - Firebase/CoreOnly + - FirebaseStorage (~> 7.3.0) + - firebase_auth (1.1.0): + - Firebase/Auth (= 7.3.0) + - firebase_core + - Flutter + - firebase_core (1.0.3): + - Firebase/CoreOnly (= 7.3.0) + - Flutter + - firebase_storage (8.0.3): + - Firebase/Storage (= 7.3.0) + - firebase_core + - Flutter + - FirebaseAuth (7.3.0): + - FirebaseCore (~> 7.0) + - GoogleUtilities/AppDelegateSwizzler (~> 7.0) + - GoogleUtilities/Environment (~> 7.0) + - GTMSessionFetcher/Core (~> 1.4) + - FirebaseCore (7.3.0): + - FirebaseCoreDiagnostics (~> 7.0) + - GoogleUtilities/Environment (~> 7.0) + - GoogleUtilities/Logger (~> 7.0) + - FirebaseCoreDiagnostics (7.3.0): + - GoogleDataTransport (~> 8.0) + - GoogleUtilities/Environment (~> 7.0) + - GoogleUtilities/Logger (~> 7.0) + - nanopb (~> 2.30906.0) + - FirebaseFirestore (7.3.0): + - abseil/algorithm (= 0.20200225.0) + - abseil/base (= 0.20200225.0) + - abseil/memory (= 0.20200225.0) + - abseil/meta (= 0.20200225.0) + - abseil/strings/strings (= 0.20200225.0) + - abseil/time (= 0.20200225.0) + - abseil/types (= 0.20200225.0) + - FirebaseCore (~> 7.0) + - "gRPC-C++ (~> 1.28.0)" + - leveldb-library (~> 1.22) + - nanopb (~> 2.30906.0) + - FirebaseStorage (7.3.0): + - FirebaseCore (~> 7.0) + - GTMSessionFetcher/Core (~> 1.4) + - Flutter (1.0.0) + - google_sign_in (0.0.1): + - Flutter + - GoogleSignIn (~> 5.0) + - GoogleDataTransport (8.1.0): + - nanopb (~> 2.30906.0) + - GoogleSignIn (5.0.2): + - AppAuth (~> 1.2) + - GTMAppAuth (~> 1.0) + - GTMSessionFetcher/Core (~> 1.1) + - GoogleUtilities/AppDelegateSwizzler (7.3.1): + - GoogleUtilities/Environment + - GoogleUtilities/Logger + - GoogleUtilities/Network + - GoogleUtilities/Environment (7.3.1): + - PromisesObjC (~> 1.2) + - GoogleUtilities/Logger (7.3.1): + - GoogleUtilities/Environment + - GoogleUtilities/Network (7.3.1): + - GoogleUtilities/Logger + - "GoogleUtilities/NSData+zlib" + - GoogleUtilities/Reachability + - "GoogleUtilities/NSData+zlib (7.3.1)" + - GoogleUtilities/Reachability (7.3.1): + - GoogleUtilities/Logger + - "gRPC-C++ (1.28.2)": + - "gRPC-C++/Implementation (= 1.28.2)" + - "gRPC-C++/Interface (= 1.28.2)" + - "gRPC-C++/Implementation (1.28.2)": + - abseil/container/inlined_vector (= 0.20200225.0) + - abseil/memory/memory (= 0.20200225.0) + - abseil/strings/str_format (= 0.20200225.0) + - abseil/strings/strings (= 0.20200225.0) + - abseil/types/optional (= 0.20200225.0) + - "gRPC-C++/Interface (= 1.28.2)" + - gRPC-Core (= 1.28.2) + - "gRPC-C++/Interface (1.28.2)" + - gRPC-Core (1.28.2): + - gRPC-Core/Implementation (= 1.28.2) + - gRPC-Core/Interface (= 1.28.2) + - gRPC-Core/Implementation (1.28.2): + - abseil/container/inlined_vector (= 0.20200225.0) + - abseil/memory/memory (= 0.20200225.0) + - abseil/strings/str_format (= 0.20200225.0) + - abseil/strings/strings (= 0.20200225.0) + - abseil/types/optional (= 0.20200225.0) + - BoringSSL-GRPC (= 0.0.7) + - gRPC-Core/Interface (= 1.28.2) + - gRPC-Core/Interface (1.28.2) + - GTMAppAuth (1.2.1): + - AppAuth/Core (~> 1.4) + - GTMSessionFetcher/Core (~> 1.5) + - GTMSessionFetcher/Core (1.5.0) + - image_picker (0.0.1): + - Flutter + - leveldb-library (1.22.1) + - nanopb (2.30906.0): + - nanopb/decode (= 2.30906.0) + - nanopb/encode (= 2.30906.0) + - nanopb/decode (2.30906.0) + - nanopb/encode (2.30906.0) + - PromisesObjC (1.2.12) + +DEPENDENCIES: + - cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`) + - firebase_auth (from `.symlinks/plugins/firebase_auth/ios`) + - firebase_core (from `.symlinks/plugins/firebase_core/ios`) + - firebase_storage (from `.symlinks/plugins/firebase_storage/ios`) + - Flutter (from `Flutter`) + - google_sign_in (from `.symlinks/plugins/google_sign_in/ios`) + - image_picker (from `.symlinks/plugins/image_picker/ios`) + +SPEC REPOS: + trunk: + - abseil + - AppAuth + - BoringSSL-GRPC + - Firebase + - FirebaseAuth + - FirebaseCore + - FirebaseCoreDiagnostics + - FirebaseFirestore + - FirebaseStorage + - GoogleDataTransport + - GoogleSignIn + - GoogleUtilities + - "gRPC-C++" + - gRPC-Core + - GTMAppAuth + - GTMSessionFetcher + - leveldb-library + - nanopb + - PromisesObjC + +EXTERNAL SOURCES: + cloud_firestore: + :path: ".symlinks/plugins/cloud_firestore/ios" + firebase_auth: + :path: ".symlinks/plugins/firebase_auth/ios" + firebase_core: + :path: ".symlinks/plugins/firebase_core/ios" + firebase_storage: + :path: ".symlinks/plugins/firebase_storage/ios" + Flutter: + :path: Flutter + google_sign_in: + :path: ".symlinks/plugins/google_sign_in/ios" + image_picker: + :path: ".symlinks/plugins/image_picker/ios" + +SPEC CHECKSUMS: + abseil: 6c8eb7892aefa08d929b39f9bb108e5367e3228f + AppAuth: 31bcec809a638d7bd2f86ea8a52bd45f6e81e7c7 + BoringSSL-GRPC: 8edf627ee524575e2f8d19d56f068b448eea3879 + cloud_firestore: 8887a0c9657c09ca73c9273939c5e6bdb5d7aff2 + Firebase: 26223c695fe322633274198cb19dca8cb7e54416 + firebase_auth: d09964a120e218411768f5ca2d3ce938abd319f2 + firebase_core: b5d81dfd4fb2d6f700e67de34d9a633ae325c4e9 + firebase_storage: 2ce2146c1fa764e68330e6998fa386522c95d199 + FirebaseAuth: c224a0cf1afa0949bd5c7bfcf154b4f5ce8ddef2 + FirebaseCore: 4d3c72622ce0e2106aaa07bb4b2935ba2c370972 + FirebaseCoreDiagnostics: d50e11039e5984d92c8a512be2395f13df747350 + FirebaseFirestore: 1906bf163afdb7c432d2e3b5c40ceb9dd2df5820 + FirebaseStorage: 5002b1895bfe74a5ce92ad54f966e6162d0da2e5 + Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c + google_sign_in: 6bd214b9c154f881422f5fe27b66aaa7bbd580cc + GoogleDataTransport: 116c84c4bdeb76be2a7a46de51244368f9794eab + GoogleSignIn: 7137d297ddc022a7e0aa4619c86d72c909fa7213 + GoogleUtilities: e1d9ed4e544fc32a93e00e721400cbc3f377200d + "gRPC-C++": 13d8ccef97d5c3c441b7e3c529ef28ebee86fad2 + gRPC-Core: 4afa11bfbedf7cdecd04de535a9e046893404ed5 + GTMAppAuth: 5b53231ef6920f149ab84b2969cb0ab572da3077 + GTMSessionFetcher: b3503b20a988c4e20cc189aa798fd18220133f52 + image_picker: 50e7c7ff960e5f58faa4d1f4af84a771c671bc4a + leveldb-library: 50c7b45cbd7bf543c81a468fe557a16ae3db8729 + nanopb: 1bf24dd71191072e120b83dd02d08f3da0d65e53 + PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97 + +PODFILE CHECKSUM: fe0e1ee7f3d1f7d00b11b474b62dd62134535aea + +COCOAPODS: 1.10.1 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 139513d..4304ceb 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -3,13 +3,15 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 8968AC637E32B9BA53AA4AD6 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 893B39976F17BF7174A7E5E3 /* Pods_Runner.framework */; }; + 8CD293C9262C973D0028C733 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 8CD293C8262C973D0028C733 /* GoogleService-Info.plist */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; @@ -29,12 +31,17 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 02DA1C7D3C2E155E0D902DF8 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + 0461B6A1F2CCA3F2A880A396 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 65EBBEEF26CB070A5DD623DE /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 893B39976F17BF7174A7E5E3 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 8CD293C8262C973D0028C733 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -49,12 +56,24 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 8968AC637E32B9BA53AA4AD6 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 6CA65B1BD1675C0FFB65FDF7 /* Pods */ = { + isa = PBXGroup; + children = ( + 0461B6A1F2CCA3F2A880A396 /* Pods-Runner.debug.xcconfig */, + 65EBBEEF26CB070A5DD623DE /* Pods-Runner.release.xcconfig */, + 02DA1C7D3C2E155E0D902DF8 /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -72,6 +91,8 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, + 6CA65B1BD1675C0FFB65FDF7 /* Pods */, + DB293E7CC7A099CCF9269844 /* Frameworks */, ); sourceTree = ""; }; @@ -86,6 +107,7 @@ 97C146F01CF9000F007C117D /* Runner */ = { isa = PBXGroup; children = ( + 8CD293C8262C973D0028C733 /* GoogleService-Info.plist */, 97C146FA1CF9000F007C117D /* Main.storyboard */, 97C146FD1CF9000F007C117D /* Assets.xcassets */, 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, @@ -98,6 +120,14 @@ path = Runner; sourceTree = ""; }; + DB293E7CC7A099CCF9269844 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 893B39976F17BF7174A7E5E3 /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -105,12 +135,15 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + 58385400E981462675A46B9A /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + AD19B4B70A0F6C002C291B94 /* [CP] Embed Pods Frameworks */, + 79A1CC9D3F00DE8A4AA9D815 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -161,6 +194,7 @@ files = ( 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 8CD293C9262C973D0028C733 /* GoogleService-Info.plist in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, ); @@ -183,6 +217,45 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 58385400E981462675A46B9A /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + 79A1CC9D3F00DE8A4AA9D815 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -197,6 +270,23 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + AD19B4B70A0F6C002C291B94 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -290,8 +380,11 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = br.com.lucasgabriel.chat.chat; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = br.com.lucasgabriel.chat; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -399,7 +492,8 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -414,8 +508,11 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = br.com.lucasgabriel.chat.chat; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = br.com.lucasgabriel.chat; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -433,8 +530,11 @@ CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = br.com.lucasgabriel.chat.chat; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = br.com.lucasgabriel.chat; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/ios/Runner.xcworkspace/contents.xcworkspacedata b/ios/Runner.xcworkspace/contents.xcworkspacedata index 1d526a1..21a3cc1 100644 --- a/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + diff --git a/ios/Runner/GoogleService-Info.plist b/ios/Runner/GoogleService-Info.plist new file mode 100644 index 0000000..daee6fe --- /dev/null +++ b/ios/Runner/GoogleService-Info.plist @@ -0,0 +1,36 @@ + + + + + CLIENT_ID + 778715077891-3gi3aopno8dm4kqid3de06mq7c02ps2m.apps.googleusercontent.com + REVERSED_CLIENT_ID + com.googleusercontent.apps.778715077891-3gi3aopno8dm4kqid3de06mq7c02ps2m + ANDROID_CLIENT_ID + 778715077891-8cv2tokv7al69c8ldsjnoasmsss7dsri.apps.googleusercontent.com + API_KEY + AIzaSyA7l7Hq0KeWq99qCzlyeBPlQIhMUL5-o30 + GCM_SENDER_ID + 778715077891 + PLIST_VERSION + 1 + BUNDLE_ID + br.com.lucasgabriel.chat + PROJECT_ID + chat-flutter-4b882 + STORAGE_BUCKET + chat-flutter-4b882.appspot.com + IS_ADS_ENABLED + + IS_ANALYTICS_ENABLED + + IS_APPINVITE_ENABLED + + IS_GCM_ENABLED + + IS_SIGNIN_ENABLED + + GOOGLE_APP_ID + 1:778715077891:ios:4baf94117a6526039a5d36 + + \ No newline at end of file diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 5bec9d5..9bee527 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -41,5 +41,23 @@ UIViewControllerBasedStatusBarAppearance + NSPhotoLibraryUsageDescription + Select picture to send message + NSCameraUsageDescription + Take a picture to send message + NSMicrophoneUsageDescription + Take a picture to send message + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + + com.googleusercontent.apps.778715077891-3gi3aopno8dm4kqid3de06mq7c02ps2m + + + diff --git a/lib/main.dart b/lib/main.dart index e04130f..0ec8e82 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,35 @@ import 'package:flutter/material.dart'; +import 'package:firebase_core/firebase_core.dart'; -void main() {} +import 'package:chat/ui/chat_screen.dart'; + +void main() { + WidgetsFlutterBinding.ensureInitialized(); + runApp(Home()); +} + +class Home extends StatelessWidget { + final Future _firebaseInit = Firebase.initializeApp(); + + @override + Widget build(BuildContext context) { + return FutureBuilder( + future: _firebaseInit, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + return MaterialApp( + title: 'Chat Flutter', + debugShowCheckedModeBanner: false, + theme: ThemeData( + primarySwatch: Colors.green, + iconTheme: IconThemeData(color: Colors.green), + ), + home: ChatScreen(), + ); + } + + return CircularProgressIndicator(); + }, + ); + } +} diff --git a/lib/ui/chat_screen.dart b/lib/ui/chat_screen.dart new file mode 100644 index 0000000..25eab6f --- /dev/null +++ b/lib/ui/chat_screen.dart @@ -0,0 +1,169 @@ +import 'package:flutter/material.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_storage/firebase_storage.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:google_sign_in/google_sign_in.dart'; +import 'dart:io'; + +import 'package:chat/widgets/chat_message.dart'; +import 'package:chat/widgets/input.dart'; + +class ChatScreen extends StatefulWidget { + @override + _ChatScreenState createState() => _ChatScreenState(); +} + +class _ChatScreenState extends State { + final GoogleSignIn googleSignin = GoogleSignIn(); + + User _user; + bool _isLoading = false; + + Future _getUser() async { + try { + if (_user != null) return _user; + + final GoogleSignInAccount googleUser = await GoogleSignIn().signIn(); + final GoogleSignInAuthentication googleAuth = + await googleUser.authentication; + + final GoogleAuthCredential credential = GoogleAuthProvider.credential( + accessToken: googleAuth.accessToken, + idToken: googleAuth.idToken, + ); + + final UserCredential userCredential = + await FirebaseAuth.instance.signInWithCredential(credential); + + final User user = userCredential.user; + + return user; + } catch (error) { + print(error); + return null; + } + } + + void _sendMessage({String value, File file}) async { + final User user = await _getUser(); + + if (user == null) { + Widget snackbar = SnackBar( + content: Text('Login error. Try again.'), + backgroundColor: Colors.red, + ); + + ScaffoldMessenger.of(context).removeCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar(snackbar); + + return; + } + + Map data = { + 'senderUid': user.uid, + 'senderName': user.displayName, + 'senderPhotoUrl': user.photoURL, + 'createdAt': Timestamp.now(), + }; + + if (file != null) { + setState(() { + _isLoading = true; + }); + + UploadTask task = FirebaseStorage.instance + .ref() + .child(user.uid + DateTime.now().millisecondsSinceEpoch.toString()) + .putFile(file); + + TaskSnapshot taskSnapshot = await task.whenComplete(() {}); + String url = await taskSnapshot.ref.getDownloadURL(); + data['imageUrl'] = url; + + setState(() { + _isLoading = false; + }); + } + + if (value != null) { + data['value'] = value; + } + + FirebaseFirestore.instance.collection('messages').add(data); + } + + @override + void initState() { + super.initState(); + + FirebaseAuth.instance.authStateChanges().listen((user) { + setState(() { + _user = user; + }); + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text( + _user != null ? 'Hello, ${_user.displayName}' : 'Chat Flutter'), + actions: [ + if (_user != null) + IconButton( + icon: Icon(Icons.logout), + onPressed: () { + FirebaseAuth.instance.signOut(); + GoogleSignIn().signOut(); + + Widget snackbar = SnackBar( + content: Text('You logged out.'), + ); + + ScaffoldMessenger.of(context).removeCurrentSnackBar(); + ScaffoldMessenger.of(context).showSnackBar(snackbar); + }, + ), + ], + ), + body: Column( + children: [ + Expanded( + child: StreamBuilder( + stream: FirebaseFirestore.instance + .collection('messages') + .orderBy('createdAt') + .snapshots(), + builder: (context, snapshot) { + switch (snapshot.connectionState) { + case ConnectionState.none: + case ConnectionState.waiting: + return Center( + child: CircularProgressIndicator(), + ); + default: + List documentList = + snapshot.data.docs.reversed.toList(); + + return ListView.builder( + itemCount: documentList.length, + reverse: true, + itemBuilder: (context, index) { + return ChatMessage( + documentList[index].data(), + documentList[index].data()['senderUid'] == + _user?.uid); + }, + ); + } + }, + ), + ), + if (_isLoading) LinearProgressIndicator(), + Input(_sendMessage), + ], + ), + ); + } +} diff --git a/lib/widgets/chat_message.dart b/lib/widgets/chat_message.dart new file mode 100644 index 0000000..643ac95 --- /dev/null +++ b/lib/widgets/chat_message.dart @@ -0,0 +1,60 @@ +import 'package:flutter/material.dart'; + +class ChatMessage extends StatelessWidget { + /// Props + /// Message info + final Map data; + + /// Check if message is mine + final bool isOwner; + + /// Constructor + ChatMessage(this.data, this.isOwner); + + @override + Widget build(BuildContext context) { + return Container( + margin: EdgeInsets.symmetric(vertical: 8, horizontal: 8), + child: Row( + children: [ + if (!isOwner) + Container( + padding: EdgeInsets.only(right: 8), + child: CircleAvatar( + backgroundImage: NetworkImage(data['senderPhotoUrl']), + ), + ), + Expanded( + child: Column( + crossAxisAlignment: + isOwner ? CrossAxisAlignment.end : CrossAxisAlignment.start, + children: [ + data['imageUrl'] != null + ? Image.network( + data['imageUrl'], + width: 250, + ) + : Text( + data['value'], + textAlign: isOwner ? TextAlign.end : TextAlign.start, + style: TextStyle(fontSize: 14), + ), + Text( + data['senderName'], + style: TextStyle(fontSize: 10, fontWeight: FontWeight.w300), + ), + ], + ), + ), + if (isOwner) + Container( + padding: EdgeInsets.only(left: 8), + child: CircleAvatar( + backgroundImage: NetworkImage(data['senderPhotoUrl']), + ), + ), + ], + ), + ); + } +} diff --git a/lib/widgets/input.dart b/lib/widgets/input.dart new file mode 100644 index 0000000..7025805 --- /dev/null +++ b/lib/widgets/input.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; +import 'dart:io'; +import 'package:image_picker/image_picker.dart'; + +class Input extends StatefulWidget { + /// Props + /// Send message to Firebase + final Function({String value, File file}) sendMessage; + + /// Constructor + Input(this.sendMessage); + + @override + _InputState createState() => _InputState(); +} + +class _InputState extends State { + bool _isSendEnabled = false; + final TextEditingController _messageController = TextEditingController(); + + void _reset() { + _messageController.clear(); + setState(() { + _isSendEnabled = false; + }); + } + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.all(8), + child: Row( + children: [ + IconButton( + icon: Icon(Icons.photo_camera), + onPressed: () async { + final ImagePicker _picker = ImagePicker(); + final PickedFile response = + await _picker.getImage(source: ImageSource.gallery); + final File file = File(response.path); + + if (response == null) return; + widget.sendMessage(file: file); + }, + ), + Expanded( + child: TextField( + controller: _messageController, + decoration: InputDecoration.collapsed(hintText: 'Send a message'), + onChanged: (value) { + setState(() { + _isSendEnabled = value.isNotEmpty; + }); + }, + onSubmitted: (value) { + widget.sendMessage(value: value); + _reset(); + }, + ), + ), + IconButton( + icon: Icon(Icons.send), + onPressed: _isSendEnabled + ? () { + widget.sendMessage(value: _messageController.text); + _reset(); + } + : null, + ), + ], + ), + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 763ea98..94d0656 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -36,6 +36,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.0" + cloud_firestore: + dependency: "direct main" + description: + name: cloud_firestore + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" + cloud_firestore_platform_interface: + dependency: transitive + description: + name: cloud_firestore_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.1" + cloud_firestore_web: + dependency: transitive + description: + name: cloud_firestore_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" collection: dependency: transitive description: @@ -57,16 +78,161 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + firebase_auth: + dependency: "direct main" + description: + name: firebase_auth + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + firebase_auth_platform_interface: + dependency: transitive + description: + name: firebase_auth_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "4.1.0" + firebase_auth_web: + dependency: transitive + description: + name: firebase_auth_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.6" + firebase_core: + dependency: "direct main" + description: + name: firebase_core + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + firebase_core_platform_interface: + dependency: transitive + description: + name: firebase_core_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" + firebase_core_web: + dependency: transitive + description: + name: firebase_core_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + firebase_storage: + dependency: "direct main" + description: + name: firebase_storage + url: "https://pub.dartlang.org" + source: hosted + version: "8.0.3" + firebase_storage_platform_interface: + dependency: transitive + description: + name: firebase_storage_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + firebase_storage_web: + dependency: transitive + description: + name: firebase_storage_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + google_sign_in: + dependency: "direct main" + description: + name: google_sign_in + url: "https://pub.dartlang.org" + source: hosted + version: "5.0.2" + google_sign_in_platform_interface: + dependency: transitive + description: + name: google_sign_in_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + google_sign_in_web: + dependency: transitive + description: + name: google_sign_in_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.0" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.13.1" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "4.0.0" + image_picker: + dependency: "direct main" + description: + name: image_picker + url: "https://pub.dartlang.org" + source: hosted + version: "0.7.4" + image_picker_for_web: + dependency: transitive + description: + name: image_picker_for_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + image_picker_platform_interface: + dependency: transitive + description: + name: image_picker_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.17.0" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.3" matcher: dependency: transitive description: @@ -88,6 +254,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.11.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + quiver: + dependency: transitive + description: + name: quiver + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" sky_engine: dependency: transitive description: flutter @@ -150,4 +337,5 @@ packages: source: hosted version: "2.1.0" sdks: - dart: ">=2.12.0-0.0 <3.0.0" + dart: ">=2.12.0 <3.0.0" + flutter: ">=1.20.0" diff --git a/pubspec.yaml b/pubspec.yaml index 01495aa..9659d31 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -28,6 +28,12 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + firebase_core: ^1.0.3 + cloud_firestore: ^1.0.5 + firebase_auth: ^1.1.0 + google_sign_in: ^5.0.2 + firebase_storage: ^8.0.3 + image_picker: ^0.7.4 dev_dependencies: flutter_test: diff --git a/web/index.html b/web/index.html index 951a703..14c8970 100644 --- a/web/index.html +++ b/web/index.html @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - chat - - - - + + + + + + + + + chat + + + + - - - + + + + + + + + + + + + + +