Skip to content

Commit

Permalink
Merge pull request #39 from GeekTree0101/bug/ControlArea-SafeAreaInse…
Browse files Browse the repository at this point in the history
…ts-Bug-And-Hotfix-v1.2.1

fix safe area insets on typing control area layoutSpec & ready for release hot fix v1.2.1
  • Loading branch information
GeekTree0101 authored Jan 15, 2019
2 parents e676a63 + e895563 commit d4699f6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion VEditorKit.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'VEditorKit'
s.version = '1.2.0'
s.version = '1.2.1'
s.summary = 'Lightweight and Powerful Editor Kit'

s.description = 'Lightweight and Powerful Editor Kit built on Texture(AsyncDisplayKit)'
Expand Down
37 changes: 28 additions & 9 deletions VEditorKit/Classes/VEditorNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ open class VEditorNode: ASDisplayNode, ASTableDelegate, ASTableDataSource {
open let editorStatusRelay = PublishRelay<Status>()
open let disposeBag = DisposeBag()
open weak var delegate: VEditorNodeDelegate!
open var keyboardHeight: CGFloat = 0.0

private var typingControls: [VEditorTypingControlNode] = []
private var keyboardHeight: CGFloat = 0.0
private var activeTextDisposeBag = DisposeBag()

public init(editorRule: VEditorRule,
Expand Down Expand Up @@ -122,24 +122,43 @@ open class VEditorNode: ASDisplayNode, ASTableDelegate, ASTableDataSource {
}

open override func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
var tableNodeInsets: UIEdgeInsets = .zero
tableNodeInsets.bottom = keyboardHeight

var tableNodeInsets: UIEdgeInsets = self.safeAreaInsets
tableNodeInsets.bottom += keyboardHeight
let tableLayout = ASInsetLayoutSpec(insets: tableNodeInsets,
child: tableNode)

if let node = controlAreaNode {
var controlAreaInsets: UIEdgeInsets =
.init(top: .infinity, left: 0.0, bottom: 0.0, right: 0.0)
controlAreaInsets.bottom = keyboardHeight
let controlLayout = ASInsetLayoutSpec(insets: controlAreaInsets,
child: node)
let controlLayout = controlAreaLayoutSpec(constrainedSize, controlAreaNode: node)
return ASOverlayLayoutSpec(child: tableLayout,
overlay: controlLayout)

} else {
return tableLayout
}
}

/**
Create controlArea Layout Spec
- important: If you needs customize control area layout than you have to override this methods
- parameter constrainedSize: VEditorNode constrainedSize
- parameter controlAreaNode: controlAreaNode
- returns: ControlAreaLayout
*/
open func controlAreaLayoutSpec(_ constrainedSize: ASSizeRange,
controlAreaNode: ASDisplayNode) -> ASLayoutSpec {
var controlAreaInsets: UIEdgeInsets = self.safeAreaInsets
controlAreaInsets.top = .infinity
if keyboardHeight > 0.0 {
controlAreaInsets.bottom = keyboardHeight
} else {
controlAreaInsets.bottom += keyboardHeight
}
return ASInsetLayoutSpec(insets: controlAreaInsets,
child: controlAreaNode)
}

override open func layout() {
super.layout()
Expand Down

0 comments on commit d4699f6

Please sign in to comment.