Skip to content

Commit

Permalink
added some hiddenBindings
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyclaysmith committed Mar 22, 2015
1 parent 8d93111 commit 8ec582b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions AwfulBindingUI/BindableLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,24 @@ public class BindableLabel:UILabel{

deinit{
_bindableValue?.removeListener(self)
_hiddenBinding?.removeListener(self)
}

private var _hiddenBinding:BindableValue<Bool>?
public var hiddenBinding:BindableValue<Bool>?{
get{
return _hiddenBinding
}

set(newValue){
_hiddenBinding?.removeListener(self)

_hiddenBinding = newValue

_hiddenBinding?.addListener(self, listener:hiddenBinding_valueChanged, alertNow: true)
}
}
private func hiddenBinding_valueChanged(newValue:Bool){
self.hidden = newValue
}
}
19 changes: 19 additions & 0 deletions AwfulBindingUI/BindableTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class BindableTableView : UITableView, UITableViewDataSource, UITableView
_sections?.removeChangedListener(self)
_sections?.removeIndexChangedListener(self)

_hiddenBinding?.removeListener(self)
//TODO:remove child listeners
}

Expand Down Expand Up @@ -187,4 +188,22 @@ public class BindableTableView : UITableView, UITableViewDataSource, UITableView
tableView.reloadData()
}
}

private var _hiddenBinding:BindableValue<Bool>?
public var hiddenBinding:BindableValue<Bool>?{
get{
return _hiddenBinding
}

set(newValue){
_hiddenBinding?.removeListener(self)

_hiddenBinding = newValue

_hiddenBinding?.addListener(self, listener:hiddenBinding_valueChanged, alertNow: true)
}
}
private func hiddenBinding_valueChanged(newValue:Bool){
self.hidden = newValue
}
}

0 comments on commit 8ec582b

Please sign in to comment.