1 | /*
|
2 | * Copyright (c) Facebook, Inc. and its affiliates.
|
3 | *
|
4 | * This source code is licensed under the MIT license found in the
|
5 | * LICENSE file in the root directory of this source tree.
|
6 | */
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | @class RCTBridge;
|
18 | @class RCTShadowView;
|
19 | @class RCTSparseArray;
|
20 | @class RCTUIManager;
|
21 |
|
22 | typedef void (^RCTViewManagerUIBlock)(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry);
|
23 |
|
24 | @interface RCTViewManager : NSObject <RCTBridgeModule>
|
25 |
|
26 | /**
|
27 | * The bridge can be used to access both the RCTUIIManager and the RCTEventDispatcher,
|
28 | * allowing the manager (or the views that it manages) to manipulate the view
|
29 | * hierarchy and send events back to the JS context.
|
30 | */
|
31 | @property (nonatomic, weak) RCTBridge *bridge;
|
32 |
|
33 | /**
|
34 | * This method instantiates a native view to be managed by the module. Override
|
35 | * this to return a custom view instance, which may be preconfigured with default
|
36 | * properties, subviews, etc. This method will be called many times, and should
|
37 | * return a fresh instance each time. The view module MUST NOT cache the returned
|
38 | * view and return the same instance for subsequent calls.
|
39 | */
|
40 | - (UIView *)view;
|
41 |
|
42 | /**
|
43 | * This method instantiates a shadow view to be managed by the module. If omitted,
|
44 | * an ordinary RCTShadowView instance will be created, which is typically fine for
|
45 | * most view types. As with the -view method, the -shadowView method should return
|
46 | * a fresh instance each time it is called.
|
47 | */
|
48 | - (RCTShadowView *)shadowView;
|
49 |
|
50 | /**
|
51 | * DEPRECATED: declare properties of type RCTBubblingEventBlock instead
|
52 | *
|
53 | * Returns an array of names of events that can be sent by native views. This
|
54 | * should return bubbling, directly-dispatched event types. The event name
|
55 | * should not include a prefix such as 'on' or 'top', as this will be applied
|
56 | * as needed. When subscribing to the event, use the 'Captured' suffix to
|
57 | * indicate the captured form, or omit the suffix for the bubbling form.
|
58 | *
|
59 | * Note that this method is not inherited when you subclass a view module, and
|
60 | * you should not call [super customBubblingEventTypes] when overriding it.
|
61 | */
|
62 | - (NSArray<NSString *> *)customBubblingEventTypes __deprecated_msg("Use RCTBubblingEventBlock props instead.");
|
63 |
|
64 | /**
|
65 | * This handles the simple case, where JS and native property names match.
|
66 | */
|
67 |
|
68 | + (NSArray<NSString *> *)propConfig_#
|
69 |
|
70 | /**
|
71 | * This macro maps a named property to an arbitrary key path in the view.
|
72 | */
|
73 |
|
74 | + (NSArray<NSString *> *)propConfig_#
|
75 |
|
76 | /**
|
77 | * This macro can be used when you need to provide custom logic for setting
|
78 | * view properties. The macro should be followed by a method body, which can
|
79 | * refer to "json", "view" and "defaultView" to implement the required logic.
|
80 | */
|
81 |
|
82 | RCT_REMAP_VIEW_PROPERTY(name, __custom__, type) \
|
83 | - (void)set_#
|
84 |
|
85 | /**
|
86 | * This macro is used to map properties to the shadow view, instead of the view.
|
87 | */
|
88 |
|
89 | + (NSArray<NSString *> *)propConfigShadow_#
|
90 |
|
91 | /**
|
92 | * This macro maps a named property to an arbitrary key path in the shadow view.
|
93 | */
|
94 |
|
95 | + (NSArray<NSString *> *)propConfigShadow_#
|
96 |
|
97 | /**
|
98 | * This macro can be used when you need to provide custom logic for setting
|
99 | * shadow view properties. The macro should be followed by a method body, which can
|
100 | * refer to "json" and "view".
|
101 | */
|
102 |
|
103 | RCT_REMAP_SHADOW_PROPERTY(name, __custom__, type) \
|
104 | - (void)set_#
|
105 |
|
106 | @end
|