Skip to content

Commit e1bf4f2

Browse files
duom青源duom青源
authored andcommitted
feat: 添加测试用例
1 parent 02f33e9 commit e1bf4f2

File tree

4 files changed

+37
-56
lines changed

4 files changed

+37
-56
lines changed

android/src/main/java/com/variabletextinput/VariableTextInput.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,5 @@ public void insertImage(String imagePath) {
276276
spannableString.setSpan(span, 0, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
277277
editText.append(spannableString);
278278
}
279-
public static Drawable loadImage(String iconUri){
280-
if (TextUtils.isEmpty(iconUri)){
281-
return null;
282-
}
283-
// boolean isDebug = MainApplication.instance
284-
}
285279
}
286280

example/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
},
1111
"dependencies": {
1212
"react": "18.2.0",
13-
"react-native": "0.71.4",
14-
"react-native-reanimated": "^3.0.2"
13+
"react-native": "0.71.4"
1514
},
1615
"devDependencies": {
1716
"@babel/core": "^7.20.0",

example/src/App.tsx

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,55 @@ import {
66
ScrollView,
77
ImageResolvedAssetSource,
88
Image,
9-
NativeModules,
109
View,
10+
processColor,
1111
} from 'react-native';
1212
import VariableTextInputView, {
1313
IATTextViewBase,
1414
} from 'react-native-variable-text-input';
15-
const VariableTextInputViewManager = NativeModules.VariableTextInputViewManager;
1615
export const App = () => {
1716
const inPutRef = React.createRef<IATTextViewBase>();
1817
const onChangeText = (text: string) => {
1918
console.log('sdkljflksdjfl====>', text);
2019
};
21-
const testAction = () => {
22-
VariableTextInputViewManager.getKeyboardHeight((height: number) => {
23-
console.log('=====>', height);
24-
});
25-
};
2620
const insertEmoji = () => {
2721
const data: ImageResolvedAssetSource = Image.resolveAssetSource(
2822
require('./[苦笑].png')
2923
);
3024
inPutRef.current?.insertEmoji({ img: data, tag: '[苦笑]' });
3125
};
3226
const blur = () => {
33-
//todo
27+
inPutRef.current?.blur();
3428
};
3529
const insertMonthons = () => {
36-
//todo
30+
inPutRef.current?.insertMentions({
31+
tag: '#',
32+
name: '测试tag',
33+
color: 'red',
34+
id: '123344',
35+
});
3736
};
3837
const changeAttributedText = () => {
39-
//todo
38+
const imageData: ImageResolvedAssetSource = Image.resolveAssetSource(
39+
require('./[苦笑].png')
40+
);
41+
const emojiData = { img: imageData, tag: '[苦笑]' };
42+
inPutRef.current?.changeAttributedText([
43+
{ type: 0, text: '普通字符' },
44+
{ type: 1, emojiData },
45+
{
46+
type: 2,
47+
targData: {
48+
tag: '#',
49+
name: '测试tag',
50+
color: processColor('red'),
51+
id: '123344',
52+
},
53+
},
54+
]);
4055
};
4156
const focus = () => {
42-
//todo
57+
inPutRef.current?.focus();
4358
};
4459
return (
4560
<ScrollView contentContainerStyle={styles.container}>
@@ -51,7 +66,7 @@ export const App = () => {
5166
underlineColorAndroid={'rgba(0,0,0,0)'}
5267
/>
5368
<View style={{ flexDirection: 'row', marginTop: 40 }}>
54-
<TouchableOpacity onPress={testAction} style={{ marginLeft: 20 }}>
69+
<TouchableOpacity onPress={blur} style={{ marginLeft: 20 }}>
5570
<Text style={{ backgroundColor: 'yellow', color: 'red' }}>
5671
{'blur'}
5772
</Text>
@@ -71,6 +86,14 @@ export const App = () => {
7186
{'insertEmoji'}
7287
</Text>
7388
</TouchableOpacity>
89+
<TouchableOpacity
90+
onPress={changeAttributedText}
91+
style={{ marginLeft: 20 }}
92+
>
93+
<Text style={{ backgroundColor: 'yellow', color: 'red' }}>
94+
{'insertEmoji'}
95+
</Text>
96+
</TouchableOpacity>
7497
</View>
7598
</ScrollView>
7699
);

example/yarn.lock

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -728,13 +728,6 @@
728728
dependencies:
729729
"@babel/helper-plugin-utils" "^7.18.6"
730730

731-
"@babel/plugin-transform-object-assign@^7.16.7":
732-
version "7.18.6"
733-
resolved "https://registry.npmmirror.com/@babel/plugin-transform-object-assign/-/plugin-transform-object-assign-7.18.6.tgz#7830b4b6f83e1374a5afb9f6111bcfaea872cdd2"
734-
integrity sha512-mQisZ3JfqWh2gVXvfqYCAAyRs6+7oev+myBsTwW5RnPhYXOTuCEw2oe3YgxlXMViXUS53lG8koulI7mJ+8JE+A==
735-
dependencies:
736-
"@babel/helper-plugin-utils" "^7.18.6"
737-
738731
"@babel/plugin-transform-object-super@^7.0.0", "@babel/plugin-transform-object-super@^7.18.6":
739732
version "7.18.6"
740733
resolved "https://registry.npmmirror.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.18.6.tgz#fb3c6ccdd15939b6ff7939944b51971ddc35912c"
@@ -978,7 +971,7 @@
978971
"@babel/types" "^7.4.4"
979972
esutils "^2.0.2"
980973

981-
"@babel/preset-typescript@^7.13.0", "@babel/preset-typescript@^7.16.7":
974+
"@babel/preset-typescript@^7.13.0":
982975
version "7.21.0"
983976
resolved "https://registry.npmmirror.com/@babel/preset-typescript/-/preset-typescript-7.21.0.tgz#bcbbca513e8213691fe5d4b23d9251e01f00ebff"
984977
integrity sha512-myc9mpoVA5m1rF8K8DgLEatOYFDpwC+RkMkjZ0Du6uI62YvDe8uxIEYVs/VCdSJ097nlALiU/yBC7//3nI+hNg==
@@ -2993,11 +2986,6 @@ lodash.debounce@^4.0.8:
29932986
resolved "https://registry.npmmirror.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
29942987
integrity sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==
29952988

2996-
lodash.isequal@^4.5.0:
2997-
version "4.5.0"
2998-
resolved "https://registry.npmmirror.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
2999-
integrity sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==
3000-
30012989
lodash.throttle@^4.1.1:
30022990
version "4.1.1"
30032991
resolved "https://registry.npmmirror.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
@@ -3846,19 +3834,6 @@ react-native-gradle-plugin@^0.71.16:
38463834
resolved "https://registry.npmmirror.com/react-native-gradle-plugin/-/react-native-gradle-plugin-0.71.16.tgz#822bb0c680e03b5df5aa65f2e5ffc2bc2930854a"
38473835
integrity sha512-H2BjG2zk7B7Wii9sXvd9qhCVRQYDAHSWdMw9tscmZBqSP62DkIWEQSk4/B2GhQ4aK9ydVXgtqR6tBeg3yy8TSA==
38483836

3849-
react-native-reanimated@^3.0.2:
3850-
version "3.0.2"
3851-
resolved "https://registry.npmmirror.com/react-native-reanimated/-/react-native-reanimated-3.0.2.tgz#8f7284fab2b0cd949779429e48f32d19a966bbd6"
3852-
integrity sha512-8Et90yTI9yxchGbDP79k391XZqc/64zNbASbGy8X3Vgv4EbZ1M3IkKwcIbZmbVwpA804VJ6V9nJAGUh9fP0LrA==
3853-
dependencies:
3854-
"@babel/plugin-transform-object-assign" "^7.16.7"
3855-
"@babel/preset-typescript" "^7.16.7"
3856-
convert-source-map "^1.7.0"
3857-
invariant "^2.2.4"
3858-
lodash.isequal "^4.5.0"
3859-
setimmediate "^1.0.5"
3860-
string-hash-64 "^1.0.3"
3861-
38623837
react-native@0.71.4:
38633838
version "0.71.4"
38643839
resolved "https://registry.npmmirror.com/react-native/-/react-native-0.71.4.tgz#f03f600efe68f745d19454ab17f9c1a9ef304790"
@@ -4166,11 +4141,6 @@ set-value@^2.0.0, set-value@^2.0.1:
41664141
is-plain-object "^2.0.3"
41674142
split-string "^3.0.1"
41684143

4169-
setimmediate@^1.0.5:
4170-
version "1.0.5"
4171-
resolved "https://registry.npmmirror.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
4172-
integrity sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==
4173-
41744144
setprototypeof@1.2.0:
41754145
version "1.2.0"
41764146
resolved "https://registry.npmmirror.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424"
@@ -4342,11 +4312,6 @@ statuses@~1.5.0:
43424312
resolved "https://registry.npmmirror.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"
43434313
integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==
43444314

4345-
string-hash-64@^1.0.3:
4346-
version "1.0.3"
4347-
resolved "https://registry.npmmirror.com/string-hash-64/-/string-hash-64-1.0.3.tgz#0deb56df58678640db5c479ccbbb597aaa0de322"
4348-
integrity sha512-D5OKWKvDhyVWWn2x5Y9b+37NUllks34q1dCDhk/vYcso9fmhs+Tl3KR/gE4v5UNj2UA35cnX4KdVVGkG1deKqw==
4349-
43504315
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
43514316
version "4.2.3"
43524317
resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"

0 commit comments

Comments
 (0)