Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducting
-[UIManager.setLocalData:forView:]
, the way to provide…
… environmental data to ShadowView Summary: In some cases we need a way to specify some environmental data to shadow view to improve layout (or do something similar), so `localData` serves these needs. For example, any stateful embedded native views may benefit from this. Have in mind that this data is not supposed to interfere with the state of the shadow view. Reviewed By: mmmulani Differential Revision: D5884711 fbshipit-source-id: f0bf66e4608894ec4479b8aca262afcfba6b9f4b
- Loading branch information
1 parent
e5d4d49
commit 8b4ed94
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -339,6 +339,20 @@ - (void)setAvailableSize:(CGSize)availableSize forRootView:(UIView *)rootView | |
}); | ||
} | ||
|
||
- (void)setLocalData:(NSObject *)localData forView:(UIView *)view | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
shergin
Author
Contributor
|
||
{ | ||
RCTAssertMainQueue(); | ||
NSNumber *tag = view.reactTag; | ||
|
||
dispatch_async(RCTGetUIManagerQueue(), ^{ | ||
RCTShadowView *shadowView = self->_shadowViewRegistry[tag]; | ||
RCTAssert(shadowView != nil, @"Could not locate shadow view with tag #%@", tag); | ||
|
||
shadowView.localData = localData; | ||
[self setNeedsLayout]; | ||
}); | ||
} | ||
|
||
/** | ||
* TODO(yuwang): implement the nativeID functionality in a more efficient way | ||
* instead of searching the whole view tree | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
All this code needed to not write in view part couple lines of code?
Not very good, because:
localData
on you shadow views every time, because anyone can set itIt would be better to have more agile interface that allow to any communication with shadow views, something like:
With that interface: