Sha256: 6c543df357d189d95e6de6336af6861078ca998c620ce72a6483ce2ade7cf77e

Contents?: true

Size: 1.93 KB

Versions: 3

Compression:

Stored size: 1.93 KB

Contents

module ProMotion
  if defined?(Formotion) && defined?(Formotion::FormController)
    class FormotionScreen < Formotion::FormController
      include ProMotion::ScreenModule

      def self.new(args = {})
        s = self.alloc.initWithStyle(UITableViewStyleGrouped)
        s.on_create(args) if s.respond_to?(:on_create)

        if s.respond_to?(:table_data)
          s.form = s.table_data
        elsif args[:form]
          s.form = args[:form]
        else
          PM.logger.error "PM::FormotionScreen requires a `table_data` method or form: to be passed into `new`."
        end

        s.tableView.allowsSelectionDuringEditing = true

        s
      end

      # emulate the ProMotion table update for formotion
      def update_table_data
        self.form            = table_data
        self.form.controller = self
        self.tableView.reloadData
      end

      def viewDidLoad
        super
        self.view_did_load if self.respond_to?(:view_did_load)
      end

      def viewWillAppear(animated)
        super
        self.view_will_appear(animated) if self.respond_to?(:view_will_appear)
      end

      def viewDidAppear(animated)
        super
        self.view_did_appear(animated) if self.respond_to?(:view_did_appear)
      end

      def viewWillDisappear(animated)
        self.view_will_disappear(animated) if self.respond_to?(:view_will_disappear)
        super
      end

      def viewDidDisappear(animated)
        self.view_did_disappear(animated) if self.respond_to?(:view_did_disappear)
        super
      end

      def shouldAutorotateToInterfaceOrientation(orientation)
        self.should_rotate(orientation)
      end

      def shouldAutorotate
        self.should_autorotate
      end

      def willRotateToInterfaceOrientation(orientation, duration:duration)
        self.will_rotate(orientation, duration)
      end

      def didRotateFromInterfaceOrientation(orientation)
        self.on_rotate
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ProMotion-0.7.8 lib/ProMotion/screens/_compatibility/formotion_screen.rb
ProMotion-0.7.6 lib/ProMotion/screens/_compatibility/formotion_screen.rb
ProMotion-0.7.5 lib/ProMotion/screens/_compatibility/formotion_screen.rb