Commit 415577d7 by Daniel Dahan

cleanup before merge from PRs

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