Class: RMXView

Inherits:
UIView
  • Object
show all
Includes:
RMXCommonMethods, RMXSetAttributes
Defined in:
lib/motion/RMXView.rb

Direct Known Subclasses

RMXTableViewCellInnerContentView

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RMXSetAttributes

included

Methods included from RMXCommonMethods

#dealloc, #description, #inspect

Instance Attribute Details

#reportSizeChangesObject

Returns the value of attribute reportSizeChanges.



6
7
8
# File 'lib/motion/RMXView.rb', line 6

def reportSizeChanges
  @reportSizeChanges
end

#updatedSizeObject

Returns the value of attribute updatedSize.



6
7
8
# File 'lib/motion/RMXView.rb', line 6

def updatedSize
  @updatedSize
end

Class Method Details

.create(attributes = {}) ⇒ Object



31
32
33
34
35
# File 'lib/motion/RMXView.rb', line 31

def self.create(attributes={})
  x = new
  x.attributes = attributes
  x
end

Instance Method Details

#hitTest(point, withEvent: event) ⇒ Object

normal userInteractionEnabled means the view and all subviews can’t be clicked. what we normally want is subviews to be clickable, but not the parent. this custom hitTest allows that behavior.



39
40
41
42
43
44
45
# File 'lib/motion/RMXView.rb', line 39

def hitTest(point, withEvent:event)
  s = super
  if s == self && @userInteractionEnabled == false
    return nil
  end
  s
end

#initObject



19
20
21
22
23
24
25
# File 'lib/motion/RMXView.rb', line 19

def init
  s = super
  prepare
  setUserInteractionEnabled(false)
  setup
  s
end

#layoutSubviewsObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/motion/RMXView.rb', line 51

def layoutSubviews
  s = super
  if reportSizeChanges
    Dispatch::Queue.main.async do
      size = systemLayoutSizeFittingSize(UILayoutFittingCompressedSize)
      unless updatedSize == size
        self.updatedSize = size
        RMX.new(self).trigger(:updatedSize, size)
        
        if tableView = is_or_within_a?(UITableView)
          if tableView.delegate.respondsToSelector('tableView:viewDidUpdateSize:')
            tableView.delegate.tableView(tableView, viewDidUpdateSize:self)
          end
          # p "unbounced reload"
          RMX.new(self).debounce(:reloadTableUpdatedSize) do
            # p "debounced reload"
            if controller = tableView.lAncestorViewController
              if controller.viewState == :viewDidAppear
                tableView.beginUpdates
                tableView.endUpdates
              else
                tableView.reloadData
              end
            end
          end
        end

      end
    end
  end
  s
end

#prepareObject



13
14
# File 'lib/motion/RMXView.rb', line 13

def prepare
end

#requiresConstraintBasedLayoutObject



47
48
49
# File 'lib/motion/RMXView.rb', line 47

def requiresConstraintBasedLayout
  true
end

#rmx_deallocObject



8
9
10
11
# File 'lib/motion/RMXView.rb', line 8

def rmx_dealloc
  NSNotificationCenter.defaultCenter.removeObserver(self)
  super
end

#setupObject



16
17
# File 'lib/motion/RMXView.rb', line 16

def setup
end

#setUserInteractionEnabled(bool) ⇒ Object



27
28
29
# File 'lib/motion/RMXView.rb', line 27

def setUserInteractionEnabled(bool)
  @userInteractionEnabled = bool
end