forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Android: Enable views to be nested within <Text>
Depends on this css-layout PR: facebook/yoga#202 Implements same feature as this iOS PR: facebook#7304 Previously, only Text and Image could be nested within Text. Now, any view can be nested within Text. One restriction of this feature is that developers must give inline views a width and a height via the style prop. Previously, inline Images were supported via FrescoBasedReactTextInlineImageSpan. To get support for nesting views within Text, we create one special kind of span per inline view. This span is called TextInlineViewPlaceholderSpan. It is the same size as the inline view. It's job is just to occupy space -- it doesn't render any visual. After the text is rendered, we query the Android Layout associated with the TextView to find out where it has positioned each TextInlineViewPlaceholderSpan. We then position the views to be at those locations. Limitation: Clipping ==== If Text's height/width is small such that an inline view doesn't completely fit, the inline view may still be fully visible due to hoisting (the inline view isn't actually parented to the Text which has the limited size. It is parented to an ancestor which may have a different clipping rectangle.). Prior to this change, layout-only views had a similar limitation.
- Loading branch information
Adam Comella
committed
Jul 6, 2016
1 parent
2fc87f6
commit bc7ddf0
Showing
12 changed files
with
402 additions
and
103 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
23 changes: 23 additions & 0 deletions
23
ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeKind.java
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
package com.facebook.react.uimanager; | ||
|
||
public enum NativeKind { | ||
// Node is in the native hierarchy and the HierarchyOptimizer should assume it can host children | ||
// (e.g. because it's a ViewGroup). Note that it's okay if the node doesn't support children. When | ||
// the HierarchyOptimizer generates children manipulation commands for that node, the | ||
// HierarchyManager will catch this case and throw an exception. | ||
PARENT, | ||
// Node is in the native hierarchy, it may have children, but it cannot host them itself (e.g. | ||
// because it isn't a ViewGroup). Consequently, its children need to be hosted by an ancestor. | ||
LEAF, | ||
// Node is not in the native hierarchy. | ||
NONE | ||
} |
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
Oops, something went wrong.