-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add UIBlock Interface #1050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add UIBlock Interface #1050
Changes from 9 commits
94bb735
ae2c77a
8495837
9ddb628
4e76093
38a2ade
2c21d07
43491c9
967e7d6
ad5ae4d
04c7308
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| using ReactNative.UIManager; | ||
|
|
||
| namespace ReactNative.UIManager | ||
| { | ||
| /// <summary> | ||
| /// Interface that represents a block to execute on the UI thread. | ||
| /// Exposes NativeViewHierarchyManager for third party libraries. | ||
| /// </summary> | ||
| public interface IUIBlock | ||
| { | ||
| /// <summary> | ||
| /// Executes the block. | ||
| /// </summary> | ||
| /// <param name="nativeViewHierarchyManager">The Native View Hierarchy Manager.</param> | ||
| void Execute(NativeViewHierarchyManager nativeViewHierarchyManager); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fill in.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rozele Not sure what you mean here. Do you want this method to have a default body or something? |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -575,7 +575,7 @@ public void ShowPopupMenu(int tag, string[] items, ICallback success) | |
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| private DependencyObject ResolveView(int tag) | ||
| public DependencyObject ResolveView(int tag) | ||
| { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing comments on public classes produce warnings. |
||
| var view = default(DependencyObject); | ||
| if (!_tagsToViews.TryGetValue(tag, out view)) | ||
|
|
@@ -587,7 +587,7 @@ private DependencyObject ResolveView(int tag) | |
| return view; | ||
| } | ||
|
|
||
| private IViewManager ResolveViewManager(int tag) | ||
| public IViewManager ResolveViewManager(int tag) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Hmm, I wonder if we should go one step further on Android and create a simple interface that exposes only the methods that we want exposed (e.g., ResolveView and ResolveViewManager). Thoughts @matthargett? #Closed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe. I'd need to look at the consumption of the methods being exposed, but it's not jumping out at me in this diff. Also, since its only two methods and they take a POD and return a pure interface, there isn't a coupling problem -- just an ISP problem. #Closed
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I think that makes sense from a design standpoint I think there is probably more value to having a more similar interfaces between iOS, Android, and Windows as it makes adding Windows support to existing extensions easier. #Closed |
||
| { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing comments on public classes produce warnings. |
||
| var viewManager = default(IViewManager); | ||
| if (!_tagsToViewManagers.TryGetValue(tag, out viewManager)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -623,6 +623,15 @@ public void ShowPopupMenu(int reactTag, string[] items, ICallback error, ICallba | |
| _operationsQueue.EnqueueShowPopupMenu(reactTag, items, error, success); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Enqueues UIBlock to be executed. | ||
| /// </summary> | ||
| /// <param name="block"></param> | ||
| public void AddUIBlock(IUIBlock block) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing comment. |
||
| { | ||
| _operationsQueue.EnqueueUIBlock(block); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Called when the host receives the suspend event. | ||
| /// </summary> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -164,6 +164,15 @@ public void EnqueueShowPopupMenu(int tag, string[] items, ICallback error, ICall | |
| EnqueueOperation(() => _nativeViewHierarchyManager.ShowPopupMenu(tag, items, success)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Enqueues a operation to execute a UIBlock. | ||
| /// </summary> | ||
| /// <param name="block"></param> | ||
| public void EnqueueUIBlock(IUIBlock block) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing comment. |
||
| { | ||
| EnqueueOperation(() => block.Execute(_nativeViewHierarchyManager)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Enqueues an operation to create a view. | ||
| /// </summary> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,7 +132,17 @@ public int AddMeasuredRootView(SizeMonitoringCanvas rootView) | |
| return tag; | ||
| } | ||
|
|
||
| #region React Methods | ||
| /// <summary> | ||
| /// Schedule a block to be executed on the UI thread. Useful if you need to execute | ||
| /// view logic after all currently queued view updates have completed. | ||
| /// </summary> | ||
| /// <param name="block"></param> | ||
| public void AddUIBlock(IUIBlock block) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty comment |
||
| { | ||
| _uiImplementation.AddUIBlock(block); | ||
| } | ||
|
|
||
| #region React Methods | ||
|
|
||
| /// <summary> | ||
| /// Removes the root view. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty comment.