react-native-advanced-text 0.1.19 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -32,6 +32,7 @@ class AdvancedTextView : TextView {
|
|
|
32
32
|
private var lastSelectedText: String = ""
|
|
33
33
|
private var customActionMode: ActionMode? = null
|
|
34
34
|
private var currentText: String = ""
|
|
35
|
+
private var textColor: String = "#000000"
|
|
35
36
|
|
|
36
37
|
// Cache for word positions to avoid recalculating
|
|
37
38
|
private var wordPositions: List<WordPosition> = emptyList()
|
|
@@ -90,6 +91,12 @@ class AdvancedTextView : TextView {
|
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
|
|
95
|
+
fun setAdvancedTextColor(colorInt: Int) {
|
|
96
|
+
textColor = String.format("#%06X", 0xFFFFFF and colorInt)
|
|
97
|
+
updateTextWithHighlights()
|
|
98
|
+
}
|
|
99
|
+
|
|
93
100
|
fun setAdvancedText(text: String) {
|
|
94
101
|
if (currentText == text) {
|
|
95
102
|
Log.d(TAG, "Text unchanged, skipping update")
|
|
@@ -165,7 +172,7 @@ class AdvancedTextView : TextView {
|
|
|
165
172
|
// Apply indicator color
|
|
166
173
|
if (wordPos.index == indicatorWordIndex) {
|
|
167
174
|
spannableString.setSpan(
|
|
168
|
-
ForegroundColorSpan(Color.
|
|
175
|
+
ForegroundColorSpan(Color.parseColor(textColor)),
|
|
169
176
|
wordPos.start,
|
|
170
177
|
wordPos.end,
|
|
171
178
|
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
|
|
@@ -213,8 +220,8 @@ class AdvancedTextView : TextView {
|
|
|
213
220
|
}
|
|
214
221
|
|
|
215
222
|
private inner class WordClickableSpan(
|
|
216
|
-
|
|
217
|
-
|
|
223
|
+
private val wordIndex: Int,
|
|
224
|
+
private val word: String
|
|
218
225
|
) : ClickableSpan() {
|
|
219
226
|
|
|
220
227
|
override fun onClick(widget: View) {
|
|
@@ -231,6 +238,7 @@ class AdvancedTextView : TextView {
|
|
|
231
238
|
override fun updateDrawState(ds: TextPaint) {
|
|
232
239
|
super.updateDrawState(ds)
|
|
233
240
|
ds.isUnderlineText = false
|
|
241
|
+
ds.color = Color.parseColor(textColor)
|
|
234
242
|
}
|
|
235
243
|
}
|
|
236
244
|
|
|
@@ -86,7 +86,9 @@ class AdvancedTextViewManager : SimpleViewManager<AdvancedTextView>() {
|
|
|
86
86
|
@ReactProp(name = "color", customType = "Color")
|
|
87
87
|
fun setColor(view: AdvancedTextView?, color: Int?) {
|
|
88
88
|
android.util.Log.d(NAME, "setColor called with: $color")
|
|
89
|
-
|
|
89
|
+
if (color != null) {
|
|
90
|
+
view?.setAdvancedTextColor(color)
|
|
91
|
+
}
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
@ReactProp(name = "fontSize")
|
package/package.json
CHANGED