Sha256: 20775b006c9871981fa1bca9ed7d0879ab9e273a9d2d66d7d250e573091d81e2

Contents?: true

Size: 1.52 KB

Versions: 2

Compression:

Stored size: 1.52 KB

Contents

motion_require '../support/mp_view_controller.rb'
motion_require '../views/layout.rb'
motion_require '../screens/_base_mixin.rb'
motion_require './extensions/_indicators_mixin'
motion_require './extensions/_navigation_bar_mixin'
motion_require '../helpers/has_authorization'
motion_require '../helpers/has_search_bar'
module MotionPrime
  class Screen < MPViewController
    include Layout
    include ScreenBaseMixin

    # extensions
    include ScreenIndicatorsMixin
    include ScreenNavigationBarMixin

    # helpers
    include HasAuthorization
    include HasSearchBar

    extend HasClassFactory

    define_callbacks :render

    after_render :add_sections

    def render
    end

    def default_styles
      [:base_screen, self.class_name_without_kvo.underscore.to_sym]
    end

    def will_appear
      @visible = true
      @on_appear_happened ||= {}
      unless @on_appear_happened[view.object_id]
        setup view, styles: default_styles do
          run_callbacks :render do 
            send((action).to_sym)
          end
        end
      end
      @on_appear_happened[view.object_id] = true
    end

    def will_disappear
      @visible = false
    end

    def dealloc
      Prime.logger.dealloc_message :screen, self
      # FIXME: calling instance_eval in title method (_base_screen_mixin) instance variables need to be cleared manually
      clear_instance_variables(except: [:_search_bar])
      super
    end

    def strong_references
      self.main_controller
    end

    def visible?
      !!@visible
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
motion-prime-0.9.5 motion-prime/screens/screen.rb
motion-prime-0.9.4 motion-prime/screens/screen.rb