forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRCTComponentViewProtocol.h
More file actions
122 lines (102 loc) · 4.03 KB
/
RCTComponentViewProtocol.h
File metadata and controls
122 lines (102 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <UIKit/UIKit.h>
#import <React/RCTPrimitives.h>
#import <react/core/EventEmitter.h>
#import <react/core/LayoutMetrics.h>
#import <react/core/Props.h>
#import <react/core/State.h>
#import <react/uimanager/ComponentDescriptorProvider.h>
NS_ASSUME_NONNULL_BEGIN
/*
* Bitmask for all types of possible updates performing during mounting.
*/
typedef NS_OPTIONS(NSInteger, RNComponentViewUpdateMask) {
RNComponentViewUpdateMaskNone = 0,
RNComponentViewUpdateMaskProps = 1 << 0,
RNComponentViewUpdateMaskEventEmitter = 1 << 1,
RNComponentViewUpdateMaskState = 1 << 3,
RNComponentViewUpdateMaskLayoutMetrics = 1 << 4,
RNComponentViewUpdateMaskAll = RNComponentViewUpdateMaskProps | RNComponentViewUpdateMaskEventEmitter |
RNComponentViewUpdateMaskState | RNComponentViewUpdateMaskLayoutMetrics
};
/*
* Represents a `UIView` instance managed by React.
* All methods are non-@optional.
* `UIView+ComponentViewProtocol` category provides default implementation
* for all of them.
*/
@protocol RCTComponentViewProtocol <NSObject>
/*
* Returns a `ComponentDescriptorProvider` of a particular `ComponentDescriptor` which this component view
* represents.
*/
+ (facebook::react::ComponentDescriptorProvider)componentDescriptorProvider;
/*
* Returns a list of supplemental `ComponentDescriptorProvider`s (with do not have `ComponentView` counterparts) that
* require for this component view.
*/
+ (std::vector<facebook::react::ComponentDescriptorProvider>)supplementalComponentDescriptorProviders;
/*
* Called for mounting (attaching) a child component view inside `self`
* component view.
* Receiver must add `childComponentView` as a subview.
*/
- (void)mountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index;
/*
* Called for unmounting (detaching) a child component view from `self`
* component view.
* Receiver must remove `childComponentView` as a subview.
*/
- (void)unmountChildComponentView:(UIView<RCTComponentViewProtocol> *)childComponentView index:(NSInteger)index;
/*
* Called for updating component's props.
* Receiver must update native view props accordingly changed props.
*/
- (void)updateProps:(facebook::react::Props::Shared const &)props
oldProps:(facebook::react::Props::Shared const &)oldProps;
/*
* Called for updating component's state.
* Receiver must update native view according to changed state.
*/
- (void)updateState:(facebook::react::State::Shared const &)state
oldState:(facebook::react::State::Shared const &)oldState;
/*
* Called for updating component's event handlers set.
* Receiver must cache `eventEmitter` object inside and use it for emitting
* events when needed.
*/
- (void)updateEventEmitter:(facebook::react::EventEmitter::Shared const &)eventEmitter;
/*
* Called for updating component's layout metrics.
* Receiver must update `UIView` layout-related fields (such as `frame`,
* `bounds`, `layer.zPosition`, and so on) accordingly.
*/
- (void)updateLayoutMetrics:(facebook::react::LayoutMetrics const &)layoutMetrics
oldLayoutMetrics:(facebook::react::LayoutMetrics const &)oldLayoutMetrics;
/*
* Called when receiving a command
*/
- (void)handleCommand:(NSString const *)commandName args:(NSArray const *)args;
/*
* Called right after all update methods were called for a particular component view.
* Useful for performing updates that require knowledge of several independent aspects of the compound mounting change
* (e.g. props *and* layout constraints).
*/
- (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask;
/*
* Called right after the component view is moved to a recycle pool.
* Receiver must reset any local state and release associated
* non-reusable resources.
*/
- (void)prepareForRecycle;
/**
* Read the last props used to update the view.
*/
- (facebook::react::SharedProps)props;
@end
NS_ASSUME_NONNULL_END