Skip to content

Commit 940b422

Browse files
committed
cleanup
1 parent cbc76d5 commit 940b422

File tree

6 files changed

+22
-113
lines changed

6 files changed

+22
-113
lines changed

TextGradientExample/App.js

Lines changed: 9 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -19,75 +19,20 @@ const instructions = Platform.select({
1919

2020
type Props = {};
2121
export default class App extends Component<Props> {
22-
23-
grad(text, key) {
24-
return (
25-
<LinearTextGradient
26-
style = {
27-
[styles.welcome, {
28-
backgroundColor: 'red',
29-
textDecorationLine: 'underline',
30-
}]
31-
}
32-
key={key}
33-
locations={[0, 1]}
34-
colors={['green', 'red']}
35-
start={{ x: 0, y: 0 }}
36-
end={{ x: 1, y: 0 }}
37-
>
38-
{text}
39-
</LinearTextGradient>
40-
)
41-
}
4222
render() {
4323
return (
4424
<View style={styles.container}>
4525
<LinearTextGradient
46-
style = {
47-
[styles.welcome, {
48-
backgroundColor: 'lightgray'
49-
}]
50-
}
26+
style={styles.welcome}
5127
locations={[0, 1]}
52-
colors={['lime', 'purple']}
53-
start={{ x: 1, y: 0 }}
54-
end={{ x: 0, y: 0 }}
28+
colors={['blue', 'red']}
29+
start={{ x: 0, y: 0 }}
30+
end={{ x: 1, y: 0 }}
5531
>
56-
{/* _████████████_ */}
57-
{this.grad('.█ ██ ███ █ ███ ',1)}
58-
{this.grad('.█ ',2)}
59-
{this.grad('2█ ')}
60-
{this.grad('3█ ')}
61-
{this.grad('.██ ')}
62-
{this.grad('.███ ')}
63-
{this.grad('.█ █ ')}
64-
{this.grad('.█ █ █ ')}
65-
{this.grad('.█ ██ ██ ', 'yellow')}
66-
{this.grad('.█ ')}
67-
{this.grad('?██ ')}
68-
{this.grad('.███ ')}
69-
{this.grad('.█ █ ')}
70-
{this.grad('.█ █ █ ')}
71-
{this.grad('.█ ██ ██ ')}
72-
{this.grad('.█')}
73-
{this.grad('.██ ')}
74-
{this.grad('.█████████ ')}
75-
{this.grad('.█ █ ')}
76-
{this.grad('.█ █ █ ')}
77-
{this.grad('.█ ██ █ ')}
78-
{this.grad('.█ ')}
79-
{this.grad('.██ ')}
80-
{this.grad('.███ ')}
81-
{this.grad('.█ █ ')}
82-
{this.grad('.█ █ █ ')}
32+
Welcome to React Native!
8333
</LinearTextGradient>
84-
<Text style={styles.instructions}>
85-
To get started, edit App.js
86-
<Text style={[styles.instructions, {
87-
textDecorationLine: 'underline',
88-
fontWeight: 'bold'
89-
}]}>{instructions}</Text>
90-
</Text>
34+
<Text style={styles.instructions}>To get started, edit App.js</Text>
35+
<Text style={styles.instructions}>{instructions}</Text>
9136
</View>
9237
);
9338
}
@@ -101,14 +46,13 @@ const styles = StyleSheet.create({
10146
backgroundColor: '#F5FCFF',
10247
},
10348
welcome: {
104-
fontSize: 30,
49+
fontSize: 20,
10550
textAlign: 'center',
10651
margin: 10,
107-
color: 'white'
10852
},
10953
instructions: {
11054
textAlign: 'center',
11155
color: '#333333',
112-
marginBottom: 5
56+
marginBottom: 5,
11357
},
11458
});

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import javax.annotation.Nonnull;
1010

1111
@ReactModule(name = RNVirtualLinearTextGradientManager.REACT_CLASS)
12-
public class RNVirtualLinearTextGradientManager extends RNVirtualTextGradientManager<RNVirtualShadowLinearTextGradient> {
12+
public class RNVirtualLinearTextGradientManager extends RNVirtualTextGradientManager<
13+
RNVirtualShadowLinearTextGradient
14+
> {
1315

1416
@VisibleForTesting
1517
static final String REACT_CLASS = "RNVirtualLinearTextGradient";

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

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

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,11 @@ public void run() {
237237
that.getPadding(Spacing.TOP),
238238
that.getPadding(Spacing.END),
239239
that.getPadding(Spacing.BOTTOM),
240-
(int) ReflectUtils.invokeMethod(that, "getTextAlign", ReactTextShadowNode.class),
240+
(int) ReflectUtils.invokeMethod(
241+
that,
242+
"getTextAlign",
243+
ReactTextShadowNode.class
244+
),
241245
that.mTextBreakStrategy,
242246
that.mJustificationMode
243247
);
@@ -344,7 +348,11 @@ private static void buildSpannedGradientFromTextCSSNode(
344348

345349
} else if (child instanceof ReactTextInlineImageShadowNode) {
346350
builder.append(
347-
(String) ReflectUtils.getFieldValue(textGradientShadowNode, "INLINE_IMAGE_PLACEHOLDER", ReactTextShadowNode.class)
351+
(String) ReflectUtils.getFieldValue(
352+
textGradientShadowNode,
353+
"INLINE_IMAGE_PLACEHOLDER",
354+
ReactTextShadowNode.class
355+
)
348356
);
349357
}
350358

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,4 @@ public class RNTextGradient extends ReactTextView {
1010
public RNTextGradient(Context context) {
1111
super(context);
1212
}
13-
//
14-
// @Override
15-
// protected void onDraw(Canvas canvas) {
16-
// super.onDraw(canvas);
17-
//
18-
// LogLayout.log(getLayout(), 0, getText().length(), "DRAW");
19-
// }
2013
}

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,6 @@ static <T> T getFieldValue(Object target, String name, @Nullable Class type) {
2828
return null;
2929
}
3030

31-
@SuppressWarnings("unused")
32-
static <T> void setFieldValue(Object target, String name, T value, @Nullable Class type) {
33-
type = type == null ? target.getClass() : type;
34-
35-
try {
36-
Field field = type.getDeclaredField(name);
37-
field.setAccessible(true);
38-
field.set(target, value);
39-
40-
} catch (Exception e) {
41-
FLog.w(ReactConstants.TAG, "Can't set " + type.getName() + " field " + name);
42-
FLog.w(ReactConstants.TAG, e.getMessage());
43-
}
44-
}
45-
4631
@SuppressWarnings({"unchecked", "SameParameterValue"})
4732
static <T> T invokeMethod(Object target, String name, @Nullable Class type) {
4833
type = type == null ? target.getClass() : type;

0 commit comments

Comments
 (0)