@whetware/react-native-stroke-text 0.0.7 → 0.0.9
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.
|
@@ -58,6 +58,10 @@ internal class StrokeTextView(context: ThemedReactContext) : TextView(context) {
|
|
|
58
58
|
init {
|
|
59
59
|
gravity = Gravity.TOP or Gravity.START
|
|
60
60
|
includeFontPadding = true
|
|
61
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
62
|
+
breakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY
|
|
63
|
+
hyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NONE
|
|
64
|
+
}
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
fun invalidateTextLayout() {
|
|
@@ -81,8 +85,6 @@ internal class StrokeTextView(context: ThemedReactContext) : TextView(context) {
|
|
|
81
85
|
val prevStrike = textPaint.isStrikeThruText
|
|
82
86
|
|
|
83
87
|
val saveCount = canvas.save()
|
|
84
|
-
val compoundPaddingLeft = compoundPaddingLeft
|
|
85
|
-
val extendedPaddingTop = extendedPaddingTop
|
|
86
88
|
|
|
87
89
|
canvas.translate(compoundPaddingLeft.toFloat(), extendedPaddingTop.toFloat())
|
|
88
90
|
canvas.translate(-scrollX.toFloat(), -scrollY.toFloat())
|
package/lib/StrokeText.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { StyleSheet, Text, View } from 'react-native';
|
|
2
|
+
import { I18nManager, StyleSheet, Text, View, } from 'react-native';
|
|
3
3
|
import { callback, getHostComponent } from 'react-native-nitro-modules';
|
|
4
4
|
import StrokeTextViewConfig from '../nitrogen/generated/shared/json/StrokeTextViewConfig.json';
|
|
5
5
|
const NativeStrokeTextView = getHostComponent('StrokeTextView', () => StrokeTextViewConfig);
|
|
@@ -71,12 +71,32 @@ export function StrokeText({ text, children, style, hybridRef, ...rest }) {
|
|
|
71
71
|
const baseRight = firstNumber(paddingRight, stylePaddingRight, paddingHorizontal, stylePaddingHorizontal, padding, stylePadding) ?? 0;
|
|
72
72
|
const baseBottom = firstNumber(paddingBottom, stylePaddingBottom, paddingVertical, stylePaddingVertical, padding, stylePadding) ?? 0;
|
|
73
73
|
const baseLeft = firstNumber(paddingLeft, stylePaddingLeft, paddingHorizontal, stylePaddingHorizontal, padding, stylePadding) ?? 0;
|
|
74
|
+
const baseMarginTop = firstNumber(containerStyle.marginTop, containerStyle.marginVertical, containerStyle.margin) ?? 0;
|
|
75
|
+
const baseMarginRight = firstNumber(containerStyle.marginRight, I18nManager.isRTL ? containerStyle.marginStart : containerStyle.marginEnd, containerStyle.marginHorizontal, containerStyle.margin) ?? 0;
|
|
76
|
+
const baseMarginBottom = firstNumber(containerStyle.marginBottom, containerStyle.marginVertical, containerStyle.margin) ?? 0;
|
|
77
|
+
const baseMarginLeft = firstNumber(containerStyle.marginLeft, I18nManager.isRTL ? containerStyle.marginEnd : containerStyle.marginStart, containerStyle.marginHorizontal, containerStyle.margin) ?? 0;
|
|
78
|
+
const baseMarginStart = toNumber(containerStyle.marginStart);
|
|
79
|
+
const baseMarginEnd = toNumber(containerStyle.marginEnd);
|
|
80
|
+
const strokeInsetMarginStyle = strokeInset === 0
|
|
81
|
+
? null
|
|
82
|
+
: {
|
|
83
|
+
marginTop: baseMarginTop - strokeInset,
|
|
84
|
+
marginRight: baseMarginRight - strokeInset,
|
|
85
|
+
marginBottom: baseMarginBottom - strokeInset,
|
|
86
|
+
marginLeft: baseMarginLeft - strokeInset,
|
|
87
|
+
...(baseMarginStart == null
|
|
88
|
+
? {}
|
|
89
|
+
: { marginStart: baseMarginStart - strokeInset }),
|
|
90
|
+
...(baseMarginEnd == null
|
|
91
|
+
? {}
|
|
92
|
+
: { marginEnd: baseMarginEnd - strokeInset }),
|
|
93
|
+
};
|
|
74
94
|
const effectiveNumberOfLines = nativeProps.numberOfLines != null && nativeProps.numberOfLines > 0
|
|
75
95
|
? nativeProps.numberOfLines
|
|
76
96
|
: undefined;
|
|
77
97
|
const effectiveEllipsizeMode = effectiveNumberOfLines == null
|
|
78
98
|
? undefined
|
|
79
|
-
: nativeProps.ellipsizeMode ?? 'tail';
|
|
99
|
+
: (nativeProps.ellipsizeMode ?? 'tail');
|
|
80
100
|
const mappedTextAlignVerticalFromVerticalAlign = styleVerticalAlign === 'middle'
|
|
81
101
|
? 'center'
|
|
82
102
|
: toTextAlignVertical(styleVerticalAlign);
|
|
@@ -122,28 +142,18 @@ export function StrokeText({ text, children, style, hybridRef, ...rest }) {
|
|
|
122
142
|
effectiveTextTransform,
|
|
123
143
|
effectiveIncludeFontPadding,
|
|
124
144
|
]);
|
|
125
|
-
return (React.createElement(View, { style: [styles.container, containerStyle] },
|
|
145
|
+
return (React.createElement(View, { style: [styles.container, containerStyle, strokeInsetMarginStyle] },
|
|
126
146
|
React.createElement(Text, { accessible: false, pointerEvents: "none", numberOfLines: effectiveNumberOfLines, ellipsizeMode: effectiveEllipsizeMode, allowFontScaling: nativeProps.allowFontScaling, maxFontSizeMultiplier: nativeProps.maxFontSizeMultiplier, style: [
|
|
127
147
|
measurerTextStyle,
|
|
128
148
|
{
|
|
129
|
-
paddingTop: baseTop,
|
|
130
|
-
paddingRight: baseRight,
|
|
131
|
-
paddingBottom: baseBottom,
|
|
132
|
-
paddingLeft: baseLeft,
|
|
149
|
+
paddingTop: baseTop + strokeInset,
|
|
150
|
+
paddingRight: baseRight + strokeInset,
|
|
151
|
+
paddingBottom: baseBottom + strokeInset,
|
|
152
|
+
paddingLeft: baseLeft + strokeInset,
|
|
133
153
|
},
|
|
134
154
|
styles.hiddenText,
|
|
135
155
|
] }, resolvedText),
|
|
136
|
-
React.createElement(NativeStrokeTextView, { ...nativeProps, text: resolvedText, color: effectiveColor, fontSize: effectiveFontSize, fontWeight: effectiveFontWeight, fontFamily: effectiveFontFamily, fontStyle: effectiveFontStyle, lineHeight: effectiveLineHeight, letterSpacing: effectiveLetterSpacing, textAlign: effectiveTextAlign, textAlignVertical: effectiveTextAlignVertical, textDecorationLine: effectiveTextDecorationLine, textTransform: effectiveTextTransform, opacity: nativeProps.opacity ?? toNumber(styleOpacity), includeFontPadding: effectiveIncludeFontPadding, numberOfLines: nativeProps.numberOfLines, ellipsizeMode: effectiveEllipsizeMode, paddingTop: baseTop, paddingRight: baseRight, paddingBottom: baseBottom, paddingLeft: baseLeft, hybridRef: wrappedHybridRef, pointerEvents: "none", style:
|
|
137
|
-
styles.overlay,
|
|
138
|
-
strokeInset === 0
|
|
139
|
-
? null
|
|
140
|
-
: {
|
|
141
|
-
top: -strokeInset,
|
|
142
|
-
right: -strokeInset,
|
|
143
|
-
bottom: -strokeInset,
|
|
144
|
-
left: -strokeInset,
|
|
145
|
-
},
|
|
146
|
-
] })));
|
|
156
|
+
React.createElement(NativeStrokeTextView, { ...nativeProps, text: resolvedText, color: effectiveColor, fontSize: effectiveFontSize, fontWeight: effectiveFontWeight, fontFamily: effectiveFontFamily, fontStyle: effectiveFontStyle, lineHeight: effectiveLineHeight, letterSpacing: effectiveLetterSpacing, textAlign: effectiveTextAlign, textAlignVertical: effectiveTextAlignVertical, textDecorationLine: effectiveTextDecorationLine, textTransform: effectiveTextTransform, opacity: nativeProps.opacity ?? toNumber(styleOpacity), includeFontPadding: effectiveIncludeFontPadding, numberOfLines: nativeProps.numberOfLines, ellipsizeMode: effectiveEllipsizeMode, paddingTop: baseTop, paddingRight: baseRight, paddingBottom: baseBottom, paddingLeft: baseLeft, hybridRef: wrappedHybridRef, pointerEvents: "none", style: styles.overlay })));
|
|
147
157
|
}
|
|
148
158
|
const styles = StyleSheet.create({
|
|
149
159
|
container: {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whetware/react-native-stroke-text",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Stroke/outline text for React Native (New Architecture) on iOS, Android, and Web.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -121,4 +121,4 @@
|
|
|
121
121
|
"useTabs": false,
|
|
122
122
|
"semi": false
|
|
123
123
|
}
|
|
124
|
-
}
|
|
124
|
+
}
|