Commit 415577d7 by Daniel Dahan

cleanup before merge from PRs

parent 87baa186
......@@ -252,6 +252,7 @@ open class CollectionViewCell: UICollectionViewCell, Pulseable, PulseableLayer {
open func prepare() {
backgroundColor = .white
contentScaleFactor = Screen.scale
prepareVisualLayer()
preparePulse()
}
......
......@@ -63,6 +63,6 @@ open class DynamicFontType: NSObject {
/// Prepares observation for content size changes.
private func prepareContentSizeObservation() {
NotificationCenter.default.addObserver(self, selector: #selector(handleContentSizeChange), name: NSNotification.Name.UIContentSizeCategoryDidChange, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(handleContentSizeChange), name: .UIContentSizeCategoryDidChange, object: nil)
}
}
......@@ -44,6 +44,12 @@ public enum EdgeInsetsPreset: Int {
case square7
case square8
case square9
case square10
case square11
case square12
case square13
case square14
case square15
// rectangle
case wideRectangle1
......@@ -98,16 +104,28 @@ public func EdgeInsetsPresetToValue(preset: EdgeInsetsPreset) -> EdgeInsets {
case .square3:
return EdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
case .square4:
return EdgeInsets(top: 24, left: 24, bottom: 24, right: 24)
return EdgeInsets(top: 20, left: 20, bottom: 20, right: 20)
case .square5:
return EdgeInsets(top: 32, left: 32, bottom: 32, right: 32)
return EdgeInsets(top: 24, left: 24, bottom: 24, right: 24)
case .square6:
return EdgeInsets(top: 40, left: 40, bottom: 40, right: 40)
return EdgeInsets(top: 28, left: 28, bottom: 28, right: 28)
case .square7:
return EdgeInsets(top: 48, left: 48, bottom: 48, right: 48)
return EdgeInsets(top: 32, left: 32, bottom: 32, right: 32)
case .square8:
return EdgeInsets(top: 56, left: 56, bottom: 56, right: 56)
return EdgeInsets(top: 36, left: 36, bottom: 36, right: 36)
case .square9:
return EdgeInsets(top: 40, left: 40, bottom: 40, right: 40)
case .square10:
return EdgeInsets(top: 44, left: 44, bottom: 44, right: 44)
case .square11:
return EdgeInsets(top: 48, left: 48, bottom: 48, right: 48)
case .square12:
return EdgeInsets(top: 52, left: 52, bottom: 52, right: 52)
case .square13:
return EdgeInsets(top: 56, left: 56, bottom: 56, right: 56)
case .square14:
return EdgeInsets(top: 60, left: 60, bottom: 60, right: 60)
case .square15:
return EdgeInsets(top: 64, left: 64, bottom: 64, right: 64)
// rectangle
......
......@@ -279,32 +279,33 @@ open class TextView: UITextView {
backgroundColor = nil
font = RobotoFont.regular(with: 16)
textColor = Color.darkText.primary
prepareNotificationHandlers()
prepareRegularExpression()
preparePlaceholderLabel()
}
}
extension TextView {
fileprivate extension TextView {
/// Prepares the Notification handlers.
fileprivate func prepareNotificationHandlers() {
func prepareNotificationHandlers() {
let defaultCenter = NotificationCenter.default
defaultCenter.addObserver(self, selector: #selector(handleKeyboardWillShow(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
defaultCenter.addObserver(self, selector: #selector(handleKeyboardWillHide(notification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
defaultCenter.addObserver(self, selector: #selector(handleKeyboardDidShow(notification:)), name: NSNotification.Name.UIKeyboardDidShow, object: nil)
defaultCenter.addObserver(self, selector: #selector(handleKeyboardDidHide(notification:)), name: NSNotification.Name.UIKeyboardDidHide, object: nil)
defaultCenter.addObserver(self, selector: #selector(handleTextViewTextDidBegin), name: NSNotification.Name.UITextViewTextDidBeginEditing, object: self)
defaultCenter.addObserver(self, selector: #selector(handleTextViewTextDidChange), name: NSNotification.Name.UITextViewTextDidChange, object: self)
defaultCenter.addObserver(self, selector: #selector(handleTextViewTextDidEnd), name: NSNotification.Name.UITextViewTextDidEndEditing, object: self)
defaultCenter.addObserver(self, selector: #selector(handleKeyboardWillShow(notification:)), name: .UIKeyboardWillShow, object: nil)
defaultCenter.addObserver(self, selector: #selector(handleKeyboardWillHide(notification:)), name: .UIKeyboardWillHide, object: nil)
defaultCenter.addObserver(self, selector: #selector(handleKeyboardDidShow(notification:)), name: .UIKeyboardDidShow, object: nil)
defaultCenter.addObserver(self, selector: #selector(handleKeyboardDidHide(notification:)), name: .UIKeyboardDidHide, object: nil)
defaultCenter.addObserver(self, selector: #selector(handleTextViewTextDidBegin), name: .UITextViewTextDidBeginEditing, object: self)
defaultCenter.addObserver(self, selector: #selector(handleTextViewTextDidChange), name: .UITextViewTextDidChange, object: self)
defaultCenter.addObserver(self, selector: #selector(handleTextViewTextDidEnd), name: .UITextViewTextDidEndEditing, object: self)
}
/// Prepares the regular expression for matching.
fileprivate func prepareRegularExpression() {
func prepareRegularExpression() {
(textStorage as? TextStorage)?.expression = try? NSRegularExpression(pattern: pattern, options: [])
}
/// prepares the placeholderLabel property.
fileprivate func preparePlaceholderLabel() {
func preparePlaceholderLabel() {
placeholderLabel.textColor = Color.darkText.others
placeholderLabel.textAlignment = textAlignment
placeholderLabel.numberOfLines = 0
......@@ -313,22 +314,22 @@ extension TextView {
}
}
extension TextView {
fileprivate extension TextView {
/// Updates the placeholderLabel text color.
fileprivate func updatePlaceholderLabelColor() {
func updatePlaceholderLabelColor() {
tintColor = placeholderActiveColor
placeholderLabel.textColor = isEditing ? placeholderActiveColor : placeholderNormalColor
}
/// Updates the placeholderLabel visibility.
fileprivate func updatePlaceholderVisibility() {
func updatePlaceholderVisibility() {
placeholderLabel.isHidden = !isEmpty
}
}
extension TextView {
fileprivate extension TextView {
/// Laysout the placeholder UILabel.
fileprivate func layoutPlaceholderLabel() {
func layoutPlaceholderLabel() {
placeholderLabel.preferredMaxLayoutWidth = textContainer.size.width - textContainer.lineFragmentPadding * 2
let x = textContainerInset.left + textContainer.lineFragmentPadding
......@@ -341,13 +342,13 @@ extension TextView {
}
}
extension TextView {
fileprivate extension TextView {
/**
Handler for when the keyboard will open.
- Parameter notification: A Notification.
*/
@objc
fileprivate func handleKeyboardWillShow(notification: Notification) {
func handleKeyboardWillShow(notification: Notification) {
guard isKeyboardHidden else {
return
}
......@@ -364,7 +365,7 @@ extension TextView {
- Parameter notification: A Notification.
*/
@objc
fileprivate func handleKeyboardDidShow(notification: Notification) {
func handleKeyboardDidShow(notification: Notification) {
guard isKeyboardHidden else {
return
}
......@@ -383,7 +384,7 @@ extension TextView {
- Parameter notification: A Notification.
*/
@objc
fileprivate func handleKeyboardWillHide(notification: Notification) {
func handleKeyboardWillHide(notification: Notification) {
guard !isKeyboardHidden else {
return
}
......@@ -400,7 +401,7 @@ extension TextView {
- Parameter notification: A Notification.
*/
@objc
fileprivate func handleKeyboardDidHide(notification: Notification) {
func handleKeyboardDidHide(notification: Notification) {
guard !isKeyboardHidden else {
return
}
......@@ -416,19 +417,19 @@ extension TextView {
/// Notification handler for when text editing began.
@objc
fileprivate func handleTextViewTextDidBegin() {
func handleTextViewTextDidBegin() {
isEditing = true
}
/// Notification handler for when text changed.
@objc
fileprivate func handleTextViewTextDidChange() {
func handleTextViewTextDidChange() {
updatePlaceholderVisibility()
}
/// Notification handler for when text editing ended.
@objc
fileprivate func handleTextViewTextDidEnd() {
func handleTextViewTextDidEnd() {
isEditing = false
updatePlaceholderVisibility()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment