forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
TextFragmentList
into AttributedString
...preparing it to support another layer over fragments.
- Loading branch information
Showing
12 changed files
with
122 additions
and
99 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
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
15 changes: 15 additions & 0 deletions
15
...tAndroid/src/main/java/com/facebook/react/views/text/attributedstring/AttributedString.kt
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,15 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.views.text.attributedstring | ||
|
||
/** Interface for an attributed string */ | ||
internal interface AttributedString { | ||
fun getFragment(index: Int): AttributedStringFragment | ||
|
||
val fragmentCount: Int | ||
} |
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
22 changes: 22 additions & 0 deletions
22
...id/src/main/java/com/facebook/react/views/text/attributedstring/BridgeAttributedString.kt
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,22 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.views.text.attributedstring | ||
|
||
import com.facebook.react.bridge.ReadableArray | ||
import com.facebook.react.bridge.ReadableMap | ||
|
||
/** An [AttributedString] backed by a [ReadableMap] */ | ||
internal class BridgeAttributedString(private val attributedString: ReadableMap) : AttributedString { | ||
override fun getFragment(index: Int): AttributedStringFragment = BridgeAttributedStringFragment(fragments.getMap(index)) | ||
|
||
override val fragmentCount: Int | ||
get() = fragments.size() | ||
|
||
private val fragments: ReadableArray | ||
get() = attributedString.getArray("fragments")!! | ||
} |
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
...src/main/java/com/facebook/react/views/text/attributedstring/MapBufferAttributedString.kt
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) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.views.text.attributedstring | ||
|
||
import com.facebook.react.common.mapbuffer.MapBuffer | ||
import com.facebook.react.views.text.TextLayoutManagerMapBuffer.AS_KEY_FRAGMENTS | ||
|
||
/** An [AttributedString] backed by a [MapBuffer] */ | ||
internal class MapBufferAttributedString(private val attributedString: MapBuffer) : AttributedString { | ||
override fun getFragment(index: Int): AttributedStringFragment = | ||
MapBufferAttributedStringFragment(fragments.getMapBuffer(index)) | ||
|
||
override val fragmentCount: Int | ||
get() = fragments.count | ||
|
||
private val fragments: MapBuffer | ||
get() = attributedString.getMapBuffer(AS_KEY_FRAGMENTS.toInt()) | ||
} |
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
18 changes: 0 additions & 18 deletions
18
...ctAndroid/src/main/java/com/facebook/react/views/text/fragments/BridgeTextFragmentList.kt
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
...ndroid/src/main/java/com/facebook/react/views/text/fragments/MapBufferTextFragmentList.kt
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
...ve/ReactAndroid/src/main/java/com/facebook/react/views/text/fragments/TextFragmentList.kt
This file was deleted.
Oops, something went wrong.