Sha256: 48b24eff4a78d626137dce246a39d96377c7afd56a8752227f6e21798912af5e

Contents?: true

Size: 1.68 KB

Versions: 10

Compression:

Stored size: 1.68 KB

Contents

module ProMotion
  module SplitScreen
    def open_split_screen(master, detail, args={})
      split = create_split_screen(master, detail, args)
      open split, args
      split
    end

    def create_split_screen(master, detail, args={})
      master = master.new if master.respond_to?(:new)
      detail = detail.new if detail.respond_to?(:new)
      split = split_screen_controller(master, detail)
      split_screen_setup(split, args)
      split
    end

    # UISplitViewControllerDelegate methods

    def splitViewController(svc, willHideViewController: vc, withBarButtonItem: button, forPopoverController: pc)
      button.title = @pm_split_screen_button_title || vc.title
      svc.detail_screen.navigationItem.leftBarButtonItem = button
    end

    def splitViewController(svc, willShowViewController: vc, invalidatingBarButtonItem: barButtonItem)
      svc.detail_screen.navigationItem.leftBarButtonItem = nil
    end

  private

    def split_screen_controller(master, detail)
      split = SplitViewController.alloc.init
      split.viewControllers = [ (master.navigationController || master), (detail.navigationController || detail) ]
      split.delegate = self

      [ master, detail ].map { |s| s.split_screen = split if s.respond_to?(:split_screen=) }

      split
    end

    def split_screen_setup(split, args)
      args[:icon] ||= args[:item] # TODO: Remove in PM 2.2+.
      if (args[:item] || args[:title]) && respond_to?(:create_tab_bar_item)
        split.tabBarItem = create_tab_bar_item(args)
      end
      @pm_split_screen_button_title = args[:button_title] if args.has_key?(:button_title)
      split.presentsWithGesture = args[:swipe] if args.has_key?(:swipe)
    end

  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ProMotion-2.2.0 lib/ProMotion/ipad/split_screen.rb
ProMotion-2.1.0 lib/ProMotion/ipad/split_screen.rb
ProMotion-2.1.0.beta1 lib/ProMotion/ipad/split_screen.rb
ProMotion-2.0.1 lib/ProMotion/ipad/split_screen.rb
ProMotion-2.0.0 lib/ProMotion/ipad/split_screen.rb
ProMotion-2.0.0.rc5 lib/ProMotion/ipad/split_screen.rb
ProMotion-2.0.0.rc4 lib/ProMotion/ipad/split_screen.rb
ProMotion-2.0.0.rc3 lib/ProMotion/ipad/split_screen.rb
ProMotion-2.0.0.rc2 lib/ProMotion/ipad/split_screen.rb
ProMotion-2.0.0.rc1 lib/ProMotion/ipad/split_screen.rb