Module: MotionPrime::ScreenNavigationMixin

Included in:
ScreenBaseMixin
Defined in:
motion-prime/screens/_navigation_mixin.rb

Instance Method Summary collapse

Instance Method Details

#backObject



35
36
37
# File 'motion-prime/screens/_navigation_mixin.rb', line 35

def back
  close_screen
end

#close_screen(args = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'motion-prime/screens/_navigation_mixin.rb', line 25

def close_screen(args = {})
  args[:animated] = args.fetch(:animated, true)
  # Pop current view, maybe with arguments, if in navigation controller
  if modal?
    close_screen_modal(args)
  elsif has_navigation?
    close_screen_navigational(args)
  end
end

#has_navigation?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'motion-prime/screens/_navigation_mixin.rb', line 61

def has_navigation?
  navigation_controller.weakref_alive? && !navigation_controller.nil?
end


65
66
67
# File 'motion-prime/screens/_navigation_mixin.rb', line 65

def navigation_controller
  @navigation_controller ||= self.navigationController.try(:weak_ref)
end


69
70
71
# File 'motion-prime/screens/_navigation_mixin.rb', line 69

def navigation_controller=(val)
  @navigation_controller = val.try(:weak_ref)
end

#open_screen(screen, args = {}) ⇒ MotionPrime::Screen

Parameters:

  • screen (MotionPrime::Screen)

    Screen to be opened

  • args (Hash) (defaults to: {})

    Options for opening screen

Returns:



12
13
14
15
16
17
18
19
20
21
22
# File 'motion-prime/screens/_navigation_mixin.rb', line 12

def open_screen(screen, args = {})
  screen = setup_screen_for_open(screen, args)
  screen.send(:on_screen_load) if screen.respond_to?(:on_screen_load)
  args[:animated] = args.has_key?(:animated) ? args[:animated] : true
  if args[:modal] || !has_navigation?
    open_screen_modal(screen, args.merge(modal: true))
  else
    open_screen_navigational(screen, args)
  end
  screen
end

#send_on_leaveObject



45
46
47
48
49
# File 'motion-prime/screens/_navigation_mixin.rb', line 45

def send_on_leave
  if respond_to?(:on_leave)
    on_leave
  end
end

#send_on_return(screen) ⇒ Object



39
40
41
42
43
# File 'motion-prime/screens/_navigation_mixin.rb', line 39

def send_on_return(screen)
  if screen && screen.respond_to?(:on_return)
    screen.send(:on_return)
  end
end

#wrap_in_navigationObject



55
56
57
58
59
# File 'motion-prime/screens/_navigation_mixin.rb', line 55

def wrap_in_navigation
  if wrap_in_navigation?
    wrap_in_navigation!
  end
end

#wrap_in_navigation?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'motion-prime/screens/_navigation_mixin.rb', line 51

def wrap_in_navigation?
  options.fetch(:navigation, true)
end