Skip to content

Commit 4715dbe

Browse files
committed
cleanup
1 parent 765ae17 commit 4715dbe

File tree

9 files changed

+131
-705
lines changed

9 files changed

+131
-705
lines changed

TextGradientExample/App.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ export default class App extends Component<Props> {
2828
colors={['blue', 'red']}
2929
start={{ x: 0, y: 0 }}
3030
end={{ x: 1, y: 0 }}
31+
// useViewFrame={true}
3132
>
32-
Welcome to React Native!
33+
Welcome to React Native!Welcome to React Native
3334
</LinearTextGradient>
3435
<Text style={styles.instructions}>To get started, edit App.js</Text>
3536
<Text style={styles.instructions}>{instructions}</Text>
@@ -47,7 +48,9 @@ const styles = StyleSheet.create({
4748
},
4849
welcome: {
4950
fontSize: 20,
50-
textAlign: 'center',
51+
// width: '100%',
52+
// textAlign: 'right',
53+
// backgroundColor: 'lightgray',
5154
margin: 10,
5255
},
5356
instructions: {

TextGradientExample/ios/TextGradientExample-tvOS/Info.plist

Lines changed: 0 additions & 54 deletions
This file was deleted.

TextGradientExample/ios/TextGradientExample-tvOSTests/Info.plist

Lines changed: 0 additions & 24 deletions
This file was deleted.

TextGradientExample/ios/TextGradientExample.xcodeproj/project.pbxproj

Lines changed: 109 additions & 516 deletions
Large diffs are not rendered by default.

TextGradientExample/ios/TextGradientExampleTests/Info.plist

Lines changed: 0 additions & 24 deletions
This file was deleted.

TextGradientExample/ios/TextGradientExampleTests/TextGradientExampleTests.m

Lines changed: 0 additions & 68 deletions
This file was deleted.

android/src/main/java/iyegoroff/RNTextGradient/Linear/RNLinearTextGradientSpan.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ public class RNLinearTextGradientSpan extends CharacterStyle implements UpdateAp
2929
int textEnd,
3030
float maxWidth,
3131
float maxHeight,
32-
String text,
33-
boolean useAbsoluteSizes
32+
String text
3433
) {
3534
if (
3635
start != null &&
@@ -48,12 +47,23 @@ public class RNLinearTextGradientSpan extends CharacterStyle implements UpdateAp
4847
layout.getSelectionPath(textStart, textEnd, path);
4948
path.computeBounds(bounds, true);
5049

50+
if (layout.getLineForOffset(textEnd - 1) != layout.getLineForOffset(textEnd)) {
51+
RectF lastSymbolBounds = new RectF();
52+
layout.getSelectionPath(textEnd - 1, textEnd, path);
53+
path.computeBounds(lastSymbolBounds, true);
54+
55+
if (lastSymbolBounds.contains(bounds) && bounds.contains(lastSymbolBounds)) {
56+
layout.getSelectionPath(textStart, textEnd - 1, path);
57+
path.computeBounds(bounds, true);
58+
}
59+
}
60+
5161
float width = useViewFrame ? maxWidth : bounds.width();
5262
float height = useViewFrame ? maxHeight : bounds.height();
53-
float x0 = useAbsoluteSizes ? start[0] : (bounds.left + start[0] * width);
54-
float y0 = useAbsoluteSizes ? start[1] : (bounds.top + start[1] * height);
55-
float x1 = useAbsoluteSizes ? end[0] : (bounds.left + end[0] * width);
56-
float y1 = useAbsoluteSizes ? end[1] : (bounds.top + end[1] * height);
63+
float x0 = (useViewFrame ? 0 : bounds.left) + start[0] * width;
64+
float y0 = (useViewFrame ? 0 : bounds.top) + start[1] * height;
65+
float x1 = (useViewFrame ? 0 : bounds.left) + end[0] * width;
66+
float y1 = (useViewFrame ? 0 : bounds.top) + end[1] * height;
5767

5868
mGradient = new LinearGradient(x0, y0, x1, y1, colors, locations, Shader.TileMode.CLAMP);
5969
}

android/src/main/java/iyegoroff/RNTextGradient/Linear/RNShadowLinearTextGradient.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ protected RNSetGradientSpanOperation createSpan(
6565
end,
6666
maxWidth,
6767
maxHeight,
68-
builder.toString(),
69-
mUseAbsoluteSizes
68+
builder.toString()
7069
);
7170

7271
return new RNSetGradientSpanOperation(start, end, span);

android/src/main/java/iyegoroff/RNTextGradient/RNShadowTextGradient.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom, int
6969
protected float[] mLocations;
7070
protected int[] mColors;
7171
protected boolean mUseViewFrame;
72-
protected boolean mUseAbsoluteSizes;
7372
private WeakReference<ReactApplicationContext> mContext;
7473

7574
public RNShadowTextGradient(ReactApplicationContext context) {
@@ -149,14 +148,6 @@ public void setUseViewFrame(boolean useViewFrame) {
149148
markUpdated();
150149
}
151150

152-
@SuppressWarnings("unused")
153-
@ReactProp(name = "useAbsoluteSizes")
154-
public void setUseAbsoluteSizes(boolean useAbsoluteSizes) {
155-
mUseAbsoluteSizes = useAbsoluteSizes;
156-
157-
markUpdated();
158-
}
159-
160151
@Override
161152
public boolean dispatchUpdates(
162153
float absoluteX,

0 commit comments

Comments
 (0)