Sha256: cb6466b150c62b053d5dff2ac1164a9812a0a7f8a439c9ddc21857dce0f76bb6

Contents?: true

Size: 1.37 KB

Versions: 6

Compression:

Stored size: 1.37 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

    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 { render }
        end
      end
      @on_appear_happened[view.object_id] = true
    end

    def will_disappear
      @visible = false
    end

    def dealloc
      pp 'Deallocating Screen', self.object_id, self.to_s
      # FIXME: calling instance_eval in title method (_base_screen_mixin) instance variables need to be cleared manually
      clear_instance_variables
      super
    end

    def visible?
      @visible
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
motion-prime-0.6.0 motion-prime/screens/screen.rb
motion-prime-0.5.7 motion-prime/screens/screen.rb
motion-prime-0.5.6 motion-prime/screens/screen.rb
motion-prime-0.5.5 motion-prime/screens/screen.rb
motion-prime-0.5.4 motion-prime/screens/screen.rb
motion-prime-0.5.3 motion-prime/screens/screen.rb