class MotionWizard::WizardViewController

Constants

DEFAULT_NAVIGATION_BAR_HEIGHT

Attributes

content_view[R]
navigation_bar_view[R]
wizard_data[R]

Public Class Methods

backward_animation_strategy(animation_strategy_class) click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 15
def self.backward_animation_strategy(animation_strategy_class)
  @_backward_animation_strategy_class = animation_strategy_class
end
forward_animation_strategy(animation_strategy_class) click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 11
def self.forward_animation_strategy(animation_strategy_class)
  @_forward_animation_strategy_class = animation_strategy_class
end
index_item_view_class(index_item_view_class) click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 19
def self.index_item_view_class(index_item_view_class)
  @_index_item_view_class = index_item_view_class
end
steps(*steps) click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 7
def self.steps(*steps)
  @_wizard_steps = steps
end

Public Instance Methods

add_new_step_view(animation_strategy) click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 58
def add_new_step_view(animation_strategy)
  @current_view_controller = get_current_step_view_controller
  self.addChildViewController(@current_view_controller)
  @content_view.addSubview(@current_view_controller.view)

  @current_view_controller.view.origin = [0,0]
  animation_strategy.show_view(@current_view_controller.view)
  navigation_bar_view.select(@current_step)
end
change_step_view(animation_strategy_klass) click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 123
def change_step_view(animation_strategy_klass)
  animation_strategy = animation_strategy_klass.new
  remove_current_step_view(animation_strategy)
  add_new_step_view(animation_strategy)
  animation_strategy.animate
end
create_index_item_at(index) click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 130
def create_index_item_at(index)
  index_item = @index_item_view_class.alloc.init
  index_item.label.text = "%02d" % (index+1)
  index_item
end
finish(data = {}) click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 118
def finish(data = {})
  @wizard_data.merge! data
  self.when_finished
end
get_current_step_view_controller() click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 68
def get_current_step_view_controller
  @steps_controllers[@current_step] ||= begin
    new_view_controller = @steps_controllers_classes[@current_step].alloc.init
    new_view_controller.extend(MotionWizard::ContentController)
    new_view_controller.wizard_view_controller = self
    new_view_controller.view.size = @content_view.size
    new_view_controller
  end
end
go_to_step(step_number, data = {}) click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 110
def go_to_step(step_number, data = {})
  @wizard_data.merge! data
  animation_klass = @current_step > step_number ? @backward_animation_strategy_class : @forward_animation_strategy_class
  @current_step = step_number
  change_step_view(animation_klass)
  self
end
init() click to toggle source
Calls superclass method
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 23
def init
  super
  @steps_controllers_classes = self.class.instance_variable_get(:@_wizard_steps) || []
  @forward_animation_strategy_class = self.class.instance_variable_get(:@_forward_animation_strategy_class) || AnimationStrategy::RightToLeft
  @backward_animation_strategy_class = self.class.instance_variable_get(:@_backward_animation_strategy_class) || AnimationStrategy::LeftToRight
  @index_item_view_class = self.class.instance_variable_get(:@_index_item_view_class) || IndexItem
  @current_step = 0
  @wizard_data = {}
  @steps_controllers = []
  self
end
next(data = {}) click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 90
def next(data = {})
  @wizard_data.merge! data
  @current_step+=1
  if @current_step >= number_of_steps
    @current_step = number_of_steps - 1
    self.finish
    return
  end
  change_step_view(@forward_animation_strategy_class)
  self
end
number_of_steps() click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 86
def number_of_steps
  @steps_controllers_classes.size
end
previous(data = {}) click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 102
def previous(data = {})
  @wizard_data.merge! data
  @current_step-=1
  return if @current_step < 0
  change_step_view(@backward_animation_strategy_class)
  self
end
remove_current_step_view(animation_strategy) click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 78
def remove_current_step_view(animation_strategy)
  current_local_view = @current_view_controller
  animation_strategy.hide_view(@current_view_controller.view) do |view|
    view.removeFromSuperview
    current_local_view.removeFromParentViewController
  end
end
reset!() click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 51
def reset!
  @wizard_data = {}
  @steps_controllers = []
  @navigation_bar_view.reset!
  navigation_bar_view.select(@current_step)
end
setup_index_item_at(index_item, index) click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 136
def setup_index_item_at(index_item, index)
  index_item.label_wrapper.size = index_item.size
  index_item.label.size = index_item.size
end
viewDidLoad() click to toggle source
Calls superclass method
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 35
def viewDidLoad
  super

  @content_view = UIView.alloc.init
  @content_view.origin = [0,0]
  @content_view.size = self.view.size
  self.view.addSubview(@content_view)

  @navigation_bar_view = WizardNavigationBar.alloc.init_with_number_of_steps(number_of_steps, self)
  @navigation_bar_view.origin = [0,0]
  @navigation_bar_view.size = [self.view.size.width, DEFAULT_NAVIGATION_BAR_HEIGHT]
  self.view.addSubview(navigation_bar_view)

  add_new_step_view(AnimationStrategy::None.new)
end
when_finished() click to toggle source
# File lib/motion-wizard/controllers/wizard_view_controller.rb, line 141
def when_finished;end