Sha256: b1678f7bf657174a5a2a17db025b20dc22c082fece8f36eb7c40893a02db86bd

Contents?: true

Size: 939 Bytes

Versions: 4

Compression:

Stored size: 939 Bytes

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
    @_.visibleViewController.wrapper
  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

4 entries across 4 versions & 1 rubygems

Version Path
under-os-1.2.1 lib/under_os/history.rb
under-os-1.2.0 lib/under_os/history.rb
under-os-1.1.0 lib/under_os/history.rb
under-os-1.0.0 lib/under_os/history.rb