diff --git a/chatty/.gitignore b/chatty/.gitignore new file mode 100644 index 0000000..80fbb56 --- /dev/null +++ b/chatty/.gitignore @@ -0,0 +1,43 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json +ios/Runner/GoogleService-Info.plist +android/app/google-services.json diff --git a/chatty/.metadata b/chatty/.metadata new file mode 100644 index 0000000..cd984dd --- /dev/null +++ b/chatty/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 9b2d32b605630f28625709ebd9d78ab3016b2bf6 + channel: stable + +project_type: app diff --git a/chatty/LICENSE b/chatty/LICENSE new file mode 100644 index 0000000..61b67e2 --- /dev/null +++ b/chatty/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2021, Diego Velásquez López +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/chatty/README.md b/chatty/README.md new file mode 100644 index 0000000..0c17de7 --- /dev/null +++ b/chatty/README.md @@ -0,0 +1,41 @@ +# Stream Chatty + +Stream Chatty is a sample chat app made in Flutter using [Stream Chat](https://getstream.io/chat/sdk/flutter/), [Firebase](https://firebase.google.com/), and [flutter_bloc](https://bloclibrary.dev/#/). It has full light and dark mode support, real-time chat, and full authentication using Firebase auth. + +Stream Chatty was created by [Diego Velasquez](http://www.twitter.com/diegoveloper) as part of a Youtube series. A step by step guide to building Stream Chatty from scratch can be found here: + +- Part 1 - https://www.youtube.com/watch?v=H7FjCWHmP9Y => Project Structure, StreamChat, flutter_bloc +- Part 2 - https://www.youtube.com/watch?v=xGXvgrA_vNY => Clean Architecture, dependency injection, auth, storage, chat +- Part 3 - https://www.youtube.com/watch?v=EVvGdFc4SvQ => UI/UX, customizing StreamChat and demo + +> Activate English subtitles + +# Image + +![design](art/fluchat.png?raw=true "Stream Chatty") + + +# Design + +- https://dribbble.com/shots/15263978-Fluchat +- https://projects.invisionapp.com/prototype/Chat-App-cklk8tiia002tqz01u0q1u3cl/play/9ef3ca44 + +# Diego's Networks + +- www.twitter.com/diegoveloper +- www.youtube.com/diegoveloper + +## Features + +- Login using Firebase Auth and Google Sign In +- Upload pictures using Firebase Storage +- Realtime chat using StreamChat package +- Dark mode/Light mode +- State Management using flutter_bloc and cubits + +## Installation + +- Clone project +- Configure Firebase (google-services.json and Google-Service.info.plist files) +- Configure Google Sign In +- Configure your Stream project diff --git a/chatty/android/.gitignore b/chatty/android/.gitignore new file mode 100644 index 0000000..0a741cb --- /dev/null +++ b/chatty/android/.gitignore @@ -0,0 +1,11 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties diff --git a/chatty/android/app/build.gradle b/chatty/android/app/build.gradle new file mode 100644 index 0000000..d2aab44 --- /dev/null +++ b/chatty/android/app/build.gradle @@ -0,0 +1,69 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion 29 + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + lintOptions { + disable 'InvalidPackage' + checkReleaseBuilds false + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.diegoveloper.fluchat" + minSdkVersion 26 + targetSdkVersion 29 + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + minifyEnabled false + useProguard false + shrinkResources false + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} + +apply plugin: 'com.google.gms.google-services' \ No newline at end of file diff --git a/chatty/android/app/src/debug/AndroidManifest.xml b/chatty/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..bda6c33 --- /dev/null +++ b/chatty/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/chatty/android/app/src/main/AndroidManifest.xml b/chatty/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a8a09e4 --- /dev/null +++ b/chatty/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + diff --git a/chatty/android/app/src/main/kotlin/com/diegoveloper/fluchat/MainActivity.kt b/chatty/android/app/src/main/kotlin/com/diegoveloper/fluchat/MainActivity.kt new file mode 100644 index 0000000..51930b7 --- /dev/null +++ b/chatty/android/app/src/main/kotlin/com/diegoveloper/fluchat/MainActivity.kt @@ -0,0 +1,6 @@ +package com.diegoveloper.fluchat + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/chatty/android/app/src/main/res/drawable/launch_background.xml b/chatty/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/chatty/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/chatty/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/chatty/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..db77bb4 Binary files /dev/null and b/chatty/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/chatty/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/chatty/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..17987b7 Binary files /dev/null and b/chatty/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/chatty/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/chatty/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..09d4391 Binary files /dev/null and b/chatty/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/chatty/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/chatty/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..d5f1c8d Binary files /dev/null and b/chatty/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/chatty/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/chatty/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4d6372e Binary files /dev/null and b/chatty/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/chatty/android/app/src/main/res/values/styles.xml b/chatty/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..1f83a33 --- /dev/null +++ b/chatty/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/chatty/android/app/src/profile/AndroidManifest.xml b/chatty/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..bda6c33 --- /dev/null +++ b/chatty/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/chatty/android/build.gradle b/chatty/android/build.gradle new file mode 100644 index 0000000..7372192 --- /dev/null +++ b/chatty/android/build.gradle @@ -0,0 +1,32 @@ +buildscript { + ext.kotlin_version = '1.3.50' + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.0.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'com.google.gms:google-services:4.3.3' + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/chatty/android/gradle.properties b/chatty/android/gradle.properties new file mode 100644 index 0000000..a673820 --- /dev/null +++ b/chatty/android/gradle.properties @@ -0,0 +1,4 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true +android.enableR8=true diff --git a/chatty/android/gradle/wrapper/gradle-wrapper.properties b/chatty/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..493072b --- /dev/null +++ b/chatty/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/chatty/android/settings.gradle b/chatty/android/settings.gradle new file mode 100644 index 0000000..44e62bc --- /dev/null +++ b/chatty/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/chatty/android/settings_aar.gradle b/chatty/android/settings_aar.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/chatty/android/settings_aar.gradle @@ -0,0 +1 @@ +include ':app' diff --git a/chatty/art/fluchat.png b/chatty/art/fluchat.png new file mode 100644 index 0000000..0a7b2e2 Binary files /dev/null and b/chatty/art/fluchat.png differ diff --git a/chatty/assets/icon-bottom-right.png b/chatty/assets/icon-bottom-right.png new file mode 100644 index 0000000..8ec9282 Binary files /dev/null and b/chatty/assets/icon-bottom-right.png differ diff --git a/chatty/assets/icon-google.png b/chatty/assets/icon-google.png new file mode 100644 index 0000000..f9d47fc Binary files /dev/null and b/chatty/assets/icon-google.png differ diff --git a/chatty/assets/icon-top-right.png b/chatty/assets/icon-top-right.png new file mode 100644 index 0000000..0034db3 Binary files /dev/null and b/chatty/assets/icon-top-right.png differ diff --git a/chatty/assets/logo.png b/chatty/assets/logo.png new file mode 100644 index 0000000..296f9b5 Binary files /dev/null and b/chatty/assets/logo.png differ diff --git a/chatty/ios/.gitignore b/chatty/ios/.gitignore new file mode 100644 index 0000000..e96ef60 --- /dev/null +++ b/chatty/ios/.gitignore @@ -0,0 +1,32 @@ +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/chatty/ios/Flutter/AppFrameworkInfo.plist b/chatty/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..4f8d4d2 --- /dev/null +++ b/chatty/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 11.0 + + diff --git a/chatty/ios/Flutter/Debug.xcconfig b/chatty/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..e8efba1 --- /dev/null +++ b/chatty/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/chatty/ios/Flutter/Release.xcconfig b/chatty/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..399e934 --- /dev/null +++ b/chatty/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" diff --git a/chatty/ios/Runner.xcodeproj/project.pbxproj b/chatty/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..3e47d59 --- /dev/null +++ b/chatty/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,609 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 51; + 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 */; }; + 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 */; }; + F5CFF8E625F08BBE00C304A9 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = F5CFF8E525F08BBE00C304A9 /* GoogleService-Info.plist */; }; + FB7765FF5CC347F9C712FA62 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 40B0FCA72C62C135629B3D83 /* Pods_Runner.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 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 = ""; }; + 40B0FCA72C62C135629B3D83 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 7430D861790AE1F50B4E922F /* 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 = ""; }; + 7D7209A1F031C39E3DC3421F /* 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 = ""; }; + 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; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + A8573CD2B6898A29F5C8B294 /* 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 = ""; }; + F5CFF8E525F08BBE00C304A9 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + FB7765FF5CC347F9C712FA62 /* Pods_Runner.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + DF144A162B77171986C53884 /* Pods */, + E16EDD54509B5CAB32FBDFC1 /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + F5CFF8E525F08BBE00C304A9 /* GoogleService-Info.plist */, + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; + DF144A162B77171986C53884 /* Pods */ = { + isa = PBXGroup; + children = ( + 7D7209A1F031C39E3DC3421F /* Pods-Runner.debug.xcconfig */, + 7430D861790AE1F50B4E922F /* Pods-Runner.release.xcconfig */, + A8573CD2B6898A29F5C8B294 /* Pods-Runner.profile.xcconfig */, + ); + path = Pods; + sourceTree = ""; + }; + E16EDD54509B5CAB32FBDFC1 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 40B0FCA72C62C135629B3D83 /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 794C749773D7932A43B8BD34 /* [CP] Check Pods Manifest.lock */, + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + C3991DF06AD2C2FF0E1CACF7 /* [CP] Embed Pods Frameworks */, + 50CF9F5875290FEF1EABAC13 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1020; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + F5CFF8E625F08BBE00C304A9 /* GoogleService-Info.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 50CF9F5875290FEF1EABAC13 /* [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; + }; + 794C749773D7932A43B8BD34 /* [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; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; + C3991DF06AD2C2FF0E1CACF7 /* [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 */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = YPGH95V8AL; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.teamgo.fluchat; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = YPGH95V8AL; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.teamgo.fluchat; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = YPGH95V8AL; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.teamgo.fluchat; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/chatty/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/chatty/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/chatty/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/chatty/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/chatty/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/chatty/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/chatty/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/chatty/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/chatty/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/chatty/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/chatty/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..a28140c --- /dev/null +++ b/chatty/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/chatty/ios/Runner.xcworkspace/contents.xcworkspacedata b/chatty/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..21a3cc1 --- /dev/null +++ b/chatty/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/chatty/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/chatty/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/chatty/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/chatty/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/chatty/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/chatty/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/chatty/ios/Runner/AppDelegate.swift b/chatty/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..70693e4 --- /dev/null +++ b/chatty/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d36b1fa --- /dev/null +++ b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000..dc9ada4 Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000..28c6bf0 Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000..2ccbfd9 Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000..f091b6b Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000..4cde121 Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000..d0ef06e Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000..dcdc230 Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000..2ccbfd9 Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000..c8f9ed8 Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000..a6d6b86 Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..a6d6b86 Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000..75b2d16 Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..c4df70d Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000..6a84f41 Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000..d0e1f58 Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000..0bedcf2 --- /dev/null +++ b/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000..89c2725 --- /dev/null +++ b/chatty/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +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. \ No newline at end of file diff --git a/chatty/ios/Runner/Base.lproj/LaunchScreen.storyboard b/chatty/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f2e259c --- /dev/null +++ b/chatty/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/chatty/ios/Runner/Base.lproj/Main.storyboard b/chatty/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/chatty/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/chatty/ios/Runner/Info.plist b/chatty/ios/Runner/Info.plist new file mode 100644 index 0000000..aff3c30 --- /dev/null +++ b/chatty/ios/Runner/Info.plist @@ -0,0 +1,62 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Chatty + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLSchemes + + com.googleusercontent.apps.880353337418-6ogtdb83ub9sjfovcv2k98dte87fmpnv + + + + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + NSCameraUsageDescription + Used to demonstrate image picker plugin + NSMicrophoneUsageDescription + Used to capture audio for image picker plugin + NSPhotoLibraryUsageDescription + Used to demonstrate image picker plugin + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/chatty/ios/Runner/Runner-Bridging-Header.h b/chatty/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000..308a2a5 --- /dev/null +++ b/chatty/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/chatty/lib/data/auth_repository.dart b/chatty/lib/data/auth_repository.dart new file mode 100644 index 0000000..2ac77e8 --- /dev/null +++ b/chatty/lib/data/auth_repository.dart @@ -0,0 +1,7 @@ +import 'package:stream_chatter/domain/models/auth_user.dart'; + +abstract class AuthRepository { + Future getAuthUser(); + Future signIn(); + Future logout(); +} diff --git a/chatty/lib/data/image_picker_repository.dart b/chatty/lib/data/image_picker_repository.dart new file mode 100644 index 0000000..f5632f0 --- /dev/null +++ b/chatty/lib/data/image_picker_repository.dart @@ -0,0 +1,5 @@ +import 'dart:io'; + +abstract class ImagePickerRepository { + Future pickImage(); +} diff --git a/chatty/lib/data/local/auth_local_impl.dart b/chatty/lib/data/local/auth_local_impl.dart new file mode 100644 index 0000000..c3d4d72 --- /dev/null +++ b/chatty/lib/data/local/auth_local_impl.dart @@ -0,0 +1,21 @@ +import 'package:stream_chatter/data/auth_repository.dart'; +import 'package:stream_chatter/domain/models/auth_user.dart'; + +class AuthLocalImpl extends AuthRepository { + @override + Future getAuthUser() async { + await Future.delayed(const Duration(seconds: 2)); + return AuthUser('diego'); + } + + @override + Future signIn() async { + await Future.delayed(const Duration(seconds: 2)); + return AuthUser('diego'); + } + + @override + Future logout() async { + return; + } +} diff --git a/chatty/lib/data/local/image_picker_impl.dart b/chatty/lib/data/local/image_picker_impl.dart new file mode 100644 index 0000000..21a1b15 --- /dev/null +++ b/chatty/lib/data/local/image_picker_impl.dart @@ -0,0 +1,12 @@ +import 'dart:io'; +import 'package:image_picker/image_picker.dart'; +import 'package:stream_chatter/data/image_picker_repository.dart'; + +class ImagePickerImpl extends ImagePickerRepository { + @override + Future pickImage() async { + final picker = ImagePicker(); + final pickedFile = await picker.getImage(source: ImageSource.gallery, maxWidth: 400); + return File(pickedFile.path); + } +} diff --git a/chatty/lib/data/local/persistent_storage_local_impl.dart b/chatty/lib/data/local/persistent_storage_local_impl.dart new file mode 100644 index 0000000..85d1e4d --- /dev/null +++ b/chatty/lib/data/local/persistent_storage_local_impl.dart @@ -0,0 +1,15 @@ +import 'package:stream_chatter/data/persistent_storage_repository.dart'; + +class PersistentStorageLocalImpl extends PersistentStorageRepository { + @override + Future isDarkMode() async { + await Future.delayed(const Duration(milliseconds: 50)); + return false; + } + + @override + Future updateDarkMode(bool isDarkMode) async { + await Future.delayed(const Duration(milliseconds: 50)); + return; + } +} diff --git a/chatty/lib/data/local/stream_api_local_impl.dart b/chatty/lib/data/local/stream_api_local_impl.dart new file mode 100644 index 0000000..f772a26 --- /dev/null +++ b/chatty/lib/data/local/stream_api_local_impl.dart @@ -0,0 +1,86 @@ +import 'package:stream_chatter/data/stream_api_repository.dart'; +import 'package:stream_chatter/domain/models/chat_user.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; + +class StreamApiLocalImpl extends StreamApiRepository { + StreamApiLocalImpl(this._client); + + final StreamChatClient _client; + + @override + Future connectUser(ChatUser user, String token) async { + Map extraData = {}; + if (user.image != null) { + extraData['image'] = user.image; + } + if (user.name != null) { + extraData['name'] = user.name; + } + await _client.disconnect(); + await _client.connectUser( + User(id: user.id, extraData: extraData), + token, + ); + return user; + } + + @override + Future> getChatUsers() async { + final result = await _client.queryUsers(); + final chatUsers = result.users + .where((element) => element.id != _client.state.user.id) + .map( + (e) => ChatUser( + id: e.id, + name: e.name, + image: e.extraData['image'], + ), + ) + .toList(); + return chatUsers; + } + + @override + Future getToken(String userId) async { + return _client.devToken(userId); + } + + @override + Future createGroupChat(String channelId, String name, List members, {String image}) async { + final channel = _client.channel('messaging', id: channelId, extraData: { + 'name': name, + 'image': image, + 'members': [_client.state.user.id, ...members], + }); + await channel.watch(); + return channel; + } + + @override + Future createSimpleChat(String friendId) async { + final channel = + _client.channel('messaging', id: '${_client.state.user.id.hashCode}${friendId.hashCode}', extraData: { + 'members': [ + friendId, + _client.state.user.id, + ], + }); + await channel.watch(); + return channel; + } + + @override + Future logout() { + return _client.disconnect(); + } + + @override + Future connectIfExist(String userId) async { + final token = await getToken(userId); + await _client.connectUser( + User(id: userId), + token, + ); + return _client.state.user.name != null && _client.state.user.name != userId; + } +} diff --git a/chatty/lib/data/local/upload_storage_local_impl.dart b/chatty/lib/data/local/upload_storage_local_impl.dart new file mode 100644 index 0000000..8a3b804 --- /dev/null +++ b/chatty/lib/data/local/upload_storage_local_impl.dart @@ -0,0 +1,10 @@ +import 'dart:io'; + +import 'package:stream_chatter/data/upload_storage_repository.dart'; + +class UploadStorageLocalImpl extends UploadStorageRepository { + @override + Future uploadPhoto(File file, String path) async { + return 'https://lh3.googleusercontent.com/a-/AOh14GjhqGZ-V7tNXS1pOIp9vbBij4OS9JbzxXgxgy1t=s600-k-no-rp-mo'; + } +} diff --git a/chatty/lib/data/persistent_storage_repository.dart b/chatty/lib/data/persistent_storage_repository.dart new file mode 100644 index 0000000..c061619 --- /dev/null +++ b/chatty/lib/data/persistent_storage_repository.dart @@ -0,0 +1,4 @@ +abstract class PersistentStorageRepository { + Future isDarkMode(); + Future updateDarkMode(bool isDarkMode); +} diff --git a/chatty/lib/data/prod/auth_impl.dart b/chatty/lib/data/prod/auth_impl.dart new file mode 100644 index 0000000..90547bb --- /dev/null +++ b/chatty/lib/data/prod/auth_impl.dart @@ -0,0 +1,41 @@ +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:stream_chatter/data/auth_repository.dart'; +import 'package:stream_chatter/domain/models/auth_user.dart'; +import 'package:google_sign_in/google_sign_in.dart'; + +class AuthImpl extends AuthRepository { + FirebaseAuth _auth = FirebaseAuth.instance; + + @override + Future getAuthUser() async { + final user = _auth.currentUser; + if (user != null) { + return AuthUser(user.uid); + } + return null; + } + + @override + Future signIn() async { + try { + UserCredential userCredential; + final GoogleSignInAccount googleUser = await GoogleSignIn().signIn(); + final GoogleSignInAuthentication googleAuth = await googleUser.authentication; + final GoogleAuthCredential googleAuthCredential = GoogleAuthProvider.credential( + accessToken: googleAuth.accessToken, + idToken: googleAuth.idToken, + ); + userCredential = await _auth.signInWithCredential(googleAuthCredential); + final user = userCredential.user; + return AuthUser(user.uid); + } catch (e) { + print(e); + throw Exception('login error'); + } + } + + @override + Future logout() async { + return _auth.signOut(); + } +} diff --git a/chatty/lib/data/prod/persistent_storage_impl.dart b/chatty/lib/data/prod/persistent_storage_impl.dart new file mode 100644 index 0000000..5d247d5 --- /dev/null +++ b/chatty/lib/data/prod/persistent_storage_impl.dart @@ -0,0 +1,18 @@ +import 'package:stream_chatter/data/persistent_storage_repository.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +const _isDarkMode = 'isDarkMode'; + +class PersistentStorageImpl extends PersistentStorageRepository { + @override + Future isDarkMode() async { + final preference = await SharedPreferences.getInstance(); + return preference.getBool(_isDarkMode) ?? false; + } + + @override + Future updateDarkMode(bool isDarkMode) async { + final preference = await SharedPreferences.getInstance(); + return await preference.setBool(_isDarkMode, isDarkMode); + } +} diff --git a/chatty/lib/data/prod/stream_api_impl.dart b/chatty/lib/data/prod/stream_api_impl.dart new file mode 100644 index 0000000..1bcab14 --- /dev/null +++ b/chatty/lib/data/prod/stream_api_impl.dart @@ -0,0 +1,102 @@ +import 'dart:convert'; + +import 'package:stream_chatter/data/stream_api_repository.dart'; +import 'package:stream_chatter/domain/models/chat_user.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +import 'package:http/http.dart' as http; + +class StreamApiImpl extends StreamApiRepository { + StreamApiImpl(this._client); + + final StreamChatClient _client; + + @override + Future connectUser(ChatUser user, String token) async { + Map extraData = {}; + if (user.image != null) { + extraData['image'] = user.image; + } + if (user.name != null) { + extraData['name'] = user.name; + } + await _client.disconnect(); + await _client.connectUser( + User(id: user.id, extraData: extraData), + token, + ); + return user; + } + + @override + Future> getChatUsers() async { + final result = await _client.queryUsers(); + final chatUsers = result.users + .where((element) => element.id != _client.state.user.id) + .map( + (e) => ChatUser( + id: e.id, + name: e.name, + image: e.extraData['image'], + ), + ) + .toList(); + return chatUsers; + } + + @override + Future getToken(String userId) async { + //TODO: use your own implementation in Production + final response = await http.post( + 'your_backend_url', + body: jsonEncode({'id': userId}), + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + ); + final token = jsonDecode(response.body)['token']; + + //In Development mode you can just use : + // _client.devToken(userId); + + return token; + } + + @override + Future createGroupChat(String id, String name, List members, {String image}) async { + final channel = _client.channel('messaging', id: id, extraData: { + 'name': name, + 'image': image, + 'members': [_client.state.user.id, ...members], + }); + await channel.watch(); + return channel; + } + + @override + Future createSimpleChat(String friendId) async { + final channel = + _client.channel('messaging', id: '${_client.state.user.id.hashCode}${friendId.hashCode}', extraData: { + 'members': [ + friendId, + _client.state.user.id, + ], + }); + await channel.watch(); + return channel; + } + + @override + Future logout() async { + return _client.disconnect(); + } + + @override + Future connectIfExist(String userId) async { + final token = await getToken(userId); + await _client.connectUser( + User(id: userId), + token, + ); + return _client.state.user.name != null && _client.state.user.name != userId; + } +} diff --git a/chatty/lib/data/prod/upload_storage_impl.dart b/chatty/lib/data/prod/upload_storage_impl.dart new file mode 100644 index 0000000..37f6830 --- /dev/null +++ b/chatty/lib/data/prod/upload_storage_impl.dart @@ -0,0 +1,13 @@ +import 'dart:io'; +import 'package:firebase_storage/firebase_storage.dart' as firebase_storage; +import 'package:stream_chatter/data/upload_storage_repository.dart'; + +class UploadStorageImpl extends UploadStorageRepository { + @override + Future uploadPhoto(File file, String path) async { + final ref = firebase_storage.FirebaseStorage.instance.ref(path); + final uploadTask = ref.putFile(file); + await uploadTask; + return await ref.getDownloadURL(); + } +} diff --git a/chatty/lib/data/stream_api_repository.dart b/chatty/lib/data/stream_api_repository.dart new file mode 100644 index 0000000..4ae31cb --- /dev/null +++ b/chatty/lib/data/stream_api_repository.dart @@ -0,0 +1,12 @@ +import 'package:stream_chatter/domain/models/chat_user.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; + +abstract class StreamApiRepository { + Future> getChatUsers(); + Future getToken(String userId); + Future connectIfExist(String userId); + Future connectUser(ChatUser user, String token); + Future createGroupChat(String channelId, String name, List members, {String image}); + Future createSimpleChat(String friendId); + Future logout(); +} diff --git a/chatty/lib/data/upload_storage_repository.dart b/chatty/lib/data/upload_storage_repository.dart new file mode 100644 index 0000000..6876138 --- /dev/null +++ b/chatty/lib/data/upload_storage_repository.dart @@ -0,0 +1,5 @@ +import 'dart:io'; + +abstract class UploadStorageRepository { + Future uploadPhoto(File file, String path); +} diff --git a/chatty/lib/dependencies.dart b/chatty/lib/dependencies.dart new file mode 100644 index 0000000..78a5c7a --- /dev/null +++ b/chatty/lib/dependencies.dart @@ -0,0 +1,56 @@ +import 'package:stream_chatter/data/auth_repository.dart'; +import 'package:stream_chatter/data/image_picker_repository.dart'; +import 'package:stream_chatter/data/local/auth_local_impl.dart'; +import 'package:stream_chatter/data/local/image_picker_impl.dart'; +import 'package:stream_chatter/data/local/persistent_storage_local_impl.dart'; +import 'package:stream_chatter/data/local/stream_api_local_impl.dart'; +import 'package:stream_chatter/data/local/upload_storage_local_impl.dart'; +import 'package:stream_chatter/data/persistent_storage_repository.dart'; +import 'package:stream_chatter/data/prod/auth_impl.dart'; +import 'package:stream_chatter/data/prod/persistent_storage_impl.dart'; +import 'package:stream_chatter/data/prod/stream_api_impl.dart'; +import 'package:stream_chatter/data/prod/upload_storage_impl.dart'; +import 'package:stream_chatter/data/stream_api_repository.dart'; +import 'package:stream_chatter/data/upload_storage_repository.dart'; +import 'package:stream_chatter/domain/usecases/create_group_usecase.dart'; +import 'package:stream_chatter/domain/usecases/login_usecase.dart'; +import 'package:stream_chatter/domain/usecases/logout_usecase.dart'; +import 'package:stream_chatter/domain/usecases/profile_sign_in_usecase.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; + +List buildRepositories(StreamChatClient client) { + //TODO: Here you can use your local implementations of your repositories + return [ + RepositoryProvider(create: (_) => StreamApiImpl(client)), + RepositoryProvider(create: (_) => PersistentStorageImpl()), + RepositoryProvider(create: (_) => AuthImpl()), + RepositoryProvider(create: (_) => UploadStorageImpl()), + RepositoryProvider(create: (_) => ImagePickerImpl()), + RepositoryProvider( + create: (context) => ProfileSignInUseCase( + context.read(), + context.read(), + context.read(), + ), + ), + RepositoryProvider( + create: (context) => CreateGroupUseCase( + context.read(), + context.read(), + ), + ), + RepositoryProvider( + create: (context) => LogoutUseCase( + context.read(), + context.read(), + ), + ), + RepositoryProvider( + create: (context) => LoginUseCase( + context.read(), + context.read(), + ), + ), + ]; +} diff --git a/chatty/lib/domain/exceptions/auth_exception.dart b/chatty/lib/domain/exceptions/auth_exception.dart new file mode 100644 index 0000000..22cbf09 --- /dev/null +++ b/chatty/lib/domain/exceptions/auth_exception.dart @@ -0,0 +1,10 @@ +enum AuthErrorCode { + not_auth, + not_chat_user, +} + +class AuthException implements Exception { + AuthException(this.error); + + final AuthErrorCode error; +} diff --git a/chatty/lib/domain/models/auth_user.dart b/chatty/lib/domain/models/auth_user.dart new file mode 100644 index 0000000..7ffcd9d --- /dev/null +++ b/chatty/lib/domain/models/auth_user.dart @@ -0,0 +1,4 @@ +class AuthUser { + AuthUser(this.id); + final String id; +} diff --git a/chatty/lib/domain/models/chat_user.dart b/chatty/lib/domain/models/chat_user.dart new file mode 100644 index 0000000..05a0a61 --- /dev/null +++ b/chatty/lib/domain/models/chat_user.dart @@ -0,0 +1,6 @@ +class ChatUser { + const ChatUser({this.name, this.image, this.id}); + final String name; + final String image; + final String id; +} diff --git a/chatty/lib/domain/usecases/create_group_usecase.dart b/chatty/lib/domain/usecases/create_group_usecase.dart new file mode 100644 index 0000000..82122a2 --- /dev/null +++ b/chatty/lib/domain/usecases/create_group_usecase.dart @@ -0,0 +1,38 @@ +import 'dart:io'; + +import 'package:stream_chatter/data/stream_api_repository.dart'; +import 'package:stream_chatter/data/upload_storage_repository.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +import 'package:uuid/uuid.dart'; + +class CreateGroupInput { + CreateGroupInput({this.imageFile, this.name, this.members}); + final File imageFile; + final String name; + final List members; +} + +class CreateGroupUseCase { + CreateGroupUseCase( + this._streamApiRepository, + this._uploadStorageRepository, + ); + + final UploadStorageRepository _uploadStorageRepository; + final StreamApiRepository _streamApiRepository; + + Future createGroup(CreateGroupInput input) async { + final channelId = Uuid().v4(); + String image; + if (input.imageFile != null) { + image = await _uploadStorageRepository.uploadPhoto(input.imageFile, 'channels/$channelId'); + } + final channel = await _streamApiRepository.createGroupChat( + channelId, + input.name, + input.members, + image: image, + ); + return channel; + } +} diff --git a/chatty/lib/domain/usecases/login_usecase.dart b/chatty/lib/domain/usecases/login_usecase.dart new file mode 100644 index 0000000..5b0d04d --- /dev/null +++ b/chatty/lib/domain/usecases/login_usecase.dart @@ -0,0 +1,30 @@ +import 'package:stream_chatter/data/auth_repository.dart'; +import 'package:stream_chatter/data/stream_api_repository.dart'; +import 'package:stream_chatter/domain/exceptions/auth_exception.dart'; +import 'package:stream_chatter/domain/models/auth_user.dart'; + +class LoginUseCase { + LoginUseCase(this.authRepository, this.streamApiRepository); + + final AuthRepository authRepository; + final StreamApiRepository streamApiRepository; + + Future validateLogin() async { + print('validateLogin'); + final user = await authRepository.getAuthUser(); + print('user: ${user?.id}'); + if (user != null) { + final result = await streamApiRepository.connectIfExist(user.id); + if (result) { + return true; + } else { + throw AuthException(AuthErrorCode.not_chat_user); + } + } + throw AuthException(AuthErrorCode.not_auth); + } + + Future signIn() async { + return await authRepository.signIn(); + } +} diff --git a/chatty/lib/domain/usecases/logout_usecase.dart b/chatty/lib/domain/usecases/logout_usecase.dart new file mode 100644 index 0000000..96b419e --- /dev/null +++ b/chatty/lib/domain/usecases/logout_usecase.dart @@ -0,0 +1,13 @@ +import 'package:stream_chatter/data/auth_repository.dart'; +import 'package:stream_chatter/data/stream_api_repository.dart'; + +class LogoutUseCase { + LogoutUseCase(this.streamApiRepository, this.authRepository); + final StreamApiRepository streamApiRepository; + final AuthRepository authRepository; + + Future logout() async { + await streamApiRepository.logout(); + await authRepository.logout(); + } +} diff --git a/chatty/lib/domain/usecases/profile_sign_in_usecase.dart b/chatty/lib/domain/usecases/profile_sign_in_usecase.dart new file mode 100644 index 0000000..8450581 --- /dev/null +++ b/chatty/lib/domain/usecases/profile_sign_in_usecase.dart @@ -0,0 +1,34 @@ +import 'dart:io'; + +import 'package:stream_chatter/data/auth_repository.dart'; +import 'package:stream_chatter/data/stream_api_repository.dart'; +import 'package:stream_chatter/data/upload_storage_repository.dart'; +import 'package:stream_chatter/domain/models/chat_user.dart'; + +class ProfileInput { + ProfileInput({this.imageFile, this.name}); + final File imageFile; + final String name; +} + +class ProfileSignInUseCase { + ProfileSignInUseCase( + this._authRepository, + this._streamApiRepository, + this._uploadStorageRepository, + ); + + final AuthRepository _authRepository; + final UploadStorageRepository _uploadStorageRepository; + final StreamApiRepository _streamApiRepository; + + Future verify(ProfileInput input) async { + final auth = await _authRepository.getAuthUser(); + final token = await _streamApiRepository.getToken(auth.id); + String image; + if (input.imageFile != null) { + image = await _uploadStorageRepository.uploadPhoto(input.imageFile, 'users/${auth.id}'); + } + await _streamApiRepository.connectUser(ChatUser(name: input.name, id: auth.id, image: image), token); + } +} diff --git a/chatty/lib/main.dart b/chatty/lib/main.dart new file mode 100644 index 0000000..479c1c8 --- /dev/null +++ b/chatty/lib/main.dart @@ -0,0 +1,50 @@ +import 'package:firebase_core/firebase_core.dart'; +import 'package:stream_chatter/dependencies.dart'; +import 'package:stream_chatter/ui/app_theme_cubit.dart'; +import 'package:stream_chatter/ui/splash/splash_view.dart'; +import 'package:stream_chatter/ui/themes.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + await Firebase.initializeApp(); + runApp(MyApp()); +} + +class MyApp extends StatelessWidget { + final _streamChatClient = StreamChatClient('c2rynysx9x6b'); + + @override + Widget build(BuildContext context) { + SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]); + + return MultiRepositoryProvider( + providers: buildRepositories(_streamChatClient), + child: BlocProvider( + create: (context) => AppThemeCubit(context.read())..init(), + child: BlocBuilder(builder: (context, snapshot) { + return MaterialApp( + title: 'Stream Chatty', + home: SplashView(), + theme: snapshot ? Themes.themeDark : Themes.themeLight, + builder: (context, child) { + return StreamChat( + child: child, + client: _streamChatClient, + streamChatThemeData: StreamChatThemeData.fromTheme(Theme.of(context)).copyWith( + ownMessageTheme: MessageTheme( + messageBackgroundColor: Theme.of(context).accentColor, + messageText: TextStyle(color: Colors.white), + ), + ), + ); + }, + ); + }), + ), + ); + } +} diff --git a/chatty/lib/navigator_utils.dart b/chatty/lib/navigator_utils.dart new file mode 100644 index 0000000..2d5c27f --- /dev/null +++ b/chatty/lib/navigator_utils.dart @@ -0,0 +1,22 @@ +import 'package:flutter/material.dart'; + +Future pushToPage(BuildContext context, Widget widget) async { + await Navigator.of(context).push( + MaterialPageRoute( + builder: (_) => widget, + ), + ); +} + +Future pushAndReplaceToPage(BuildContext context, Widget widget) async { + await Navigator.of(context).pushReplacement( + MaterialPageRoute( + builder: (_) => widget, + ), + ); +} + +Future popAllAndPush(BuildContext context, Widget widget) async { + await Navigator.pushAndRemoveUntil( + context, MaterialPageRoute(builder: (BuildContext context) => widget), ModalRoute.withName('/')); +} diff --git a/chatty/lib/ui/app_theme_cubit.dart b/chatty/lib/ui/app_theme_cubit.dart new file mode 100644 index 0000000..8633aec --- /dev/null +++ b/chatty/lib/ui/app_theme_cubit.dart @@ -0,0 +1,21 @@ +import 'package:stream_chatter/data/persistent_storage_repository.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class AppThemeCubit extends Cubit { + AppThemeCubit(this._persistentStorageRepository) : super(false); + final PersistentStorageRepository _persistentStorageRepository; + + bool _isDark = false; + bool get isDark => _isDark; + + Future init() async { + _isDark = await _persistentStorageRepository.isDarkMode(); + emit(_isDark); + } + + Future updateTheme(bool isDarkMode) async { + _isDark = isDarkMode; + await _persistentStorageRepository.updateDarkMode(isDarkMode); + emit(_isDark); + } +} diff --git a/chatty/lib/ui/common/avatar_image_view.dart b/chatty/lib/ui/common/avatar_image_view.dart new file mode 100644 index 0000000..76ee22a --- /dev/null +++ b/chatty/lib/ui/common/avatar_image_view.dart @@ -0,0 +1,45 @@ +import 'package:flutter/material.dart'; + +class AvatarImageView extends StatelessWidget { + const AvatarImageView({Key key, this.onTap, this.child}) : super(key: key); + final Widget child; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(20.0), + child: Stack( + clipBehavior: Clip.none, + children: [ + ClipOval( + child: Container( + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.grey[100], + ), + height: 180, + width: 180, + child: child, + ), + ), + Positioned( + bottom: -15, + right: 0, + child: GestureDetector( + onTap: onTap, + child: CircleAvatar( + backgroundColor: Colors.white, + radius: 30, + child: Icon( + Icons.camera_alt_outlined, + color: Colors.black, + ), + ), + ), + ), + ], + ), + ); + } +} diff --git a/chatty/lib/ui/common/initial_background_view.dart b/chatty/lib/ui/common/initial_background_view.dart new file mode 100644 index 0000000..4e26bba --- /dev/null +++ b/chatty/lib/ui/common/initial_background_view.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; + +class InitialBackgroundView extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Stack( + children: [ + Positioned( + top: 20, + right: -75, + child: Image.asset( + 'assets/icon-top-right.png', + height: 150, + ), + ), + Positioned( + bottom: -50, + right: -50, + child: Image.asset( + 'assets/icon-bottom-right.png', + height: 200, + ), + ), + ], + ); + } +} diff --git a/chatty/lib/ui/common/loading_view.dart b/chatty/lib/ui/common/loading_view.dart new file mode 100644 index 0000000..9e1cded --- /dev/null +++ b/chatty/lib/ui/common/loading_view.dart @@ -0,0 +1,30 @@ +import 'package:flutter/material.dart'; + +class LoadingView extends StatelessWidget { + final bool isLoading; + final Widget child; + + const LoadingView({ + Key key, + @required this.child, + this.isLoading = false, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Stack( + children: [ + child, + if (isLoading) + Container( + color: Colors.black26, + child: Center( + child: CircularProgressIndicator(), + ), + ), + ], + ), + ); + } +} diff --git a/chatty/lib/ui/common/my_channel_preview.dart b/chatty/lib/ui/common/my_channel_preview.dart new file mode 100644 index 0000000..b561e45 --- /dev/null +++ b/chatty/lib/ui/common/my_channel_preview.dart @@ -0,0 +1,326 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:jiffy/jiffy.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; +import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'; + +/*Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return StreamChannel( + child: widget.channelWidget, + channel: client, + ); + }, + ), + ); + */ + +/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/channel_preview.png) +/// ![screenshot](https://raw.githubusercontent.com/GetStream/stream-chat-flutter/master/screenshots/channel_preview_paint.png) +/// +/// It shows the current [Channel] preview. +/// +/// The widget uses a [StreamBuilder] to render the channel information image as soon as it updates. +/// +/// Usually you don't use this widget as it's the default channel preview used by [ChannelListView]. +/// +/// The widget renders the ui based on the first ancestor of type [StreamChatTheme]. +/// Modify it to change the widget appearance. +class MyChannelPreview extends StatelessWidget { + /// Function called when tapping this widget + final void Function(Channel) onTap; + + /// Function called when long pressing this widget + final void Function(Channel) onLongPress; + + /// Channel displayed + final Channel channel; + + /// The function called when the image is tapped + final VoidCallback onImageTap; + + final String heroTag; + + MyChannelPreview({ + @required this.channel, + Key key, + this.onTap, + this.onLongPress, + this.onImageTap, + this.heroTag, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return StreamBuilder( + stream: channel.isMutedStream, + initialData: channel.isMuted, + builder: (context, snapshot) { + return Opacity( + opacity: snapshot.data ? 0.5 : 1, + child: ListTile( + contentPadding: const EdgeInsets.symmetric( + horizontal: 8, + ), + onTap: () { + if (onTap != null) { + onTap(channel); + } + }, + onLongPress: () { + if (onLongPress != null) { + onLongPress(channel); + } + }, + leading: Material( + child: Hero( + tag: heroTag, + child: StreamChannel( + channel: channel, + child: ChannelImage( + onTap: onImageTap, + ), + ), + ), + ), + title: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible( + child: ChannelName( + textStyle: StreamChatTheme.of(context).channelPreviewTheme.title, + ), + ), + StreamBuilder>( + stream: channel.state.membersStream, + initialData: channel.state.members, + builder: (context, snapshot) { + if (!snapshot.hasData || + snapshot.data.isEmpty || + !snapshot.data.any((Member e) => e.user.id == channel.client.state.user.id)) { + return SizedBox(); + } + return ChannelUnreadIndicator( + channel: channel, + ); + }), + ], + ), + subtitle: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible(child: _buildSubtitle(context)), + Builder( + builder: (context) { + final lastMessage = channel.state.messages.lastWhere( + (m) => !m.isDeleted && m.shadowed != true, + orElse: () => null, + ); + if (lastMessage?.user?.id == StreamChat.of(context).user.id) { + return Padding( + padding: const EdgeInsets.only(right: 4.0), + child: SendingIndicator( + message: lastMessage, + size: StreamChatTheme.of(context).channelPreviewTheme.indicatorIconSize, + isMessageRead: channel.state.read + ?.where((element) => element.user.id != channel.client.state.user.id) + ?.where((element) => element.lastRead.isAfter(lastMessage.createdAt)) + ?.isNotEmpty == + true, + ), + ); + } + return SizedBox(); + }, + ), + _buildDate(context), + ], + ), + ), + ); + }); + } + + Widget _buildDate(BuildContext context) { + return StreamBuilder( + stream: channel.lastMessageAtStream, + initialData: channel.lastMessageAt, + builder: (context, snapshot) { + if (!snapshot.hasData) { + return SizedBox(); + } + final lastMessageAt = snapshot.data.toLocal(); + + String stringDate; + final now = DateTime.now(); + + var startOfDay = DateTime(now.year, now.month, now.day); + + if (lastMessageAt.millisecondsSinceEpoch >= startOfDay.millisecondsSinceEpoch) { + stringDate = Jiffy(lastMessageAt.toLocal()).format('HH:mm'); + } else if (lastMessageAt.millisecondsSinceEpoch >= + startOfDay.subtract(Duration(days: 1)).millisecondsSinceEpoch) { + stringDate = 'Yesterday'; + } else if (startOfDay.difference(lastMessageAt).inDays < 7) { + stringDate = Jiffy(lastMessageAt.toLocal()).EEEE; + } else { + stringDate = Jiffy(lastMessageAt.toLocal()).format('dd/MM/yyyy'); + } + + return Text( + stringDate, + style: StreamChatTheme.of(context).channelPreviewTheme.lastMessageAt, + ); + }, + ); + } + + Widget _buildSubtitle(BuildContext context) { + if (channel.isMuted) { + return Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + StreamSvgIcon.mute( + size: 16, + ), + Text( + ' Channel is muted', + style: StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( + color: StreamChatTheme.of(context).channelPreviewTheme.subtitle.color, + ), + ), + ], + ); + } + return TypingIndicator( + channel: channel, + alternativeWidget: _buildLastMessage(context), + style: StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( + color: StreamChatTheme.of(context).channelPreviewTheme.subtitle.color, + ), + ); + } + + Widget _buildLastMessage(BuildContext context) { + return StreamBuilder>( + stream: channel.state.messagesStream, + initialData: channel.state.messages, + builder: (context, snapshot) { + final lastMessage = snapshot.data?.lastWhere((m) => m.shadowed != true && !m.isDeleted, orElse: () => null); + if (lastMessage == null) { + return SizedBox(); + } + + var text = lastMessage.text; + if (lastMessage.attachments != null) { + final parts = [ + ...lastMessage.attachments.map((e) { + if (e.type == 'image') { + return '📷'; + } else if (e.type == 'video') { + return '🎬'; + } else if (e.type == 'giphy') { + return '[GIF]'; + } + return e == lastMessage.attachments.last ? (e.title ?? 'File') : '${e.title ?? 'File'} , '; + }).where((e) => e != null), + lastMessage.text ?? '', + ]; + + text = parts.join(' '); + } + + return Text.rich( + _getDisplayText( + text, + lastMessage.mentionedUsers, + lastMessage.attachments, + StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( + color: StreamChatTheme.of(context).channelPreviewTheme.subtitle.color, + fontStyle: (lastMessage.isSystem || lastMessage.isDeleted) ? FontStyle.italic : FontStyle.normal), + StreamChatTheme.of(context).channelPreviewTheme.subtitle.copyWith( + color: StreamChatTheme.of(context).channelPreviewTheme.subtitle.color, + fontStyle: (lastMessage.isSystem || lastMessage.isDeleted) ? FontStyle.italic : FontStyle.normal, + fontWeight: FontWeight.bold), + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + ); + }, + ); + } + + TextSpan _getDisplayText(String text, List mentions, List attachments, TextStyle normalTextStyle, + TextStyle mentionsTextStyle) { + var textList = text.split(' '); + var resList = []; + for (var e in textList) { + if (mentions != null && mentions.isNotEmpty && mentions.any((element) => '@${element.name}' == e)) { + resList.add(TextSpan( + text: '$e ', + style: mentionsTextStyle, + )); + } else if (attachments != null && + attachments.isNotEmpty && + attachments.where((e) => e.title != null).any((element) => element.title == e)) { + resList.add(TextSpan( + text: '$e ', + style: normalTextStyle.copyWith(fontStyle: FontStyle.italic), + )); + } else { + resList.add(TextSpan( + text: e == textList.last ? '$e' : '$e ', + style: normalTextStyle, + )); + } + } + + return TextSpan(children: resList); + } +} + +class ChannelUnreadIndicator extends StatelessWidget { + const ChannelUnreadIndicator({ + Key key, + @required this.channel, + }) : super(key: key); + + final Channel channel; + + @override + Widget build(BuildContext context) { + return StreamBuilder( + stream: channel.state.unreadCountStream, + initialData: channel.state.unreadCount, + builder: (context, snapshot) { + if (!snapshot.hasData || snapshot.data == 0) { + return SizedBox(); + } + + return Material( + borderRadius: BorderRadius.circular(8), + color: StreamChatTheme.of(context).channelPreviewTheme.unreadCounterColor, + child: Padding( + padding: const EdgeInsets.only( + left: 5.0, + right: 5.0, + top: 2, + bottom: 1, + ), + child: Center( + child: Text( + '${snapshot.data > 99 ? '99+' : snapshot.data}', + style: TextStyle( + fontSize: 11, + color: Colors.white, + ), + ), + ), + ), + ); + }, + ); + } +} diff --git a/chatty/lib/ui/home/chat/chat_view.dart b/chatty/lib/ui/home/chat/chat_view.dart new file mode 100644 index 0000000..b9f4ea7 --- /dev/null +++ b/chatty/lib/ui/home/chat/chat_view.dart @@ -0,0 +1,160 @@ +import 'package:stream_chatter/ui/common/my_channel_preview.dart'; +import 'package:flutter/material.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; + +class ChatView extends StatelessWidget { + @override + Widget build(BuildContext context) { + final textColor = Theme.of(context).appBarTheme.color; + return Scaffold( + backgroundColor: Theme.of(context).canvasColor, + appBar: AppBar( + title: Text( + 'Chats', + style: TextStyle( + fontSize: 24, + color: textColor, + fontWeight: FontWeight.w800, + ), + ), + centerTitle: false, + elevation: 0, + backgroundColor: Theme.of(context).canvasColor, + ), + body: ChannelsBloc( + child: ChannelListView( + filter: { + 'members': { + '\$in': [StreamChat.of(context).user?.id], + } + }, + sort: [SortOption('last_message_at')], + channelPreviewBuilder: (context, channel) { + return Container( + color: Theme.of(context).canvasColor, + child: MyChannelPreview( + channel: channel, + heroTag: channel.id, + onImageTap: () { + String name; + String image; + final currentUser = StreamChat.of(context).client.state.user; + if (channel.isGroup) { + name = channel.extraData['name']; + image = channel.extraData['image']; + } else { + final friend = + channel.state.members.where((element) => element.userId != currentUser.id).first.user; + name = friend.name; + image = friend.extraData['image']; + } + + return Navigator.of(context).push( + PageRouteBuilder( + barrierColor: Colors.black45, + barrierDismissible: true, + opaque: false, + pageBuilder: (context, animation1, _) { + return FadeTransition( + opacity: animation1, + child: ChatDetailView( + channelId: channel.id, + image: image, + name: name, + ), + ); + }), + ); + }, + onTap: (channel) => { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) { + return StreamChannel( + child: ChannelPage(), + channel: channel, + ); + }, + ), + ) + }, + ), + ); + }, + channelWidget: ChannelPage(), + ), + ), + ); + } +} + +class ChannelPage extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: ChannelHeader(), + body: Column( + children: [ + Expanded( + child: MessageListView(), + ), + MessageInput(), + ], + ), + ); + } +} + +class ChatDetailView extends StatelessWidget { + const ChatDetailView({ + Key key, + this.image, + this.name, + this.channelId, + }) : super(key: key); + + final String image; + final String name; + final String channelId; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: Navigator.of(context).pop, + child: Material( + color: Colors.transparent, + child: Dialog( + backgroundColor: Colors.transparent, + elevation: 0, + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Hero( + tag: channelId, + child: ClipOval( + child: Image.network( + image, + height: 180, + width: 180, + fit: BoxFit.cover, + ), + ), + ), + Text( + name, + style: TextStyle( + fontWeight: FontWeight.w700, + fontSize: 22, + ), + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/chatty/lib/ui/home/chat/selection/friends_selection_cubit.dart b/chatty/lib/ui/home/chat/selection/friends_selection_cubit.dart new file mode 100644 index 0000000..3f35080 --- /dev/null +++ b/chatty/lib/ui/home/chat/selection/friends_selection_cubit.dart @@ -0,0 +1,38 @@ +import 'package:stream_chatter/data/stream_api_repository.dart'; +import 'package:stream_chatter/domain/models/chat_user.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; + +class ChatUserState { + const ChatUserState(this.chatUser, {this.selected = false}); + final ChatUser chatUser; + final bool selected; +} + +class FriendsSelectionCubit extends Cubit> { + FriendsSelectionCubit(this._streamApiRepository) : super([]); + final StreamApiRepository _streamApiRepository; + + List get selectedUsers => state.where((element) => element.selected).toList(); + + Future init() async { + final chatUsers = (await _streamApiRepository.getChatUsers()).map((e) => ChatUserState(e)).toList(); + emit(chatUsers); + } + + void selectUser(ChatUserState chatUser) { + final index = state.indexWhere((element) => element.chatUser.id == chatUser.chatUser.id); + state[index] = ChatUserState(state[index].chatUser, selected: !chatUser.selected); + emit(List.from(state)); + } + + Future createFriendChannel(ChatUserState chatUserState) async { + return await _streamApiRepository.createSimpleChat(chatUserState.chatUser.id); + } +} + +class FriendsGroupCubit extends Cubit { + FriendsGroupCubit() : super(false); + + void changeToGroup() => emit(!state); +} diff --git a/chatty/lib/ui/home/chat/selection/friends_selection_view.dart b/chatty/lib/ui/home/chat/selection/friends_selection_view.dart new file mode 100644 index 0000000..4cafcef --- /dev/null +++ b/chatty/lib/ui/home/chat/selection/friends_selection_view.dart @@ -0,0 +1,190 @@ +import 'package:stream_chatter/navigator_utils.dart'; +import 'package:stream_chatter/ui/home/chat/chat_view.dart'; +import 'package:stream_chatter/ui/home/chat/selection/friends_selection_cubit.dart'; +import 'package:stream_chatter/ui/home/chat/selection/group_selection_view.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; + +class FriendsSelectionView extends StatelessWidget { + void _createFriendChannel(BuildContext context, ChatUserState chatUserState) async { + final channel = await context.read().createFriendChannel(chatUserState); + pushAndReplaceToPage( + context, + Scaffold( + body: StreamChannel( + channel: channel, + child: ChannelPage(), + ), + ), + ); + } + + @override + Widget build(BuildContext context) { + final textColor = Theme.of(context).appBarTheme.color; + final accentColor = Theme.of(context).accentColor; + return MultiBlocProvider( + providers: [ + BlocProvider(create: (context) => FriendsSelectionCubit(context.read())..init()), + BlocProvider(create: (_) => FriendsGroupCubit()), + ], + child: BlocBuilder(builder: (context, isGroup) { + return BlocBuilder>(builder: (context, snapshot) { + final selectedUsers = context.read().selectedUsers; + + return Scaffold( + floatingActionButton: isGroup && selectedUsers.isNotEmpty + ? FloatingActionButton( + child: Icon(Icons.arrow_right_alt_rounded), + onPressed: () { + pushAndReplaceToPage(context, GroupSelectionView(selectedUsers)); + }) + : null, + backgroundColor: Theme.of(context).canvasColor, + body: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10.0, + vertical: 20, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (isGroup) + Row( + children: [ + BackButton( + onPressed: () { + context.read().changeToGroup(); + }, + ), + Text( + 'New Group', + style: TextStyle( + fontSize: 24, + color: textColor, + fontWeight: FontWeight.w800, + ), + ), + ], + ) + else + Row( + children: [ + BackButton( + onPressed: Navigator.of(context).pop, + ), + Text( + 'People', + style: TextStyle( + fontSize: 24, + color: textColor, + fontWeight: FontWeight.w800, + ), + ), + ], + ), + if (!isGroup) + ListTile( + onTap: context.read().changeToGroup, + leading: CircleAvatar( + backgroundColor: accentColor, + child: Icon(Icons.group_outlined), + ), + title: Text('Create group', style: TextStyle(fontWeight: FontWeight.w700)), + subtitle: Text('Talk with 2 or more contacts'), + ) + else if (isGroup && selectedUsers.isEmpty) + Padding( + padding: const EdgeInsets.only(top: 15.0, left: 20.0, bottom: 20), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CircleAvatar( + backgroundColor: Colors.grey[200], + ), + Text( + 'Add a friend', + style: TextStyle( + fontSize: 12, + color: Colors.grey[500], + ), + ), + ], + ), + ) + else + SizedBox( + height: 100, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: selectedUsers.length, + itemBuilder: (context, index) { + final chatUserState = selectedUsers[index]; + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 13.0), + child: Stack( + clipBehavior: Clip.none, + children: [ + Column( + mainAxisSize: MainAxisSize.min, + children: [ + CircleAvatar( + radius: 30, + backgroundImage: NetworkImage(chatUserState.chatUser.image), + ), + Text(chatUserState.chatUser.name), + ], + ), + Positioned( + bottom: 40, + right: -4, + child: InkWell( + onTap: () => context.read().selectUser(chatUserState), + child: CircleAvatar( + radius: 9, + backgroundColor: accentColor, + child: Icon(Icons.close_rounded, size: 12), + ), + ), + ), + ], + ), + ); + })), + Expanded( + child: ListView.builder( + itemCount: snapshot.length, + itemBuilder: (context, index) { + final chatUserState = snapshot[index]; + return ListTile( + onTap: () { + _createFriendChannel(context, chatUserState); + }, + leading: CircleAvatar( + backgroundImage: NetworkImage(chatUserState.chatUser.image), + ), + title: Text(chatUserState.chatUser.name), + trailing: isGroup + ? Checkbox( + value: chatUserState.selected, + onChanged: (val) { + print('select user for group'); + context.read().selectUser(chatUserState); + }, + ) + : null, + ); + }, + ), + ), + ], + ), + ), + ); + }); + }), + ); + } +} diff --git a/chatty/lib/ui/home/chat/selection/group_selection_cubit.dart b/chatty/lib/ui/home/chat/selection/group_selection_cubit.dart new file mode 100644 index 0000000..79ac5eb --- /dev/null +++ b/chatty/lib/ui/home/chat/selection/group_selection_cubit.dart @@ -0,0 +1,47 @@ +import 'dart:io'; + +import 'package:stream_chatter/data/image_picker_repository.dart'; +import 'package:stream_chatter/domain/usecases/create_group_usecase.dart'; +import 'package:stream_chatter/ui/home/chat/selection/friends_selection_cubit.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; + +class GroupSelectionState { + const GroupSelectionState( + this.file, { + this.channel, + this.isLoading = false, + }); + final File file; + final Channel channel; + final bool isLoading; +} + +class GroupSelectionCubit extends Cubit { + GroupSelectionCubit( + this.members, + this._createGroupUseCase, + this._imagePickerRepository, + ) : super(GroupSelectionState(null)); + + final nameTextController = TextEditingController(); + final List members; + final CreateGroupUseCase _createGroupUseCase; + final ImagePickerRepository _imagePickerRepository; + + void createGroup() async { + emit(GroupSelectionState(state.file, isLoading: true)); + final channel = await _createGroupUseCase.createGroup(CreateGroupInput( + imageFile: state.file, + members: members.map((e) => e.chatUser.id).toList(), + name: nameTextController.text, + )); + emit(GroupSelectionState(state.file, channel: channel, isLoading: false)); + } + + void pickImage() async { + final image = await _imagePickerRepository.pickImage(); + emit(GroupSelectionState(image)); + } +} diff --git a/chatty/lib/ui/home/chat/selection/group_selection_view.dart b/chatty/lib/ui/home/chat/selection/group_selection_view.dart new file mode 100644 index 0000000..7f336f9 --- /dev/null +++ b/chatty/lib/ui/home/chat/selection/group_selection_view.dart @@ -0,0 +1,117 @@ +import 'package:stream_chatter/navigator_utils.dart'; +import 'package:stream_chatter/ui/common/avatar_image_view.dart'; +import 'package:stream_chatter/ui/common/loading_view.dart'; +import 'package:stream_chatter/ui/home/chat/chat_view.dart'; +import 'package:stream_chatter/ui/home/chat/selection/friends_selection_cubit.dart'; +import 'package:stream_chatter/ui/home/chat/selection/group_selection_cubit.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; + +class GroupSelectionView extends StatelessWidget { + GroupSelectionView(this.selectedUsers); + + final List selectedUsers; + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (context) => GroupSelectionCubit( + selectedUsers, + context.read(), + context.read(), + ), + child: BlocConsumer(listener: (context, snapshot) { + if (snapshot.channel != null) { + pushAndReplaceToPage( + context, + Scaffold( + body: StreamChannel( + channel: snapshot.channel, + child: ChannelPage(), + ), + ), + ); + } + }, builder: (context, snapshot) { + return LoadingView( + isLoading: snapshot.isLoading, + child: Scaffold( + floatingActionButton: FloatingActionButton( + child: Icon(Icons.arrow_right_alt_rounded), + onPressed: context.read().createGroup, + ), + backgroundColor: Theme.of(context).canvasColor, + appBar: AppBar( + title: Text( + 'New Group', + style: TextStyle( + fontSize: 24, + color: Theme.of(context).appBarTheme.color, + fontWeight: FontWeight.w800, + ), + ), + centerTitle: false, + elevation: 0, + backgroundColor: Theme.of(context).canvasColor, + ), + body: Column( + children: [ + AvatarImageView( + onTap: context.read().pickImage, + child: snapshot?.file != null + ? Image.file( + snapshot?.file, + fit: BoxFit.cover, + ) + : Icon( + Icons.person_outline, + size: 100, + color: Colors.grey[400], + ), + ), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 50.0, + vertical: 20, + ), + child: TextField( + controller: context.read().nameTextController, + decoration: InputDecoration( + fillColor: Theme.of(context).bottomNavigationBarTheme.backgroundColor, + hintText: 'Name of the group', + hintStyle: TextStyle( + fontSize: 13, + color: Colors.grey[400], + ), + border: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ), + Wrap( + children: List.generate(selectedUsers.length, (index) { + final chatUserState = selectedUsers[index]; + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 10.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + CircleAvatar( + radius: 30, + backgroundImage: NetworkImage(chatUserState.chatUser.image), + ), + Text(chatUserState.chatUser.name), + ], + ), + ); + }), + ), + ], + ), + ), + ); + }), + ); + } +} diff --git a/chatty/lib/ui/home/home_cubit.dart b/chatty/lib/ui/home/home_cubit.dart new file mode 100644 index 0000000..a3af8da --- /dev/null +++ b/chatty/lib/ui/home/home_cubit.dart @@ -0,0 +1,7 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; + +class HomeCubit extends Cubit { + HomeCubit() : super(0); + + void onChangeTab(int index) => emit(index); +} diff --git a/chatty/lib/ui/home/home_view.dart b/chatty/lib/ui/home/home_view.dart new file mode 100644 index 0000000..5199415 --- /dev/null +++ b/chatty/lib/ui/home/home_view.dart @@ -0,0 +1,139 @@ +import 'package:stream_chatter/navigator_utils.dart'; +import 'package:stream_chatter/ui/home/chat/chat_view.dart'; +import 'package:stream_chatter/ui/home/chat/selection/friends_selection_view.dart'; +import 'package:stream_chatter/ui/home/home_cubit.dart'; +import 'package:stream_chatter/ui/home/settings/settings_view.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class HomeView extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Theme.of(context).canvasColor, + body: BlocProvider( + create: (_) => HomeCubit(), + child: Column( + children: [ + Expanded( + child: BlocBuilder(builder: (context, snapshot) { + return IndexedStack( + index: snapshot, + children: [ + ChatView(), + SettingsView(), + ], + ); + }), + ), + HomeNavigationBar(), + ], + ), + ), + ); + } +} + +class HomeNavigationBar extends StatelessWidget { + const HomeNavigationBar({ + Key key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + final cubit = BlocProvider.of(context, listen: true); + final navigationBarSize = 80.0; + final buttonSize = 56.0; + final buttonMargin = 4.0; + final topMargin = buttonSize / 2 + buttonMargin / 2; + final canvasColor = Theme.of(context).canvasColor; + return Padding( + padding: const EdgeInsets.only(bottom: 20.0), + child: Material( + child: Container( + height: navigationBarSize + topMargin, + width: MediaQuery.of(context).size.width * 0.7, + color: canvasColor, + child: Stack( + children: [ + Positioned.fill( + top: topMargin, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(25), + color: Theme.of(context).bottomNavigationBarTheme.backgroundColor, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + _HomeNavItem( + text: 'Chats', + iconData: Icons.chat_bubble, + onTap: () => cubit.onChangeTab(0), + selected: cubit.state == 0, + ), + _HomeNavItem( + text: 'Settings', + iconData: Icons.settings, + onTap: () => cubit.onChangeTab(1), + selected: cubit.state == 1, + ), + ], + ), + ), + ), + Align( + alignment: Alignment.topCenter, + child: Container( + decoration: BoxDecoration( + color: canvasColor, + shape: BoxShape.circle, + ), + padding: EdgeInsets.all(buttonMargin / 2), + child: FloatingActionButton( + onPressed: () { + pushToPage(context, FriendsSelectionView()); + }, + child: Icon(Icons.add), + ), + ), + ), + ], + ), + ), + ), + ); + } +} + +class _HomeNavItem extends StatelessWidget { + const _HomeNavItem({ + Key key, + this.iconData, + this.text, + this.onTap, + this.selected = false, + }) : super(key: key); + + final IconData iconData; + final String text; + final VoidCallback onTap; + final bool selected; + + @override + Widget build(BuildContext context) { + final selectedColor = Theme.of(context).bottomNavigationBarTheme.selectedItemColor; + final unselectedColor = Theme.of(context).bottomNavigationBarTheme.unselectedItemColor; + final color = selected ? selectedColor : unselectedColor; + return GestureDetector( + onTap: onTap, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(iconData, color: color), + Text(text, style: TextStyle(color: color)), + ], + ), + ); + } +} diff --git a/chatty/lib/ui/home/settings/settings_cubit.dart b/chatty/lib/ui/home/settings/settings_cubit.dart new file mode 100644 index 0000000..465f04e --- /dev/null +++ b/chatty/lib/ui/home/settings/settings_cubit.dart @@ -0,0 +1,19 @@ +import 'package:stream_chatter/domain/usecases/logout_usecase.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class SettingsSwitchCubit extends Cubit { + SettingsSwitchCubit(bool state) : super(state); + + void onChangeDarkMode(bool isDark) => emit(isDark); +} + +class SettingsLogoutCubit extends Cubit { + SettingsLogoutCubit(this._logoutUseCase) : super(null); + + final LogoutUseCase _logoutUseCase; + + void logOut() async { + await _logoutUseCase.logout(); + emit(null); + } +} diff --git a/chatty/lib/ui/home/settings/settings_view.dart b/chatty/lib/ui/home/settings/settings_view.dart new file mode 100644 index 0000000..77ce96a --- /dev/null +++ b/chatty/lib/ui/home/settings/settings_view.dart @@ -0,0 +1,119 @@ +import 'package:stream_chatter/navigator_utils.dart'; +import 'package:stream_chatter/ui/app_theme_cubit.dart'; +import 'package:stream_chatter/ui/common/avatar_image_view.dart'; +import 'package:stream_chatter/ui/home/settings/settings_cubit.dart'; +import 'package:stream_chatter/ui/sign_in/sign_in_view.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:stream_chat_flutter/stream_chat_flutter.dart'; + +class SettingsView extends StatelessWidget { + @override + Widget build(BuildContext context) { + final user = StreamChat.of(context).client.state.user; + final image = user?.extraData['image']; + final textColor = Theme.of(context).appBarTheme.color; + return MultiBlocProvider( + providers: [ + BlocProvider( + create: (_) => SettingsSwitchCubit(context.read().isDark), + ), + BlocProvider( + create: (_) => SettingsLogoutCubit(context.read()), + ), + ], + child: Scaffold( + backgroundColor: Theme.of(context).canvasColor, + appBar: AppBar( + title: Text( + 'Settings', + style: TextStyle( + fontSize: 24, + color: textColor, + fontWeight: FontWeight.w800, + ), + ), + centerTitle: false, + elevation: 0, + backgroundColor: Theme.of(context).canvasColor, + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(15.0), + child: Column( + children: [ + AvatarImageView( + //TODO: implement change avatar + onTap: () => null, + child: image != null + ? Image.network( + image, + fit: BoxFit.cover, + ) + : Icon( + Icons.person_outline, + size: 100, + color: Colors.grey[400], + ), + ), + Text( + user.name, + style: TextStyle( + fontSize: 24, + color: textColor, + fontWeight: FontWeight.w800, + ), + ), + Row( + children: [ + Icon(Icons.nights_stay_outlined), + const SizedBox(width: 10), + Text( + 'Dark Mode', + style: TextStyle( + color: textColor, + ), + ), + Spacer(), + BlocBuilder(builder: (context, snapshot) { + return Switch( + value: snapshot, + onChanged: (val) { + context.read().onChangeDarkMode(val); + context.read().updateTheme(val); + }, + ); + }), + ], + ), + const SizedBox(height: 15), + Builder(builder: (context) { + return GestureDetector( + onTap: context.read().logOut, + child: BlocListener( + listener: (context, snapshot) { + popAllAndPush(context, SignInView()); + }, + child: Row(children: [ + Icon(Icons.logout), + const SizedBox(width: 10), + Text( + 'Logout', + style: TextStyle( + color: textColor, + ), + ), + Spacer(), + Icon(Icons.arrow_right), + ]), + ), + ); + }), + ], + ), + ), + ), + ), + ); + } +} diff --git a/chatty/lib/ui/profile_verify/profile_verify_cubit.dart b/chatty/lib/ui/profile_verify/profile_verify_cubit.dart new file mode 100644 index 0000000..2593f36 --- /dev/null +++ b/chatty/lib/ui/profile_verify/profile_verify_cubit.dart @@ -0,0 +1,44 @@ +import 'dart:io'; + +import 'package:stream_chatter/data/image_picker_repository.dart'; +import 'package:stream_chatter/domain/usecases/profile_sign_in_usecase.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class ProfileState { + const ProfileState( + this.file, { + this.success = false, + this.loading = false, + }); + final File file; + final bool success; + final bool loading; +} + +class ProfileVerifyCubit extends Cubit { + ProfileVerifyCubit( + this._imagePickerRepository, + this._profileSignInUseCase, + ) : super(ProfileState(null)); + + final nameController = TextEditingController(); + final ImagePickerRepository _imagePickerRepository; + final ProfileSignInUseCase _profileSignInUseCase; + + void startChatting() async { + emit(ProfileState(null, loading: true)); + final file = state.file; + final name = nameController.text; + await _profileSignInUseCase.verify(ProfileInput( + imageFile: file, + name: name, + )); + emit(ProfileState(file, success: true, loading: false)); + } + + void pickImage() async { + final file = await _imagePickerRepository.pickImage(); + emit(ProfileState(file)); + } +} diff --git a/chatty/lib/ui/profile_verify/profile_verify_view.dart b/chatty/lib/ui/profile_verify/profile_verify_view.dart new file mode 100644 index 0000000..3a475c3 --- /dev/null +++ b/chatty/lib/ui/profile_verify/profile_verify_view.dart @@ -0,0 +1,108 @@ +import 'package:stream_chatter/navigator_utils.dart'; +import 'package:stream_chatter/ui/common/avatar_image_view.dart'; +import 'package:stream_chatter/ui/common/loading_view.dart'; +import 'package:stream_chatter/ui/home/home_view.dart'; +import 'package:stream_chatter/ui/profile_verify/profile_verify_cubit.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class ProfileVerifyView extends StatelessWidget { + ProfileVerifyView(); + + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (context) => ProfileVerifyCubit(context.read(), context.read()), + child: BlocConsumer(listener: (context, snapshot) { + if (snapshot.success) { + pushAndReplaceToPage(context, HomeView()); + } + }, builder: (context, snapshot) { + //refresh the photo + return LoadingView( + isLoading: snapshot.loading, + child: Scaffold( + backgroundColor: Theme.of(context).canvasColor, + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'Verify your identity', + style: TextStyle( + fontSize: 24, + fontWeight: FontWeight.w800, + ), + ), + AvatarImageView( + onTap: context.read().pickImage, + child: snapshot.file != null + ? Image.file( + snapshot.file, + fit: BoxFit.cover, + ) + : Icon( + Icons.person_outline, + size: 100, + color: Colors.grey[400], + ), + ), + Text( + 'Your name', + style: TextStyle( + fontWeight: FontWeight.w700, + ), + ), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 50.0, + vertical: 20, + ), + child: TextField( + controller: context.read().nameController, + decoration: InputDecoration( + fillColor: Theme.of(context).bottomNavigationBarTheme.backgroundColor, + hintText: 'Or just how people now you', + hintStyle: TextStyle( + fontSize: 13, + color: Colors.grey[400], + ), + border: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ), + Hero( + tag: 'home_hero', + child: Material( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + color: Theme.of(context).accentColor, + child: InkWell( + onTap: () { + context.read().startChatting(); + }, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 40.0, + vertical: 15, + ), + child: Text( + 'Start chatting now', + style: TextStyle( + color: Colors.white, + ), + ), + )), + ), + ), + ], + ), + ), + ), + ); + }), + ); + } +} diff --git a/chatty/lib/ui/sign_in/sign_in_cubit.dart b/chatty/lib/ui/sign_in/sign_in_cubit.dart new file mode 100644 index 0000000..af3eb17 --- /dev/null +++ b/chatty/lib/ui/sign_in/sign_in_cubit.dart @@ -0,0 +1,30 @@ +import 'package:stream_chatter/domain/exceptions/auth_exception.dart'; +import 'package:stream_chatter/domain/usecases/login_usecase.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +enum SignInState { + none, + existing_user, +} + +class SignInCubit extends Cubit { + SignInCubit( + this._loginUseCase, + ) : super(SignInState.none); + + final LoginUseCase _loginUseCase; + + void signIn() async { + try { + final result = await _loginUseCase.validateLogin(); + if (result) { + emit(SignInState.existing_user); + } + } catch (ex) { + final result = await _loginUseCase.signIn(); + if (result != null) { + emit(SignInState.none); + } + } + } +} diff --git a/chatty/lib/ui/sign_in/sign_in_view.dart b/chatty/lib/ui/sign_in/sign_in_view.dart new file mode 100644 index 0000000..41ff317 --- /dev/null +++ b/chatty/lib/ui/sign_in/sign_in_view.dart @@ -0,0 +1,100 @@ +import 'package:stream_chatter/navigator_utils.dart'; +import 'package:stream_chatter/ui/home/home_view.dart'; +import 'package:stream_chatter/ui/profile_verify/profile_verify_view.dart'; +import 'package:stream_chatter/ui/sign_in/sign_in_cubit.dart'; +import 'package:stream_chatter/ui/common/initial_background_view.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class SignInView extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (context) => SignInCubit(context.read()), + child: BlocConsumer(listener: (context, snapshot) { + if (snapshot == SignInState.none) { + pushAndReplaceToPage(context, ProfileVerifyView()); + } else { + pushAndReplaceToPage(context, HomeView()); + } + }, builder: (context, snapshot) { + return Scaffold( + backgroundColor: Theme.of(context).canvasColor, + body: Stack(children: [ + InitialBackgroundView(), + Padding( + padding: const EdgeInsets.only(left: 25.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 150), + Hero( + tag: 'logo_hero', + child: Image.asset( + 'assets/logo.png', + height: 50, + ), + ), + const SizedBox(height: 30), + Text( + 'Welcome to\nChatty', + style: TextStyle( + fontSize: 30, + fontWeight: FontWeight.w900, + ), + ), + Padding( + padding: const EdgeInsets.only(top: 8.0, bottom: 40), + child: Text( + 'A platform to chat with users very easily and friendly', + style: TextStyle( + fontWeight: FontWeight.w600, + color: Colors.grey, + ), + ), + ), + Material( + elevation: 2, + shadowColor: Colors.black45, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + ), + color: Theme.of(context).bottomNavigationBarTheme.backgroundColor, + child: InkWell( + onTap: () { + context.read().signIn(); + }, + child: Padding( + padding: const EdgeInsets.all(20.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset('assets/icon-google.png', height: 20), + const SizedBox(width: 15), + Text('Login with Google'), + ], + ), + ), + ), + ), + Spacer(), + Align( + alignment: Alignment.bottomLeft, + child: Text( + '"in the modern world the\nquality of life is the quality\nof communication', + style: TextStyle( + fontWeight: FontWeight.w400, + color: Colors.grey, + ), + ), + ), + const SizedBox(height: 20), + ], + ), + ), + ]), + ); + }), + ); + } +} diff --git a/chatty/lib/ui/splash/splash_cubit.dart b/chatty/lib/ui/splash/splash_cubit.dart new file mode 100644 index 0000000..1b5fbc9 --- /dev/null +++ b/chatty/lib/ui/splash/splash_cubit.dart @@ -0,0 +1,32 @@ +import 'package:stream_chatter/domain/exceptions/auth_exception.dart'; +import 'package:stream_chatter/domain/usecases/login_usecase.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +enum SplashState { + none, + existing_user, + new_user, +} + +class SplashCubit extends Cubit { + SplashCubit( + this._loginUseCase, + ) : super(SplashState.none); + + final LoginUseCase _loginUseCase; + + void init() async { + try { + final result = await _loginUseCase.validateLogin(); + if (result) { + emit(SplashState.existing_user); + } + } on AuthException catch (ex) { + if (ex.error == AuthErrorCode.not_auth) { + emit(SplashState.none); + } else { + emit(SplashState.new_user); + } + } + } +} diff --git a/chatty/lib/ui/splash/splash_view.dart b/chatty/lib/ui/splash/splash_view.dart new file mode 100644 index 0000000..b9d2ad9 --- /dev/null +++ b/chatty/lib/ui/splash/splash_view.dart @@ -0,0 +1,44 @@ +import 'package:stream_chatter/navigator_utils.dart'; +import 'package:stream_chatter/ui/home/home_view.dart'; +import 'package:stream_chatter/ui/profile_verify/profile_verify_view.dart'; +import 'package:stream_chatter/ui/sign_in/sign_in_view.dart'; +import 'package:stream_chatter/ui/common/initial_background_view.dart'; +import 'package:stream_chatter/ui/splash/splash_cubit.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +class SplashView extends StatelessWidget { + @override + Widget build(BuildContext context) { + return BlocProvider( + create: (context) => SplashCubit(context.read())..init(), + child: BlocListener( + listener: (context, snapshot) { + if (snapshot == SplashState.none) { + pushAndReplaceToPage(context, SignInView()); + } else if (snapshot == SplashState.existing_user) { + pushAndReplaceToPage(context, HomeView()); + } else { + pushAndReplaceToPage(context, ProfileVerifyView()); + } + }, + child: Scaffold( + body: Stack( + children: [ + InitialBackgroundView(), + Center( + child: Hero( + tag: 'logo_hero', + child: Image.asset( + 'assets/logo.png', + height: 100, + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/chatty/lib/ui/themes.dart b/chatty/lib/ui/themes.dart new file mode 100644 index 0000000..c99082d --- /dev/null +++ b/chatty/lib/ui/themes.dart @@ -0,0 +1,54 @@ +import 'package:flutter/material.dart'; + +const primaryColor = Color(0xFF3883FB); +const backgroundLightColor = Color(0xFFFCFCFC); +const backgroundDarkColor = Color(0xFF1F2026); +const navigationBarLightColor = Colors.white; +const navigationBarDarkColor = Color(0xFF30313C); + +class Themes { + static final themeLight = ThemeData.light().copyWith( + backgroundColor: backgroundLightColor, + // selected color + accentColor: primaryColor, + // floating action button + floatingActionButtonTheme: FloatingActionButtonThemeData( + backgroundColor: primaryColor, + foregroundColor: Colors.white, + ), + // bottom bar + bottomNavigationBarTheme: BottomNavigationBarThemeData( + backgroundColor: navigationBarLightColor, + selectedItemColor: primaryColor, + unselectedItemColor: Colors.grey[200], + ), + // switch active color + toggleableActiveColor: primaryColor, + canvasColor: backgroundLightColor, + appBarTheme: AppBarTheme( + color: Colors.black, + )); + + static final themeDark = ThemeData.dark().copyWith( + backgroundColor: backgroundDarkColor, + // selected color + accentColor: primaryColor, + // floating action button + floatingActionButtonTheme: FloatingActionButtonThemeData( + backgroundColor: primaryColor, + foregroundColor: Colors.white, + ), + // bottom bar + bottomNavigationBarTheme: BottomNavigationBarThemeData( + backgroundColor: navigationBarDarkColor, + selectedItemColor: primaryColor, + unselectedItemColor: Colors.grey[300], + ), + textSelectionColor: Colors.white, + // switch active color + toggleableActiveColor: primaryColor, + canvasColor: backgroundDarkColor, + appBarTheme: AppBarTheme( + color: Colors.white, + )); +} diff --git a/chatty/pubspec.yaml b/chatty/pubspec.yaml new file mode 100644 index 0000000..6327bfd --- /dev/null +++ b/chatty/pubspec.yaml @@ -0,0 +1,40 @@ +name: stream_chatter +description: Chat App implemented using Clean Architecture. +publish_to: 'none' +version: 1.0.0+1 + +environment: + sdk: ">=2.7.0 <3.0.0" + +dependencies: + flutter: + sdk: flutter + + flutter_bloc: 6.1.2 + stream_chat_flutter: 1.3.0-beta + uuid: 2.2.2 + + firebase_core: 0.7.0 + google_sign_in: 4.5.9 + firebase_auth: 0.20.0+1 + firebase_storage: 7.0.0 + shared_preferences: 0.5.12+4 + http: any + +dev_dependencies: + flutter_test: + sdk: flutter + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + assets: + - assets/ \ No newline at end of file