Class: UnderOs::History

Inherits:
Object show all
Defined in:
lib/under_os/history.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHistory

Returns a new instance of History.



4
5
6
7
# File 'lib/under_os/history.rb', line 4

def initialize
  @_      = UINavigationController.alloc
  @navbar = UnderOs::UI::Navbar.new(@_)
end

Instance Attribute Details

#_Object (readonly)

Returns the value of attribute _.



2
3
4
# File 'lib/under_os/history.rb', line 2

def _
  @_
end

Returns the value of attribute navbar.



2
3
4
# File 'lib/under_os/history.rb', line 2

def navbar
  @navbar
end

Instance Method Details

#current_pageObject



17
18
19
20
21
22
# File 'lib/under_os/history.rb', line 17

def current_page
  controller = @_.topViewController

  controller.is_a?(UnderOs::Page::UIViewControllerWrap) ?
    controller.wrapper : root_page
end

#pagesObject



42
43
44
# File 'lib/under_os/history.rb', line 42

def pages
  @_.viewControllers.map{|c| c.wrapper rescue nil }.compact
end

#pop(page = nil, animated = true) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/under_os/history.rb', line 34

def pop(page=nil, animated=true)
  if page
    @_.popToViewController(page._, animated: animated)
  else
    @_.popViewControllerAnimated(animated)
  end
end

#pop_to(page, animated = true) ⇒ Object



46
47
48
# File 'lib/under_os/history.rb', line 46

def pop_to(page, animated=true)
  pop(page, animated)
end

#pop_to_root(animated = true) ⇒ Object



50
51
52
# File 'lib/under_os/history.rb', line 50

def pop_to_root(animated=true)
  @_.popToRootViewControllerAnimated(animated)
end

#push(page, animated = true) ⇒ Object Also known as: <<



24
25
26
27
28
29
30
# File 'lib/under_os/history.rb', line 24

def push(page, animated=true)
  if pages.include?(page)
    pop_to(page)
  else
    @_.pushViewController(page._, animated: animated)
  end
end

#root_pageObject



9
10
11
# File 'lib/under_os/history.rb', line 9

def root_page
  @_.topViewController.wrapper
end

#root_page=(page) ⇒ Object



13
14
15
# File 'lib/under_os/history.rb', line 13

def root_page=(page)
  @_.initWithRootViewController(page._)
end