Skip to content

Commit

Permalink
unnecessary lines are removed, pod name is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
furkanhatipoglu committed Jan 30, 2018
1 parent 32eaa59 commit 8f9e160
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 47 deletions.
Binary file modified .DS_Store
Binary file not shown.
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#################### OSX Finder
.DS_Store

#################### Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout

#################### Cocoapods
Podfile.lock
Pods
contents.xcworkspacedata
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Furkan Hatipoğlu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
10 changes: 5 additions & 5 deletions MultilineTextField.podspec → MultiLineTextField.podspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Pod::Spec.new do |s|
s.name = 'MultilineTextField'
s.version = '0.0.1'
s.name = 'MultiLineTextField'
s.version = '0.1.0'
s.summary = 'Multiline textfield is written in Swift 3 with a customizable line.'

s.description = <<-DESC
Multiline textfield is written in Swift 3 with a customizable line.
Multiline textfield is written in Swift 3 with a customizable line. Author is Furkan Hatipoglu.
DESC

s.homepage = 'https://github.com/furkanhatipoglu/multiline-textfield.git'
Expand All @@ -15,7 +15,7 @@ Pod::Spec.new do |s|
s.dependency 'GrowingTextView', '~> 0.4.0'

s.ios.deployment_target = '8.0'
s.resources = 'MultilineTextField/*'
s.source_files = 'MultilineTextField/*'
s.resources = 'MultiLineTextField/*'
s.source_files = 'MultiLineTextField/*'

end
Binary file added MultilineTextField/.DS_Store
Binary file not shown.
77 changes: 35 additions & 42 deletions MultilineTextField/MultilineTextField.swift
Original file line number Diff line number Diff line change
@@ -1,69 +1,62 @@
//
// MultilineTextField.swift
// ErstreamDemo
//
// Created by Erstream on 12/12/2017.
//
// Created by Furkan Hatipoglu on 12/12/2017.
// Copyright © 2017 frknhatipoglu. All rights reserved.
//

import Foundation
import GrowingTextView

class MultilineTextField: UIView, GrowingTextViewDelegate {

public class MultilineTextField: UIView, GrowingTextViewDelegate {

private var titleLabel: UILabel!
private var lineLayer: CALayer!
var growTextView: GrowingTextView!

public var textView: GrowingTextView!
public var endEditingWithReturnButton = false

public var placeHolderText: String? {
didSet {
updatePlaceHolder()
}
}
public var placeHolderTextColor: UIColor! {
public var placeHolderTextColor: UIColor! = UIColor.darkGray {
didSet {
if placeHolderTextColor == nil {
placeHolderTextColor = UIColor.darkGray
}
updateTextColor()
}
}
public var lineColor: UIColor! {
public var lineColor: UIColor! = UIColor.darkGray {
didSet {
if lineColor == nil {
lineColor = UIColor.red
}
self.lineLayer.backgroundColor = lineColor.cgColor
}
}

public var textColor: UIColor! {
public var textColor: UIColor! = UIColor.darkGray {
didSet {
if textColor == nil {
textColor = UIColor.black
}
growTextView.textColor = textColor
textView.textColor = textColor
}
}

override init(frame: CGRect) {
public override init(frame: CGRect) {
super.init(frame: frame)
setComponents()
}

required init?(coder aDecoder: NSCoder) {
public required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func updatePlaceHolder () {
titleLabel.text = placeHolderText
growTextView.placeHolder = placeHolderText
textView.placeHolder = placeHolderText
}

private func updateTextColor () {
titleLabel.textColor = placeHolderTextColor
growTextView.placeHolderColor = placeHolderTextColor ?? UIColor.darkGray
textView.placeHolderColor = placeHolderTextColor
}

private func setComponents () {
Expand All @@ -84,32 +77,31 @@ class MultilineTextField: UIView, GrowingTextViewDelegate {
private func setTextView () {

let textFieldFrame = CGRect(x: 0, y: 20, width: self.bounds.width, height: self.bounds.height - 25)
growTextView = GrowingTextView(frame: textFieldFrame)
growTextView.placeHolderColor = UIColor.darkGray
growTextView.delegate = self
growTextView.textColor = UIColor.black
growTextView.backgroundColor = UIColor.clear
growTextView.placeHolderLeftMargin = 0
growTextView.textContainerInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
growTextView.font = UIFont.systemFont(ofSize: 16)
growTextView.returnKeyType = .done
self.addSubview(growTextView)

textView = GrowingTextView(frame: textFieldFrame)
textView.placeHolderColor = UIColor.darkGray
textView.delegate = self
textView.textColor = UIColor.black
textView.backgroundColor = UIColor.clear
textView.placeHolderLeftMargin = 0
textView.textContainerInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
textView.font = UIFont.systemFont(ofSize: 16)
self.addSubview(textView)

}

private func setLineLayer () {
lineLayer = CALayer()
lineLayer.frame = CGRect(x: 0, y: growTextView.frame.maxY + 2, width: growTextView.bounds.width, height: 0.5)
lineLayer.frame = CGRect(x: 0, y: textView.frame.maxY + 2, width: textView.bounds.width, height: 0.5)
lineLayer.backgroundColor = UIColor.darkGray.cgColor
self.layer.addSublayer(lineLayer)

}

internal func textViewDidBeginEditing(_ textView: UITextView) {
public func textViewDidBeginEditing(_ textView: UITextView) {
setTextIsNotNill()
}

internal func textViewDidEndEditing(_ textView: UITextView) {
public func textViewDidEndEditing(_ textView: UITextView) {
if textView.text.isEmpty {
setTextIsNill()
} else {
Expand All @@ -120,9 +112,9 @@ class MultilineTextField: UIView, GrowingTextViewDelegate {
private func setTextIsNotNill () {
UIView.animate(withDuration: 0.5) {
self.lineLayer.frame = CGRect(x: 0, y: self.lineLayer.frame.minY, width: self.lineLayer.bounds.width, height: 2)
self.lineLayer.backgroundColor = UIColor.red.cgColor
self.lineLayer.backgroundColor = UIColor.darkGray.cgColor
self.titleLabel.alpha = 1
self.growTextView.placeHolderColor = self.placeHolderTextColor.withAlphaComponent(0)
self.textView.placeHolderColor = self.placeHolderTextColor.withAlphaComponent(0)
}
}

Expand All @@ -131,12 +123,13 @@ class MultilineTextField: UIView, GrowingTextViewDelegate {
self.lineLayer.frame = CGRect(x: 0, y: self.lineLayer.frame.minY, width: self.lineLayer.bounds.width, height: 0.5)
self.lineLayer.backgroundColor = UIColor.darkGray.cgColor
self.titleLabel.alpha = 0
self.growTextView.placeHolderColor = self.placeHolderTextColor
self.textView.placeHolderColor = self.placeHolderTextColor
}
}

func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
if(text == "\n") {
public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {

if text == "\n" && endEditingWithReturnButton {
textView.resignFirstResponder()
return false
}
Expand All @@ -146,7 +139,7 @@ class MultilineTextField: UIView, GrowingTextViewDelegate {

extension MultilineTextField {
func getText() -> String {
if let text = self.growTextView.text {
if let text = self.textView.text {
return text
}
return ""
Expand Down

0 comments on commit 8f9e160

Please sign in to comment.