Class: Bureau::Bureau
- Inherits:
-
UIViewController
- Object
- UIViewController
- Bureau::Bureau
- Defined in:
- lib/bureau/bureau.rb
Instance Attribute Summary collapse
-
#active_controller ⇒ Object
Returns the value of attribute active_controller.
-
#active_view_origin ⇒ Object
Returns the value of attribute active_view_origin.
-
#bureau_sections ⇒ Object
Returns the value of attribute bureau_sections.
-
#bureau_table ⇒ Object
Returns the value of attribute bureau_table.
-
#drawer_height ⇒ Object
Returns the value of attribute drawer_height.
-
#drawer_width ⇒ Object
Returns the value of attribute drawer_width.
-
#reuse_id ⇒ Object
Returns the value of attribute reuse_id.
-
#slide_duration ⇒ Object
Returns the value of attribute slide_duration.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(bureau_sections, options = {}) ⇒ Bureau
constructor
A new instance of Bureau.
- #numberOfSectionsInTableView(table_view) ⇒ Object
- #open ⇒ Object
-
#section(section, header: header) ⇒ Object
stubbed for menu customization in a subclass:.
-
#tableView(table_view, heightForRowAtIndexPath: index_path) ⇒ Object
def tableView(table_view, viewForHeaderInSection: section) puts “getting header for section ##section” header = UIView.alloc.init.tap do |view| view.backgroundColor = :blue.uicolor view.frame = [[0,0], [320,60]] view << UILabel.alloc.init.tap do |label| label.text = @bureau_sections[:title] label.frame = [[15,4], [74,17]] end end section(section, header:header) end.
- #toggle ⇒ Object
- #viewDidLoad ⇒ Object
Constructor Details
#initialize(bureau_sections, options = {}) ⇒ Bureau
Returns a new instance of Bureau.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/bureau/bureau.rb', line 7 def initialize(bureau_sections, = {}) setup_bureau_table @state = [:state] || :closed @drawer_width = [:drawer_width] || 250 @drawer_height = [:drawer_height] || 44 @slide_duration = [:slide_duration] || 0.3 @bureau_sections = bureau_sections initialize_controllers update_active_controller init end |
Instance Attribute Details
#active_controller ⇒ Object
Returns the value of attribute active_controller.
3 4 5 |
# File 'lib/bureau/bureau.rb', line 3 def active_controller @active_controller end |
#active_view_origin ⇒ Object
Returns the value of attribute active_view_origin.
3 4 5 |
# File 'lib/bureau/bureau.rb', line 3 def active_view_origin @active_view_origin end |
#bureau_sections ⇒ Object
Returns the value of attribute bureau_sections.
3 4 5 |
# File 'lib/bureau/bureau.rb', line 3 def bureau_sections @bureau_sections end |
#bureau_table ⇒ Object
Returns the value of attribute bureau_table.
3 4 5 |
# File 'lib/bureau/bureau.rb', line 3 def bureau_table @bureau_table end |
#drawer_height ⇒ Object
Returns the value of attribute drawer_height.
3 4 5 |
# File 'lib/bureau/bureau.rb', line 3 def drawer_height @drawer_height end |
#drawer_width ⇒ Object
Returns the value of attribute drawer_width.
3 4 5 |
# File 'lib/bureau/bureau.rb', line 3 def drawer_width @drawer_width end |
#reuse_id ⇒ Object
Returns the value of attribute reuse_id.
3 4 5 |
# File 'lib/bureau/bureau.rb', line 3 def reuse_id @reuse_id end |
#slide_duration ⇒ Object
Returns the value of attribute slide_duration.
3 4 5 |
# File 'lib/bureau/bureau.rb', line 3 def @slide_duration end |
#state ⇒ Object
Returns the value of attribute state.
3 4 5 |
# File 'lib/bureau/bureau.rb', line 3 def state @state end |
Instance Method Details
#close ⇒ Object
33 34 35 36 37 38 |
# File 'lib/bureau/bureau.rb', line 33 def close UIView.animateWithDuration(@slide_duration, delay:0, options:0, animations: lambda do @active_controller.view.frame = @active_controller.view.frame.left(@drawer_width) end, completion: nil) @state = :closed end |
#numberOfSectionsInTableView(table_view) ⇒ Object
109 110 111 |
# File 'lib/bureau/bureau.rb', line 109 def numberOfSectionsInTableView(table_view) @bureau_sections.count end |
#open ⇒ Object
40 41 42 43 44 45 |
# File 'lib/bureau/bureau.rb', line 40 def open UIView.animateWithDuration(@slide_duration, delay:0, options:0, animations: lambda do @active_controller.view.frame = @active_controller.view.frame.right(@drawer_width) end, completion: nil) @state = :open end |
#section(section, header: header) ⇒ Object
stubbed for menu customization in a subclass:
163 164 165 |
# File 'lib/bureau/bureau.rb', line 163 def section(section, row:row, cell:cell) cell end |
#tableView(table_view, heightForRowAtIndexPath: index_path) ⇒ Object
def tableView(table_view, viewForHeaderInSection: section)
puts "getting header for section #{section}"
header = UIView.alloc.init.tap do |view|
view.backgroundColor = :blue.uicolor
view.frame = [[0,0], [320,60]]
view << UILabel.alloc.init.tap do |label|
label.text = @bureau_sections[section][:title]
label.frame = [[15,4], [74,17]]
end
end
section(section, header:header)
end
134 135 136 |
# File 'lib/bureau/bureau.rb', line 134 def tableView(table_view, numberOfRowsInSection:section) @bureau_sections[section].count end |
#toggle ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/bureau/bureau.rb', line 25 def toggle if @state == :open close else open end end |
#viewDidLoad ⇒ Object
19 20 21 22 23 |
# File 'lib/bureau/bureau.rb', line 19 def viewDidLoad super view.backgroundColor = UIColor.whiteColor view.addSubview(@bureau_sections_table.tableView) end |