Skip to content

Commit

Permalink
Merge pull request #1 from ErikPerez312/login
Browse files Browse the repository at this point in the history
Fix - constrains, merge conflicts
  • Loading branch information
ErikPerez312 committed Oct 21, 2018
2 parents f3cc585 + e8fc70c commit 1bef270
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
8 changes: 6 additions & 2 deletions improve-talking.xcodeproj/project.pbxproj
Expand Up @@ -423,7 +423,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = QFR976VMLD;

DEVELOPMENT_TEAM = X3T6G6B4MK;

INFOPLIST_FILE = "$(SRCROOT)/improve-talking/Supporting-Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -443,7 +445,9 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = QFR976VMLD;

DEVELOPMENT_TEAM = X3T6G6B4MK;

INFOPLIST_FILE = "$(SRCROOT)/improve-talking/Supporting-Files/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
33 changes: 28 additions & 5 deletions improve-talking/ViewControllers/InitialViewController.swift
Expand Up @@ -14,13 +14,22 @@ class InitialViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
view.backgroundColor = #colorLiteral(red: 0.934114673, green: 0.9433633331, blue: 0.9433633331, alpha: 1)
hideKeyboardWhenTappedAround()
addSubviews()
setConstraints()
}

// MARK: - Private

private var keyboardHeight = UIScreen.main.bounds.height * 0.3
private var originalY = UIScreen.main.bounds.origin.y
private let iconHeightWidth = UIScreen.main.bounds.height * 0.17
private let iconTopDistance = UIScreen.main.bounds.height * 0.095
private let textFieldWidth = UIScreen.main.bounds.width * 0.616
private let textFieldTopDistance = UIScreen.main.bounds.height * 0.08

/// Flag which indicates whether a login request should be attempted.
private var shouldAttemptLogin = false {
Expand Down Expand Up @@ -111,11 +120,6 @@ class InitialViewController: UIViewController {
}

private func setConstraints() {
let iconHeightWidth = UIScreen.main.bounds.height * 0.17
let iconTopDistance = UIScreen.main.bounds.height * 0.095
let textFieldWidth = UIScreen.main.bounds.width * 0.616
let textFieldTopDistance = UIScreen.main.bounds.height * 0.08

iconImageView.snp.makeConstraints { (make) in
make.height.width.equalTo(iconHeightWidth)
make.centerX.equalToSuperview()
Expand Down Expand Up @@ -226,6 +230,25 @@ class InitialViewController: UIViewController {
}
}

@objc private func keyboardWillShow(notification: NSNotification) {
let userInfo = notification.userInfo!
let beginFrameValue = (userInfo[UIKeyboardFrameBeginUserInfoKey] as? NSValue)!
let beginFrame = beginFrameValue.cgRectValue
let endFrameValue = (userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)!
let endFrame = endFrameValue.cgRectValue

if beginFrame.equalTo(endFrame) {
return
}
if originalY == self.view.frame.origin.y {
self.view.frame.origin.y -= keyboardHeight
}
}

@objc private func keyboardWillHide(notification: NSNotification) {
self.view.frame.origin.y += keyboardHeight
}

@objc private func continueButtonPressed(_ sender: UIButton) {
// Attempt to create a new account, if username is already registered we update 'shouldLogin' flag
// inorder to attempt login with provided credentials
Expand Down

0 comments on commit 1bef270

Please sign in to comment.