Class: MotionPrime::TabbedSection
- Includes:
- HasNormalizer
- Defined in:
- motion-prime/sections/tabbed.rb
Constant Summary
Constants inherited from Section
Section::DEFAULT_CONTENT_HEIGHT, Section::KEYBOARD_HEIGHT_LANDSCAPE, Section::KEYBOARD_HEIGHT_PORTRAIT
Instance Attribute Summary collapse
-
#tab_pages ⇒ Object
Returns the value of attribute tab_pages.
Attributes inherited from Section
#elements, #model, #name, #options, #screen, #section_styles
Attributes included from DrawSectionMixin
#cached_draw_image, #container_element, #container_gesture_recognizers
Class Method Summary collapse
Instance Method Summary collapse
-
#disable_at(index) ⇒ Object
Make tab button disabled by index.
-
#enable_at(index) ⇒ Object
Make tab button enabled by index.
-
#on_click(*control) ⇒ Object
on click to segment tab.
- #set_title(key, title) ⇒ Object
- #show_at_index(index) ⇒ Object
- #show_by_key(key) ⇒ Object
- #tab_control_items ⇒ Object
- #tab_default ⇒ Object
- #tab_options ⇒ Object
- #tab_page(key) ⇒ Object
-
#toggle_at(index, value) ⇒ Object
Toggle tab button activity by index.
Methods included from HasNormalizer
#debug_info, #element?, #normalize_object, #normalize_options, #normalize_value
Methods inherited from Section
#add_element, after_element_render, after_initialize, after_render, before_initialize, before_render, bind_keyboard_close, #bind_keyboard_events, #bring_to_front, container, #container_bounds, #container_height, #container_options, #create_elements, #current_input_view_height, #dealloc, #default_name, element, #element, #elements_options, #elements_to_draw, #elements_to_render, #hard_reload_section, #has_container_bounds?, #hide, #hide_keyboard, #initialize, #keyboard_will_hide, #keyboard_will_show, #on_element_render, #on_keyboard_hide, #on_keyboard_show, #reload, #render, #render!, #render_container, #render_element?, #screen?, #show, #strong_references, #view
Methods included from DelegateMixin
#clear_delegated, #delegated_by
Methods included from DrawSectionMixin
#bind_gesture_on_container_for, #clear_gesture_for_receiver, #draw_in, #prerender_elements_for_state, #prerender_enabled?
Methods included from SectionWithContainerMixin
#container_view, #init_container_element, #load_container_with_elements
Methods included from FrameCalculatorMixin
Methods included from HasStyles
Methods included from HasClassFactory
#camelize_factory, #class_factory, #low_camelize_factory
Methods included from HasAuthorization
#api_client, #current_user, #reset_current_user, #user_signed_in?
Constructor Details
This class inherits a constructor from MotionPrime::Section
Instance Attribute Details
#tab_pages ⇒ Object
Returns the value of attribute tab_pages.
16 17 18 |
# File 'motion-prime/sections/tabbed.rb', line 16 def tab_pages @tab_pages end |
Class Method Details
.inherited(subclass) ⇒ Object
88 89 90 91 92 93 |
# File 'motion-prime/sections/tabbed.rb', line 88 def inherited(subclass) super subclass. = self..try(:clone) subclass.tabs_default = self.tabs_default.try(:clone) subclass.tabs_indexes = self.tabs_indexes.try(:clone) end |
.tab(id, options = {}) ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 |
# File 'motion-prime/sections/tabbed.rb', line 95 def tab(id, = {}) [:name] ||= id.to_s.titleize [:id] = id self.tabs_indexes ||= {} self.tabs_indexes[id] = tabs_indexes.length self.tabs_default = tabs_indexes.length - 1 if [:default] self. ||= {} self.[id] = end |
Instance Method Details
#disable_at(index) ⇒ Object
Make tab button disabled by index
38 39 40 |
# File 'motion-prime/sections/tabbed.rb', line 38 def disable_at(index) toggle_at(index, false) end |
#enable_at(index) ⇒ Object
Make tab button enabled by index
44 45 46 |
# File 'motion-prime/sections/tabbed.rb', line 44 def enable_at(index) toggle_at(index, true) end |
#on_click(*control) ⇒ Object
on click to segment tab
60 61 62 |
# File 'motion-prime/sections/tabbed.rb', line 60 def on_click(*control) show_at_index(control.selectedSegment) end |
#set_title(key, title) ⇒ Object
82 83 84 85 |
# File 'motion-prime/sections/tabbed.rb', line 82 def set_title(key, title) id = self.class.tabs_indexes[key] view(:control).setTitle(title, forSegmentAtIndex: id) end |
#show_at_index(index) ⇒ Object
64 65 66 67 68 69 70 |
# File 'motion-prime/sections/tabbed.rb', line 64 def show_at_index(index) @tab_pages.each_with_index do |page, i| page.hide if index != i end view(:control).setSelectedSegmentIndex index @tab_pages[index].show end |
#show_by_key(key) ⇒ Object
72 73 74 75 |
# File 'motion-prime/sections/tabbed.rb', line 72 def show_by_key(key) id = self.class.tabs_indexes[key] show_at_index(id) end |
#tab_control_items ⇒ Object
28 29 30 |
# File 'motion-prime/sections/tabbed.rb', line 28 def tab_control_items @tab_control_items ||= .values.map{ |o| o[:name] } end |
#tab_default ⇒ Object
32 33 34 |
# File 'motion-prime/sections/tabbed.rb', line 32 def tab_default @tab_default ||= self.class.tabs_default || 0 end |
#tab_options ⇒ Object
24 25 26 |
# File 'motion-prime/sections/tabbed.rb', line 24 def @tab_options ||= (self.class..clone) end |
#tab_page(key) ⇒ Object
77 78 79 80 |
# File 'motion-prime/sections/tabbed.rb', line 77 def tab_page(key) id = self.class.tabs_indexes[key] tab_pages[id] end |
#toggle_at(index, value) ⇒ Object
Toggle tab button activity by index
51 52 53 54 55 56 |
# File 'motion-prime/sections/tabbed.rb', line 51 def toggle_at(index, value) if index.is_a?(Symbol) index = self.class.tabs_indexes[index] end view(:control).setEnabled value, forSegmentAtIndex: index end |