To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit aae1614e authored by domenicw's avatar domenicw
Browse files

Implemented login password autofill

parent 5355ec41
......@@ -121,6 +121,7 @@
B07A8A0521523B96003CC2D8 /* InfoViewControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoViewControllerDelegate.swift; sourceTree = "<group>"; };
B07A8A0821524384003CC2D8 /* OnboardingNavigatorDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingNavigatorDelegate.swift; sourceTree = "<group>"; };
B07A8A0A21524474003CC2D8 /* LoginModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginModel.swift; sourceTree = "<group>"; };
B0A2F35921579FD0002C340F /* Amiv.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Amiv.entitlements; sourceTree = "<group>"; };
B0D3F92A21552E8E005209FF /* UIButton+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+Extension.swift"; sourceTree = "<group>"; };
B0FE2EFB2154179600F3D073 /* JobsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JobsViewController.swift; sourceTree = "<group>"; };
B0FE2EFE21541A2B00F3D073 /* EventsNavigator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventsNavigator.swift; sourceTree = "<group>"; };
......@@ -179,6 +180,7 @@
B050E11E215169230090CB79 /* Amiv */ = {
isa = PBXGroup;
children = (
B0A2F35921579FD0002C340F /* Amiv.entitlements */,
B0FE2F1921552A8800F3D073 /* Keychain */,
B0FE2F0E2154494100F3D073 /* View */,
B050E15D215173470090CB79 /* Extension */,
......@@ -570,6 +572,11 @@
TargetAttributes = {
B050E11B215169230090CB79 = {
CreatedOnToolsVersion = 10.0;
SystemCapabilities = {
com.apple.SafariKeychain = {
enabled = 1;
};
};
};
B050E12F215169250090CB79 = {
CreatedOnToolsVersion = 10.0;
......@@ -826,6 +833,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Amiv/Amiv.entitlements;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 28J3L9UEGT;
INFOPLIST_FILE = Amiv/Info.plist;
......@@ -845,6 +853,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Amiv/Amiv.entitlements;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 28J3L9UEGT;
INFOPLIST_FILE = Amiv/Info.plist;
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>webcredentials:amiv.ethz.ch</string>
</array>
</dict>
</plist>
......@@ -73,6 +73,12 @@ public class LoginViewController: UIViewController {
fatalError("init(coder:) has not been implemented")
}
// MARK: - Deinitializers
deinit {
self.hideKeyboard()
}
// MARK: - View Creation
private func createTitleLabel(_ title: String) -> UILabel {
......@@ -126,7 +132,7 @@ public class LoginViewController: UIViewController {
private func applyButtonConstraints() {
NSLayoutConstraint(item: self.button, attribute: .leading, relatedBy: .equal, toItem: self.view, attribute: .leadingMargin, multiplier: 1, constant: 10).isActive = true
NSLayoutConstraint(item: self.button, attribute: .trailing, relatedBy: .equal, toItem: self.view, attribute: .trailingMargin, multiplier: 1, constant: -10).isActive = true
NSLayoutConstraint(item: self.button, attribute: .bottom, relatedBy: .equal, toItem: self.view, attribute: .bottomMargin, multiplier: 1, constant: -10).isActive = true
NSLayoutConstraint(item: self.button, attribute: .bottom, relatedBy: .equal, toItem: self.view, attribute: .bottomMargin, multiplier: 1, constant: -20).isActive = true
NSLayoutConstraint(item: self.button, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 50).isActive = true
}
......@@ -152,9 +158,11 @@ public class LoginViewController: UIViewController {
let field = UITextField()
field.tintColor = .amivRed
field.placeholder = "Username"
field.textContentType = .username
field.autocapitalizationType = .none
field.returnKeyType = .continue
field.borderStyle = .roundedRect
field.addTarget(self, action: #selector(self.checkLoginButtonEnabling), for: .editingChanged)
field.addTarget(self, action: #selector(self.fillPassword), for: .primaryActionTriggered)
field.translatesAutoresizingMaskIntoConstraints = false
......@@ -171,10 +179,12 @@ public class LoginViewController: UIViewController {
let field = UITextField()
field.tintColor = .amivRed
field.placeholder = "Password"
field.textContentType = .password
field.returnKeyType = .go
field.autocapitalizationType = .none
field.isSecureTextEntry = true
field.borderStyle = .roundedRect
field.addTarget(self, action: #selector(self.checkLoginButtonEnabling), for: .editingChanged)
field.addTarget(self, action: #selector(self.login), for: .primaryActionTriggered)
field.translatesAutoresizingMaskIntoConstraints = false
......@@ -193,12 +203,20 @@ public class LoginViewController: UIViewController {
super.viewDidLoad()
self.view.backgroundColor = .white
self.modalPresentationStyle = .formSheet
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.navigationBar.isHidden = true
self.checkLoginButtonEnabling()
}
public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.hideKeyboard()
}
// MARK: - View Interaction
......@@ -215,6 +233,7 @@ public class LoginViewController: UIViewController {
}
@objc private func smallButtonAction() {
self.hideKeyboard()
self.delegate?.smallButtonTapped()
}
......@@ -237,4 +256,14 @@ public class LoginViewController: UIViewController {
}
}
@objc private func checkLoginButtonEnabling() {
if self.usernameTextField.text == "" || self.passwordTextField.text == "" {
self.button.isEnabled = false
self.button.setBackgroundColor(UIColor.amivRed.withAlphaComponent(0.9), for: .normal)
} else {
self.button.isEnabled = true
self.button.setBackgroundColor(UIColor.amivRed.withAlphaComponent(1), for: .normal)
}
}
}
......@@ -122,7 +122,7 @@ public class InfoViewController: UIViewController {
}
NSLayoutConstraint(item: self.button, attribute: .leading, relatedBy: .equal, toItem: self.view, attribute: .leadingMargin, multiplier: 1, constant: 10).isActive = true
NSLayoutConstraint(item: self.button, attribute: .trailing, relatedBy: .equal, toItem: self.view, attribute: .trailingMargin, multiplier: 1, constant: -10).isActive = true
NSLayoutConstraint(item: self.button, attribute: .bottom, relatedBy: .equal, toItem: self.view, attribute: .bottomMargin, multiplier: 1, constant: -10).isActive = true
NSLayoutConstraint(item: self.button, attribute: .bottom, relatedBy: .equal, toItem: self.view, attribute: .bottomMargin, multiplier: 1, constant: -20).isActive = true
NSLayoutConstraint(item: self.button, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 50).isActive = true
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment