diff --git a/Flash Chat iOS13.xcodeproj/project.pbxproj b/Flash Chat iOS13.xcodeproj/project.pbxproj index 57604ade7..46dcff624 100644 --- a/Flash Chat iOS13.xcodeproj/project.pbxproj +++ b/Flash Chat iOS13.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ @@ -17,6 +17,13 @@ 0B62818F235DF01000E35CAF /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B62818E235DF01000E35CAF /* LoginViewController.swift */; }; 0B628191235DF01B00E35CAF /* ChatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B628190235DF01B00E35CAF /* ChatViewController.swift */; }; 0B62819E235F0F4D00E35CAF /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 0B62819D235F0F4D00E35CAF /* README.md */; }; + 7FA5103F0CDC3908FBB438DC /* Pods_Flash_Chat_iOS13.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3ACCDD53FCE88B52F1B41B9E /* Pods_Flash_Chat_iOS13.framework */; }; + 843A1ABA28211E5800E33CFE /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 843A1AB928211E5800E33CFE /* Message.swift */; }; + 84580639281C15DF00084E09 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 84580638281C15DF00084E09 /* GoogleService-Info.plist */; }; + 8458063B281C350300084E09 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8458063A281C350300084E09 /* Constants.swift */; }; + 849B0ECF282129A300FE35AF /* MessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849B0ECD282129A300FE35AF /* MessageCell.swift */; }; + 849B0ED0282129A300FE35AF /* MessageCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 849B0ECE282129A300FE35AF /* MessageCell.xib */; }; + 849B0ED328214C6600FE35AF /* IQKeyboardManagerSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 849B0ED228214C6600FE35AF /* IQKeyboardManagerSwift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -32,6 +39,14 @@ 0B62818E235DF01000E35CAF /* LoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = ""; }; 0B628190235DF01B00E35CAF /* ChatViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatViewController.swift; sourceTree = ""; }; 0B62819D235F0F4D00E35CAF /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; + 3ACCDD53FCE88B52F1B41B9E /* Pods_Flash_Chat_iOS13.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Flash_Chat_iOS13.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 4E5A5E82D8E39ED9DE87CCA0 /* Pods-Flash Chat iOS13.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Flash Chat iOS13.debug.xcconfig"; path = "Target Support Files/Pods-Flash Chat iOS13/Pods-Flash Chat iOS13.debug.xcconfig"; sourceTree = ""; }; + 843A1AB928211E5800E33CFE /* Message.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Message.swift; sourceTree = ""; }; + 84580638281C15DF00084E09 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; + 8458063A281C350300084E09 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; }; + 849B0ECD282129A300FE35AF /* MessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageCell.swift; sourceTree = ""; }; + 849B0ECE282129A300FE35AF /* MessageCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MessageCell.xib; sourceTree = ""; }; + E7251A3155E7B1709B28DA1C /* Pods-Flash Chat iOS13.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Flash Chat iOS13.release.xcconfig"; path = "Target Support Files/Pods-Flash Chat iOS13/Pods-Flash Chat iOS13.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -39,6 +54,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 7FA5103F0CDC3908FBB438DC /* Pods_Flash_Chat_iOS13.framework in Frameworks */, + 849B0ED328214C6600FE35AF /* IQKeyboardManagerSwift in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -51,6 +68,8 @@ 0B62819D235F0F4D00E35CAF /* README.md */, 0B628175235DEE8100E35CAF /* Flash Chat iOS13 */, 0B628174235DEE8100E35CAF /* Products */, + EAC636738F21B7646336FF05 /* Pods */, + 25B8E04F7711789CC93069F5 /* Frameworks */, ); sourceTree = ""; }; @@ -67,12 +86,14 @@ children = ( 0B628176235DEE8100E35CAF /* AppDelegate.swift */, 0B628178235DEE8100E35CAF /* SceneDelegate.swift */, - 0B628194235DF03A00E35CAF /* Models */, + 84A1B8A828171035006CE3E7 /* Model */, 0B628193235DF03400E35CAF /* Views */, 0B628192235DF02000E35CAF /* Controllers */, 0B62817F235DEE8400E35CAF /* Assets.xcassets */, 0B628181235DEE8400E35CAF /* LaunchScreen.storyboard */, 0B628184235DEE8400E35CAF /* Info.plist */, + 84580638281C15DF00084E09 /* GoogleService-Info.plist */, + 8458063A281C350300084E09 /* Constants.swift */, ); path = "Flash Chat iOS13"; sourceTree = ""; @@ -92,15 +113,35 @@ isa = PBXGroup; children = ( 0B62817C235DEE8100E35CAF /* Main.storyboard */, + 849B0ECD282129A300FE35AF /* MessageCell.swift */, + 849B0ECE282129A300FE35AF /* MessageCell.xib */, ); path = Views; sourceTree = ""; }; - 0B628194235DF03A00E35CAF /* Models */ = { + 25B8E04F7711789CC93069F5 /* Frameworks */ = { isa = PBXGroup; children = ( + 3ACCDD53FCE88B52F1B41B9E /* Pods_Flash_Chat_iOS13.framework */, ); - path = Models; + name = Frameworks; + sourceTree = ""; + }; + 84A1B8A828171035006CE3E7 /* Model */ = { + isa = PBXGroup; + children = ( + 843A1AB928211E5800E33CFE /* Message.swift */, + ); + path = Model; + sourceTree = ""; + }; + EAC636738F21B7646336FF05 /* Pods */ = { + isa = PBXGroup; + children = ( + 4E5A5E82D8E39ED9DE87CCA0 /* Pods-Flash Chat iOS13.debug.xcconfig */, + E7251A3155E7B1709B28DA1C /* Pods-Flash Chat iOS13.release.xcconfig */, + ); + path = Pods; sourceTree = ""; }; /* End PBXGroup section */ @@ -110,15 +151,20 @@ isa = PBXNativeTarget; buildConfigurationList = 0B628187235DEE8400E35CAF /* Build configuration list for PBXNativeTarget "Flash Chat iOS13" */; buildPhases = ( + 3A5BFDB1360F452B17496E40 /* [CP] Check Pods Manifest.lock */, 0B62816F235DEE8100E35CAF /* Sources */, 0B628170235DEE8100E35CAF /* Frameworks */, 0B628171235DEE8100E35CAF /* Resources */, + ABE0F76CA8CD6BE2A99EB744 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); dependencies = ( ); name = "Flash Chat iOS13"; + packageProductDependencies = ( + 849B0ED228214C6600FE35AF /* IQKeyboardManagerSwift */, + ); productName = "Flash Chat iOS13"; productReference = 0B628173235DEE8100E35CAF /* Flash Chat iOS13.app */; productType = "com.apple.product-type.application"; @@ -147,6 +193,9 @@ Base, ); mainGroup = 0B62816A235DEE8100E35CAF; + packageReferences = ( + 849B0ED128214C6600FE35AF /* XCRemoteSwiftPackageReference "IQKeyboardManager" */, + ); productRefGroup = 0B628174235DEE8100E35CAF /* Products */; projectDirPath = ""; projectRoot = ""; @@ -162,7 +211,9 @@ buildActionMask = 2147483647; files = ( 0B628183235DEE8400E35CAF /* LaunchScreen.storyboard in Resources */, + 849B0ED0282129A300FE35AF /* MessageCell.xib in Resources */, 0B628180235DEE8400E35CAF /* Assets.xcassets in Resources */, + 84580639281C15DF00084E09 /* GoogleService-Info.plist in Resources */, 0B62819E235F0F4D00E35CAF /* README.md in Resources */, 0B62817E235DEE8100E35CAF /* Main.storyboard in Resources */, ); @@ -170,6 +221,48 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 3A5BFDB1360F452B17496E40 /* [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-Flash Chat iOS13-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; + }; + ABE0F76CA8CD6BE2A99EB744 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Flash Chat iOS13/Pods-Flash Chat iOS13-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Flash Chat iOS13/Pods-Flash Chat iOS13-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Flash Chat iOS13/Pods-Flash Chat iOS13-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 0B62816F235DEE8100E35CAF /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -179,8 +272,11 @@ 0B628177235DEE8100E35CAF /* AppDelegate.swift in Sources */, 0B628179235DEE8100E35CAF /* SceneDelegate.swift in Sources */, 0B62818F235DF01000E35CAF /* LoginViewController.swift in Sources */, + 8458063B281C350300084E09 /* Constants.swift in Sources */, + 843A1ABA28211E5800E33CFE /* Message.swift in Sources */, 0B628191235DF01B00E35CAF /* ChatViewController.swift in Sources */, 0B62818D235DF00B00E35CAF /* RegisterViewController.swift in Sources */, + 849B0ECF282129A300FE35AF /* MessageCell.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -322,16 +418,17 @@ }; 0B628188235DEE8400E35CAF /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 4E5A5E82D8E39ED9DE87CCA0 /* Pods-Flash Chat iOS13.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 3ECFYJZ64T; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "Flash Chat iOS13/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "co.appbrewery.Flash-Chat-iOS13"; + PRODUCT_BUNDLE_IDENTIFIER = com.dsankovsky.FlashChat; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 1; @@ -340,16 +437,17 @@ }; 0B628189235DEE8400E35CAF /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = E7251A3155E7B1709B28DA1C /* Pods-Flash Chat iOS13.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = 3ECFYJZ64T; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "Flash Chat iOS13/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "co.appbrewery.Flash-Chat-iOS13"; + PRODUCT_BUNDLE_IDENTIFIER = com.dsankovsky.FlashChat; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 1; @@ -378,6 +476,25 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 849B0ED128214C6600FE35AF /* XCRemoteSwiftPackageReference "IQKeyboardManager" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/hackiftekhar/IQKeyboardManager"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 6.5.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 849B0ED228214C6600FE35AF /* IQKeyboardManagerSwift */ = { + isa = XCSwiftPackageProductDependency; + package = 849B0ED128214C6600FE35AF /* XCRemoteSwiftPackageReference "IQKeyboardManager" */; + productName = IQKeyboardManagerSwift; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 0B62816B235DEE8100E35CAF /* Project object */; } diff --git a/Flash Chat iOS13.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate b/Flash Chat iOS13.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 000000000..247789776 Binary files /dev/null and b/Flash Chat iOS13.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Flash Chat iOS13.xcworkspace/contents.xcworkspacedata b/Flash Chat iOS13.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..0bc3cc88e --- /dev/null +++ b/Flash Chat iOS13.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Flash Chat iOS13.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Flash Chat iOS13.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/Flash Chat iOS13.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Flash Chat iOS13.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate b/Flash Chat iOS13.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 000000000..228cd936b Binary files /dev/null and b/Flash Chat iOS13.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Flash Chat iOS13.xcworkspace/xcuserdata/admin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Flash Chat iOS13.xcworkspace/xcuserdata/admin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 000000000..f96597b01 --- /dev/null +++ b/Flash Chat iOS13.xcworkspace/xcuserdata/admin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,6 @@ + + + diff --git a/Flash Chat iOS13/AppDelegate.swift b/Flash Chat iOS13/AppDelegate.swift index 620250213..89f630ad7 100644 --- a/Flash Chat iOS13/AppDelegate.swift +++ b/Flash Chat iOS13/AppDelegate.swift @@ -7,14 +7,18 @@ // import UIKit +import Firebase +import IQKeyboardManagerSwift @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. + FirebaseApp.configure() + let db = Firestore.firestore() + IQKeyboardManager.shared.enable = true + IQKeyboardManager.shared.enableAutoToolbar = false + IQKeyboardManager.shared.shouldResignOnTouchOutside = true return true } diff --git a/Flash Chat iOS13/Constants.swift b/Flash Chat iOS13/Constants.swift new file mode 100644 index 000000000..6d2b44ffd --- /dev/null +++ b/Flash Chat iOS13/Constants.swift @@ -0,0 +1,28 @@ +// +// Constants.swift +// Flash Chat iOS13 +// +// Created by Admin on 29.04.22. +// Copyright © 2022 Angela Yu. All rights reserved. +// + +struct K { + static let appName = "⚡️FlashChat" + static let cellIdentifier = "ReusableCell" + static let cellNibName = "MessageCell" + static let registerSegue = "RegisterToChat" + static let loginSegue = "LoginToChat" + + struct BrandColors { + static let purple = "BrandPurple" + static let lightPurple = "BrandLightPurple" + static let blue = "BrandBlue" + static let lighBlue = "BrandLightBlue" + } + + struct FStore { + static let collectionName = "messages" + static let senderField = "sender" + static let bodyField = "body" + static let dateField = "date" + }} diff --git a/Flash Chat iOS13/Controllers/ChatViewController.swift b/Flash Chat iOS13/Controllers/ChatViewController.swift index eb06ca23e..399fb03d6 100644 --- a/Flash Chat iOS13/Controllers/ChatViewController.swift +++ b/Flash Chat iOS13/Controllers/ChatViewController.swift @@ -7,19 +7,104 @@ // import UIKit +import Firebase class ChatViewController: UIViewController { - + @IBOutlet weak var tableView: UITableView! @IBOutlet weak var messageTextfield: UITextField! + let db = Firestore.firestore() + + var messages: [Message] = [] + + @IBAction func logOutPressed(_ sender: UIBarButtonItem) { + do { + try Auth.auth().signOut() + navigationController?.popToRootViewController(animated: true) + } catch let signOutError as NSError { + print("Error signing out: %@", signOutError) + } + } + override func viewDidLoad() { super.viewDidLoad() - + tableView.dataSource = self + tableView.register(UINib(nibName: K.cellNibName, bundle: nil), forCellReuseIdentifier: K.cellIdentifier) + loadMessages() + navigationItem.hidesBackButton = true + title = K.appName } - @IBAction func sendPressed(_ sender: UIButton) { + private func loadMessages(){ + db.collection(K.FStore.collectionName) + .order(by: K.FStore.dateField) + .addSnapshotListener { (querySnapshot, error) in + if let e = error { + print("Error when getting data from DB. \(e.localizedDescription)") + } else { + self.messages = [] + if let snapshotDocument = querySnapshot?.documents { + for doc in snapshotDocument{ + let data = doc.data() + if let messageSender = data[K.FStore.senderField] as? String, let messageBody = data[K.FStore.bodyField] as? String { + self.messages.append(Message(sender: messageSender, body: messageBody)) + DispatchQueue.main.async { + self.tableView.reloadData() + let indexPath = IndexPath(row: self.messages.count - 1, section: 0) + self.tableView.scrollToRow(at: indexPath, at: .top, animated: true) + } + } + } + } + } + } } + @IBAction func sendPressed(_ sender: UIButton) { + + if let messageBody = messageTextfield.text, let messageSender = Auth.auth().currentUser?.email { + db.collection(K.FStore.collectionName).addDocument(data: [ + K.FStore.senderField: messageSender, + K.FStore.bodyField: messageBody, + K.FStore.dateField: Date().timeIntervalSince1970 + ]) { error in + if let e = error { + print("Error in saving in DB. \(e.localizedDescription)") + } else { + print("Saved in DB") + DispatchQueue.main.async { + self.messageTextfield.text = "" + } + } + } + } + } +} +extension ChatViewController: UITableViewDataSource{ + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return messages.count + } + + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: K.cellIdentifier, for: indexPath) as! MessageCell + + let message = messages[indexPath.row] + + cell.label.text = message.body + if message.sender == Auth.auth().currentUser?.email{ + cell.leftImageView.isHidden = true + cell.rightImageView.isHidden = false + cell.messageBuble.backgroundColor = UIColor(named: K.BrandColors.lightPurple) + cell.label.textColor = UIColor(named: K.BrandColors.purple) + } else { + cell.rightImageView.isHidden = true + cell.leftImageView.isHidden = false + cell.messageBuble.backgroundColor = UIColor(named: K.BrandColors.purple) + cell.label.textColor = UIColor(named: K.BrandColors.lightPurple) + } + return cell + } } diff --git a/Flash Chat iOS13/Controllers/LoginViewController.swift b/Flash Chat iOS13/Controllers/LoginViewController.swift index d4efc0598..7556d930c 100644 --- a/Flash Chat iOS13/Controllers/LoginViewController.swift +++ b/Flash Chat iOS13/Controllers/LoginViewController.swift @@ -7,14 +7,24 @@ // import UIKit +import Firebase class LoginViewController: UIViewController { - + @IBOutlet weak var emailTextfield: UITextField! @IBOutlet weak var passwordTextfield: UITextField! - + @IBAction func loginPressed(_ sender: UIButton) { + + if let email = emailTextfield.text, let password = passwordTextfield.text { + Auth.auth().signIn(withEmail: email, password: password) { authResult, error in + if let e = error { + print(e.localizedDescription) + } else { + self.performSegue(withIdentifier: K.loginSegue, sender: self) + } + } + } } - } diff --git a/Flash Chat iOS13/Controllers/RegisterViewController.swift b/Flash Chat iOS13/Controllers/RegisterViewController.swift index b3e7f126f..028fe4c7e 100644 --- a/Flash Chat iOS13/Controllers/RegisterViewController.swift +++ b/Flash Chat iOS13/Controllers/RegisterViewController.swift @@ -7,13 +7,22 @@ // import UIKit +import FirebaseAuth class RegisterViewController: UIViewController { - + @IBOutlet weak var emailTextfield: UITextField! @IBOutlet weak var passwordTextfield: UITextField! @IBAction func registerPressed(_ sender: UIButton) { + if let email = emailTextfield.text, let password = passwordTextfield.text { + Auth.auth().createUser(withEmail: email, password: password) { authResult, error in + if let e = error { + print(e.localizedDescription) + } else { + self.performSegue(withIdentifier: K.registerSegue, sender: self) + } + } + } } - } diff --git a/Flash Chat iOS13/Controllers/WelcomeViewController.swift b/Flash Chat iOS13/Controllers/WelcomeViewController.swift index 1f5ed9019..a5c7b8672 100644 --- a/Flash Chat iOS13/Controllers/WelcomeViewController.swift +++ b/Flash Chat iOS13/Controllers/WelcomeViewController.swift @@ -7,16 +7,24 @@ // import UIKit +import CLTypingLabel class WelcomeViewController: UIViewController { - - @IBOutlet weak var titleLabel: UILabel! + + @IBOutlet weak var titleLabel: CLTypingLabel! + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + navigationController?.isNavigationBarHidden = true + } + + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + navigationController?.isNavigationBarHidden = false + } override func viewDidLoad() { super.viewDidLoad() - - + titleLabel.text = K.appName } - - } diff --git a/Flash Chat iOS13/Model/Message.swift b/Flash Chat iOS13/Model/Message.swift new file mode 100644 index 000000000..bec96c39e --- /dev/null +++ b/Flash Chat iOS13/Model/Message.swift @@ -0,0 +1,14 @@ +// +// Message.swift +// Flash Chat iOS13 +// +// Created by Admin on 3.05.22. +// Copyright © 2022 Angela Yu. All rights reserved. +// + +import Foundation + +struct Message{ + let sender: String + let body: String +} diff --git a/Flash Chat iOS13/Views/Base.lproj/Main.storyboard b/Flash Chat iOS13/Views/Base.lproj/Main.storyboard index 84d5aa1fa..5b6a928c8 100644 --- a/Flash Chat iOS13/Views/Base.lproj/Main.storyboard +++ b/Flash Chat iOS13/Views/Base.lproj/Main.storyboard @@ -1,10 +1,12 @@ - + - + + + @@ -16,9 +18,9 @@ - - - + + @@ -62,15 +71,15 @@ - + - + @@ -81,7 +90,7 @@ - + @@ -106,9 +115,9 @@ - + -