Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AnimatedTextInput.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ DESC
s.source = { :git => 'https://github.com/jobandtalent/AnimatedTextInput.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/jobandtalentEng'

s.ios.deployment_target = '8.0'
s.ios.deployment_target = '10.0'
s.swift_version = '5.0'

s.source_files = 'AnimatedTextInput/Classes/**/*'

Expand Down
Binary file modified AnimatedTextInput/Assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified AnimatedTextInput/Assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified AnimatedTextInput/Assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified AnimatedTextInput/Assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified AnimatedTextInput/Assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified AnimatedTextInput/Assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion AnimatedTextInput/Classes/AnimatedLine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ open class AnimatedLine: UIView {

fileprivate let lineLayer = CAShapeLayer()

var animationDuration: Double = 0.4
var animationDuration: Double = 0.35

var defaultColor = UIColor.gray.withAlphaComponent(0.6) {
didSet {
Expand Down
1 change: 1 addition & 0 deletions AnimatedTextInput/Classes/AnimatedTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ final public class AnimatedTextField: UITextField {
public var contentInset: UIEdgeInsets = .zero

fileprivate var disclosureButtonAction: (() -> Void)?
fileprivate let semaphore = DispatchSemaphore(value: 1)

override public init(frame: CGRect) {
self.rightViewPadding = defaultPadding
Expand Down
52 changes: 39 additions & 13 deletions AnimatedTextInput/Classes/AnimatedTextInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,22 @@ open class AnimatedTextInput: UIControl {
}
}

open var placeHolderText = "Test" {
didSet {
placeholderLayer.string = placeHolderText
textInput.view.accessibilityLabel = placeHolderText
open var placeHolderText: String {
get {
placeholderLayer.string as? String ?? ""
}
set {
placeholderLayer.string = newValue
textInput.view.accessibilityLabel = newValue
}
}

// Some letters like 'g' or 'á' were not rendered properly, the frame need to be about 20% higher than the font size

open var frameHeightCorrectionFactor : Double = 1.2 {
open var frameHeightCorrectionFactor: Double = 1.2 {
didSet {
layoutPlaceholderLayer()
}

}

open var placeholderAlignment: CATextLayer.Alignment = .natural {
Expand All @@ -83,11 +85,15 @@ open class AnimatedTextInput: UIControl {

open var text: String? {
get {
return textInput.currentText
textQueue.sync {
return textInput.currentText
}
}
set {
(newValue != nil && !newValue!.isEmpty) ? configurePlaceholderAsInactiveHint() : configurePlaceholderAsDefault()
textInput.currentText = newValue
textQueue.sync {
newValue?.isEmpty ?? true ? configurePlaceholderAsDefault() : configurePlaceholderAsInactiveHint()
textInput.currentText = newValue
}
}
}

Expand Down Expand Up @@ -188,16 +194,30 @@ open class AnimatedTextInput: UIControl {
}
}

open var contentInset: UIEdgeInsets? {
didSet {
guard let insets = contentInset else { return }
textInput.contentInset = insets
open var contentInset: UIEdgeInsets {
get {
if let textInput = textInput as? UITextView {
var textContainerInset = textInput.contentInset
textContainerInset.left += 4
return textContainerInset
} else {
return textInput.contentInset
}
}
set {
if let textInput = textInput as? UITextView {
textInput.contentInset = newValue
textInput.contentInset.left -= 4
} else {
textInput.contentInset = newValue
}
}
}

fileprivate let lineView = AnimatedLine()
fileprivate let placeholderLayer = CATextLayer()
fileprivate let counterLabel = UILabel()
fileprivate let textQueue = DispatchQueue(label: "AnimatedTextInput.text")
fileprivate let counterLabelRightMargin: CGFloat = 15
fileprivate let counterLabelTopMargin: CGFloat = 5

Expand All @@ -211,6 +231,7 @@ open class AnimatedTextInput: UIControl {
fileprivate var disclosureView: UIView?
fileprivate var placeholderErrorText: String?


fileprivate var placeholderPosition: CGPoint {
let hintPosition = CGPoint(
x: placeholderAlignment != .natural ? 0 : style.leftMargin,
Expand Down Expand Up @@ -541,6 +562,10 @@ open class AnimatedTextInput: UIControl {
open func position(from: UITextPosition, offset: Int) -> UITextPosition? {
return textInput.currentPosition(from: from, offset: offset)
}

open func textRange(from fromPosition: UITextPosition, to toPosition: UITextPosition) -> UITextRange? {
return textInput.textRange(from: fromPosition, to: toPosition)
}
}

extension AnimatedTextInput: TextInputDelegate {
Expand Down Expand Up @@ -596,6 +621,7 @@ public protocol TextInput {
func configureInputView(newInputView: UIView)
func changeReturnKeyType(with newReturnKeyType: UIReturnKeyType)
func currentPosition(from: UITextPosition, offset: Int) -> UITextPosition?
func textRange(from fromPosition: UITextPosition, to toPosition: UITextPosition) -> UITextRange?
func changeClearButtonMode(with newClearButtonMode: UITextField.ViewMode)
}

Expand Down
2 changes: 1 addition & 1 deletion AnimatedTextInput/Classes/AnimatedTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final public class AnimatedTextView: UITextView {
}

fileprivate func setup() {
contentInset = UIEdgeInsets(top: 0, left: -4, bottom: 0, right: 0)
contentInset.left = -4
delegate = self
}

Expand Down
Binary file modified Assets/Jobandtalent Eng.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 19 additions & 15 deletions Example/AnimatedTextInput.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
996E6CB407C8BE1F63C6A8EB /* Pods-AnimatedTextInput_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AnimatedTextInput_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AnimatedTextInput_Tests/Pods-AnimatedTextInput_Tests.release.xcconfig"; sourceTree = "<group>"; };
C2CC3D147049263CCC7FACAE /* Pods_AnimatedTextInput_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AnimatedTextInput_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
C70CECE01EB0E27100BB92A9 /* SnapshotTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnapshotTests.swift; sourceTree = "<group>"; };
FC96906680158A6AEBA30E7E /* AnimatedTextInput.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = AnimatedTextInput.podspec; path = ../AnimatedTextInput.podspec; sourceTree = "<group>"; };
FC96906680158A6AEBA30E7E /* AnimatedTextInput.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = AnimatedTextInput.podspec; path = ../AnimatedTextInput.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -206,24 +206,24 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1030;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
DevelopmentTeam = 49LW9LE429;
LastSwiftMigration = 0810;
LastSwiftMigration = 1170;
};
607FACE41AFB9204008FA782 = {
CreatedOnToolsVersion = 6.3.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1170;
TestTargetID = 607FACCF1AFB9204008FA782;
};
};
};
buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "AnimatedTextInput" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -286,7 +286,7 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-AnimatedTextInput_Example/Pods-AnimatedTextInput_Example-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-AnimatedTextInput_Example/Pods-AnimatedTextInput_Example-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/AnimatedTextInput/AnimatedTextInput.framework",
);
name = "[CP] Embed Pods Frameworks";
Expand All @@ -295,7 +295,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AnimatedTextInput_Example/Pods-AnimatedTextInput_Example-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-AnimatedTextInput_Example/Pods-AnimatedTextInput_Example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
B3BF15F5F058B84F66980FC9 /* [CP] Embed Pods Frameworks */ = {
Expand All @@ -304,7 +304,7 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-AnimatedTextInput_Tests/Pods-AnimatedTextInput_Tests-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-AnimatedTextInput_Tests/Pods-AnimatedTextInput_Tests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/AnimatedTextInput/AnimatedTextInput.framework",
"${BUILT_PRODUCTS_DIR}/FBSnapshotTestCase/FBSnapshotTestCase.framework",
"${BUILT_PRODUCTS_DIR}/KIF/KIF.framework",
Expand All @@ -317,7 +317,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AnimatedTextInput_Tests/Pods-AnimatedTextInput_Tests-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-AnimatedTextInput_Tests/Pods-AnimatedTextInput_Tests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
CAC4E7ECBA55CDF296E15A0A /* [CP] Check Pods Manifest.lock */ = {
Expand Down Expand Up @@ -424,6 +424,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -467,7 +468,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand All @@ -480,6 +481,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Expand Down Expand Up @@ -516,7 +518,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -533,11 +535,12 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 49LW9LE429;
INFOPLIST_FILE = AnimatedTextInput/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -549,11 +552,12 @@
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 49LW9LE429;
INFOPLIST_FILE = AnimatedTextInput/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MODULE_NAME = ExampleApp;
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -578,7 +582,7 @@
SWIFT_OBJC_BRIDGING_HEADER = "../Tests/AnimatedTextInput_Tests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AnimatedTextInput_Example.app/AnimatedTextInput_Example";
};
name = Debug;
Expand All @@ -599,7 +603,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "../Tests/AnimatedTextInput_Tests-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AnimatedTextInput_Example.app/AnimatedTextInput_Example";
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
LastUpgradeVersion = "1030"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
28 changes: 1 addition & 27 deletions Example/AnimatedTextInput/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
internal func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

Binary file modified ...ts.AnimatedTextInputSnapshotTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...sts.AnimatedTextInputSnapshotTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...put_Tests.AnimatedTextInputSnapshotTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...t_Tests.AnimatedTextInputSnapshotTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...nput_Tests.AnimatedTextInputSnapshotTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...AnimatedTextInputSnapshotTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...ut_Tests.AnimatedTextInputSnapshotTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ...ut_Tests.AnimatedTextInputSnapshotTests/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 1 addition & 9 deletions Example/Podfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
platform :ios, '8.3'
platform :ios, '10.0'

use_frameworks!
inhibit_all_warnings!
Expand All @@ -12,11 +12,3 @@ target 'AnimatedTextInput_Tests' do
pod 'KIF', '~> 3.5'
pod 'FBSnapshotTestCase'
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.2'
end
end
end
8 changes: 4 additions & 4 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ DEPENDENCIES:
- KIF (~> 3.5)

SPEC REPOS:
https://github.com/cocoapods/specs:
https://github.com/CocoaPods/Specs.git:
- FBSnapshotTestCase
- KIF

Expand All @@ -24,10 +24,10 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
AnimatedTextInput: 81da570f4e0ca74e3092dfe235781f8c2aa18c30
AnimatedTextInput: f3f55cc027cf7a38e62e920eaedb22e9ae8d883c
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
KIF: bd770edd8ce49bc7308501e4871e58a02d137be3

PODFILE CHECKSUM: 24f7e98a4a8a1102c54d1de65b58fd857224cd7d
PODFILE CHECKSUM: dc47b2c2e48f7d8677de2eb6d4dfe24f10a1dcfc

COCOAPODS: 1.5.3
COCOAPODS: 1.9.3
2 changes: 1 addition & 1 deletion Tests/SnapshotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AnimatedTextInput

class AnimatedTextInputSnapshotTests: FBSnapshotTestCase {
private let sut = AnimatedTextInput()
private var containerView: UIView!
private var containerView = UIView()

override func setUp() {
super.setUp()
Expand Down