Class: MotionWizard::WizardNavigationBar
- Inherits:
-
UIView
- Object
- UIView
- MotionWizard::WizardNavigationBar
- Defined in:
- lib/motion-wizard/views/wizard_navigation_bar.rb
Instance Method Summary collapse
- #create_index_items ⇒ Object
- #init_with_number_of_steps(number_of_steps, wizard_controller) ⇒ Object
- #remove_all_index_items ⇒ Object
- #reset! ⇒ Object
- #resize_indexes ⇒ Object
- #select(index) ⇒ Object
- #setFrame(frame) ⇒ Object
- #setup_index_item_at(index_item, i) ⇒ Object
Instance Method Details
#create_index_items ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/motion-wizard/views/wizard_navigation_bar.rb', line 12 def create_index_items @number_of_steps.times do |i| index_item = @wizard_controller.create_index_item_at(i) @index_items << index_item addSubview(index_item) end end |
#init_with_number_of_steps(number_of_steps, wizard_controller) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/motion-wizard/views/wizard_navigation_bar.rb', line 3 def init_with_number_of_steps(number_of_steps, wizard_controller) self.init @number_of_steps = number_of_steps @index_items = [] @wizard_controller = WeakRef.new(wizard_controller) create_index_items self end |
#remove_all_index_items ⇒ Object
37 38 39 40 |
# File 'lib/motion-wizard/views/wizard_navigation_bar.rb', line 37 def remove_all_index_items @index_items.each{|i| i.removeFromSuperview} @index_items.clear end |
#reset! ⇒ Object
31 32 33 34 35 |
# File 'lib/motion-wizard/views/wizard_navigation_bar.rb', line 31 def reset! remove_all_index_items create_index_items resize_indexes end |
#resize_indexes ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/motion-wizard/views/wizard_navigation_bar.rb', line 42 def resize_indexes return unless @number_of_steps index_width = (self.frame.size.width).to_f / @number_of_steps @index_items.each_with_index do |index_item, i| index_item.frame = [[index_width*i, 0], [index_width, self.size.height]] setup_index_item_at(index_item, i) end end |
#select(index) ⇒ Object
20 21 22 23 24 |
# File 'lib/motion-wizard/views/wizard_navigation_bar.rb', line 20 def select(index) @index_items[@selected_step].unselect if @selected_step && @index_items[@selected_step].respond_to?(:unselect) @selected_step = index @index_items[@selected_step].select if @selected_step && @index_items[@selected_step].respond_to?(:select) end |
#setFrame(frame) ⇒ Object
26 27 28 29 |
# File 'lib/motion-wizard/views/wizard_navigation_bar.rb', line 26 def setFrame(frame) super resize_indexes end |
#setup_index_item_at(index_item, i) ⇒ Object
51 52 53 |
# File 'lib/motion-wizard/views/wizard_navigation_bar.rb', line 51 def setup_index_item_at(index_item, i) @wizard_controller.setup_index_item_at(index_item, i) end |