Commit 1ace72ee by Daniel Dahan

development: working TextField, final part is rotation

parent 1acfef3f
...@@ -107,7 +107,6 @@ ...@@ -107,7 +107,6 @@
TargetAttributes = { TargetAttributes = {
96090AE31D9CDD2E00709CA6 = { 96090AE31D9CDD2E00709CA6 = {
CreatedOnToolsVersion = 8.0; CreatedOnToolsVersion = 8.0;
DevelopmentTeam = 9Z76XCNLGL;
ProvisioningStyle = Automatic; ProvisioningStyle = Automatic;
}; };
}; };
...@@ -263,7 +262,7 @@ ...@@ -263,7 +262,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 9Z76XCNLGL; DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = TextField/Info.plist; INFOPLIST_FILE = TextField/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.TextField; PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.TextField;
...@@ -276,7 +275,7 @@ ...@@ -276,7 +275,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 9Z76XCNLGL; DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = TextField/Info.plist; INFOPLIST_FILE = TextField/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.TextField; PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.TextField;
......
...@@ -46,12 +46,11 @@ class ViewController: UIViewController { ...@@ -46,12 +46,11 @@ class ViewController: UIViewController {
prepareNameField() prepareNameField()
prepareEmailField() prepareEmailField()
preparePasswordField() preparePasswordField()
prepareResignResponderButton()
} }
/// Programmatic update for the textField as it rotates. /// Programmatic update for the textField as it rotates.
override func willRotate(to toInterfaceOrientation: UIInterfaceOrientation, duration: TimeInterval) { override func willRotate(to toInterfaceOrientation: UIInterfaceOrientation, duration: TimeInterval) {
emailField.width = view.bounds.height - 2 * constant emailField.width = (Device.isLandscape ? view.height : view.width) - 2 * constant
} }
/// Prepares the resign responder button. /// Prepares the resign responder button.
...@@ -90,7 +89,6 @@ class ViewController: UIViewController { ...@@ -90,7 +89,6 @@ class ViewController: UIViewController {
} }
private func prepareEmailField() { private func prepareEmailField() {
emailField = ErrorTextField(frame: CGRect(x: constant, y: 7 * constant, width: view.width - (2 * constant), height: constant)) emailField = ErrorTextField(frame: CGRect(x: constant, y: 7 * constant, width: view.width - (2 * constant), height: constant))
emailField.text = "Daniel Dahan" emailField.text = "Daniel Dahan"
emailField.placeholder = "Email" emailField.placeholder = "Email"
......
...@@ -319,17 +319,6 @@ open class TextField: UITextField { ...@@ -319,17 +319,6 @@ open class TextField: UITextField {
/// A reference to the visibilityIconButton. /// A reference to the visibilityIconButton.
open private(set) var visibilityIconButton: IconButton? open private(set) var visibilityIconButton: IconButton?
/**
`layoutIfNeeded` is called within `becomeFirstResponder` to
fix an issue that when the TextField calls `becomeFirstResponder`
immediately when launching an instance, the TextField is not
calculated correctly.
*/
open override func becomeFirstResponder() -> Bool {
layoutIfNeeded()
return super.becomeFirstResponder()
}
open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { open override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
guard "placeholderLabel.text" != keyPath else { guard "placeholderLabel.text" != keyPath else {
updatePlaceholderLabelColor() updatePlaceholderLabelColor()
...@@ -479,11 +468,12 @@ open class TextField: UITextField { ...@@ -479,11 +468,12 @@ open class TextField: UITextField {
/// Layout the placeholderLabel. /// Layout the placeholderLabel.
open func layoutPlaceholderLabel() { open func layoutPlaceholderLabel() {
let w = leftViewWidth let w = leftViewWidth
let h = 0 == height ? intrinsicContentSize.height : height
if !isEditing && true == text?.isEmpty && isPlaceholderAnimated { if !isEditing && true == text?.isEmpty && isPlaceholderAnimated {
placeholderLabel.frame = CGRect(x: w, y: bounds.origin.y, width: width - w, height: height) placeholderLabel.frame = CGRect(x: w, y: 0, width: width - w, height: h)
} else if placeholderLabel.transform.isIdentity { } else if placeholderLabel.transform.isIdentity {
placeholderLabel.frame = CGRect(x: w, y: bounds.origin.y, width: width - w, height: height) placeholderLabel.frame = CGRect(x: w, y: 0, width: width - w, height: h)
placeholderLabel.transform = CGAffineTransform(scaleX: 0.75, y: 0.75) placeholderLabel.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
switch textAlignment { switch textAlignment {
case .left, .natural: case .left, .natural:
...@@ -493,7 +483,6 @@ open class TextField: UITextField { ...@@ -493,7 +483,6 @@ open class TextField: UITextField {
default:break default:break
} }
placeholderLabel.y = -placeholderLabel.height + placeholderVerticalOffset placeholderLabel.y = -placeholderLabel.height + placeholderVerticalOffset
placeholderLabel.textColor = placeholderNormalColor
} else { } else {
switch textAlignment { switch textAlignment {
case .left, .natural: case .left, .natural:
...@@ -581,7 +570,6 @@ open class TextField: UITextField { ...@@ -581,7 +570,6 @@ open class TextField: UITextField {
} }
s.placeholderLabel.y = -s.placeholderLabel.height + s.placeholderVerticalOffset s.placeholderLabel.y = -s.placeholderLabel.height + s.placeholderVerticalOffset
s.placeholderLabel.textColor = s.placeholderActiveColor
}) { [weak self] _ in }) { [weak self] _ in
self?.isAnimating = false self?.isAnimating = false
} }
......
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