diff --git a/.DS_Store b/.DS_Store index 01a802c..9e083c6 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Alamofire 2.xcscheme b/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Alamofire 2.xcscheme new file mode 100644 index 0000000..d594691 --- /dev/null +++ b/Pods/Pods.xcodeproj/xcshareddata/xcschemes/Alamofire 2.xcscheme @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Pods/Pods.xcodeproj/xcuserdata/craigscott.xcuserdatad/xcschemes/xcschememanagement.plist b/Pods/Pods.xcodeproj/xcuserdata/craigscott.xcuserdatad/xcschemes/xcschememanagement.plist index 313ec7b..242a92b 100644 --- a/Pods/Pods.xcodeproj/xcuserdata/craigscott.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Pods/Pods.xcodeproj/xcuserdata/craigscott.xcuserdatad/xcschemes/xcschememanagement.plist @@ -4,6 +4,11 @@ SchemeUserState + Alamofire 2.xcscheme_^#shared#^_ + + orderHint + 7 + Alamofire.xcscheme isShown @@ -41,6 +46,12 @@ SuppressBuildableAutocreation - + + E76458C58C9140B6A16D60547E68E80C + + primary + + + diff --git a/Stocks.io.xcodeproj/project.pbxproj b/Stocks.io.xcodeproj/project.pbxproj index a4b0b3a..16049df 100644 --- a/Stocks.io.xcodeproj/project.pbxproj +++ b/Stocks.io.xcodeproj/project.pbxproj @@ -17,6 +17,11 @@ E12C9BEA215C538B00CB8493 /* Charts.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E12C9BE8215C538B00CB8493 /* Charts.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; E13F2A0A218E5EB500F0B15D /* companiesnasdaq.json in Resources */ = {isa = PBXBuildFile; fileRef = E13F2A09218E5EB400F0B15D /* companiesnasdaq.json */; }; E1587269218F643500D50581 /* SearchTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1587268218F643500D50581 /* SearchTableViewCell.swift */; }; + E15901AE21E015BE006CE67C /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E15901AD21E015BE006CE67C /* LoginViewController.swift */; }; + E15901B021E01C2E006CE67C /* LoginTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = E15901AF21E01C2E006CE67C /* LoginTextField.swift */; }; + E15901B221E0FEEC006CE67C /* RoundedButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = E15901B121E0FEEC006CE67C /* RoundedButton.swift */; }; + E15901B421E119F5006CE67C /* RegisterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E15901B321E119F5006CE67C /* RegisterViewController.swift */; }; + E15901B721E1ADE5006CE67C /* Profile.swift in Sources */ = {isa = PBXBuildFile; fileRef = E15901B621E1ADE5006CE67C /* Profile.swift */; }; E1BF5E5E215EDB6300C7BC40 /* newsData.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1BF5E5D215EDB6300C7BC40 /* newsData.swift */; }; E1BF5E60215EDB7000C7BC40 /* financialData.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1BF5E5F215EDB7000C7BC40 /* financialData.swift */; }; E1BF5E66215F33CE00C7BC40 /* StockCellTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1BF5E65215F33CE00C7BC40 /* StockCellTableViewCell.swift */; }; @@ -56,6 +61,11 @@ E12C9BE8215C538B00CB8493 /* Charts.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Charts.framework; sourceTree = BUILT_PRODUCTS_DIR; }; E13F2A09218E5EB400F0B15D /* companiesnasdaq.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = companiesnasdaq.json; path = Stocks.io/Controller/companiesnasdaq.json; sourceTree = SOURCE_ROOT; }; E1587268218F643500D50581 /* SearchTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchTableViewCell.swift; sourceTree = ""; }; + E15901AD21E015BE006CE67C /* LoginViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = ""; }; + E15901AF21E01C2E006CE67C /* LoginTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginTextField.swift; sourceTree = ""; }; + E15901B121E0FEEC006CE67C /* RoundedButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RoundedButton.swift; sourceTree = ""; }; + E15901B321E119F5006CE67C /* RegisterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisterViewController.swift; sourceTree = ""; }; + E15901B621E1ADE5006CE67C /* Profile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Profile.swift; sourceTree = ""; }; E1BF5E5D215EDB6300C7BC40 /* newsData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = newsData.swift; sourceTree = ""; }; E1BF5E5F215EDB7000C7BC40 /* financialData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = financialData.swift; sourceTree = ""; }; E1BF5E65215F33CE00C7BC40 /* StockCellTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StockCellTableViewCell.swift; sourceTree = ""; }; @@ -162,6 +172,8 @@ E1D3BE35215B600000B42453 /* RoundedView.swift */, E1BF5E65215F33CE00C7BC40 /* StockCellTableViewCell.swift */, E1587268218F643500D50581 /* SearchTableViewCell.swift */, + E15901AF21E01C2E006CE67C /* LoginTextField.swift */, + E15901B121E0FEEC006CE67C /* RoundedButton.swift */, ); path = Views; sourceTree = ""; @@ -173,6 +185,7 @@ E1BF5E5D215EDB6300C7BC40 /* newsData.swift */, E1BF5E5F215EDB7000C7BC40 /* financialData.swift */, E1E19B5B21601FC5007F0376 /* BarChartFormatter.swift */, + E15901B621E1ADE5006CE67C /* Profile.swift */, ); path = Model; sourceTree = ""; @@ -182,6 +195,8 @@ children = ( E1D3BE1E215B59BE00B42453 /* MainViewController.swift */, E1060C512188B4530081BF74 /* SearchViewController.swift */, + E15901AD21E015BE006CE67C /* LoginViewController.swift */, + E15901B321E119F5006CE67C /* RegisterViewController.swift */, ); path = Controller; sourceTree = ""; @@ -308,17 +323,22 @@ buildActionMask = 2147483647; files = ( E1060C522188B4530081BF74 /* SearchViewController.swift in Sources */, + E15901B021E01C2E006CE67C /* LoginTextField.swift in Sources */, E1D3BE1F215B59BE00B42453 /* MainViewController.swift in Sources */, E1D3BE1D215B59BE00B42453 /* AppDelegate.swift in Sources */, + E15901AE21E015BE006CE67C /* LoginViewController.swift in Sources */, E1BF5E5E215EDB6300C7BC40 /* newsData.swift in Sources */, E10AC593215BF7B900E96B1F /* Utilities.swift in Sources */, E1E19B5C21601FC5007F0376 /* BarChartFormatter.swift in Sources */, E1039DBF2163D921003FCBBE /* GIF.swift in Sources */, + E15901B421E119F5006CE67C /* RegisterViewController.swift in Sources */, E1BF5E60215EDB7000C7BC40 /* financialData.swift in Sources */, E1D3BE36215B600000B42453 /* RoundedView.swift in Sources */, + E15901B221E0FEEC006CE67C /* RoundedButton.swift in Sources */, E10AC58E215BF09F00E96B1F /* Stock.swift in Sources */, E1D3BE38215B613300B42453 /* Extensions.swift in Sources */, E10AC591215BF27B00E96B1F /* Constants.swift in Sources */, + E15901B721E1ADE5006CE67C /* Profile.swift in Sources */, E1BF5E66215F33CE00C7BC40 /* StockCellTableViewCell.swift in Sources */, E1587269218F643500D50581 /* SearchTableViewCell.swift in Sources */, ); diff --git a/Stocks.io.xcodeproj/xcuserdata/craigscott.xcuserdatad/xcschemes/xcschememanagement.plist b/Stocks.io.xcodeproj/xcuserdata/craigscott.xcuserdatad/xcschemes/xcschememanagement.plist index cb6b95f..46f93a3 100644 --- a/Stocks.io.xcodeproj/xcuserdata/craigscott.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Stocks.io.xcodeproj/xcuserdata/craigscott.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ Stocks.io.xcscheme orderHint - 7 + 8 diff --git a/Stocks.io.xcworkspace/xcuserdata/craigscott.xcuserdatad/UserInterfaceState.xcuserstate b/Stocks.io.xcworkspace/xcuserdata/craigscott.xcuserdatad/UserInterfaceState.xcuserstate index e5c1c9d..99b04b5 100644 Binary files a/Stocks.io.xcworkspace/xcuserdata/craigscott.xcuserdatad/UserInterfaceState.xcuserstate and b/Stocks.io.xcworkspace/xcuserdata/craigscott.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Stocks.io.xcworkspace/xcuserdata/craigscott.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Stocks.io.xcworkspace/xcuserdata/craigscott.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index e176f42..69d6f23 100644 --- a/Stocks.io.xcworkspace/xcuserdata/craigscott.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Stocks.io.xcworkspace/xcuserdata/craigscott.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -10,7 +10,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Stocks.io/Controller/MainViewController.swift" - timestampString = "563835743.469505" + timestampString = "568437911.638719" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "72" @@ -26,7 +26,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Stocks.io/Controller/MainViewController.swift" - timestampString = "563835743.471069" + timestampString = "568437911.6387939" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "277" @@ -90,7 +90,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Stocks.io/Controller/MainViewController.swift" - timestampString = "563835743.471413" + timestampString = "568437911.638883" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "115" @@ -250,7 +250,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Stocks.io/Controller/MainViewController.swift" - timestampString = "563835743.471688" + timestampString = "568437911.639025" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "104" @@ -298,7 +298,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Stocks.io/Controller/MainViewController.swift" - timestampString = "563835743.471792" + timestampString = "568437911.63908" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "105" @@ -314,7 +314,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Stocks.io/Controller/MainViewController.swift" - timestampString = "563835743.471908" + timestampString = "568437911.639133" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "106" @@ -330,7 +330,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Stocks.io/Controller/SearchViewController.swift" - timestampString = "563835743.472057" + timestampString = "568701121.9309601" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "43" @@ -408,7 +408,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Stocks.io/Extras/Utilities.swift" - timestampString = "563496543.210952" + timestampString = "568800556.388193" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "23" @@ -424,7 +424,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "Stocks.io/Extras/Utilities.swift" - timestampString = "563496543.211043" + timestampString = "568800556.388262" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "20" @@ -436,11 +436,11 @@ + + + + diff --git a/Stocks.io/.DS_Store b/Stocks.io/.DS_Store index 219ce93..c69114a 100644 Binary files a/Stocks.io/.DS_Store and b/Stocks.io/.DS_Store differ diff --git a/Stocks.io/Assets.xcassets/.DS_Store b/Stocks.io/Assets.xcassets/.DS_Store index d19b531..26b7138 100644 Binary files a/Stocks.io/Assets.xcassets/.DS_Store and b/Stocks.io/Assets.xcassets/.DS_Store differ diff --git a/Stocks.io/Assets.xcassets/backIcon.imageset/Contents.json b/Stocks.io/Assets.xcassets/backIcon.imageset/Contents.json index b7fb066..0833df1 100644 --- a/Stocks.io/Assets.xcassets/backIcon.imageset/Contents.json +++ b/Stocks.io/Assets.xcassets/backIcon.imageset/Contents.json @@ -2,7 +2,7 @@ "images" : [ { "idiom" : "universal", - "filename" : "backButton.png", + "filename" : "backIcon.png", "scale" : "1x" }, { diff --git a/Stocks.io/Assets.xcassets/backIcon.imageset/backButton.png b/Stocks.io/Assets.xcassets/backIcon.imageset/backButton.png deleted file mode 100644 index 4c1021f..0000000 Binary files a/Stocks.io/Assets.xcassets/backIcon.imageset/backButton.png and /dev/null differ diff --git a/Stocks.io/Assets.xcassets/backIcon.imageset/backIcon.png b/Stocks.io/Assets.xcassets/backIcon.imageset/backIcon.png new file mode 100644 index 0000000..89db739 Binary files /dev/null and b/Stocks.io/Assets.xcassets/backIcon.imageset/backIcon.png differ diff --git a/Stocks.io/Base.lproj/Main.storyboard b/Stocks.io/Base.lproj/Main.storyboard index e1980b3..643a3cd 100644 --- a/Stocks.io/Base.lproj/Main.storyboard +++ b/Stocks.io/Base.lproj/Main.storyboard @@ -1,6 +1,6 @@ - - + + @@ -26,7 +26,7 @@ - + @@ -37,17 +37,17 @@ - + - + - + @@ -275,7 +275,7 @@ - + - + @@ -356,7 +356,7 @@ @@ -450,7 +450,7 @@ - + @@ -466,11 +466,11 @@ - + - + @@ -480,14 +480,14 @@ - + - + - + - + @@ -561,12 +561,360 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Stocks.io/Controller/LoginViewController.swift b/Stocks.io/Controller/LoginViewController.swift index 9d4c585..dd945f0 100644 --- a/Stocks.io/Controller/LoginViewController.swift +++ b/Stocks.io/Controller/LoginViewController.swift @@ -7,16 +7,65 @@ // import UIKit +import Alamofire -class LoginViewController: UIViewController { - +class LoginViewController: UIViewController , UINavigationControllerDelegate{ + private var user_profile : Profile = Profile(first_name: "", last_name: "", email: "", Token: "", Stocks: []) + @IBOutlet weak var LoginContainer: RoundedView! + @IBOutlet weak var email_textfield: LoginTextField! + + @IBOutlet weak var password_textfield: LoginTextField! + @IBOutlet weak var login_activity: UIActivityIndicatorView! + override func viewDidLoad() { super.viewDidLoad() - + login_activity.hidesWhenStopped = true + NotificationCenter.default.addObserver( + self, + selector: #selector(keyboardWillShow), + name: NSNotification.Name.UIKeyboardWillShow, + object: nil + ) + + NotificationCenter.default.addObserver( + self, + selector: #selector(keyboardWillHide), + name: NSNotification.Name.UIKeyboardWillHide, + object: nil + ) + setupHideKeyboardOnTap() + //LoginContainer.isHidden = false // Do any additional setup after loading the view. } + @objc func keyboardWillShow(notification: Notification) { + if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue { + if self.view.frame.origin.y == 0{ + self.view.frame.origin.y -= keyboardSize.height + } + } + + } + + @objc func keyboardWillHide(notification: Notification) { + if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue { + if self.view.frame.origin.y != 0{ + self.view.frame.origin.y = 0 + } + } + } + + override func awakeFromNib() { + } + + @IBAction func RegisterButton(_ sender: Any) { + LoginContainer.isHidden = true + performSegue(withIdentifier: "RegisterSegue", sender: self.navigationController) + //let sVC = self.storyboard?.instantiateViewController(withIdentifier: "Register") as! RegisterViewController + + //self.navigationController?.pushViewController(sVC, animated: true) + } /* // MARK: - Navigation @@ -26,5 +75,42 @@ class LoginViewController: UIViewController { // Pass the selected object to the new view controller. } */ + + //Auth-token login + @IBAction func login_auth_token(_ sender: Any) { + login_activity.startAnimating() + let body = [ + "username" : email_textfield.text, + "password" : password_textfield.text + ] + + Alamofire.request(backendConstants.deploymentURL + "users/token/", method: .post, parameters: body, + encoding: JSONEncoding.default) + .responseJSON { response in + self.login_activity.stopAnimating() + + guard response.result.error == nil else { + // got an error in getting the data, need to handle it + print("error calling POST on /todos/1") + print(response.result.error!) + return + } + // make sure we got some JSON since that's what we expect + guard let json = response.result.value as? [String: Any] else { + print("\(response.result.value)") + return + } + if let token = json["token"] as? String { + print(token) + self.user_profile.Token = token + self.performSegue(withIdentifier: "LoginSegue", sender: self.navigationController) + print("Success") + }else{ + print("Invalid Login Information") + } + + } + } + } diff --git a/Stocks.io/Controller/RegisterViewController.swift b/Stocks.io/Controller/RegisterViewController.swift index b868368..fb3206a 100644 --- a/Stocks.io/Controller/RegisterViewController.swift +++ b/Stocks.io/Controller/RegisterViewController.swift @@ -7,24 +7,121 @@ // import UIKit +import Alamofire class RegisterViewController: UIViewController { + @IBOutlet weak var first_name: LoginTextField! + + @IBOutlet weak var last_name: LoginTextField! + @IBOutlet weak var email: LoginTextField! + @IBOutlet weak var RegisterActivity: UIActivityIndicatorView! + @IBOutlet weak var password: LoginTextField! + @IBOutlet weak var password_verify: LoginTextField! + @IBAction func GoToLoginButton(_ sender: Any) { + + dismiss(animated: true, completion:nil) + if let login = self.presentingViewController as? LoginViewController{ + login.LoginContainer.isHidden = false + } + + /* + if let nav = self.navigationController{ + for vc in nav.viewControllers{ + if let login = vc as? LoginViewController{ + login.LoginContainer.isHidden = false + } + } + self.navigationController?.popToRootViewController(animated: true) + } + */ + + } + override func viewDidLoad() { super.viewDidLoad() + RegisterActivity.hidesWhenStopped = true + NotificationCenter.default.addObserver( + self, + selector: #selector(keyboardWillShow), + name: NSNotification.Name.UIKeyboardWillShow, + object: nil + ) + + NotificationCenter.default.addObserver( + self, + selector: #selector(keyboardWillHide), + name: NSNotification.Name.UIKeyboardWillHide, + object: nil + ) + + setupHideKeyboardOnTap() // Do any additional setup after loading the view. } - - /* + @objc func keyboardWillShow(notification: Notification) { + if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue { + if self.view.frame.origin.y == 0{ + self.view.frame.origin.y -= keyboardSize.height + } + } + + } + + @objc func keyboardWillHide(notification: Notification) { + if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue { + if self.view.frame.origin.y != 0{ + self.view.frame.origin.y = 0 + } + } + } + + @IBAction func Register(_ sender: Any) { + RegisterActivity.startAnimating() + + let body = [ + "username" : email.text, + "email" : email.text, + "password" : password.text, + "first_name" : first_name.text, + "last_name" : last_name.text + ] + + Alamofire.request(backendConstants.deploymentURL + "users/register/", method: .post, parameters: body, + encoding: JSONEncoding.default) + .responseJSON { response in + self.RegisterActivity.stopAnimating() + + guard response.result.error == nil else { + // got an error in getting the data, need to handle it + print("error calling POST on /todos/1") + print(response.result.error!) + return + } + // make sure we got some JSON since that's what we expect + guard let json = response.result.value as? [String: Any] else { + print("\(response.result.value)") + return + } + + + } + + } + + // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { + + if let login = segue.destination as? LoginViewController{ + login.LoginContainer.isHidden = false + } // Get the new view controller using segue.destination. // Pass the selected object to the new view controller. } - */ + } diff --git a/Stocks.io/Extras/Constants.swift b/Stocks.io/Extras/Constants.swift index b6f72d5..38505ce 100644 --- a/Stocks.io/Extras/Constants.swift +++ b/Stocks.io/Extras/Constants.swift @@ -57,3 +57,8 @@ struct timeInterval { static let hour = "60min" static let none = "" } + +struct backendConstants{ + static let testingURL = "https://localhost:8000/" + static let deploymentURL = "https://www.stocksio.ml/" +} diff --git a/Stocks.io/Extras/Utilities.swift b/Stocks.io/Extras/Utilities.swift index 017c011..0a92699 100644 --- a/Stocks.io/Extras/Utilities.swift +++ b/Stocks.io/Extras/Utilities.swift @@ -7,7 +7,7 @@ // import Foundation - +import UIKit class Utilities { static var sharedInstance = Utilities() static let calendar = Calendar.current @@ -27,3 +27,18 @@ class Utilities { } } + +extension UIViewController { + /// Call this once to dismiss open keyboards by tapping anywhere in the view controller + func setupHideKeyboardOnTap() { + self.view.addGestureRecognizer(self.endEditingRecognizer()) + self.navigationController?.navigationBar.addGestureRecognizer(self.endEditingRecognizer()) + } + + /// Dismisses the keyboard from self.view + private func endEditingRecognizer() -> UIGestureRecognizer { + let tap = UITapGestureRecognizer(target: self.view, action: #selector(self.view.endEditing(_:))) + tap.cancelsTouchesInView = false + return tap + } +} diff --git a/Stocks.io/Model/Profile.swift b/Stocks.io/Model/Profile.swift new file mode 100644 index 0000000..131d4a6 --- /dev/null +++ b/Stocks.io/Model/Profile.swift @@ -0,0 +1,19 @@ +// +// Profile.swift +// Stocks.io +// +// Created by Craig Scott on 1/5/19. +// Copyright © 2019 Craig Scott. All rights reserved. +// + +import Foundation + +struct Profile{ + + var first_name : String + var last_name : String + var email : String + var Token : String + var Stocks : [String] + +} diff --git a/Stocks.io/Views/LoginTextField.swift b/Stocks.io/Views/LoginTextField.swift index ee5af50..8e0617a 100644 --- a/Stocks.io/Views/LoginTextField.swift +++ b/Stocks.io/Views/LoginTextField.swift @@ -17,5 +17,9 @@ class LoginTextField: UITextField { // Drawing code } */ + override func awakeFromNib(){ + self.layer.borderWidth = 2.0 + self.layer.borderColor = UIColor.white.cgColor + } } diff --git a/Stocks.io/Views/RoundedButton.swift b/Stocks.io/Views/RoundedButton.swift index 4860030..37fd387 100644 --- a/Stocks.io/Views/RoundedButton.swift +++ b/Stocks.io/Views/RoundedButton.swift @@ -17,5 +17,15 @@ class RoundedButton: UIButton { // Drawing code } */ + + override func awakeFromNib() { + super.awakeFromNib() + //self.addBlurEffect() + self.layer.cornerRadius = 10 + self.layer.borderWidth = 2 + self.layer.borderColor = UIColor.white.cgColor + //self.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] + self.clipsToBounds = true + } }