Sha256: 53d72eacbecbe24dee049381d566c30c422a72e79e28d8dc4c688bea4af037be

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

class UnderOs::History
  attr_reader :_, :navbar

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

  def root_page
    @_.topViewController.wrapper
  end

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

  def current_page
    controller = @_.topViewController

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

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

  alias :<< :push

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

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

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

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

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
under-os-ui-1.4.0 lib/under_os/history.rb
under-os-1.3.0 lib/under_os/history.rb