├── .DS_Store
├── CCWATextField.xcodeproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ ├── xcuserdata
│ │ ├── mac.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ │ └── admin.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
├── xcuserdata
│ ├── admin.xcuserdatad
│ │ └── xcschemes
│ │ │ └── xcschememanagement.plist
│ └── mac.xcuserdatad
│ │ └── xcschemes
│ │ └── xcschememanagement.plist
└── project.pbxproj
├── CCWATextField.podspec
├── CCWATextField
├── Info.plist
├── SupportingFiles
│ ├── CCWAUIButton.swift
│ ├── CCWATextFieldDelegate.swift
│ ├── CCWAUIImageView.swift
│ ├── CCWAUITextField.swift
│ ├── Delay.swift
│ ├── CCWADropDownModel.swift
│ ├── CCWATextViewConstraintProperty.swift
│ ├── CCWADropDownViewMaster.swift
│ ├── CCWATextViewSupport.swift
│ ├── CCWATextFieldMaster.swift
│ ├── CCWATextField.swift
│ ├── CCWATextFieldUpdate.swift
│ ├── CCWADropDownCard.swift
│ ├── CCWADropDownView.swift
│ ├── CCWATextFieldViewProperty.swift
│ └── CCWATextFieldViewPropertyUpdate.swift
└── CCWATextField.h
├── LICENSE
└── README.md
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnandKhanpara/CCWATextField/HEAD/.DS_Store
--------------------------------------------------------------------------------
/CCWATextField.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CCWATextField.xcodeproj/project.xcworkspace/xcuserdata/mac.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnandKhanpara/CCWATextField/HEAD/CCWATextField.xcodeproj/project.xcworkspace/xcuserdata/mac.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/CCWATextField.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AnandKhanpara/CCWATextField/HEAD/CCWATextField.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/CCWATextField.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/CCWATextField.xcodeproj/xcuserdata/admin.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CCWATextField.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/CCWATextField.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CCWATextField.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/CCWATextField.podspec:
--------------------------------------------------------------------------------
1 | Pod::Spec.new do |spec|
2 |
3 | spec.name = "CCWATextField"
4 | spec.version = "1.0.1"
5 | spec.summary = "CCWATextField"
6 | spec.description = <<-DESC
7 | CCWATextField
8 | DESC
9 |
10 | spec.homepage = "https://github.com/AnandKhanpara/CCWATextField"
11 | spec.license = { :type => "MIT", :file => "LICENSE" }
12 | spec.author = { "Anand Khanpara" => "anandkhanpara111@gmail.com" }
13 | spec.ios.deployment_target = "12.0"
14 | spec.swift_version = "5"
15 | spec.source = { :git => "https://github.com/AnandKhanpara/CCWATextField.git", :tag => "#{spec.version}" }
16 | spec.source_files = "CCWATextField/**/*.{h,m,swift}"
17 |
18 | end
19 |
--------------------------------------------------------------------------------
/CCWATextField/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE)
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | $(CURRENT_PROJECT_VERSION)
21 |
22 |
23 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Anand Khanpara
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWAUIButton.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import UIKit
29 |
30 | class CCWAUIButton: UIButton {
31 | var touchUpInside : (() -> ())? = nil
32 | }
33 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWATextFieldDelegate.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import Foundation
29 |
30 | public protocol CCWATextFieldDelegate {
31 | func update()
32 | func updating()
33 | func continueUpdate()
34 | }
35 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWAUIImageView.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import UIKit
29 |
30 |
31 | class CCWAUIImageView: UIImageView {
32 |
33 | var url:String? {
34 | didSet {
35 | url(url)
36 | }
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWAUITextField.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import UIKit
29 |
30 | class CCWAUITextField: UITextField {
31 | var editingChanged : ((String) -> ())? = nil
32 | var editingDidBegin : ((String) -> ())? = nil
33 | var editingDidEnd : ((String) -> ())? = nil
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/Delay.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import UIKit
29 |
30 | class Delay {
31 |
32 | @discardableResult
33 | func time(_ second:TimeInterval, complition: @escaping () -> ()) -> Delay {
34 | DispatchQueue.main.asyncAfter(deadline: .now() + second) { complition() }
35 | return self
36 | }
37 |
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/CCWATextField/CCWATextField.h:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | #import
29 |
30 | //! Project version number for CCWATextField.
31 | FOUNDATION_EXPORT double CCWATextFieldVersionNumber;
32 |
33 | //! Project version string for CCWATextField.
34 | FOUNDATION_EXPORT const unsigned char CCWATextFieldVersionString[];
35 |
36 | // In this header, you should import all the public headers of your framework using statements like #import
37 |
38 |
39 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWADropDownModel.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import UIKit
29 |
30 | public class CCWADropDownModel {
31 |
32 | public var title:String?
33 | public var subtitle:String?
34 | public var image:UIImage?
35 | public var imageURL:String?
36 | public var value:Any?
37 |
38 | public init(title:String? = nil, subtitle:String? = nil, image:UIImage? = nil, imageURL:String? = nil, value:Any? = nil) {
39 | self.title = title
40 | self.subtitle = subtitle
41 | self.image = image
42 | self.imageURL = imageURL
43 | self.value = value
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWATextViewConstraintProperty.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import UIKit
29 |
30 | class CCWATOutlineTextFieldConstraintProperty: NSObject {
31 |
32 | var stackViewHorizontalHeightConstraint:NSLayoutConstraint!
33 | var stackViewHorizontalLeadingConstraint:NSLayoutConstraint!
34 |
35 | var labelPlaceholderDeactiveTopConstraint:NSLayoutConstraint!
36 | var labelPlaceholderDeactiveLeadingConstraint:NSLayoutConstraint!
37 |
38 | var labelPlaceholderActiveTopConstraint:NSLayoutConstraint!
39 | var labelPlaceholderActiveLeadingConstraint:NSLayoutConstraint!
40 |
41 | var labelPlaceholderHeightConstraint:NSLayoutConstraint!
42 | var labelPlaceholderWidthConstraint:NSLayoutConstraint!
43 |
44 | var dropDownViewHeight:NSLayoutConstraint!
45 |
46 | var labelPlaceHolderWidth : CGFloat = 0
47 | var labelPlaceHolderHeight : CGFloat = 0
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWADropDownViewMaster.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import UIKit
29 |
30 | public class CCWADropDownViewMaster {
31 |
32 | public var dropDownBackGroundColor: UIColor = .white
33 |
34 | public var dropDownSeperatorLineColor: UIColor = .lightGray
35 |
36 | public var dropDownBorderColor: UIColor = .lightGray
37 |
38 | public var dropDownBorderWidth: CGFloat = 0.5
39 |
40 | public var dropDownCornerRadius:CGFloat = 5
41 |
42 | public var dropDownShadowColor: UIColor = .darkGray
43 |
44 | public var dropDownShadowRadius: CGFloat = 4
45 |
46 | public var dropDownShadowOpacity:Float = 0.5
47 |
48 | public var dropDownShadowOffset:CGSize = CGSize(width: 0, height: 2)
49 |
50 | public var dropDownTitleColor:UIColor = .black
51 |
52 | public var dropDownSubtitleColor:UIColor = .lightGray
53 |
54 | public var dropDownTitleFontName:String = ""
55 |
56 | public var dropDownSubtitleFontName:String = ""
57 |
58 | public var dropDownSearchPlaceholder:String = ""
59 |
60 | public var dropDownNoDataMessage:String = ""
61 |
62 | public var dropDownArrowImage:UIImage? = nil
63 |
64 | public init() {
65 |
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWATextViewSupport.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import UIKit
29 |
30 | extension String {
31 |
32 | func empty() -> Bool {
33 | return (self == "" || self.trimmingCharacters(in: .whitespacesAndNewlines) == "" || self.isEmpty == true)
34 | }
35 | }
36 |
37 |
38 | extension UIView {
39 | func findViewController() -> UIViewController? {
40 | if let nextResponder = self.next as? UIViewController {
41 | return nextResponder
42 | } else if let nextResponder = self.next as? UIView {
43 | return nextResponder.findViewController()
44 | } else {
45 | return nil
46 | }
47 | }
48 | }
49 |
50 | extension CCWAUIImageView {
51 | func url(_ url: String?) {
52 | DispatchQueue.global().async { [weak self] in
53 | guard let stringURL = url, let url = URL(string: stringURL) else {
54 | return
55 | }
56 | func setImage(image:UIImage?) {
57 | DispatchQueue.main.async {
58 | self?.image = image
59 | }
60 | }
61 | let urlToString = url.absoluteString as NSString
62 | if let cachedImage = ImageStore.imageCache.object(forKey: urlToString) {
63 | setImage(image: cachedImage)
64 | } else if let data = try? Data(contentsOf: url), let image = UIImage(data: data) {
65 | DispatchQueue.main.async {
66 | ImageStore.imageCache.setObject(image, forKey: urlToString)
67 | setImage(image: image)
68 | }
69 | }else {
70 | setImage(image: nil)
71 | }
72 | }
73 | }
74 | }
75 |
76 | class ImageStore: NSObject {
77 | static let imageCache = NSCache()
78 | }
79 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWATextFieldMaster.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import UIKit
29 |
30 | public class CCWATextFieldMaster {
31 |
32 | public var textColor:UIColor = .black
33 |
34 | public var animatePlaceholder:Bool = false
35 |
36 | public var activePlaceholderColor:UIColor? = nil
37 |
38 | public var deactivePlaceholderColor:UIColor = .lightGray
39 |
40 | public var activePlacehoderBackGroundColor:UIColor = .white
41 |
42 | public var activeBorderColor:UIColor? = nil
43 |
44 | public var deactiveBorderColor:UIColor = .darkGray
45 |
46 | public var activeBorderWidth:CGFloat = 0
47 |
48 | public var deactiveBorderWidth:CGFloat = 1
49 |
50 | public var activeCornerRadius:CGFloat = 0
51 |
52 | public var deactiveCornerRadius:CGFloat = 5
53 |
54 | public var activeBackGroundColor:UIColor? = nil
55 |
56 | public var deactiveBackGroundColor:UIColor = .white
57 |
58 | public var fontSize:CGFloat = 16
59 |
60 | public var fontName:String = ""
61 |
62 | public var activeImageLeftIcon:UIImage? = nil
63 |
64 | public var deactiveImageLeftIcon:UIImage? = nil
65 |
66 | public var activeImageLeftIconColor:UIColor? = nil
67 |
68 | public var deactiveImageLeftIconColor:UIColor? = nil
69 |
70 | public var isClearButton:Bool = true
71 |
72 | public var imageClearButton:UIImage? = nil
73 |
74 | public var isSecureText:Bool = false
75 |
76 | public var activeShadowColor: UIColor? = nil
77 |
78 | public var deactiveShadowColor: UIColor = .clear
79 |
80 | public var activeShadowRadius: CGFloat = 0
81 |
82 | public var deactiveShadowRadius: CGFloat = 0
83 |
84 | public var activeShadowOpacity:Float = 0
85 |
86 | public var deactiveShadowOpacity:Float = 1
87 |
88 | public var activeShadowOffset:CGSize = .zero
89 |
90 | public var deactiveShadowOffset:CGSize = .zero
91 |
92 | public var doneToolbar:Bool = true
93 |
94 | public var tintColor:UIColor? = nil
95 |
96 | public init() {
97 |
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CCWATextField
2 | You can improve the design and performance of your app by using CCWATextField. In the iOS app, you can see how many CCWATextField properties you can customize in your own way.
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | ###### Click to Download Example 👇🏻
11 | ## [Download Example](https://github.com/AnandKhanpara/CCWATextField/files/5432725/CCWATextFieldExample.zip)
12 |
13 |
14 | ### Installation with CocoaPods
15 |
16 | ```
17 | pod 'CCWATextField', '1.0.1'
18 | ```
19 |
20 | ## Usage
21 |
22 | ### Storyboard
23 |
24 |
25 | 
26 |
27 | ```swift
28 |
29 | import CCWATextField
30 |
31 | class ViewController: UIViewController {
32 |
33 | @IBOutlet weak var ccwaTextField:CCWATextField!
34 |
35 | override func viewDidLoad() {
36 | super.viewDidLoad()
37 |
38 | ccwaTextField.fieldType = .textField //(Default)
39 | //ccwaTextField.fieldType = .dropDown
40 | //ccwaTextField.fieldType = .dropDownSearch
41 |
42 | }
43 | }
44 |
45 | ```
46 |
47 | ### Programmatically
48 |
49 | ```swift
50 | import CCWATextField
51 |
52 | class ViewController: UIViewController {
53 |
54 | override func viewDidLoad() {
55 | super.viewDidLoad()
56 |
57 | let ccwaTextField = CCWATextField()
58 |
59 | ccwaTextField.fieldType = .textField //(Default)
60 | //ccwaTextField.fieldType = .dropDown
61 | //ccwaTextField.fieldType = .dropDownSearch
62 |
63 | view.addSubview(ccwaTextField)
64 |
65 | }
66 | }
67 |
68 | ```
69 |
70 | ### Action
71 |
72 | #### This way you can direct using four actions.
73 |
74 | ###### Text-Field
75 |
76 | 1. editingDidBegin
77 | 2. editingChanged
78 | 3. editingDidEnd
79 | 4. touchUpInsideClear
80 |
81 | ###### Drop-Down
82 |
83 | 1. dropDownDidSelectRow
84 |
85 | ###### Drop-Down-Search
86 |
87 | 1. dropDownDidSelectRow
88 | 2. dropDownSearchEditingChanged
89 |
90 | ```swift
91 |
92 | //Text-Field
93 |
94 | ccwaTextField.editingDidBegin { (text) in
95 |
96 | }.editingChanged { (text) in
97 |
98 | }.editingDidEnd { (text) in
99 |
100 | }.touchUpInsideClear {
101 |
102 | }
103 |
104 | //Drop-Down
105 |
106 | ccwaTextField.dropDownDidSelectRow = { ccwaTextField, index, value in
107 |
108 | }
109 |
110 | //Drop-Down-Search
111 |
112 | ccwaTextField.dropDownDidSelectRow = { ccwaTextField, index, value in
113 |
114 | }
115 |
116 | ccwaTextField.dropDownSearchEditingChanged = { ccwaTextField, arrCCWADropDownModel, search in
117 | let arrCCWADropDownModel = arrCCWADropDownModel.filter({ $0.title?.localizedCaseInsensitiveContains(search) == true })
118 | return arrCCWADropDownModel
119 | }
120 |
121 | ```
122 |
123 | ### Properties
124 |
125 | #### Default value of a properties
126 |
127 | #### * It is not mandatory to set the value of any properties. You can set the value as per your requirement.
128 |
129 | 
130 |
131 | ``` swift
132 |
133 | let ccwaTextField = CCWATextField()
134 |
135 | ```
136 |
137 | ``` swift
138 |
139 | ccwaTextField.fieldType = .dropDown // .textField (Default)
140 |
141 | //MARK :- CCWATextField
142 |
143 | ccwaTextField.text = ""
144 | ccwaTextField.textColor = .black
145 | ccwaTextField.placeholder = ""
146 | ccwaTextField.animatePlaceholder = false
147 | ccwaTextField.activePlaceholderColor = nil
148 | ccwaTextField.deactivePlaceholderColor = .lightGray
149 | ccwaTextField.activePlacehoderBackGroundColor = .white
150 | ccwaTextField.activeBorderColor = nil
151 | ccwaTextField.deactiveBorderColor = .darkGray
152 | ccwaTextField.activeBorderWidth = 0
153 | ccwaTextField.deactiveBorderWidth = 1
154 | ccwaTextField.activeCornerRadius = 0
155 | ccwaTextField.deactiveCornerRadius = 5
156 | ccwaTextField.activeBackGroundColor = nil
157 | ccwaTextField.deactiveBackGroundColor = .white
158 | ccwaTextField.fontSize = 16
159 | ccwaTextField.fontName = ""
160 | ccwaTextField.activeImageLeftIcon = nil
161 | ccwaTextField.deactiveImageLeftIcon = nil
162 | ccwaTextField.activeImageLeftIconColor = nil
163 | ccwaTextField.deactiveImageLeftIconColor = nil
164 | ccwaTextField.isClearButton = true
165 | ccwaTextField.imageClearButton = nil
166 | ccwaTextField.isSecureText = false
167 | ccwaTextField.activeShadowColor = nil
168 | ccwaTextField.deactiveShadowColor = .clear
169 | ccwaTextField.activeShadowRadius = 0
170 | ccwaTextField.deactiveShadowRadius = 0
171 | ccwaTextField.activeShadowOpacity = 0
172 | ccwaTextField.deactiveShadowOpacity = 1
173 | ccwaTextField.activeShadowOffset = .zero
174 | ccwaTextField.deactiveShadowOffset = .zero
175 | ccwaTextField.doneToolbar = true
176 |
177 |
178 | //MARK:- CCWADropDown
179 |
180 | ccwaTextField.dropDownBackGroundColor = .white
181 | ccwaTextField.dropDownSeperatorLineColor = .lightGray
182 | ccwaTextField.dropDownBorderColor = .lightGray
183 | ccwaTextField.dropDownBorderWidth = 0.5
184 | ccwaTextField.dropDownCornerRadius = 5
185 | ccwaTextField.dropDownShadowColor = .darkGray
186 | ccwaTextField.dropDownShadowRadius = 4
187 | ccwaTextField.dropDownShadowOpacity = 0.5
188 | ccwaTextField.dropDownShadowOffset = CGSize(width: 0, height: 2)
189 | ccwaTextField.dropDownTitleColor = .black
190 | ccwaTextField.dropDownSubtitleColor = .lightGray
191 | ccwaTextField.dropDownTitleFontName = ""
192 | ccwaTextField.dropDownSubtitleFontName = ""
193 | ccwaTextField.dropDownSearchPlaceholder = ""
194 | ccwaTextField.dropDownNoDataMessage = ""
195 | ccwaTextField.dropDownArrowImage = nil
196 |
197 | ```
198 | ##### * You can change the cursor color of CCWATextField and the color of toolbar Done with tintColor.
199 |
200 | ```swift
201 | ccwaTextField.tintColor = .link
202 |
203 | ```
204 | ##### * The Master-value of the CCWAOutlineTextField must be true to apply the MasterDesign.
205 |
206 | ```swift
207 | ccwaTextField.master = true
208 | ccwaTextField.masterValue = CCWATextFieldMaster()
209 |
210 | ccwaTextField.dropDownMaster = false
211 | ccwaTextField.dropDownMasterValue = CCWADropDownViewMaster()
212 | ```
213 |
214 | ##### * All CCWAOutlineTextField will design the same at active and dective times as you customize. If master is applied and property is not set. The default master apply will be like the image below.
215 |
216 | ```swift
217 |
218 | class func masterValue() -> CCWATextFieldMaster {
219 | //MARK:- Master Property of CCWATextFieldMaster
220 |
221 | //Note: The Master-value of the CCWATextField must be true to apply the TextField MasterDesign.
222 |
223 | let ccwaTextFieldMaster = CCWATextFieldMaster()
224 | ccwaTextFieldMaster.textColor = .black
225 | ccwaTextFieldMaster.animatePlaceholder = false
226 | ccwaTextFieldMaster.activePlaceholderColor = nil
227 | ccwaTextFieldMaster.deactivePlaceholderColor = .lightGray
228 | ccwaTextFieldMaster.activePlacehoderBackGroundColor = .white
229 | ccwaTextFieldMaster.activeBorderColor = nil
230 | ccwaTextFieldMaster.deactiveBorderColor = .darkGray
231 | ccwaTextFieldMaster.activeBorderWidth = 0
232 | ccwaTextFieldMaster.deactiveBorderWidth = 1
233 | ccwaTextFieldMaster.activeCornerRadius = 0
234 | ccwaTextFieldMaster.deactiveCornerRadius = 5
235 | ccwaTextFieldMaster.activeBackGroundColor = nil
236 | ccwaTextFieldMaster.deactiveBackGroundColor = .white
237 | ccwaTextFieldMaster.fontSize = 16
238 | ccwaTextFieldMaster.fontName = ""
239 | ccwaTextFieldMaster.activeImageLeftIcon = nil
240 | ccwaTextFieldMaster.deactiveImageLeftIcon = nil
241 | ccwaTextFieldMaster.activeImageLeftIconColor = nil
242 | ccwaTextFieldMaster.deactiveImageLeftIconColor = nil
243 | ccwaTextFieldMaster.isClearButton = true
244 | ccwaTextFieldMaster.imageClearButton = nil
245 | ccwaTextFieldMaster.isSecureText = false
246 | ccwaTextFieldMaster.activeShadowColor = nil
247 | ccwaTextFieldMaster.deactiveShadowColor = .clear
248 | ccwaTextFieldMaster.activeShadowRadius = 0
249 | ccwaTextFieldMaster.deactiveShadowRadius = 0
250 | ccwaTextFieldMaster.activeShadowOpacity = 0
251 | ccwaTextFieldMaster.deactiveShadowOpacity = 1
252 | ccwaTextFieldMaster.activeShadowOffset = .zero
253 | ccwaTextFieldMaster.deactiveShadowOffset = .zero
254 | ccwaTextFieldMaster.doneToolbar = true
255 | ccwaTextFieldMaster.tintColor = nil
256 |
257 | return ccwaTextFieldMaster
258 | }
259 |
260 |
261 |
262 | class func dropDownMasterValue() -> CCWADropDownViewMaster {
263 |
264 | //MARK:- Master Property of CCWADropDownViewMaster
265 |
266 | //Note: The Master-value of the CCWATextField must be true to apply the DropDown MasterDesign.
267 |
268 | let ccwaDropDownViewMaster = CCWADropDownViewMaster()
269 | ccwaDropDownViewMaster.dropDownBackGroundColor = .white
270 | ccwaDropDownViewMaster.dropDownSeperatorLineColor = .lightGray
271 | ccwaDropDownViewMaster.dropDownBorderColor = .lightGray
272 | ccwaDropDownViewMaster.dropDownBorderWidth = 0.5
273 | ccwaDropDownViewMaster.dropDownCornerRadius = 5
274 | ccwaDropDownViewMaster.dropDownShadowColor = .darkGray
275 | ccwaDropDownViewMaster.dropDownShadowRadius = 4
276 | ccwaDropDownViewMaster.dropDownShadowOpacity = 0.5
277 | ccwaDropDownViewMaster.dropDownShadowOffset = CGSize(width: 0, height: 2)
278 | ccwaDropDownViewMaster.dropDownTitleColor = .black
279 | ccwaDropDownViewMaster.dropDownSubtitleColor = .lightGray
280 | ccwaDropDownViewMaster.dropDownTitleFontName = ""
281 | ccwaDropDownViewMaster.dropDownSubtitleFontName = ""
282 | ccwaDropDownViewMaster.dropDownSearchPlaceholder = ""
283 | ccwaDropDownViewMaster.dropDownNoDataMessage = ""
284 | ccwaDropDownViewMaster.dropDownArrowImage = nil
285 |
286 | return ccwaDropDownViewMaster
287 | }
288 |
289 |
290 | ```
291 |
292 | ## Requirements
293 |
294 | - iOS 12.0
295 | - Xcode 11
296 | - Swift 5.0
297 |
298 | ## Available
299 |
300 | - iPhone & iPad Development
301 |
302 | ## Author
303 |
304 | * [Anand Khanpara](https://www.linkedin.com/in/anand-khanpara-212a96125)
305 |
306 | ## Contact
307 | [
308 | ](https://www.linkedin.com/in/anand-khanpara-212a96125) [
309 | ](https://www.youtube.com/channel/UCuONhSZPQNmitGaOVZ7kQmg/videos?view=0&sort=da&flow=grid)
310 |
311 |
312 |
313 | CCWATextField is released under the MIT license. See [LICENSE](https://github.com/AnandKhanpara/CCWATextField/blob/master/LICENSE) for details.
314 |
315 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWATextField.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import UIKit
29 |
30 | //@IBDesignable
31 | public class CCWATextField: CCWATextFieldViewProperty {
32 |
33 | @IBInspectable public var master:Bool = false {
34 | didSet {
35 | delegate?.update()
36 | }
37 | }
38 |
39 | @IBInspectable public var text:String? = "" {
40 | didSet {
41 | delegate?.updating()
42 | }
43 | }
44 |
45 | @IBInspectable public var textColor:UIColor = .black {
46 | didSet {
47 | delegate?.update()
48 | }
49 | }
50 |
51 | @IBInspectable public var placeholder:String = "" {
52 | didSet {
53 | delegate?.update()
54 | }
55 | }
56 |
57 | @IBInspectable public var animatePlaceholder:Bool = false {
58 | didSet {
59 | delegate?.update()
60 | }
61 | }
62 |
63 | @IBInspectable public var activePlaceholderColor:UIColor? = nil {
64 | didSet {
65 | delegate?.update()
66 | }
67 | }
68 |
69 | @IBInspectable public var deactivePlaceholderColor:UIColor = .lightGray {
70 | didSet {
71 | delegate?.update()
72 | }
73 | }
74 |
75 | @IBInspectable public var activePlacehoderBackGroundColor:UIColor = .white {
76 | didSet {
77 | delegate?.update()
78 | }
79 | }
80 |
81 | @IBInspectable public var activeBorderColor:UIColor? = nil {
82 | didSet {
83 | delegate?.update()
84 | }
85 | }
86 |
87 | @IBInspectable public var deactiveBorderColor:UIColor = .darkGray {
88 | didSet {
89 | delegate?.update()
90 | }
91 | }
92 |
93 | @IBInspectable public var activeBorderWidth:CGFloat = 0 {
94 | didSet {
95 | delegate?.update()
96 | }
97 | }
98 |
99 | @IBInspectable public var deactiveBorderWidth:CGFloat = 1 {
100 | didSet {
101 | delegate?.update()
102 | }
103 | }
104 |
105 | @IBInspectable public var activeCornerRadius:CGFloat = 0 {
106 | didSet {
107 | delegate?.update()
108 | }
109 | }
110 |
111 | @IBInspectable public var deactiveCornerRadius:CGFloat = 5 {
112 | didSet {
113 | delegate?.update()
114 | }
115 | }
116 |
117 | @IBInspectable public var activeBackGroundColor:UIColor? = nil {
118 | didSet {
119 | delegate?.update()
120 | }
121 | }
122 |
123 | @IBInspectable public var deactiveBackGroundColor:UIColor = .white {
124 | didSet {
125 | delegate?.update()
126 | }
127 | }
128 |
129 | @IBInspectable public var fontSize:CGFloat = 16 {
130 | didSet {
131 | delegate?.update()
132 | }
133 | }
134 |
135 | @IBInspectable public var fontName:String = "" {
136 | didSet {
137 | delegate?.update()
138 | }
139 | }
140 |
141 | @IBInspectable public var activeImageLeftIcon:UIImage? = nil {
142 | didSet {
143 | delegate?.update()
144 | }
145 | }
146 |
147 | @IBInspectable public var deactiveImageLeftIcon:UIImage? = nil {
148 | didSet {
149 | delegate?.update()
150 | }
151 | }
152 |
153 | @IBInspectable public var activeImageLeftIconColor:UIColor? = nil {
154 | didSet {
155 | delegate?.update()
156 | }
157 | }
158 |
159 | @IBInspectable public var deactiveImageLeftIconColor:UIColor? = nil {
160 | didSet {
161 | delegate?.update()
162 | }
163 | }
164 |
165 | @IBInspectable public var isClearButton:Bool = true {
166 | didSet {
167 | delegate?.update()
168 | }
169 | }
170 |
171 | @IBInspectable public var imageClearButton:UIImage? = nil {
172 | didSet {
173 | delegate?.update()
174 | }
175 | }
176 |
177 | @IBInspectable public var isSecureText:Bool = false {
178 | didSet {
179 | delegate?.update()
180 | }
181 | }
182 |
183 | @IBInspectable public var activeShadowColor: UIColor? = nil {
184 | didSet {
185 | delegate?.update()
186 | }
187 | }
188 |
189 | @IBInspectable public var deactiveShadowColor: UIColor = .clear {
190 | didSet {
191 | delegate?.update()
192 | }
193 | }
194 |
195 | @IBInspectable public var activeShadowRadius: CGFloat = 0 {
196 | didSet {
197 | delegate?.update()
198 | }
199 | }
200 |
201 | @IBInspectable public var deactiveShadowRadius: CGFloat = 0 {
202 | didSet {
203 | delegate?.update()
204 | }
205 | }
206 |
207 | @IBInspectable public var activeShadowOpacity:Float = 0 {
208 | didSet {
209 | delegate?.update()
210 | }
211 | }
212 |
213 | @IBInspectable public var deactiveShadowOpacity:Float = 1 {
214 | didSet {
215 | delegate?.update()
216 | }
217 | }
218 |
219 | @IBInspectable public var activeShadowOffset:CGSize = .zero {
220 | didSet {
221 | delegate?.update()
222 | }
223 | }
224 |
225 | @IBInspectable public var deactiveShadowOffset:CGSize = .zero {
226 | didSet {
227 | delegate?.update()
228 | }
229 | }
230 |
231 | @IBInspectable public var doneToolbar:Bool = true {
232 | didSet {
233 | delegate?.update()
234 | }
235 | }
236 |
237 | @IBInspectable public var dropDownMaster:Bool = false {
238 | didSet {
239 | delegate?.update()
240 | }
241 | }
242 |
243 | @IBInspectable public var dropDownBackGroundColor: UIColor = .white {
244 | didSet {
245 | delegate?.update()
246 | }
247 | }
248 |
249 | @IBInspectable public var dropDownSeperatorLineColor: UIColor = .lightGray {
250 | didSet {
251 | delegate?.update()
252 | }
253 | }
254 |
255 | @IBInspectable public var dropDownBorderColor: UIColor = .lightGray {
256 | didSet {
257 | delegate?.update()
258 | }
259 | }
260 |
261 | @IBInspectable public var dropDownBorderWidth: CGFloat = 0.5 {
262 | didSet {
263 | delegate?.update()
264 | }
265 | }
266 |
267 | @IBInspectable public var dropDownCornerRadius:CGFloat = 5 {
268 | didSet {
269 | delegate?.update()
270 | }
271 | }
272 |
273 | @IBInspectable public var dropDownShadowColor: UIColor = .darkGray {
274 | didSet {
275 | delegate?.update()
276 | }
277 | }
278 |
279 | @IBInspectable public var dropDownShadowRadius: CGFloat = 4 {
280 | didSet {
281 | delegate?.update()
282 | }
283 | }
284 |
285 | @IBInspectable public var dropDownShadowOpacity:Float = 0.5 {
286 | didSet {
287 | delegate?.update()
288 | }
289 | }
290 |
291 | @IBInspectable public var dropDownShadowOffset:CGSize = CGSize(width: 0, height: 2) {
292 | didSet {
293 | delegate?.update()
294 | }
295 | }
296 |
297 | @IBInspectable public var dropDownTitleColor:UIColor = .black {
298 | didSet {
299 | delegate?.update()
300 | }
301 | }
302 |
303 | @IBInspectable public var dropDownSubtitleColor:UIColor = .lightGray {
304 | didSet {
305 | delegate?.update()
306 | }
307 | }
308 |
309 | @IBInspectable public var dropDownTitleFontName:String = "" {
310 | didSet {
311 | delegate?.update()
312 | }
313 | }
314 |
315 | @IBInspectable public var dropDownSubtitleFontName:String = "" {
316 | didSet {
317 | delegate?.update()
318 | }
319 | }
320 |
321 | @IBInspectable public var dropDownSearchPlaceholder:String = "" {
322 | didSet {
323 | delegate?.update()
324 | }
325 | }
326 |
327 | @IBInspectable public var dropDownNoDataMessage:String = "" {
328 | didSet {
329 | delegate?.update()
330 | }
331 | }
332 |
333 | @IBInspectable public var dropDownArrowImage:UIImage? = nil {
334 | didSet {
335 | delegate?.update()
336 | }
337 | }
338 |
339 |
340 | public var masterValue = CCWATextFieldMaster() {
341 | didSet {
342 | delegate?.update()
343 | }
344 | }
345 |
346 | public var dropDownMasterValue = CCWADropDownViewMaster() {
347 | didSet {
348 | delegate?.update()
349 | }
350 | }
351 |
352 | public var fieldType:FieldType = .textField {
353 | didSet {
354 | delegate?.update()
355 | }
356 | }
357 |
358 | public var arrCCWADropDownModel = [CCWADropDownModel]() {
359 | didSet {
360 | delegate?.update()
361 | }
362 | }
363 |
364 | public var dropDownDidSelectRow:((_ ccwaTextField:CCWATextField, _ row:Int, _ value:Any?) -> ())?
365 |
366 | public var dropDownSearchEditingChanged:((_ ccwaTextField:CCWATextField, _ arrCCWADropDownModel:[CCWADropDownModel], _ search:String) -> ([CCWADropDownModel]))?
367 |
368 | override init(frame: CGRect) {
369 | super.init(frame: frame)
370 | delegate()
371 | }
372 |
373 | required init?(coder: NSCoder) {
374 | super.init(coder: coder)
375 | delegate()
376 | }
377 |
378 | func delegate() {
379 | delegate = self
380 | delegate?.update()
381 | }
382 | }
383 |
384 |
385 |
386 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWATextFieldUpdate.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import UIKit
29 |
30 | extension CCWATextField: CCWATextFieldDelegate {
31 |
32 | public func updating() {
33 | setText = text
34 | }
35 |
36 | public func update() {
37 |
38 | if master == false {
39 | setTextColor = textColor
40 | }else {
41 | setTextColor = masterValue.textColor
42 | }
43 |
44 | setPlaceholder = placeholder
45 |
46 | if master == false {
47 | setAnimatePlaceholder = animatePlaceholder
48 | }else {
49 | setAnimatePlaceholder = masterValue.animatePlaceholder
50 | }
51 |
52 | if master == false {
53 | setActivePlaceholderColor = activePlaceholderColor
54 | }else {
55 | setActivePlaceholderColor = masterValue.activePlaceholderColor
56 | }
57 |
58 | if master == false {
59 | setDeactivePlaceholderColor = deactivePlaceholderColor
60 | }else {
61 | setDeactivePlaceholderColor = masterValue.deactivePlaceholderColor
62 | }
63 |
64 | if master == false {
65 | setActivePlacehoderBackGroundColor = activePlacehoderBackGroundColor
66 | }else {
67 | setActivePlacehoderBackGroundColor = masterValue.activePlacehoderBackGroundColor
68 | }
69 |
70 | if master == false {
71 | setActiveBorderColor = activeBorderColor
72 | }else {
73 | setActiveBorderColor = masterValue.activeBorderColor
74 | }
75 |
76 | if master == false {
77 | setDeactiveBorderColor = deactiveBorderColor
78 | }else {
79 | setDeactiveBorderColor = masterValue.deactiveBorderColor
80 | }
81 |
82 | if master == false {
83 | setActiveBorderWidth = activeBorderWidth
84 | }else {
85 | setActiveBorderWidth = masterValue.activeBorderWidth
86 | }
87 |
88 | if master == false {
89 | setDeactiveBorderWidth = deactiveBorderWidth
90 | }else {
91 | setDeactiveBorderWidth = masterValue.deactiveBorderWidth
92 | }
93 |
94 | if master == false {
95 | setActiveCornerRadius = activeCornerRadius
96 | }else {
97 | setActiveCornerRadius = masterValue.activeCornerRadius
98 | }
99 |
100 | if master == false {
101 | setDeactiveCornerRadius = deactiveCornerRadius
102 | }else {
103 | setDeactiveCornerRadius = masterValue.deactiveCornerRadius
104 | }
105 |
106 | if master == false {
107 | setActiveBackGroundColor = activeBackGroundColor
108 | }else {
109 | setActiveBackGroundColor = masterValue.activeBackGroundColor
110 | }
111 |
112 | if master == false {
113 | setDeactiveBackGroundColor = deactiveBackGroundColor
114 | }else {
115 | setDeactiveBackGroundColor = masterValue.deactiveBackGroundColor
116 | }
117 |
118 | if master == false {
119 | setFontSize = fontSize
120 | }else {
121 | setFontSize = masterValue.fontSize
122 | }
123 |
124 | if master == false {
125 | setFontName = fontName
126 | }else {
127 | setFontName = masterValue.fontName
128 | }
129 |
130 | if master == false {
131 | setActiveImageLeftIcon = activeImageLeftIcon
132 | }else {
133 | setActiveImageLeftIcon = masterValue.activeImageLeftIcon
134 | }
135 |
136 | if master == false {
137 | setDeactiveImageLeftIcon = deactiveImageLeftIcon
138 | }else {
139 | setDeactiveImageLeftIcon = masterValue.deactiveImageLeftIcon
140 | }
141 |
142 | if master == false {
143 | setActiveImageLeftIconColor = activeImageLeftIconColor
144 | }else {
145 | setActiveImageLeftIconColor = masterValue.activeImageLeftIconColor
146 | }
147 |
148 | if master == false {
149 | setDeactiveImageLeftIconColor = deactiveImageLeftIconColor
150 | }else {
151 | setDeactiveImageLeftIconColor = masterValue.deactiveImageLeftIconColor
152 | }
153 |
154 | if master == false {
155 | setIsClearButton = isClearButton
156 | }else {
157 | setIsClearButton = masterValue.isClearButton
158 | }
159 |
160 | if master == false {
161 | setImageClearButton = imageClearButton
162 | }else {
163 | setImageClearButton = masterValue.imageClearButton
164 | }
165 |
166 | if master == false {
167 | setIsSecureText = isSecureText
168 | }else {
169 | setIsSecureText = masterValue.isSecureText
170 | }
171 |
172 | if master == false {
173 | setActiveShadowColor = activeShadowColor
174 | }else {
175 | setActiveShadowColor = masterValue.activeShadowColor
176 | }
177 |
178 | if master == false {
179 | setDeactiveShadowColor = deactiveShadowColor
180 | }else {
181 | setDeactiveShadowColor = masterValue.deactiveShadowColor
182 | }
183 |
184 | if master == false {
185 | setActiveShadowRadius = activeShadowRadius
186 | }else {
187 | setActiveShadowRadius = masterValue.activeShadowRadius
188 | }
189 |
190 | if master == false {
191 | setDeactiveShadowRadius = deactiveShadowRadius
192 | }else {
193 | setDeactiveShadowRadius = masterValue.deactiveShadowRadius
194 | }
195 |
196 | if master == false {
197 | setActiveShadowOpacity = activeShadowOpacity
198 | }else {
199 | setActiveShadowOpacity = masterValue.activeShadowOpacity
200 | }
201 |
202 | if master == false {
203 | setDeactiveShadowOpacity = deactiveShadowOpacity
204 | }else {
205 | setDeactiveShadowOpacity = masterValue.deactiveShadowOpacity
206 | }
207 |
208 | if master == false {
209 | setActiveShadowOffset = activeShadowOffset
210 | }else {
211 | setActiveShadowOffset = masterValue.activeShadowOffset
212 | }
213 |
214 | if master == false {
215 | setDeactiveShadowOffset = deactiveShadowOffset
216 | }else {
217 | setDeactiveShadowOffset = masterValue.deactiveShadowOffset
218 | }
219 |
220 | if master == false {
221 | setDoneToolbar = doneToolbar
222 | }else {
223 | setDoneToolbar = masterValue.doneToolbar
224 | }
225 |
226 | if master == true {
227 | if let tint = masterValue.tintColor {
228 | tintColor = tint
229 | }
230 | }
231 |
232 | if dropDownMaster == false {
233 | setDropDownBackGroundColor = dropDownBackGroundColor
234 | }else {
235 | setDropDownBackGroundColor = dropDownMasterValue.dropDownBackGroundColor
236 | }
237 |
238 | if dropDownMaster == false {
239 | setDropDownSeperatorLineColor = dropDownSeperatorLineColor
240 | }else {
241 | setDropDownSeperatorLineColor = dropDownMasterValue.dropDownSeperatorLineColor
242 | }
243 |
244 | if dropDownMaster == false {
245 | setDropDownBorderColor = dropDownBorderColor
246 | }else {
247 | setDropDownBorderColor = dropDownMasterValue.dropDownBorderColor
248 | }
249 |
250 | if dropDownMaster == false {
251 | setDropDownBorderWidth = dropDownBorderWidth
252 | }else {
253 | setDropDownBorderWidth = dropDownMasterValue.dropDownBorderWidth
254 | }
255 |
256 | if dropDownMaster == false {
257 | setDropDownCornerRadius = dropDownCornerRadius
258 | }else {
259 | setDropDownCornerRadius = dropDownMasterValue.dropDownCornerRadius
260 | }
261 |
262 | if dropDownMaster == false {
263 | setDropDownShadowColor = dropDownShadowColor
264 | }else {
265 | setDropDownShadowColor = dropDownMasterValue.dropDownShadowColor
266 | }
267 |
268 | if dropDownMaster == false {
269 | setDropDownShadowRadius = dropDownShadowRadius
270 | }else {
271 | setDropDownShadowRadius = dropDownMasterValue.dropDownShadowRadius
272 | }
273 |
274 | if dropDownMaster == false {
275 | setDropDownShadowOpacity = dropDownShadowOpacity
276 | }else {
277 | setDropDownShadowOpacity = dropDownMasterValue.dropDownShadowOpacity
278 | }
279 |
280 | if dropDownMaster == false {
281 | setDropDownShadowOffset = dropDownShadowOffset
282 | }else {
283 | setDropDownShadowOffset = dropDownMasterValue.dropDownShadowOffset
284 | }
285 |
286 | if dropDownMaster == false {
287 | setDropDownTitleColor = dropDownTitleColor
288 | }else {
289 | setDropDownTitleColor = dropDownMasterValue.dropDownTitleColor
290 | }
291 |
292 | if dropDownMaster == false {
293 | setDropDownSubtitleColor = dropDownSubtitleColor
294 | }else {
295 | setDropDownSubtitleColor = dropDownMasterValue.dropDownSubtitleColor
296 | }
297 |
298 | if dropDownMaster == false {
299 | setDropDownTitleFontName = dropDownTitleFontName
300 | }else {
301 | setDropDownTitleFontName = dropDownMasterValue.dropDownTitleFontName
302 | }
303 |
304 | if dropDownMaster == false {
305 | setDropDownSubtitleFontName = dropDownSubtitleFontName
306 | }else {
307 | setDropDownSubtitleFontName = dropDownMasterValue.dropDownSubtitleFontName
308 | }
309 |
310 | if dropDownMaster == false {
311 | setDropDownSearchPlaceholder = dropDownSearchPlaceholder
312 | }else {
313 | setDropDownSearchPlaceholder = dropDownMasterValue.dropDownSearchPlaceholder
314 | }
315 |
316 | if dropDownMaster == false {
317 | setDropDownNoDataMessage = dropDownNoDataMessage
318 | }else {
319 | setDropDownNoDataMessage = dropDownMasterValue.dropDownNoDataMessage
320 | }
321 |
322 | if dropDownMaster == false {
323 | setDropDownArrowImage = dropDownArrowImage
324 | }else {
325 | setDropDownArrowImage = dropDownMasterValue.dropDownArrowImage
326 | }
327 |
328 |
329 | setFieldType = fieldType
330 |
331 | ccwaTextField = self
332 |
333 | setArrCCWADropDownModel = arrCCWADropDownModel
334 |
335 | backgroundColor = .clear
336 |
337 | }
338 |
339 | public func continueUpdate() {
340 | text = field.text
341 | }
342 | }
343 |
344 |
345 | extension CCWATextField {
346 |
347 | @discardableResult
348 | public func editingChanged(text: @escaping (String) -> ()) -> CCWATextField {
349 | textFieldInput.editingChanged = text
350 | return self
351 | }
352 |
353 | @discardableResult
354 | public func editingDidBegin(text: @escaping (String) -> ()) -> CCWATextField {
355 | textFieldInput.editingDidBegin = text
356 | return self
357 | }
358 |
359 | @discardableResult
360 | public func editingDidEnd(text: @escaping (String) -> ()) -> CCWATextField {
361 | textFieldInput.editingDidEnd = text
362 | return self
363 | }
364 |
365 | @discardableResult
366 | public func touchUpInsideClear(touch: @escaping () -> ()) -> CCWATextField {
367 | buttonClearText.touchUpInside = touch
368 | return self
369 | }
370 | }
371 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWADropDownCard.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 |
27 | */
28 |
29 | import UIKit
30 |
31 | class CCWADropDownCardStyle1TableViewCell: UITableViewCell {
32 |
33 | var fontSizeTitle:CGFloat = 14
34 |
35 | lazy var labelTitle:UILabel = {
36 | let label = UILabel()
37 | label.translatesAutoresizingMaskIntoConstraints = false
38 | label.font = UIFont.systemFont(ofSize: fontSizeTitle)
39 | label.textColor = .black
40 | return label
41 | }()
42 |
43 | lazy var viewBG:UIView = {
44 | let view = UIView()
45 | view.backgroundColor = .clear
46 | view.translatesAutoresizingMaskIntoConstraints = false
47 | return view
48 | }()
49 |
50 | lazy var viewSeperator:UIView = {
51 | let view = UIView()
52 | view.backgroundColor = .clear
53 | view.translatesAutoresizingMaskIntoConstraints = false
54 | return view
55 | }()
56 |
57 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
58 | super.init(style: style, reuseIdentifier: reuseIdentifier)
59 |
60 | backgroundColor = .clear
61 |
62 | addSubview(viewBG)
63 | viewBG.addSubview(labelTitle)
64 | addSubview(viewSeperator)
65 |
66 | NSLayoutConstraint.activate([
67 |
68 | viewBG.topAnchor.constraint(equalTo: topAnchor, constant: 0),
69 | viewBG.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 0),
70 | viewBG.trailingAnchor.constraint(equalTo: trailingAnchor, constant: 0),
71 | viewBG.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0),
72 | viewBG.heightAnchor.constraint(equalToConstant: 36),
73 |
74 | labelTitle.topAnchor.constraint(equalTo: viewBG.topAnchor, constant: 10),
75 | labelTitle.leadingAnchor.constraint(equalTo: viewBG.leadingAnchor, constant: 15),
76 | labelTitle.trailingAnchor.constraint(equalTo: viewBG.trailingAnchor, constant: -15),
77 | labelTitle.bottomAnchor.constraint(equalTo: viewBG.bottomAnchor, constant: -10),
78 |
79 | viewSeperator.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 15),
80 | viewSeperator.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -15),
81 | viewSeperator.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0),
82 | viewSeperator.heightAnchor.constraint(equalToConstant: 0.5)
83 | ])
84 | }
85 |
86 | required init?(coder: NSCoder) {
87 | super.init(coder: coder)
88 | }
89 | }
90 |
91 |
92 | class CCWADropDownCardStyle2TableViewCell: UITableViewCell {
93 |
94 | var fontSizeTitle:CGFloat = 14
95 | var fontSizeSubTitle:CGFloat = 12
96 |
97 | lazy var stackVertical:UIStackView = {
98 | let stackView = UIStackView()
99 | stackView.axis = .vertical
100 | stackView.alignment = .fill
101 | stackView.distribution = .fill
102 | stackView.spacing = 3
103 | stackView.addArrangedSubview(labelTitle)
104 | stackView.addArrangedSubview(labelSubtitle)
105 | stackView.translatesAutoresizingMaskIntoConstraints = false
106 | return stackView
107 | }()
108 |
109 | lazy var labelTitle:UILabel = {
110 | let label = UILabel()
111 | label.translatesAutoresizingMaskIntoConstraints = false
112 | label.font = UIFont.systemFont(ofSize: fontSizeTitle)
113 | return label
114 | }()
115 |
116 | lazy var labelSubtitle:UILabel = {
117 | let label = UILabel()
118 | label.translatesAutoresizingMaskIntoConstraints = false
119 | label.font = UIFont.systemFont(ofSize: fontSizeSubTitle)
120 | label.textColor = .lightGray
121 | return label
122 | }()
123 |
124 | lazy var viewBG:UIView = {
125 | let view = UIView()
126 | view.backgroundColor = .clear
127 | view.translatesAutoresizingMaskIntoConstraints = false
128 | return view
129 | }()
130 |
131 | lazy var viewSeperator:UIView = {
132 | let view = UIView()
133 | view.backgroundColor = .clear
134 | view.translatesAutoresizingMaskIntoConstraints = false
135 | return view
136 | }()
137 |
138 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
139 | super.init(style: style, reuseIdentifier: reuseIdentifier)
140 |
141 | backgroundColor = .clear
142 |
143 | addSubview(viewBG)
144 | viewBG.addSubview(stackVertical)
145 | addSubview(viewSeperator)
146 |
147 | NSLayoutConstraint.activate([
148 |
149 | viewBG.topAnchor.constraint(equalTo: topAnchor, constant: 0),
150 | viewBG.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 0),
151 | viewBG.trailingAnchor.constraint(equalTo: trailingAnchor, constant: 0),
152 | viewBG.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0),
153 | viewBG.heightAnchor.constraint(equalToConstant: 53),
154 |
155 | stackVertical.topAnchor.constraint(equalTo: viewBG.topAnchor, constant: 10),
156 | stackVertical.leadingAnchor.constraint(equalTo: viewBG.leadingAnchor, constant: 15),
157 | stackVertical.trailingAnchor.constraint(equalTo: viewBG.trailingAnchor, constant: -15),
158 | stackVertical.bottomAnchor.constraint(equalTo: viewBG.bottomAnchor, constant: -10),
159 |
160 | labelTitle.heightAnchor.constraint(equalToConstant: 16),
161 |
162 | labelSubtitle.heightAnchor.constraint(equalToConstant: 14),
163 |
164 | viewSeperator.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 15),
165 | viewSeperator.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -15),
166 | viewSeperator.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0),
167 | viewSeperator.heightAnchor.constraint(equalToConstant: 0.5)
168 | ])
169 | }
170 |
171 | required init?(coder: NSCoder) {
172 | super.init(coder: coder)
173 | }
174 |
175 | }
176 |
177 |
178 | class CCWADropDownCardStyle3TableViewCell: UITableViewCell {
179 |
180 | var fontSizeTitle:CGFloat = 14
181 |
182 | lazy var stackVertical:UIStackView = {
183 | let stackView = UIStackView()
184 | stackView.axis = .vertical
185 | stackView.alignment = .fill
186 | stackView.distribution = .fill
187 | stackView.spacing = 3
188 | stackView.addArrangedSubview(labelTitle)
189 | stackView.translatesAutoresizingMaskIntoConstraints = false
190 | return stackView
191 | }()
192 |
193 | lazy var labelTitle:UILabel = {
194 | let label = UILabel()
195 | label.translatesAutoresizingMaskIntoConstraints = false
196 | label.font = UIFont.systemFont(ofSize: fontSizeTitle)
197 | return label
198 | }()
199 |
200 | lazy var imgView:CCWAUIImageView = {
201 | let imageView = CCWAUIImageView()
202 | imageView.clipsToBounds = true
203 | imageView.layer.cornerRadius = 5
204 | imageView.translatesAutoresizingMaskIntoConstraints = false
205 | return imageView
206 | }()
207 |
208 | lazy var viewBG:UIView = {
209 | let view = UIView()
210 | view.backgroundColor = .clear
211 | view.translatesAutoresizingMaskIntoConstraints = false
212 | return view
213 | }()
214 |
215 | lazy var viewSeperator:UIView = {
216 | let view = UIView()
217 | view.backgroundColor = .clear
218 | view.translatesAutoresizingMaskIntoConstraints = false
219 | return view
220 | }()
221 |
222 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
223 | super.init(style: style, reuseIdentifier: reuseIdentifier)
224 |
225 | backgroundColor = .clear
226 |
227 | addSubview(viewBG)
228 | viewBG.addSubview(imgView)
229 | viewBG.addSubview(stackVertical)
230 | addSubview(viewSeperator)
231 |
232 | NSLayoutConstraint.activate([
233 |
234 | viewBG.topAnchor.constraint(equalTo: topAnchor, constant: 0),
235 | viewBG.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 0),
236 | viewBG.trailingAnchor.constraint(equalTo: trailingAnchor, constant: 0),
237 | viewBG.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0),
238 | viewBG.heightAnchor.constraint(equalToConstant: 53),
239 |
240 | imgView.topAnchor.constraint(equalTo: stackVertical.topAnchor, constant: 0),
241 | imgView.leadingAnchor.constraint(equalTo: viewBG.leadingAnchor, constant: 15),
242 | imgView.trailingAnchor.constraint(equalTo: stackVertical.leadingAnchor, constant: -15),
243 | imgView.bottomAnchor.constraint(equalTo: stackVertical.bottomAnchor, constant: 0),
244 | imgView.widthAnchor.constraint(equalTo: imgView.heightAnchor, multiplier: 1, constant: 0),
245 |
246 | stackVertical.topAnchor.constraint(equalTo: viewBG.topAnchor, constant: 10),
247 | stackVertical.trailingAnchor.constraint(equalTo: viewBG.trailingAnchor, constant: -15),
248 | stackVertical.bottomAnchor.constraint(equalTo: viewBG.bottomAnchor, constant: -10),
249 |
250 | labelTitle.heightAnchor.constraint(equalToConstant: 16),
251 |
252 | viewSeperator.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 15),
253 | viewSeperator.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -15),
254 | viewSeperator.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0),
255 | viewSeperator.heightAnchor.constraint(equalToConstant: 0.5)
256 | ])
257 | }
258 |
259 | required init?(coder: NSCoder) {
260 | super.init(coder: coder)
261 | }
262 |
263 | }
264 |
265 |
266 | class CCWADropDownCardStyle4TableViewCell: UITableViewCell {
267 |
268 | var fontSizeTitle:CGFloat = 14
269 | var fontSizeSubTitle:CGFloat = 12
270 |
271 | lazy var stackVertical:UIStackView = {
272 | let stackView = UIStackView()
273 | stackView.axis = .vertical
274 | stackView.alignment = .fill
275 | stackView.distribution = .fill
276 | stackView.spacing = 3
277 | stackView.addArrangedSubview(labelTitle)
278 | stackView.addArrangedSubview(labelSubtitle)
279 | stackView.translatesAutoresizingMaskIntoConstraints = false
280 | return stackView
281 | }()
282 |
283 | lazy var labelTitle:UILabel = {
284 | let label = UILabel()
285 | label.translatesAutoresizingMaskIntoConstraints = false
286 | label.font = UIFont.systemFont(ofSize: fontSizeTitle)
287 | return label
288 | }()
289 |
290 | lazy var labelSubtitle:UILabel = {
291 | let label = UILabel()
292 | label.translatesAutoresizingMaskIntoConstraints = false
293 | label.font = UIFont.systemFont(ofSize: fontSizeSubTitle)
294 | label.textColor = .lightGray
295 | return label
296 | }()
297 |
298 | lazy var imgView:CCWAUIImageView = {
299 | let imageView = CCWAUIImageView()
300 | imageView.clipsToBounds = true
301 | imageView.layer.cornerRadius = 5
302 | imageView.translatesAutoresizingMaskIntoConstraints = false
303 | return imageView
304 | }()
305 |
306 | lazy var viewBG:UIView = {
307 | let view = UIView()
308 | view.backgroundColor = .clear
309 | view.translatesAutoresizingMaskIntoConstraints = false
310 | return view
311 | }()
312 |
313 | lazy var viewSeperator:UIView = {
314 | let view = UIView()
315 | view.backgroundColor = .clear
316 | view.translatesAutoresizingMaskIntoConstraints = false
317 | return view
318 | }()
319 |
320 | override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
321 | super.init(style: style, reuseIdentifier: reuseIdentifier)
322 |
323 | backgroundColor = .clear
324 |
325 | addSubview(viewBG)
326 | viewBG.addSubview(imgView)
327 | viewBG.addSubview(stackVertical)
328 | addSubview(viewSeperator)
329 |
330 | NSLayoutConstraint.activate([
331 |
332 | viewBG.topAnchor.constraint(equalTo: topAnchor, constant: 0),
333 | viewBG.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 0),
334 | viewBG.trailingAnchor.constraint(equalTo: trailingAnchor, constant: 0),
335 | viewBG.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0),
336 | viewBG.heightAnchor.constraint(equalToConstant: 53),
337 |
338 | imgView.topAnchor.constraint(equalTo: stackVertical.topAnchor, constant: 0),
339 | imgView.leadingAnchor.constraint(equalTo: viewBG.leadingAnchor, constant: 15),
340 | imgView.trailingAnchor.constraint(equalTo: stackVertical.leadingAnchor, constant: -15),
341 | imgView.bottomAnchor.constraint(equalTo: stackVertical.bottomAnchor, constant: 0),
342 | imgView.widthAnchor.constraint(equalTo: imgView.heightAnchor, multiplier: 1, constant: 0),
343 |
344 | stackVertical.topAnchor.constraint(equalTo: viewBG.topAnchor, constant: 10),
345 | stackVertical.trailingAnchor.constraint(equalTo: viewBG.trailingAnchor, constant: -15),
346 | stackVertical.bottomAnchor.constraint(equalTo: viewBG.bottomAnchor, constant: -10),
347 |
348 | labelTitle.heightAnchor.constraint(equalToConstant: 16),
349 |
350 | labelSubtitle.heightAnchor.constraint(equalToConstant: 14),
351 |
352 | viewSeperator.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 15),
353 | viewSeperator.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -15),
354 | viewSeperator.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0),
355 | viewSeperator.heightAnchor.constraint(equalToConstant: 0.5)
356 | ])
357 | }
358 |
359 | required init?(coder: NSCoder) {
360 | super.init(coder: coder)
361 | }
362 |
363 | }
364 |
365 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWADropDownView.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import UIKit
29 |
30 | class CCWADropDownView: UIView {
31 |
32 | lazy var tableViewDropDown:UITableView = {
33 | let tableView = UITableView()
34 | tableView.delegate = self
35 | tableView.dataSource = self
36 | tableView.translatesAutoresizingMaskIntoConstraints = false
37 | tableView.clipsToBounds = true
38 | tableView.layer.cornerRadius = 5
39 | tableView.backgroundColor = .clear
40 | tableView.separatorStyle = .none
41 |
42 | return tableView
43 | }()
44 |
45 | lazy var textFieldSearch:CCWAUITextField = {
46 | let textField = CCWAUITextField()
47 | textField.delegate = self
48 | textField.font = UIFont.systemFont(ofSize: 14)
49 | textField.translatesAutoresizingMaskIntoConstraints = false
50 | textField.placeholder = "Search ...."
51 | textField.clipsToBounds = true
52 | textField.layer.cornerRadius = 5
53 | textField.leftViewMode = .always
54 | textField.leftView = UIView(frame: CGRect(x: 0, y: 0, width: 15, height: 50))
55 | textField.rightViewMode = .always
56 | textField.rightView = UIView(frame: CGRect(x: 0, y: 0, width: 15, height: 50))
57 | textField.addTarget(self, action: #selector(textFieldSearch_editingChanged), for: .editingChanged)
58 | return textField
59 | }()
60 |
61 | lazy var labelNoDataAvailabel:UILabel = {
62 | let label = UILabel()
63 | label.translatesAutoresizingMaskIntoConstraints = false
64 | label.font = UIFont.systemFont(ofSize: 12)
65 | label.textColor = .lightGray
66 | label.textAlignment = .center
67 | label.text = "No Data Availabel!"
68 | return label
69 | }()
70 |
71 | lazy var viewSearchSeperator:UIView = {
72 | let view = UIView()
73 | view.translatesAutoresizingMaskIntoConstraints = false
74 | return view
75 | }()
76 |
77 | var ccwaTextField:CCWATextField?
78 |
79 | var arrCCWADropDownModel = [CCWADropDownModel]()
80 |
81 | var arrAllCCWADropDownModel = [CCWADropDownModel]()
82 |
83 | var dropDownMaximumHeight:CGFloat = 0
84 |
85 | var dropDownFrame:CGRect? = nil
86 |
87 | let cellIdentifierCCWADropDownCardStyle1TableViewCell = "CCWADropDownCardStyle1TableViewCell"
88 | let cellIdentifierCCWADropDownCardStyle2TableViewCell = "CCWADropDownCardStyle2TableViewCell"
89 | let cellIdentifierCCWADropDownCardStyle3TableViewCell = "CCWADropDownCardStyle3TableViewCell"
90 | let cellIdentifierCCWADropDownCardStyle4TableViewCell = "CCWADropDownCardStyle4TableViewCell"
91 |
92 | init(frame: CGRect = .zero, ccwaTextField:CCWATextField?, arrCCWADropDownModel:[CCWADropDownModel] = [CCWADropDownModel]()) {
93 | super.init(frame: frame)
94 |
95 | self.ccwaTextField = ccwaTextField
96 |
97 | if arrCCWADropDownModel.count > 0 {
98 | self.arrCCWADropDownModel = arrCCWADropDownModel
99 | self.arrAllCCWADropDownModel = arrCCWADropDownModel
100 | }
101 |
102 | addSubview(labelNoDataAvailabel)
103 | addSubview(tableViewDropDown)
104 |
105 | if ccwaTextField?.setFieldType == .dropDownSearch {
106 | addSubview(textFieldSearch)
107 | addSubview(viewSearchSeperator)
108 | }
109 |
110 | NSLayoutConstraint.activate([
111 | tableViewDropDown.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 0),
112 | tableViewDropDown.trailingAnchor.constraint(equalTo: trailingAnchor, constant: 0),
113 | tableViewDropDown.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0),
114 |
115 | labelNoDataAvailabel.topAnchor.constraint(equalTo: tableViewDropDown.topAnchor, constant: 0),
116 | labelNoDataAvailabel.leadingAnchor.constraint(equalTo: tableViewDropDown.leadingAnchor, constant: 0),
117 | labelNoDataAvailabel.trailingAnchor.constraint(equalTo: tableViewDropDown.trailingAnchor, constant: 0),
118 | labelNoDataAvailabel.bottomAnchor.constraint(equalTo: tableViewDropDown.bottomAnchor, constant: 0),
119 | ])
120 |
121 | if ccwaTextField?.setFieldType == .dropDownSearch {
122 | NSLayoutConstraint.activate([
123 | textFieldSearch.topAnchor.constraint(equalTo: topAnchor, constant: 0),
124 | textFieldSearch.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 0),
125 | textFieldSearch.trailingAnchor.constraint(equalTo: trailingAnchor, constant: 0),
126 | textFieldSearch.bottomAnchor.constraint(equalTo: tableViewDropDown.topAnchor, constant: 0),
127 | textFieldSearch.heightAnchor.constraint(equalToConstant: 40),
128 |
129 | viewSearchSeperator.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 0),
130 | viewSearchSeperator.trailingAnchor.constraint(equalTo: trailingAnchor, constant: 0),
131 | viewSearchSeperator.bottomAnchor.constraint(equalTo: textFieldSearch.bottomAnchor, constant: 0),
132 | viewSearchSeperator.heightAnchor.constraint(equalToConstant: 0.5),
133 | ])
134 | }else {
135 | tableViewDropDown.topAnchor.constraint(equalTo: topAnchor, constant: 0).isActive = true
136 | }
137 |
138 | tableViewDropDown.register(CCWADropDownCardStyle1TableViewCell.self, forCellReuseIdentifier: cellIdentifierCCWADropDownCardStyle1TableViewCell)
139 | tableViewDropDown.register(CCWADropDownCardStyle2TableViewCell.self, forCellReuseIdentifier: cellIdentifierCCWADropDownCardStyle2TableViewCell)
140 | tableViewDropDown.register(CCWADropDownCardStyle3TableViewCell.self, forCellReuseIdentifier: cellIdentifierCCWADropDownCardStyle3TableViewCell)
141 | tableViewDropDown.register(CCWADropDownCardStyle4TableViewCell.self, forCellReuseIdentifier: cellIdentifierCCWADropDownCardStyle4TableViewCell)
142 |
143 | noDataMessage()
144 |
145 | reloadDropDown()
146 | }
147 |
148 | required init?(coder: NSCoder) {
149 | super.init(coder: coder)
150 | }
151 |
152 | func shadow(frame:CGRect = .zero) {
153 | guard let ccwaTextField = ccwaTextField else { return }
154 |
155 | if dropDownFrame == nil {
156 | dropDownFrame = frame
157 | dropDownMaximumHeight = frame.size.height
158 | setDropDwon()
159 | }
160 |
161 | layer.shadowPath = UIBezierPath(roundedRect: frame, cornerRadius: ccwaTextField.setDropDownCornerRadius).cgPath
162 | layer.shadowColor = ccwaTextField.setDropDownShadowColor.cgColor
163 | layer.shadowOffset = ccwaTextField.setDropDownShadowOffset
164 | layer.shadowRadius = ccwaTextField.setDropDownShadowRadius
165 | layer.shadowOpacity = ccwaTextField.setDropDownShadowOpacity
166 | }
167 |
168 | func setDropDwon() {
169 | guard let ccwaTextField = ccwaTextField else { return }
170 | tableViewDropDown.layer.cornerRadius = ccwaTextField.setDropDownCornerRadius
171 | viewSearchSeperator.backgroundColor = ccwaTextField.setDropDownSeperatorLineColor
172 |
173 | backgroundColor = ccwaTextField.setDropDownBackGroundColor
174 |
175 | layer.cornerRadius = ccwaTextField.setDropDownCornerRadius
176 | layer.borderWidth = ccwaTextField.setDropDownBorderWidth
177 | layer.borderColor = ccwaTextField.setDropDownBorderColor.cgColor
178 |
179 | if ccwaTextField.setDropDownSearchPlaceholder.empty() == false {
180 | textFieldSearch.placeholder = ccwaTextField.setDropDownSearchPlaceholder
181 | }
182 |
183 | if ccwaTextField.setDropDownNoDataMessage.empty() == false {
184 | labelNoDataAvailabel.text = ccwaTextField.setDropDownNoDataMessage
185 | }
186 |
187 | textFieldSearch.tintColor = ccwaTextField.setDropDownTitleColor.withAlphaComponent(0.5)
188 | labelNoDataAvailabel.textColor = ccwaTextField.setDropDownTitleColor.withAlphaComponent(0.5)
189 | textFieldSearch.textColor = ccwaTextField.setDropDownTitleColor
190 |
191 | textFieldSearch.attributedPlaceholder = NSAttributedString(string: textFieldSearch.placeholder ?? "", attributes: [NSAttributedString.Key.foregroundColor: ccwaTextField.setDropDownTitleColor.withAlphaComponent(0.35)])
192 |
193 | if ccwaTextField.setDropDownTitleFontName.empty() == false {
194 | textFieldSearch.font = UIFont(name: ccwaTextField.setDropDownTitleFontName, size: 14)
195 | }
196 | }
197 |
198 | func reloadDropDown() {
199 | OperationQueue.main.addOperation { [weak self] in
200 | guard let self = self else { return }
201 | self.tableViewDropDown.reloadData()
202 | }
203 | }
204 |
205 | func noDataMessage() {
206 | if self.arrCCWADropDownModel.count > 0 {
207 | tableViewDropDown.isHidden = false
208 | labelNoDataAvailabel.isHidden = true
209 | }else {
210 | tableViewDropDown.isHidden = true
211 | labelNoDataAvailabel.isHidden = false
212 | }
213 | }
214 |
215 | func dropDownUpdateHeight() {
216 | let extraSpace = CGFloat(arrCCWADropDownModel.filter({ (($0.image != nil) || ($0.imageURL != nil) || (($0.subtitle ?? "").isEmpty == false)) == true }).count * 17)
217 | var count = arrCCWADropDownModel.count
218 | if count == 0 {
219 | count = 1
220 | }
221 | var heightDropDown :CGFloat = CGFloat(count * 36) + extraSpace
222 | if ccwaTextField?.fieldType == .dropDownSearch {
223 | heightDropDown += 40
224 | }
225 | ccwaTextField?.ccwaOutlineTFConstraint.dropDownViewHeight.constant = (heightDropDown < dropDownMaximumHeight ? heightDropDown : dropDownMaximumHeight)
226 | shadow(frame: CGRect(x: dropDownFrame?.origin.x ?? 0, y: dropDownFrame?.origin.y ?? 0, width: dropDownFrame?.size.width ?? 0, height: (heightDropDown < dropDownMaximumHeight ? heightDropDown : dropDownMaximumHeight)))
227 | noDataMessage()
228 | }
229 |
230 | @objc func textFieldSearch_editingChanged(_ sender:CCWAUITextField) {
231 | let search = sender.text ?? ""
232 | if search.empty() == true {
233 | arrCCWADropDownModel = arrAllCCWADropDownModel
234 | reloadDropDown()
235 | }else {
236 | if let ccwaTextField = ccwaTextField {
237 | let arrCCWADropDownModel = ccwaTextField.dropDownSearchEditingChanged?(ccwaTextField, arrAllCCWADropDownModel, sender.text ?? "")
238 | self.arrCCWADropDownModel = arrCCWADropDownModel ?? []
239 | reloadDropDown()
240 | }
241 | }
242 | dropDownUpdateHeight()
243 | }
244 | }
245 |
246 | extension CCWADropDownView: UITableViewDelegate, UITableViewDataSource {
247 |
248 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
249 | return arrCCWADropDownModel.count
250 | }
251 |
252 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
253 |
254 | let value = arrCCWADropDownModel[indexPath.row]
255 | //value.title = "\(indexPath.row)"
256 |
257 | if let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifierCCWADropDownCardStyle4TableViewCell, for: indexPath) as? CCWADropDownCardStyle4TableViewCell, (value.image != nil || value.imageURL != nil), let subtitle = value.subtitle, subtitle.isEmpty == false {
258 | cell.labelTitle.text = value.title
259 | cell.labelSubtitle.text = subtitle
260 | if let image = value.image {
261 | cell.imgView.image = image
262 | }
263 | if let url = value.imageURL {
264 | cell.imgView.url = url
265 | }
266 | if let titleFont = ccwaTextField?.setDropDownTitleFontName, titleFont.empty() == false {
267 | cell.labelTitle.font = UIFont(name: titleFont, size: cell.fontSizeTitle)
268 | }
269 | if let subtitleFont = ccwaTextField?.setDropDownSubtitleFontName, subtitleFont.empty() == false {
270 | cell.labelSubtitle.font = UIFont(name: subtitleFont, size: cell.fontSizeTitle)
271 | }
272 | cell.labelTitle.textColor = ccwaTextField?.setDropDownTitleColor
273 | cell.labelSubtitle.textColor = ccwaTextField?.setDropDownSubtitleColor
274 | cell.viewSeperator.backgroundColor = ccwaTextField?.setDropDownSeperatorLineColor
275 | cell.viewSeperator.isHidden = (arrCCWADropDownModel.count - 1 == indexPath.row)
276 | return cell
277 | }
278 |
279 | if let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifierCCWADropDownCardStyle3TableViewCell, for: indexPath) as? CCWADropDownCardStyle3TableViewCell, (value.image != nil || value.imageURL != nil) {
280 | cell.labelTitle.text = value.title
281 | if let image = value.image {
282 | cell.imgView.image = image
283 | }
284 | if let url = value.imageURL {
285 | cell.imgView.url = url
286 | }
287 | if let titleFont = ccwaTextField?.setDropDownTitleFontName, titleFont.empty() == false {
288 | cell.labelTitle.font = UIFont(name: titleFont, size: cell.fontSizeTitle)
289 | }
290 | cell.labelTitle.textColor = ccwaTextField?.setDropDownTitleColor
291 | cell.viewSeperator.backgroundColor = ccwaTextField?.setDropDownSeperatorLineColor
292 | cell.viewSeperator.isHidden = (arrCCWADropDownModel.count - 1 == indexPath.row)
293 | return cell
294 | }
295 |
296 | if let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifierCCWADropDownCardStyle2TableViewCell, for: indexPath) as? CCWADropDownCardStyle2TableViewCell, let subtitle = value.subtitle, subtitle.isEmpty == false {
297 | cell.labelTitle.text = value.title
298 | cell.labelSubtitle.text = subtitle
299 | if let titleFont = ccwaTextField?.setDropDownTitleFontName, titleFont.empty() == false {
300 | cell.labelTitle.font = UIFont(name: titleFont, size: cell.fontSizeTitle)
301 | }
302 | if let subtitleFont = ccwaTextField?.setDropDownSubtitleFontName, subtitleFont.empty() == false {
303 | cell.labelSubtitle.font = UIFont(name: subtitleFont, size: cell.fontSizeTitle)
304 | }
305 | cell.labelTitle.textColor = ccwaTextField?.setDropDownTitleColor
306 | cell.labelSubtitle.textColor = ccwaTextField?.setDropDownSubtitleColor
307 | cell.viewSeperator.backgroundColor = ccwaTextField?.setDropDownSeperatorLineColor
308 | cell.viewSeperator.isHidden = (arrCCWADropDownModel.count - 1 == indexPath.row)
309 | return cell
310 | }
311 |
312 | if let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifierCCWADropDownCardStyle1TableViewCell, for: indexPath) as? CCWADropDownCardStyle1TableViewCell {
313 | cell.labelTitle.text = value.title
314 | if let titleFont = ccwaTextField?.setDropDownTitleFontName, titleFont.empty() == false {
315 | cell.labelTitle.font = UIFont(name: titleFont, size: cell.fontSizeTitle)
316 | }
317 | cell.labelTitle.textColor = ccwaTextField?.setDropDownTitleColor
318 | cell.viewSeperator.backgroundColor = ccwaTextField?.setDropDownSeperatorLineColor
319 | cell.viewSeperator.isHidden = (arrCCWADropDownModel.count - 1 == indexPath.row)
320 | return cell
321 | }
322 |
323 | return UITableViewCell()
324 | }
325 |
326 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
327 | let data = arrCCWADropDownModel[indexPath.row]
328 | ccwaTextField?.text = data.title
329 | ccwaTextField?.removeDropDown(ccwaTextField?.text?.isEmpty ?? false)
330 | if let ccwaTextField = ccwaTextField {
331 | ccwaTextField.dropDownDidSelectRow?(ccwaTextField, indexPath.row, data.value)
332 | }
333 | }
334 |
335 | }
336 |
337 |
338 | extension CCWADropDownView: UITextFieldDelegate {
339 |
340 | func textFieldShouldReturn(_ textField: UITextField) -> Bool {
341 | endEditing(true)
342 | return false
343 | }
344 |
345 | }
346 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWATextFieldViewProperty.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import UIKit
29 |
30 | public class CCWATextFieldViewProperty:UIView {
31 |
32 | lazy internal var viewMainBase: UIView = {
33 | let view = UIView()
34 | view.backgroundColor = .clear
35 | view.translatesAutoresizingMaskIntoConstraints = false
36 | return view
37 | }()
38 |
39 | lazy internal var viewSubBase: UIView = {
40 | let view = UIView()
41 | view.backgroundColor = .clear
42 | view.translatesAutoresizingMaskIntoConstraints = false
43 | return view
44 | }()
45 |
46 | lazy internal var viewBG: UIView = {
47 | let view = UIView()
48 | view.backgroundColor = .clear
49 | view.translatesAutoresizingMaskIntoConstraints = false
50 | return view
51 | }()
52 |
53 | lazy internal var viewActiveTitlePosition: UIView = {
54 | let view = UIView()
55 | view.backgroundColor = .clear
56 | view.translatesAutoresizingMaskIntoConstraints = false
57 | return view
58 | }()
59 |
60 | lazy internal var stackViewHorizontal: UIStackView = {
61 | let stackView = UIStackView()
62 | stackView.alignment = .fill
63 | stackView.distribution = .fill
64 | stackView.spacing = 10
65 | stackView.axis = .horizontal
66 | stackView.translatesAutoresizingMaskIntoConstraints = false
67 |
68 | stackView.addArrangedSubview(viewLeftSideImageViewBase)
69 | stackView.addArrangedSubview(viewTextFieldInputBase)
70 | stackView.addArrangedSubview(viewRightSideImageViewBase)
71 | stackView.addArrangedSubview(viewRightSideDropDownArrowImageViewBase)
72 | NSLayoutConstraint.activate([
73 | viewLeftSideImageViewBase.widthAnchor.constraint(equalTo: viewLeftSideImageViewBase.heightAnchor, multiplier: 1),
74 | ])
75 | return stackView
76 | }()
77 |
78 | lazy internal var imageViewLeftSideImageView:UIImageView = {
79 | let imageView = UIImageView()
80 | imageView.contentMode = .scaleAspectFill
81 | imageView.clipsToBounds = true
82 | imageView.translatesAutoresizingMaskIntoConstraints = false
83 | return imageView
84 | }()
85 |
86 | lazy internal var viewLeftSideImageViewBase: UIView = {
87 | let view = UIView()
88 | view.backgroundColor = .clear
89 | view.translatesAutoresizingMaskIntoConstraints = false
90 |
91 | view.addSubview(imageViewLeftSideImageView)
92 | NSLayoutConstraint.activate([
93 | imageViewLeftSideImageView.topAnchor.constraint(equalTo: view.topAnchor, constant: 0),
94 | imageViewLeftSideImageView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0),
95 | imageViewLeftSideImageView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0),
96 | imageViewLeftSideImageView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0)
97 | ])
98 | return view
99 | }()
100 |
101 | lazy internal var viewLeftSideSpace: UIView = {
102 | let view = UIView()
103 | view.backgroundColor = .clear
104 | view.translatesAutoresizingMaskIntoConstraints = false
105 | return view
106 | }()
107 |
108 | lazy internal var viewRightSideImageViewBase: UIView = {
109 | let view = UIView()
110 | view.backgroundColor = .clear
111 | view.isHidden = true
112 | view.translatesAutoresizingMaskIntoConstraints = false
113 |
114 | view.addSubview(buttonClearText)
115 | NSLayoutConstraint.activate([
116 | buttonClearText.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0),
117 | buttonClearText.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0),
118 | buttonClearText.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 0),
119 | buttonClearText.heightAnchor.constraint(equalToConstant: 15),
120 | buttonClearText.widthAnchor.constraint(equalTo: buttonClearText.heightAnchor, multiplier: 1)
121 | ])
122 | return view
123 | }()
124 |
125 | lazy internal var viewRightSideDropDownArrowImageViewBase: UIView = {
126 | let view = UIView()
127 | view.backgroundColor = .clear
128 | view.translatesAutoresizingMaskIntoConstraints = false
129 |
130 | view.addSubview(imageViewDropDownArrow)
131 | NSLayoutConstraint.activate([
132 | imageViewDropDownArrow.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0),
133 | imageViewDropDownArrow.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0),
134 | imageViewDropDownArrow.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 0),
135 | imageViewDropDownArrow.heightAnchor.constraint(equalToConstant: 20),
136 | imageViewDropDownArrow.widthAnchor.constraint(equalTo: imageViewDropDownArrow.heightAnchor, multiplier: 1)
137 | ])
138 | return view
139 | }()
140 |
141 | lazy internal var buttonClearText:CCWAUIButton = {
142 | let button = CCWAUIButton()
143 | button.setImage(UIImage(named: ""), for: .normal)
144 | button.translatesAutoresizingMaskIntoConstraints = false
145 | return button
146 | }()
147 |
148 | lazy internal var buttonFieldActive:UIButton = {
149 | let button = UIButton()
150 | button.isHidden = true
151 | button.setImage(UIImage(named: ""), for: .normal)
152 | button.translatesAutoresizingMaskIntoConstraints = false
153 | return button
154 | }()
155 |
156 | lazy internal var viewTextFieldInputBase: UIView = {
157 | let view = UIView()
158 | view.backgroundColor = .clear
159 | view.translatesAutoresizingMaskIntoConstraints = false
160 |
161 | view.addSubview(textFieldInput)
162 | NSLayoutConstraint.activate([
163 | textFieldInput.topAnchor.constraint(equalTo: view.topAnchor, constant: 2),
164 | textFieldInput.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0),
165 | textFieldInput.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0),
166 | textFieldInput.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0),
167 | ])
168 | return view
169 | }()
170 |
171 | lazy internal var textFieldInput: CCWAUITextField = {
172 | let textField = CCWAUITextField()
173 | textField.translatesAutoresizingMaskIntoConstraints = false
174 | textField.borderStyle = .none
175 | textField.font = UIFont.systemFont(ofSize: 16)
176 | textField.backgroundColor = .clear
177 | textField.placeholder = ""
178 | field = textField
179 | return textField
180 | }()
181 |
182 | lazy internal var labelPlaceholder:UILabel = {
183 | let label = UILabel()
184 | label.font = UIFont.systemFont(ofSize: 16)
185 | label.backgroundColor = .clear
186 | label.minimumScaleFactor = 0.1
187 | label.adjustsFontSizeToFitWidth = true
188 | label.textColor = UIColor.gray.withAlphaComponent(0.5)
189 | label.translatesAutoresizingMaskIntoConstraints = false
190 | return label
191 | }()
192 |
193 | lazy var imageViewDropDownArrow:UIImageView = {
194 | let imageView = UIImageView()
195 | imageView.contentMode = .scaleAspectFit
196 | if #available(iOS 13.0, *) {
197 | imageView.image = UIImage(systemName: "chevron.down")
198 | }
199 | imageView.translatesAutoresizingMaskIntoConstraints = false
200 | return imageView
201 | }()
202 |
203 | //MARK:- CCWATOutlineTextFieldConstraintProperty
204 |
205 | internal var ccwaOutlineTFConstraint = CCWATOutlineTextFieldConstraintProperty()
206 |
207 | //MARK:- CCWATextFieldDelegate
208 |
209 | internal var delegate:CCWATextFieldDelegate?
210 |
211 | //MARK:- Static Internal Value
212 |
213 | internal var isFirstTimeLoad = true
214 |
215 | //MARK:- Set Property
216 |
217 | public var field = UITextField() {
218 | didSet {
219 | Delay().time(0.3) {
220 | self.textFieldInput.delegate = self.findViewController() as? UITextFieldDelegate
221 | }
222 | }
223 | }
224 |
225 | internal var setText:String? = "" {
226 | didSet {
227 | if isFirstTimeLoad == true {
228 | Delay().time(0.3) {
229 | self.isFirstTimeLoad = false
230 | self.textFieldInput.text = self.setText
231 | self.adjustActivePlaceholder()
232 | }
233 | }else {
234 | self.textFieldInput.text = self.setText
235 | self.adjustActivePlaceholder()
236 | }
237 | }
238 | }
239 |
240 | internal var setTextColor:UIColor = .black {
241 | didSet {
242 | textFieldInput.textColor = setTextColor
243 | }
244 | }
245 |
246 | internal var setPlaceholder:String = "" {
247 | didSet {
248 | labelPlaceholder.text = setPlaceholder
249 | Delay().time(0.1) {
250 | self.adjustDeactivePlaceholder()
251 | }
252 | }
253 | }
254 |
255 | internal var setAnimatePlaceholder:Bool = false {
256 | didSet {
257 | if setAnimatePlaceholder == true {
258 | labelPlaceholder.isHidden = false
259 | textFieldInput.placeholder = ""
260 | textFieldInput.attributedPlaceholder = NSAttributedString(string: setPlaceholder, attributes: [NSAttributedString.Key.foregroundColor : UIColor.clear])
261 | }else {
262 | labelPlaceholder.isHidden = true
263 | textFieldInput.placeholder = setPlaceholder
264 | textFieldInput.attributedPlaceholder = NSAttributedString(string: setPlaceholder, attributes: [NSAttributedString.Key.foregroundColor : setDeactivePlaceholderColor])
265 | }
266 | }
267 | }
268 |
269 | internal var setActivePlaceholderColor:UIColor? = nil
270 |
271 | internal var setDeactivePlaceholderColor:UIColor = .lightGray {
272 | didSet {
273 | labelPlaceholder.textColor = setDeactivePlaceholderColor
274 | }
275 | }
276 |
277 | internal var setActivePlacehoderBackGroundColor:UIColor = .white
278 |
279 | internal var setActiveBorderColor:UIColor? = nil
280 |
281 | internal var setDeactiveBorderColor:UIColor = .darkGray {
282 | didSet {
283 | viewBG.layer.borderColor = setDeactiveBorderColor.cgColor
284 | }
285 | }
286 |
287 | internal var setActiveBorderWidth:CGFloat = 0
288 |
289 | internal var setDeactiveBorderWidth:CGFloat = 1 {
290 | didSet {
291 | viewBG.layer.borderWidth = setDeactiveBorderWidth
292 | }
293 | }
294 |
295 | internal var setActiveCornerRadius:CGFloat = 0
296 |
297 | internal var setDeactiveCornerRadius:CGFloat = 5 {
298 | didSet {
299 | viewBG.layer.cornerRadius = setDeactiveCornerRadius
300 | }
301 | }
302 |
303 | internal var setActiveBackGroundColor:UIColor? = nil
304 |
305 | internal var setDeactiveBackGroundColor:UIColor = .white {
306 | didSet {
307 | viewBG.backgroundColor = setDeactiveBackGroundColor
308 | }
309 | }
310 |
311 | internal var setFontSize:CGFloat = 16 {
312 | didSet {
313 | setFont()
314 | }
315 | }
316 |
317 | internal var setFontName:String = "" {
318 | didSet {
319 | setFont()
320 | }
321 | }
322 |
323 | internal var setActiveImageLeftIcon:UIImage? = nil
324 |
325 | internal var setDeactiveImageLeftIcon:UIImage? = nil {
326 | didSet {
327 | imageViewLeftSideImageView.image = setDeactiveImageLeftIcon
328 | viewLeftSideImageViewBase.isHidden = setDeactiveImageLeftIcon == nil
329 | }
330 | }
331 |
332 | internal var setActiveImageLeftIconColor:UIColor? = nil
333 |
334 | internal var setDeactiveImageLeftIconColor:UIColor? = nil {
335 | didSet {
336 | if let color = setDeactiveImageLeftIconColor {
337 | imageViewLeftSideImageView.image = imageViewLeftSideImageView.image?.withRenderingMode(.alwaysTemplate)
338 | imageViewLeftSideImageView.tintColor = color
339 | }
340 | }
341 | }
342 |
343 | internal var setIsClearButton:Bool = true {
344 | didSet {
345 | buttonClearShowHide()
346 | }
347 | }
348 |
349 | internal var setImageClearButton:UIImage? = nil {
350 | didSet {
351 | buttonClearText.setImage(setImageClearButton, for: .normal)
352 | btnClearTintColorChange()
353 | }
354 | }
355 |
356 | internal var setIsSecureText:Bool = false {
357 | didSet {
358 | textFieldInput.isSecureTextEntry = setIsSecureText
359 | }
360 | }
361 |
362 | internal var setActiveShadowColor: UIColor? = nil
363 |
364 | internal var setDeactiveShadowColor: UIColor = .clear {
365 | didSet {
366 | setShadowPath()
367 | viewBG.layer.shadowColor = setDeactiveShadowColor.cgColor
368 | }
369 | }
370 |
371 | internal var setActiveShadowRadius: CGFloat = 0
372 |
373 | internal var setDeactiveShadowRadius: CGFloat = 0 {
374 | didSet {
375 | setShadowPath()
376 | viewBG.layer.shadowRadius = setDeactiveShadowRadius
377 | }
378 | }
379 |
380 | internal var setActiveShadowOpacity:Float = 0
381 |
382 | internal var setDeactiveShadowOpacity:Float = 1 {
383 | didSet {
384 | setShadowPath()
385 | viewBG.layer.shadowOpacity = setDeactiveShadowOpacity
386 | }
387 | }
388 |
389 | internal var setActiveShadowOffset:CGSize = .zero
390 |
391 | internal var setDeactiveShadowOffset:CGSize = .zero {
392 | didSet {
393 | setShadowPath()
394 | viewBG.layer.shadowOffset = setDeactiveShadowOffset
395 | }
396 | }
397 |
398 | internal var setDoneToolbar:Bool = true {
399 | didSet {
400 | Delay().time(0.2) {
401 | self.textFieldInput.inputAccessoryView = self.setDoneToolbar ? self.setToolBarDone() : nil
402 | }
403 | }
404 | }
405 |
406 | internal var setDropDownBackGroundColor: UIColor = .white
407 |
408 | internal var setDropDownSeperatorLineColor: UIColor = .lightGray
409 |
410 | internal var setDropDownBorderColor: UIColor = .lightGray
411 |
412 | internal var setDropDownBorderWidth: CGFloat = 0.5
413 |
414 | internal var setDropDownCornerRadius:CGFloat = 5
415 |
416 | internal var setDropDownShadowColor: UIColor = .darkGray
417 |
418 | internal var setDropDownShadowRadius: CGFloat = 4
419 |
420 | internal var setDropDownShadowOpacity:Float = 0.5
421 |
422 | internal var setDropDownShadowOffset:CGSize = CGSize(width: 0, height: 2)
423 |
424 | internal var setDropDownTitleColor:UIColor = .black
425 |
426 | internal var setDropDownSubtitleColor:UIColor = .lightGray
427 |
428 | internal var setDropDownTitleFontName:String = ""
429 |
430 | internal var setDropDownSubtitleFontName:String = ""
431 |
432 | internal var setDropDownSearchPlaceholder:String = ""
433 |
434 | internal var setDropDownNoDataMessage:String = ""
435 |
436 | internal var setDropDownArrowImage:UIImage? = nil {
437 | didSet {
438 | if let image = setDropDownArrowImage {
439 | imageViewDropDownArrow.image = image
440 | imageViewDropDownArrow.tintColor = self.tintColor
441 | viewRightSideDropDownArrowImageViewBase.isHidden = false
442 | }else {
443 | viewRightSideDropDownArrowImageViewBase.isHidden = true
444 | }
445 | }
446 | }
447 |
448 | internal var setFieldType:FieldType = .textField {
449 | didSet {
450 | if setFieldType == .textField {
451 | buttonFieldActive.isHidden = true
452 | viewRightSideDropDownArrowImageViewBase.isHidden = true
453 | }else {
454 | viewRightSideDropDownArrowImageViewBase.isHidden = false
455 | buttonFieldActive.isHidden = false
456 | }
457 | }
458 | }
459 |
460 | internal var ccwaTextField:CCWATextField?
461 |
462 | internal var viewDropDown:UIView?
463 |
464 | internal var viewDropDownBack:UIButton?
465 |
466 | internal var setArrCCWADropDownModel = [CCWADropDownModel]()
467 |
468 | internal let _UIConstraintBasedLayoutLogUnsatisfiable = "_UIConstraintBasedLayoutLogUnsatisfiable"
469 |
470 | override init(frame: CGRect) {
471 | super.init(frame: frame)
472 | setUpCCWATOutlineTextField()
473 | }
474 |
475 | required init?(coder: NSCoder) {
476 | super.init(coder: coder)
477 | setUpCCWATOutlineTextField()
478 | }
479 |
480 | public enum FieldType {
481 | case textField
482 | case dropDown
483 | case dropDownSearch
484 | }
485 | }
486 |
487 |
488 |
--------------------------------------------------------------------------------
/CCWATextField.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 50;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 0475B87525443B2300F22229 /* CCWADropDownView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B86525443B2200F22229 /* CCWADropDownView.swift */; };
11 | 0475B87625443B2300F22229 /* CCWAUIImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B86625443B2200F22229 /* CCWAUIImageView.swift */; };
12 | 0475B87725443B2300F22229 /* CCWATextFieldViewPropertyUpdate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B86725443B2200F22229 /* CCWATextFieldViewPropertyUpdate.swift */; };
13 | 0475B87825443B2300F22229 /* CCWADropDownModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B86825443B2200F22229 /* CCWADropDownModel.swift */; };
14 | 0475B87925443B2300F22229 /* CCWATextFieldUpdate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B86925443B2200F22229 /* CCWATextFieldUpdate.swift */; };
15 | 0475B87A25443B2300F22229 /* CCWATextViewConstraintProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B86A25443B2200F22229 /* CCWATextViewConstraintProperty.swift */; };
16 | 0475B87B25443B2300F22229 /* CCWAUIButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B86B25443B2200F22229 /* CCWAUIButton.swift */; };
17 | 0475B87C25443B2300F22229 /* CCWATextFieldMaster.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B86C25443B2200F22229 /* CCWATextFieldMaster.swift */; };
18 | 0475B87D25443B2300F22229 /* CCWATextFieldDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B86D25443B2300F22229 /* CCWATextFieldDelegate.swift */; };
19 | 0475B87E25443B2300F22229 /* CCWATextFieldViewProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B86E25443B2300F22229 /* CCWATextFieldViewProperty.swift */; };
20 | 0475B87F25443B2300F22229 /* CCWATextViewSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B86F25443B2300F22229 /* CCWATextViewSupport.swift */; };
21 | 0475B88025443B2300F22229 /* CCWADropDownViewMaster.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B87025443B2300F22229 /* CCWADropDownViewMaster.swift */; };
22 | 0475B88125443B2300F22229 /* Delay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B87125443B2300F22229 /* Delay.swift */; };
23 | 0475B88225443B2300F22229 /* CCWADropDownCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B87225443B2300F22229 /* CCWADropDownCard.swift */; };
24 | 0475B88325443B2300F22229 /* CCWAUITextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B87325443B2300F22229 /* CCWAUITextField.swift */; };
25 | 0475B88425443B2300F22229 /* CCWATextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0475B87425443B2300F22229 /* CCWATextField.swift */; };
26 | 8452428624DAC6BD008F51DC /* CCWATextField.h in Headers */ = {isa = PBXBuildFile; fileRef = 8452428424DAC6BD008F51DC /* CCWATextField.h */; settings = {ATTRIBUTES = (Public, ); }; };
27 | /* End PBXBuildFile section */
28 |
29 | /* Begin PBXFileReference section */
30 | 0475B86525443B2200F22229 /* CCWADropDownView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWADropDownView.swift; sourceTree = ""; };
31 | 0475B86625443B2200F22229 /* CCWAUIImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWAUIImageView.swift; sourceTree = ""; };
32 | 0475B86725443B2200F22229 /* CCWATextFieldViewPropertyUpdate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWATextFieldViewPropertyUpdate.swift; sourceTree = ""; };
33 | 0475B86825443B2200F22229 /* CCWADropDownModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWADropDownModel.swift; sourceTree = ""; };
34 | 0475B86925443B2200F22229 /* CCWATextFieldUpdate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWATextFieldUpdate.swift; sourceTree = ""; };
35 | 0475B86A25443B2200F22229 /* CCWATextViewConstraintProperty.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWATextViewConstraintProperty.swift; sourceTree = ""; };
36 | 0475B86B25443B2200F22229 /* CCWAUIButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWAUIButton.swift; sourceTree = ""; };
37 | 0475B86C25443B2200F22229 /* CCWATextFieldMaster.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWATextFieldMaster.swift; sourceTree = ""; };
38 | 0475B86D25443B2300F22229 /* CCWATextFieldDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWATextFieldDelegate.swift; sourceTree = ""; };
39 | 0475B86E25443B2300F22229 /* CCWATextFieldViewProperty.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWATextFieldViewProperty.swift; sourceTree = ""; };
40 | 0475B86F25443B2300F22229 /* CCWATextViewSupport.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWATextViewSupport.swift; sourceTree = ""; };
41 | 0475B87025443B2300F22229 /* CCWADropDownViewMaster.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWADropDownViewMaster.swift; sourceTree = ""; };
42 | 0475B87125443B2300F22229 /* Delay.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Delay.swift; sourceTree = ""; };
43 | 0475B87225443B2300F22229 /* CCWADropDownCard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWADropDownCard.swift; sourceTree = ""; };
44 | 0475B87325443B2300F22229 /* CCWAUITextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWAUITextField.swift; sourceTree = ""; };
45 | 0475B87425443B2300F22229 /* CCWATextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCWATextField.swift; sourceTree = ""; };
46 | 8452428124DAC6BD008F51DC /* CCWATextField.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CCWATextField.framework; sourceTree = BUILT_PRODUCTS_DIR; };
47 | 8452428424DAC6BD008F51DC /* CCWATextField.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CCWATextField.h; sourceTree = ""; };
48 | 8452428524DAC6BD008F51DC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
49 | /* End PBXFileReference section */
50 |
51 | /* Begin PBXFrameworksBuildPhase section */
52 | 8452427E24DAC6BD008F51DC /* Frameworks */ = {
53 | isa = PBXFrameworksBuildPhase;
54 | buildActionMask = 2147483647;
55 | files = (
56 | );
57 | runOnlyForDeploymentPostprocessing = 0;
58 | };
59 | /* End PBXFrameworksBuildPhase section */
60 |
61 | /* Begin PBXGroup section */
62 | 0477871625109087008A2B54 /* SupportingFiles */ = {
63 | isa = PBXGroup;
64 | children = (
65 | 0475B87225443B2300F22229 /* CCWADropDownCard.swift */,
66 | 0475B86825443B2200F22229 /* CCWADropDownModel.swift */,
67 | 0475B86525443B2200F22229 /* CCWADropDownView.swift */,
68 | 0475B87025443B2300F22229 /* CCWADropDownViewMaster.swift */,
69 | 0475B87425443B2300F22229 /* CCWATextField.swift */,
70 | 0475B86D25443B2300F22229 /* CCWATextFieldDelegate.swift */,
71 | 0475B86C25443B2200F22229 /* CCWATextFieldMaster.swift */,
72 | 0475B86925443B2200F22229 /* CCWATextFieldUpdate.swift */,
73 | 0475B86E25443B2300F22229 /* CCWATextFieldViewProperty.swift */,
74 | 0475B86725443B2200F22229 /* CCWATextFieldViewPropertyUpdate.swift */,
75 | 0475B86A25443B2200F22229 /* CCWATextViewConstraintProperty.swift */,
76 | 0475B86F25443B2300F22229 /* CCWATextViewSupport.swift */,
77 | 0475B86B25443B2200F22229 /* CCWAUIButton.swift */,
78 | 0475B86625443B2200F22229 /* CCWAUIImageView.swift */,
79 | 0475B87325443B2300F22229 /* CCWAUITextField.swift */,
80 | 0475B87125443B2300F22229 /* Delay.swift */,
81 | );
82 | path = SupportingFiles;
83 | sourceTree = "";
84 | };
85 | 8452427724DAC6BD008F51DC = {
86 | isa = PBXGroup;
87 | children = (
88 | 8452428324DAC6BD008F51DC /* CCWATextField */,
89 | 8452428224DAC6BD008F51DC /* Products */,
90 | );
91 | sourceTree = "";
92 | };
93 | 8452428224DAC6BD008F51DC /* Products */ = {
94 | isa = PBXGroup;
95 | children = (
96 | 8452428124DAC6BD008F51DC /* CCWATextField.framework */,
97 | );
98 | name = Products;
99 | sourceTree = "";
100 | };
101 | 8452428324DAC6BD008F51DC /* CCWATextField */ = {
102 | isa = PBXGroup;
103 | children = (
104 | 0477871625109087008A2B54 /* SupportingFiles */,
105 | 8452428424DAC6BD008F51DC /* CCWATextField.h */,
106 | 8452428524DAC6BD008F51DC /* Info.plist */,
107 | );
108 | path = CCWATextField;
109 | sourceTree = "";
110 | };
111 | /* End PBXGroup section */
112 |
113 | /* Begin PBXHeadersBuildPhase section */
114 | 8452427C24DAC6BD008F51DC /* Headers */ = {
115 | isa = PBXHeadersBuildPhase;
116 | buildActionMask = 2147483647;
117 | files = (
118 | 8452428624DAC6BD008F51DC /* CCWATextField.h in Headers */,
119 | );
120 | runOnlyForDeploymentPostprocessing = 0;
121 | };
122 | /* End PBXHeadersBuildPhase section */
123 |
124 | /* Begin PBXNativeTarget section */
125 | 8452428024DAC6BD008F51DC /* CCWATextField */ = {
126 | isa = PBXNativeTarget;
127 | buildConfigurationList = 8452428924DAC6BD008F51DC /* Build configuration list for PBXNativeTarget "CCWATextField" */;
128 | buildPhases = (
129 | 8452427C24DAC6BD008F51DC /* Headers */,
130 | 8452427D24DAC6BD008F51DC /* Sources */,
131 | 8452427E24DAC6BD008F51DC /* Frameworks */,
132 | 8452427F24DAC6BD008F51DC /* Resources */,
133 | );
134 | buildRules = (
135 | );
136 | dependencies = (
137 | );
138 | name = CCWATextField;
139 | productName = CCWATextField;
140 | productReference = 8452428124DAC6BD008F51DC /* CCWATextField.framework */;
141 | productType = "com.apple.product-type.framework";
142 | };
143 | /* End PBXNativeTarget section */
144 |
145 | /* Begin PBXProject section */
146 | 8452427824DAC6BD008F51DC /* Project object */ = {
147 | isa = PBXProject;
148 | attributes = {
149 | LastUpgradeCheck = 1160;
150 | ORGANIZATIONNAME = Admin;
151 | TargetAttributes = {
152 | 8452428024DAC6BD008F51DC = {
153 | CreatedOnToolsVersion = 11.6;
154 | LastSwiftMigration = 1200;
155 | };
156 | };
157 | };
158 | buildConfigurationList = 8452427B24DAC6BD008F51DC /* Build configuration list for PBXProject "CCWATextField" */;
159 | compatibilityVersion = "Xcode 9.3";
160 | developmentRegion = en;
161 | hasScannedForEncodings = 0;
162 | knownRegions = (
163 | en,
164 | Base,
165 | );
166 | mainGroup = 8452427724DAC6BD008F51DC;
167 | productRefGroup = 8452428224DAC6BD008F51DC /* Products */;
168 | projectDirPath = "";
169 | projectRoot = "";
170 | targets = (
171 | 8452428024DAC6BD008F51DC /* CCWATextField */,
172 | );
173 | };
174 | /* End PBXProject section */
175 |
176 | /* Begin PBXResourcesBuildPhase section */
177 | 8452427F24DAC6BD008F51DC /* Resources */ = {
178 | isa = PBXResourcesBuildPhase;
179 | buildActionMask = 2147483647;
180 | files = (
181 | );
182 | runOnlyForDeploymentPostprocessing = 0;
183 | };
184 | /* End PBXResourcesBuildPhase section */
185 |
186 | /* Begin PBXSourcesBuildPhase section */
187 | 8452427D24DAC6BD008F51DC /* Sources */ = {
188 | isa = PBXSourcesBuildPhase;
189 | buildActionMask = 2147483647;
190 | files = (
191 | 0475B87D25443B2300F22229 /* CCWATextFieldDelegate.swift in Sources */,
192 | 0475B88325443B2300F22229 /* CCWAUITextField.swift in Sources */,
193 | 0475B87E25443B2300F22229 /* CCWATextFieldViewProperty.swift in Sources */,
194 | 0475B88225443B2300F22229 /* CCWADropDownCard.swift in Sources */,
195 | 0475B87725443B2300F22229 /* CCWATextFieldViewPropertyUpdate.swift in Sources */,
196 | 0475B88425443B2300F22229 /* CCWATextField.swift in Sources */,
197 | 0475B87925443B2300F22229 /* CCWATextFieldUpdate.swift in Sources */,
198 | 0475B87B25443B2300F22229 /* CCWAUIButton.swift in Sources */,
199 | 0475B88025443B2300F22229 /* CCWADropDownViewMaster.swift in Sources */,
200 | 0475B87625443B2300F22229 /* CCWAUIImageView.swift in Sources */,
201 | 0475B87A25443B2300F22229 /* CCWATextViewConstraintProperty.swift in Sources */,
202 | 0475B87825443B2300F22229 /* CCWADropDownModel.swift in Sources */,
203 | 0475B87525443B2300F22229 /* CCWADropDownView.swift in Sources */,
204 | 0475B87F25443B2300F22229 /* CCWATextViewSupport.swift in Sources */,
205 | 0475B87C25443B2300F22229 /* CCWATextFieldMaster.swift in Sources */,
206 | 0475B88125443B2300F22229 /* Delay.swift in Sources */,
207 | );
208 | runOnlyForDeploymentPostprocessing = 0;
209 | };
210 | /* End PBXSourcesBuildPhase section */
211 |
212 | /* Begin XCBuildConfiguration section */
213 | 8452428724DAC6BD008F51DC /* Debug */ = {
214 | isa = XCBuildConfiguration;
215 | buildSettings = {
216 | ALWAYS_SEARCH_USER_PATHS = NO;
217 | CLANG_ANALYZER_NONNULL = YES;
218 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
219 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
220 | CLANG_CXX_LIBRARY = "libc++";
221 | CLANG_ENABLE_MODULES = YES;
222 | CLANG_ENABLE_OBJC_ARC = YES;
223 | CLANG_ENABLE_OBJC_WEAK = YES;
224 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
225 | CLANG_WARN_BOOL_CONVERSION = YES;
226 | CLANG_WARN_COMMA = YES;
227 | CLANG_WARN_CONSTANT_CONVERSION = YES;
228 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
229 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
230 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
231 | CLANG_WARN_EMPTY_BODY = YES;
232 | CLANG_WARN_ENUM_CONVERSION = YES;
233 | CLANG_WARN_INFINITE_RECURSION = YES;
234 | CLANG_WARN_INT_CONVERSION = YES;
235 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
236 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
237 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
238 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
239 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
240 | CLANG_WARN_STRICT_PROTOTYPES = YES;
241 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
242 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
243 | CLANG_WARN_UNREACHABLE_CODE = YES;
244 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
245 | COPY_PHASE_STRIP = NO;
246 | CURRENT_PROJECT_VERSION = 1;
247 | DEBUG_INFORMATION_FORMAT = dwarf;
248 | ENABLE_STRICT_OBJC_MSGSEND = YES;
249 | ENABLE_TESTABILITY = YES;
250 | GCC_C_LANGUAGE_STANDARD = gnu11;
251 | GCC_DYNAMIC_NO_PIC = NO;
252 | GCC_NO_COMMON_BLOCKS = YES;
253 | GCC_OPTIMIZATION_LEVEL = 0;
254 | GCC_PREPROCESSOR_DEFINITIONS = (
255 | "DEBUG=1",
256 | "$(inherited)",
257 | );
258 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
259 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
260 | GCC_WARN_UNDECLARED_SELECTOR = YES;
261 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
262 | GCC_WARN_UNUSED_FUNCTION = YES;
263 | GCC_WARN_UNUSED_VARIABLE = YES;
264 | IPHONEOS_DEPLOYMENT_TARGET = 13.6;
265 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
266 | MTL_FAST_MATH = YES;
267 | ONLY_ACTIVE_ARCH = YES;
268 | SDKROOT = iphoneos;
269 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
270 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
271 | VERSIONING_SYSTEM = "apple-generic";
272 | VERSION_INFO_PREFIX = "";
273 | };
274 | name = Debug;
275 | };
276 | 8452428824DAC6BD008F51DC /* Release */ = {
277 | isa = XCBuildConfiguration;
278 | buildSettings = {
279 | ALWAYS_SEARCH_USER_PATHS = NO;
280 | CLANG_ANALYZER_NONNULL = YES;
281 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
282 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
283 | CLANG_CXX_LIBRARY = "libc++";
284 | CLANG_ENABLE_MODULES = YES;
285 | CLANG_ENABLE_OBJC_ARC = YES;
286 | CLANG_ENABLE_OBJC_WEAK = YES;
287 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
288 | CLANG_WARN_BOOL_CONVERSION = YES;
289 | CLANG_WARN_COMMA = YES;
290 | CLANG_WARN_CONSTANT_CONVERSION = YES;
291 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
292 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
293 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
294 | CLANG_WARN_EMPTY_BODY = YES;
295 | CLANG_WARN_ENUM_CONVERSION = YES;
296 | CLANG_WARN_INFINITE_RECURSION = YES;
297 | CLANG_WARN_INT_CONVERSION = YES;
298 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
299 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
300 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
301 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
302 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
303 | CLANG_WARN_STRICT_PROTOTYPES = YES;
304 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
305 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
306 | CLANG_WARN_UNREACHABLE_CODE = YES;
307 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
308 | COPY_PHASE_STRIP = NO;
309 | CURRENT_PROJECT_VERSION = 1;
310 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
311 | ENABLE_NS_ASSERTIONS = NO;
312 | ENABLE_STRICT_OBJC_MSGSEND = YES;
313 | GCC_C_LANGUAGE_STANDARD = gnu11;
314 | GCC_NO_COMMON_BLOCKS = YES;
315 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
316 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
317 | GCC_WARN_UNDECLARED_SELECTOR = YES;
318 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
319 | GCC_WARN_UNUSED_FUNCTION = YES;
320 | GCC_WARN_UNUSED_VARIABLE = YES;
321 | IPHONEOS_DEPLOYMENT_TARGET = 13.6;
322 | MTL_ENABLE_DEBUG_INFO = NO;
323 | MTL_FAST_MATH = YES;
324 | SDKROOT = iphoneos;
325 | SWIFT_COMPILATION_MODE = wholemodule;
326 | SWIFT_OPTIMIZATION_LEVEL = "-O";
327 | VALIDATE_PRODUCT = YES;
328 | VERSIONING_SYSTEM = "apple-generic";
329 | VERSION_INFO_PREFIX = "";
330 | };
331 | name = Release;
332 | };
333 | 8452428A24DAC6BD008F51DC /* Debug */ = {
334 | isa = XCBuildConfiguration;
335 | buildSettings = {
336 | CLANG_ENABLE_MODULES = YES;
337 | CODE_SIGN_IDENTITY = "Apple Development";
338 | "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
339 | CODE_SIGN_STYLE = Automatic;
340 | DEFINES_MODULE = YES;
341 | DEVELOPMENT_TEAM = "";
342 | DYLIB_COMPATIBILITY_VERSION = 1;
343 | DYLIB_CURRENT_VERSION = 1;
344 | DYLIB_INSTALL_NAME_BASE = "@rpath";
345 | FRAMEWORK_SEARCH_PATHS = (
346 | "$(inherited)",
347 | "$(PROJECT_DIR)/CCWATextField",
348 | );
349 | INFOPLIST_FILE = CCWATextField/Info.plist;
350 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
351 | IPHONEOS_DEPLOYMENT_TARGET = 12.0;
352 | LD_RUNPATH_SEARCH_PATHS = (
353 | "$(inherited)",
354 | "@executable_path/Frameworks",
355 | "@loader_path/Frameworks",
356 | );
357 | PRODUCT_BUNDLE_IDENTIFIER = com.anandkhanpara.CCWATextFieldExample;
358 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
359 | PROVISIONING_PROFILE_SPECIFIER = "";
360 | "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
361 | SKIP_INSTALL = YES;
362 | SUPPORTS_MACCATALYST = NO;
363 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
364 | SWIFT_VERSION = 5.0;
365 | TARGETED_DEVICE_FAMILY = "1,2";
366 | };
367 | name = Debug;
368 | };
369 | 8452428B24DAC6BD008F51DC /* Release */ = {
370 | isa = XCBuildConfiguration;
371 | buildSettings = {
372 | CLANG_ENABLE_MODULES = YES;
373 | CODE_SIGN_IDENTITY = "Apple Development";
374 | "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
375 | CODE_SIGN_STYLE = Automatic;
376 | DEFINES_MODULE = YES;
377 | DEVELOPMENT_TEAM = "";
378 | DYLIB_COMPATIBILITY_VERSION = 1;
379 | DYLIB_CURRENT_VERSION = 1;
380 | DYLIB_INSTALL_NAME_BASE = "@rpath";
381 | FRAMEWORK_SEARCH_PATHS = (
382 | "$(inherited)",
383 | "$(PROJECT_DIR)/CCWATextField",
384 | );
385 | INFOPLIST_FILE = CCWATextField/Info.plist;
386 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
387 | IPHONEOS_DEPLOYMENT_TARGET = 12.0;
388 | LD_RUNPATH_SEARCH_PATHS = (
389 | "$(inherited)",
390 | "@executable_path/Frameworks",
391 | "@loader_path/Frameworks",
392 | );
393 | PRODUCT_BUNDLE_IDENTIFIER = com.anandkhanpara.CCWATextFieldExample;
394 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
395 | PROVISIONING_PROFILE_SPECIFIER = "";
396 | "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
397 | SKIP_INSTALL = YES;
398 | SUPPORTS_MACCATALYST = NO;
399 | SWIFT_VERSION = 5.0;
400 | TARGETED_DEVICE_FAMILY = "1,2";
401 | };
402 | name = Release;
403 | };
404 | /* End XCBuildConfiguration section */
405 |
406 | /* Begin XCConfigurationList section */
407 | 8452427B24DAC6BD008F51DC /* Build configuration list for PBXProject "CCWATextField" */ = {
408 | isa = XCConfigurationList;
409 | buildConfigurations = (
410 | 8452428724DAC6BD008F51DC /* Debug */,
411 | 8452428824DAC6BD008F51DC /* Release */,
412 | );
413 | defaultConfigurationIsVisible = 0;
414 | defaultConfigurationName = Release;
415 | };
416 | 8452428924DAC6BD008F51DC /* Build configuration list for PBXNativeTarget "CCWATextField" */ = {
417 | isa = XCConfigurationList;
418 | buildConfigurations = (
419 | 8452428A24DAC6BD008F51DC /* Debug */,
420 | 8452428B24DAC6BD008F51DC /* Release */,
421 | );
422 | defaultConfigurationIsVisible = 0;
423 | defaultConfigurationName = Release;
424 | };
425 | /* End XCConfigurationList section */
426 | };
427 | rootObject = 8452427824DAC6BD008F51DC /* Project object */;
428 | }
429 |
--------------------------------------------------------------------------------
/CCWATextField/SupportingFiles/CCWATextFieldViewPropertyUpdate.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Created by Anand M. Khanpara (Create Code With Anand)
3 | Copyright © 2020 CreateCodeWithAnand. All rights reserved.
4 |
5 | MIT License
6 |
7 | Copyright (c) 2020 Anand M. Khanpara (Create Code With Anand)
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all
17 | copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 | SOFTWARE.
26 | */
27 |
28 | import UIKit
29 |
30 | extension CCWATextFieldViewProperty {
31 |
32 | ///NOTE :- `Init UI CCWATextField`
33 |
34 | internal func setUpCCWATOutlineTextField() {
35 | addSubView()
36 | }
37 |
38 | internal func addSubView() {
39 | addSubview(viewMainBase)
40 | viewMainBase.addSubview(viewBG)
41 | viewMainBase.addSubview(labelPlaceholder)
42 | viewMainBase.addSubview(viewSubBase)
43 | viewSubBase.addSubview(stackViewHorizontal)
44 | viewSubBase.addSubview(buttonFieldActive)
45 |
46 | addSubViewConstraint()
47 |
48 | Delay().time(0.2) {
49 | self.labelPlaceholder.frame = self.textFieldInput.bounds
50 | }
51 | }
52 |
53 | internal func addSubViewConstraint() {
54 |
55 | NSLayoutConstraint.activate([
56 |
57 | viewMainBase.topAnchor.constraint(equalTo: topAnchor, constant: 0),
58 | viewMainBase.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 0),
59 | viewMainBase.trailingAnchor.constraint(equalTo: trailingAnchor, constant: 0),
60 | viewMainBase.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0),
61 |
62 | viewBG.topAnchor.constraint(equalTo: viewMainBase.topAnchor, constant: 10),
63 | viewBG.leadingAnchor.constraint(equalTo: viewMainBase.leadingAnchor, constant: 0),
64 | viewBG.trailingAnchor.constraint(equalTo: viewMainBase.trailingAnchor, constant: 0),
65 | viewBG.bottomAnchor.constraint(equalTo: viewMainBase.bottomAnchor, constant: 0),
66 |
67 | viewSubBase.topAnchor.constraint(equalTo: viewMainBase.topAnchor, constant: 10),
68 | viewSubBase.leadingAnchor.constraint(equalTo: viewMainBase.leadingAnchor, constant: 0),
69 | viewSubBase.trailingAnchor.constraint(equalTo: viewMainBase.trailingAnchor, constant: 0),
70 | viewSubBase.bottomAnchor.constraint(equalTo: viewMainBase.bottomAnchor, constant: 0),
71 |
72 | stackViewHorizontal.topAnchor.constraint(greaterThanOrEqualTo: viewSubBase.topAnchor, constant: 0),
73 | stackViewHorizontal.leadingAnchor.constraint(equalTo: viewSubBase.leadingAnchor, constant: 10),
74 | stackViewHorizontal.trailingAnchor.constraint(equalTo: viewSubBase.trailingAnchor, constant: -10),
75 | stackViewHorizontal.bottomAnchor.constraint(lessThanOrEqualTo: viewSubBase.bottomAnchor, constant: 0),
76 | stackViewHorizontal.centerYAnchor.constraint(equalTo: viewSubBase.centerYAnchor, constant: 0),
77 |
78 | buttonFieldActive.topAnchor.constraint(equalTo: stackViewHorizontal.topAnchor, constant: 0),
79 | buttonFieldActive.leadingAnchor.constraint(equalTo: stackViewHorizontal.leadingAnchor, constant: 0),
80 | buttonFieldActive.trailingAnchor.constraint(equalTo: stackViewHorizontal.trailingAnchor, constant: 0),
81 | buttonFieldActive.bottomAnchor.constraint(equalTo: stackViewHorizontal.bottomAnchor, constant: 0),
82 | ])
83 |
84 | self.self.ccwaOutlineTFConstraint.stackViewHorizontalHeightConstraint = stackViewHorizontal.heightAnchor.constraint(equalToConstant: 25)
85 | self.ccwaOutlineTFConstraint.stackViewHorizontalHeightConstraint.isActive = true
86 |
87 | self.addDelayConstraint()
88 | }
89 |
90 | internal func addDelayConstraint() {
91 | Delay().time(0.1) {
92 | self.ccwaOutlineTFConstraint.labelPlaceHolderHeight = self.textFieldInput.frame.size.height
93 | self.ccwaOutlineTFConstraint.labelPlaceholderDeactiveTopConstraint = self.labelPlaceholder.topAnchor.constraint(equalTo: self.textFieldInput.topAnchor, constant: -1)
94 | self.ccwaOutlineTFConstraint.labelPlaceholderDeactiveLeadingConstraint = self.labelPlaceholder.leadingAnchor.constraint(equalTo: self.textFieldInput.leadingAnchor, constant: 0)
95 | self.ccwaOutlineTFConstraint.labelPlaceholderHeightConstraint = self.labelPlaceholder.heightAnchor.constraint(equalToConstant: self.ccwaOutlineTFConstraint.labelPlaceHolderHeight)
96 | self.ccwaOutlineTFConstraint.labelPlaceholderDeactiveTopConstraint.isActive = true
97 | self.ccwaOutlineTFConstraint.labelPlaceholderDeactiveLeadingConstraint.isActive = true
98 | self.ccwaOutlineTFConstraint.labelPlaceholderHeightConstraint.isActive = true
99 |
100 | let radius = self.setActiveCornerRadius > 0 ? self.setActiveCornerRadius : self.setDeactiveCornerRadius
101 | let leadingConstant = radius <= 5 ? (radius + 10) : (radius + 5)
102 | self.ccwaOutlineTFConstraint.labelPlaceholderActiveTopConstraint = self.labelPlaceholder.topAnchor.constraint(equalTo: self.viewMainBase.topAnchor, constant: 0)
103 | self.ccwaOutlineTFConstraint.labelPlaceholderActiveLeadingConstraint = self.labelPlaceholder.leadingAnchor.constraint(equalTo: self.viewMainBase.leadingAnchor, constant: leadingConstant)
104 | self.ccwaOutlineTFConstraint.labelPlaceholderActiveTopConstraint.isActive = false
105 | self.ccwaOutlineTFConstraint.labelPlaceholderActiveLeadingConstraint.isActive = false
106 |
107 | }.time(0.1) {
108 | self.ccwaOutlineTFConstraint.labelPlaceHolderWidth = self.labelPlaceholder.frame.size.width
109 | self.ccwaOutlineTFConstraint.labelPlaceholderWidthConstraint = self.labelPlaceholder.widthAnchor.constraint(equalToConstant: self.ccwaOutlineTFConstraint.labelPlaceHolderWidth)
110 | self.ccwaOutlineTFConstraint.labelPlaceholderWidthConstraint.isActive = true
111 | }.time(0.3) {
112 | self.addTargetAction()
113 | }
114 |
115 | UserDefaults.standard.setValue(false, forKey: _UIConstraintBasedLayoutLogUnsatisfiable)
116 | UserDefaults.standard.synchronize()
117 | }
118 |
119 | ///NOTE :- `Set Value CCWATextField`
120 |
121 | internal func setFont() {
122 | var font:UIFont? = UIFont.systemFont(ofSize: setFontSize)
123 | if setFontName.empty() == false {
124 | font = UIFont(name: setFontName, size: setFontSize)
125 | }
126 | textFieldInput.font = font
127 | labelPlaceholder.font = font
128 | }
129 |
130 | internal func setShadowPath() {
131 | Delay().time(0.05) {
132 | self.viewBG.layer.shadowPath = UIBezierPath(roundedRect: self.viewBG.bounds, cornerRadius: self.setDeactiveCornerRadius).cgPath
133 | }
134 | }
135 |
136 | internal func btnClearTintColorChange() {
137 | buttonClearText.imageView?.image = buttonClearText.imageView?.image?.withRenderingMode(.alwaysTemplate)
138 | buttonClearText.imageView?.tintColor = tintColor
139 | }
140 |
141 | internal func setToolBarDone() -> UIToolbar {
142 | let space = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil)
143 | let done = UIBarButtonItem(title: "Done", style: .done, target: self, action: #selector(activityCCWATextField_toolbarDone))
144 | let toolbar = UIToolbar()
145 | toolbar.sizeToFit()
146 | done.tintColor = self.tintColor
147 | toolbar.setItems([space, done], animated: true)
148 | return toolbar
149 | }
150 |
151 | @objc internal func activityCCWATextField_toolbarDone(sender:UIBarButtonItem) {
152 | findViewController()?.view.endEditing(true)
153 | }
154 |
155 | @objc internal func activityCCWATextField_editingChanged(sender:CCWAUITextField) {
156 | buttonClearShowHide()
157 | delegate?.continueUpdate()
158 | if let editingChanged = sender.editingChanged {
159 | editingChanged(sender.text ?? "")
160 | }
161 | }
162 |
163 | @objc internal func activityCCWATextField_editingDidBegin(sender:CCWAUITextField) {
164 | btnClearTintColorChange()
165 | activePlaceholder()
166 | buttonClearShowHide()
167 | if let editingDidBegin = sender.editingDidBegin {
168 | editingDidBegin(sender.text ?? "")
169 | }
170 | }
171 |
172 | @objc internal func activityCCWATextField_editingDidEnd(sender:CCWAUITextField) {
173 | adjustDeactivePlaceholder()
174 | viewRightSideImageViewBase.isHidden = true
175 | if let editingDidEnd = sender.editingDidEnd {
176 | editingDidEnd(sender.text ?? "")
177 | }
178 | }
179 |
180 | @objc internal func activityCCWAButton_touchUpInside(sender:CCWAUIButton) {
181 | textFieldInput.text = nil
182 | buttonClearShowHide()
183 | if let touchUpInside = sender.touchUpInside {
184 | touchUpInside()
185 | }
186 | }
187 |
188 | @objc internal func activityField_touchUpInside(sender:UIButton) {
189 | addCCWADropDownView()
190 | }
191 |
192 |
193 | @objc func btnRemoveDropDown_touchUpInside(sender:UIButton) {
194 | removeDropDown(true)
195 | }
196 |
197 | @objc func btnRemoveDropDown_touchDragInside(sender:UIButton) {
198 | removeDropDown(true)
199 | }
200 |
201 | func addCCWADropDownView() {
202 |
203 | removeDropDown()
204 |
205 | guard let viewController = findViewController() else { return }
206 |
207 | activePlaceholder()
208 |
209 | let topSafeArea = viewController.view.safeAreaInsets.top
210 |
211 | let bottomSafeArea = viewController.view.safeAreaInsets.bottom
212 |
213 | let view = viewController.view ?? UIView()
214 | view.endEditing(true)
215 | let frame = convert(bounds, to: view)
216 |
217 | let buttonRemoveDropDown:UIButton = {
218 | let button = UIButton()
219 | button.addTarget(self, action: #selector(btnRemoveDropDown_touchDragInside), for: .touchDragInside)
220 | button.addTarget(self, action: #selector(btnRemoveDropDown_touchUpInside), for: .touchUpInside)
221 | button.translatesAutoresizingMaskIntoConstraints = false
222 | return button
223 | }()
224 |
225 | let ccwaDropDownView:CCWADropDownView = {
226 | let view = CCWADropDownView(frame: .zero, ccwaTextField: ccwaTextField, arrCCWADropDownModel: setArrCCWADropDownModel)
227 | view.ccwaTextField = ccwaTextField
228 | view.frame = frame
229 | view.translatesAutoresizingMaskIntoConstraints = false
230 | return view
231 | }()
232 |
233 | view.addSubview(buttonRemoveDropDown)
234 |
235 | view.addSubview(ccwaDropDownView)
236 |
237 | NSLayoutConstraint.activate([
238 | buttonRemoveDropDown.topAnchor.constraint(equalTo: view.topAnchor, constant: 0),
239 | buttonRemoveDropDown.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0),
240 | buttonRemoveDropDown.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0),
241 | buttonRemoveDropDown.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: 0),
242 |
243 | ccwaDropDownView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: frame.origin.x),
244 | ccwaDropDownView.widthAnchor.constraint(equalToConstant: frame.size.width),
245 | ])
246 |
247 | let heightConstraint = ccwaDropDownView.heightAnchor.constraint(equalToConstant: 40)
248 | heightConstraint.isActive = true
249 |
250 | let bottomSpace = (view.frame.size.height - (frame.size.height + frame.origin.y + bottomSafeArea + 20))
251 |
252 | let topSpace = frame.origin.y - (topSafeArea + 10)
253 |
254 | print(bottomSpace, topSpace, frame)
255 |
256 | let extraSpace = CGFloat(setArrCCWADropDownModel.filter({ (($0.image != nil) || ($0.imageURL != nil) || (($0.subtitle ?? "").isEmpty == false)) == true }).count * 17)
257 |
258 | var count = setArrCCWADropDownModel.count
259 |
260 | if count == 0 {
261 | count = 1
262 | }
263 |
264 | var heightDropDown :CGFloat = CGFloat(count * 36) + extraSpace
265 |
266 | if ccwaTextField?.fieldType == .dropDownSearch {
267 | heightDropDown += 40
268 | }
269 |
270 | func setCCWADropDownViewShadow(height:CGFloat, frame:CGRect) {
271 | heightConstraint.constant = height
272 | ccwaOutlineTFConstraint.dropDownViewHeight = heightConstraint
273 | ccwaDropDownView.shadow(frame: frame)
274 | }
275 |
276 | if bottomSpace > heightDropDown {
277 | print(1)
278 | ccwaDropDownView.topAnchor.constraint(equalTo: view.topAnchor, constant: (frame.origin.y + frame.size.height + 5)).isActive = true
279 | heightConstraint.constant = heightDropDown
280 | ccwaDropDownView.shadow(frame: CGRect(x: 0, y: 0, width: frame.width, height: heightDropDown))
281 | setCCWADropDownViewShadow(height: heightDropDown, frame: CGRect(x: 0, y: 0, width: frame.width, height: heightDropDown))
282 | }else if topSpace > heightDropDown {
283 | print(2)
284 | ccwaDropDownView.bottomAnchor.constraint(equalTo: view.topAnchor, constant: frame.origin.y + 5).isActive = true
285 | setCCWADropDownViewShadow(height: heightDropDown, frame: CGRect(x: 0, y: 0, width: frame.width, height: heightDropDown))
286 | }else if topSpace < bottomSpace {
287 | print(3)
288 | ccwaDropDownView.topAnchor.constraint(equalTo: view.topAnchor, constant: (frame.origin.y + frame.size.height + 5)).isActive = true
289 | setCCWADropDownViewShadow(height: bottomSpace, frame: CGRect(x: 0, y: 0, width: frame.width, height: bottomSpace))
290 | }else if bottomSpace < topSpace {
291 | print(4)
292 | ccwaDropDownView.bottomAnchor.constraint(equalTo: view.topAnchor, constant: frame.origin.y + 5).isActive = true
293 | setCCWADropDownViewShadow(height: topSpace, frame: CGRect(x: 0, y: 0, width: frame.width, height: topSpace))
294 | }else {
295 | print(5)
296 | ccwaDropDownView.topAnchor.constraint(equalTo: view.topAnchor, constant: (frame.origin.y + frame.size.height + 5)).isActive = true
297 | setCCWADropDownViewShadow(height: bottomSpace, frame: CGRect(x: 0, y: 0, width: frame.width, height: bottomSpace))
298 | }
299 |
300 | viewDropDown = ccwaDropDownView
301 | viewDropDownBack = buttonRemoveDropDown
302 |
303 | UIView.animate(withDuration: 0.2) {
304 | self.viewRightSideDropDownArrowImageViewBase.transform = CGAffineTransform(rotationAngle: .pi)
305 | self.layoutIfNeeded()
306 | }
307 |
308 | }
309 |
310 | func removeDropDown(_ animated:Bool = false) {
311 | if animated == true {
312 | deactivePlaceholder()
313 | }
314 | viewDropDownBack?.removeFromSuperview()
315 | viewDropDown?.removeFromSuperview()
316 |
317 | UIView.animate(withDuration: 0.2) {
318 | self.viewRightSideDropDownArrowImageViewBase.transform = self.viewRightSideDropDownArrowImageViewBase.transform.rotated(by: .pi)
319 | self.layoutIfNeeded()
320 | }
321 | }
322 |
323 | internal func addTargetAction() {
324 | buttonClearShowHide()
325 | textFieldInput.addTarget(self, action: #selector(activityCCWATextField_editingChanged), for: .editingChanged)
326 | textFieldInput.addTarget(self, action: #selector(activityCCWATextField_editingDidBegin), for: .editingDidBegin)
327 | textFieldInput.addTarget(self, action: #selector(activityCCWATextField_editingDidEnd), for: .editingDidEnd)
328 | buttonClearText.addTarget(self, action: #selector(activityCCWAButton_touchUpInside), for: .touchUpInside)
329 | buttonFieldActive.addTarget(self, action: #selector(activityField_touchUpInside), for: .touchUpInside)
330 | }
331 |
332 | internal func adjustDeactivePlaceholder() {
333 | if textIsEmpty() == true {
334 | textFieldInput.text = nil
335 | deactivePlaceholder()
336 | }
337 | }
338 |
339 | internal func adjustActivePlaceholder() {
340 | if textIsEmpty() == false {
341 | activePlaceholder()
342 | }
343 | }
344 |
345 | internal func buttonClearShowHide() {
346 | if setIsClearButton == false {
347 | viewRightSideImageViewBase.isHidden = true
348 | }else {
349 | self.viewRightSideImageViewBase.isHidden = textIsEmpty()
350 | }
351 | }
352 |
353 | internal func textIsEmpty() -> Bool {
354 | let text = textFieldInput.text ?? ""
355 | return (text.isEmpty == true || text.trimmingCharacters(in: .whitespacesAndNewlines) == "" || text == "")
356 | }
357 |
358 | internal func activePlaceholder() {
359 | UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseOut, animations: {
360 |
361 | self.labelPlaceholder.text = " " + self.setPlaceholder + " "
362 |
363 | if self.setAnimatePlaceholder == true {
364 | self.labelPlaceholder.textColor = self.setActivePlaceholderColor ?? self.setDeactivePlaceholderColor
365 | }else {
366 | self.textFieldInput.attributedPlaceholder = NSAttributedString(string: self.setPlaceholder, attributes: [NSAttributedString.Key.foregroundColor : self.setActivePlaceholderColor ?? self.setDeactivePlaceholderColor])
367 | }
368 |
369 | self.labelPlaceholder.backgroundColor = self.setPlaceholder.empty() ? .clear : self.setActivePlacehoderBackGroundColor
370 |
371 | self.viewBG.layer.borderColor = self.setActiveBorderColor?.cgColor ?? self.setDeactiveBorderColor.cgColor
372 |
373 | self.viewBG.layer.borderWidth = self.setActiveBorderWidth > 0 ? self.setActiveBorderWidth : self.setDeactiveBorderWidth
374 |
375 | self.viewBG.layer.cornerRadius = self.setActiveCornerRadius > 0 ? self.setActiveCornerRadius : self.setDeactiveCornerRadius
376 |
377 | self.viewBG.backgroundColor = self.setActiveBackGroundColor ?? self.setDeactiveBackGroundColor
378 |
379 | self.viewBG.layer.shadowRadius = self.setActiveShadowRadius > 0 ? self.setActiveShadowRadius : self.setDeactiveShadowRadius
380 |
381 | self.viewBG.layer.shadowOpacity = self.setActiveShadowOpacity > 0 ? self.setActiveShadowOpacity : self.setDeactiveShadowOpacity
382 |
383 | self.viewBG.layer.shadowColor = self.setActiveShadowColor?.cgColor ?? self.setDeactiveShadowColor.cgColor
384 |
385 | self.viewBG.layer.shadowOffset = self.setActiveShadowOffset != .zero ? self.setActiveShadowOffset : self.setDeactiveShadowOffset
386 |
387 | self.imageViewLeftSideImageView.image = self.setActiveImageLeftIcon ?? self.setDeactiveImageLeftIcon
388 |
389 | if let color = self.setActiveImageLeftIconColor {
390 | self.imageViewLeftSideImageView.image = self.imageViewLeftSideImageView.image?.withRenderingMode(.alwaysTemplate)
391 | self.imageViewLeftSideImageView.tintColor = color
392 | }else if let color = self.setDeactiveImageLeftIconColor {
393 | self.imageViewLeftSideImageView.image = self.imageViewLeftSideImageView.image?.withRenderingMode(.alwaysTemplate)
394 | self.imageViewLeftSideImageView.tintColor = color
395 | }
396 |
397 | self.ccwaOutlineTFConstraint.labelPlaceholderActiveTopConstraint.isActive = true
398 | self.ccwaOutlineTFConstraint.labelPlaceholderActiveLeadingConstraint.isActive = true
399 | self.ccwaOutlineTFConstraint.labelPlaceholderDeactiveTopConstraint.isActive = false
400 | self.ccwaOutlineTFConstraint.labelPlaceholderDeactiveLeadingConstraint.isActive = false
401 | self.ccwaOutlineTFConstraint.labelPlaceholderHeightConstraint.constant = 16
402 | self.ccwaOutlineTFConstraint.labelPlaceholderWidthConstraint.constant = self.ccwaOutlineTFConstraint.labelPlaceHolderWidth * 0.75
403 | self.layoutIfNeeded()
404 | })
405 | }
406 |
407 | internal func deactivePlaceholder() {
408 | UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseIn, animations: {
409 |
410 | self.labelPlaceholder.backgroundColor = .clear
411 |
412 | self.labelPlaceholder.text = self.setPlaceholder
413 |
414 | if self.setAnimatePlaceholder == true {
415 | self.labelPlaceholder.textColor = self.setDeactivePlaceholderColor
416 | }else {
417 | self.textFieldInput.attributedPlaceholder = NSAttributedString(string: self.setPlaceholder, attributes: [NSAttributedString.Key.foregroundColor : self.setDeactivePlaceholderColor])
418 | }
419 |
420 | self.labelPlaceholder.backgroundColor = .clear
421 |
422 | self.viewBG.layer.borderColor = self.setDeactiveBorderColor.cgColor
423 |
424 | self.viewBG.layer.borderWidth = self.setDeactiveBorderWidth
425 |
426 | self.viewBG.layer.cornerRadius = self.setDeactiveCornerRadius
427 |
428 | self.viewBG.backgroundColor = self.setDeactiveBackGroundColor
429 |
430 | self.viewBG.layer.shadowRadius = self.setDeactiveShadowRadius
431 |
432 | self.viewBG.layer.shadowOpacity = self.setDeactiveShadowOpacity
433 |
434 | self.viewBG.layer.shadowColor = self.setDeactiveShadowColor.cgColor
435 |
436 | self.viewBG.layer.shadowOffset = self.setDeactiveShadowOffset
437 |
438 | self.imageViewLeftSideImageView.image = self.setDeactiveImageLeftIcon
439 |
440 | if let color = self.setDeactiveImageLeftIconColor {
441 | self.imageViewLeftSideImageView.image = self.imageViewLeftSideImageView.image?.withRenderingMode(.alwaysTemplate)
442 | self.imageViewLeftSideImageView.tintColor = color
443 | }
444 |
445 | self.ccwaOutlineTFConstraint.labelPlaceholderActiveTopConstraint.isActive = false
446 | self.ccwaOutlineTFConstraint.labelPlaceholderActiveLeadingConstraint.isActive = false
447 | self.ccwaOutlineTFConstraint.labelPlaceholderDeactiveTopConstraint.isActive = true
448 | self.ccwaOutlineTFConstraint.labelPlaceholderDeactiveLeadingConstraint.isActive = true
449 | self.ccwaOutlineTFConstraint.labelPlaceholderHeightConstraint.constant = self.ccwaOutlineTFConstraint.labelPlaceHolderHeight
450 | self.ccwaOutlineTFConstraint.labelPlaceholderWidthConstraint.constant = self.ccwaOutlineTFConstraint.labelPlaceHolderWidth
451 | self.layoutIfNeeded()
452 | })
453 | }
454 | }
455 |
456 | /*
457 | //arr = [CCWADropDownModel(title: "AAAashjf", subtitle: "sdsdfsdfsfds fdsff sf dsfsdfs fdsf", image: UIImage(systemName: "book")), CCWADropDownModel(title: "aidhas isadh", image: UIImage(named: "road")), CCWADropDownModel(title: "sadh", subtitle: "sdsdfsdfsfds fdsff sf dsfsdfs fdsf"), CCWADropDownModel(title: "AAdh", image: UIImage(named: "road")), CCWADropDownModel(title: "dhas isadh")]
458 | //arr = [CCWADropDownModel(title: "AAAashjf", subtitle: "sdsdfsdfsfds fdsff sf dsfsdfs fdsf"), CCWADropDownModel(title: "aidhas isadh", subtitle: "sdsdfsdfsfds fdsff sf dsfsdfs fdsf"), CCWADropDownModel(title: "sadh", subtitle: "sdsdfsdfsfds fdsff sf dsfsdfs fdsf"), CCWADropDownModel(title: "AAdh"), CCWADropDownModel(title: "dhas isadh")]
459 | //arr = [CCWADropDownModel(title: "AAAashjf"), CCWADropDownModel(title: "aidhas isadh"), CCWADropDownModel(title: "sadh"), CCWADropDownModel(title: "AAdh"), CCWADropDownModel(title: "dhas isadh")]
460 | //arr = [CCWADropDownModel(title: "AAAashjf", subtitle: "sdsdfsdfsfds fdsff sf dsfsdfs fdsf", image: UIImage(systemName: "book")), CCWADropDownModel(title: "aidhas isadh", image: UIImage(named: "road")), CCWADropDownModel(title: "sadh", subtitle: "sdsdfsdfsfds fdsff sf dsfsdfs fdsf"), CCWADropDownModel(title: "AAdh", imageURL: "https://images.unsplash.com/photo-1593642702821-c8da6771f0c6?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1778&q=80"), CCWADropDownModel(title: "dhas isadh"), CCWADropDownModel(title: "AAAashjf", subtitle: "sdsdfsdfsfds fdsff sf dsfsdfs fdsf", image: UIImage(systemName: "book")), CCWADropDownModel(title: "aidhas isadh", image: UIImage(named: "road")), CCWADropDownModel(title: "sadh", subtitle: "sdsdfsdfsfds fdsff sf dsfsdfs fdsf"), CCWADropDownModel(title: "AAdh", image: UIImage(named: "road")), CCWADropDownModel(title: "dhas isadh"), CCWADropDownModel(title: "AAAashjf", subtitle: "sdsdfsdfsfds fdsff sf dsfsdfs fdsf", image: UIImage(systemName: "book")), CCWADropDownModel(title: "aidhas isadh", image: UIImage(named: "road")), CCWADropDownModel(title: "sadh", subtitle: "sdsdfsdfsfds fdsff sf dsfsdfs fdsf"), CCWADropDownModel(title: "AAdh", image: UIImage(named: "road")), CCWADropDownModel(title: "dhas isadh")]
461 | */
462 |
--------------------------------------------------------------------------------