@react-native-ohos/slider 4.4.4-rc.1 → 5.0.1
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.
- package/CHANGELOG.md +181 -0
- package/COMMITTERS.md +6 -0
- package/LICENSE +9 -0
- package/OAT.xml +73 -0
- package/README.OpenSource +11 -0
- package/README.md +13 -0
- package/babel.config.json +1 -1
- package/dist/RNCSliderNativeComponent.js +1 -1
- package/dist/Slider.js +1 -1
- package/dist/components/StepNumber.js +1 -0
- package/dist/components/StepsIndicator.js +1 -0
- package/dist/components/TrackMark.js +1 -0
- package/dist/utils/constants.js +1 -0
- package/dist/utils/styles.js +1 -0
- package/example/.eslintrc +19 -0
- package/example/.node-version +6 -0
- package/example/.prettierrc.js +7 -0
- package/example/.watchmanconfig +6 -0
- package/example/app.json +4 -0
- package/example/babel.config.js +9 -0
- package/example/contexts.ts +9 -0
- package/example/harmony/AppScope/app.json5 +10 -0
- package/example/harmony/AppScope/resources/base/element/string.json +8 -0
- package/example/harmony/AppScope/resources/base/media/app_icon.png +0 -0
- package/example/harmony/build-profile.template.json5 +36 -0
- package/example/harmony/codelinter.json +32 -0
- package/example/harmony/entry/build-profile.json5 +22 -0
- package/example/harmony/entry/hvigorfile.ts +8 -0
- package/example/harmony/entry/oh-package.json5 +11 -0
- package/example/harmony/entry/src/main/cpp/CMakeLists.txt +41 -0
- package/example/harmony/entry/src/main/cpp/PackageProvider.cpp +17 -0
- package/example/harmony/entry/src/main/ets/RNPackagesFactory.ets +13 -0
- package/example/harmony/entry/src/main/ets/assets/fonts/Pacifico-Regular.ttf +0 -0
- package/example/harmony/entry/src/main/ets/assets/fonts/StintUltraCondensed-Regular.ttf +0 -0
- package/example/harmony/entry/src/main/ets/entryability/EntryAbility.ets +27 -0
- package/example/harmony/entry/src/main/ets/pages/Index.ets +125 -0
- package/example/harmony/entry/src/main/ets/pages/SurfaceDeadlockTest.ets +135 -0
- package/example/harmony/entry/src/main/ets/pages/TouchDisplayer.ets +44 -0
- package/example/harmony/entry/src/main/module.json5 +52 -0
- package/example/harmony/entry/src/main/resources/base/element/color.json +8 -0
- package/example/harmony/entry/src/main/resources/base/element/string.json +16 -0
- package/example/harmony/entry/src/main/resources/base/media/icon.png +0 -0
- package/example/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
- package/example/harmony/entry/src/main/resources/rawfile/1.txt +1 -0
- package/example/harmony/format.ps1 +18 -0
- package/example/harmony/hvigor/hvigor-config.json5 +21 -0
- package/example/harmony/hvigorfile.ts +9 -0
- package/example/harmony/oh-package.json5 +12 -0
- package/example/index.js +11 -0
- package/example/jest.config.js +11 -0
- package/example/metro.config.js +30 -0
- package/example/package.json +58 -0
- package/example/react-native.config.js +11 -0
- package/example/scripts/create-build-profile.js +46 -0
- package/example/src/index.tsx +22 -0
- package/example/tsconfig.json +20 -0
- package/harmony/slider/OAT.xml +42 -0
- package/harmony/slider/index.ets +1 -2
- package/harmony/slider/oh-package.json5 +2 -2
- package/harmony/slider/src/main/cpp/ComponentDescriptor.h +2 -4
- package/harmony/slider/src/main/cpp/EventEmitters.cpp +13 -13
- package/harmony/slider/src/main/cpp/EventEmitters.h +15 -9
- package/harmony/slider/src/main/cpp/Props.cpp +9 -5
- package/harmony/slider/src/main/cpp/Props.h +15 -10
- package/harmony/slider/src/main/cpp/ShadowNodes.cpp +1 -1
- package/harmony/slider/src/main/cpp/ShadowNodes.h +6 -6
- package/harmony/slider/src/main/cpp/SliderEventEmiRequestHandler.h +28 -31
- package/harmony/slider/src/main/cpp/SliderJSIBinder.h +8 -12
- package/harmony/slider/src/main/cpp/SliderNapiBinder.h +2 -6
- package/harmony/slider/src/main/cpp/SliderPackage.h +6 -12
- package/harmony/slider.har +0 -0
- package/package.json +38 -24
- package/react-native.config.js +11 -0
- package/src/RNCSliderNativeComponent.ts +13 -6
- package/src/Slider.tsx +133 -72
- package/src/components/StepNumber.tsx +23 -0
- package/src/components/StepsIndicator.tsx +89 -0
- package/src/components/TrackMark.tsx +56 -0
- package/src/index.ts +7 -1
- package/src/utils/constants.ts +17 -0
- package/src/utils/styles.ts +61 -0
- package/tsconfig.json +3 -2
- package/typings/index.d.ts +35 -1
- package/.eslintrc.json +0 -20
- package/.flowconfig +0 -66
- package/harmony/slider/src/main/ets/SliderPackage.ets +0 -34
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-harmony-tester",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"i": "cd ../ && npm i && npm run pack && cd ./example && npm i",
|
|
7
|
+
"reStart": "npm run install:pkg && npm run codegen && hdc rport tcp:8081 tcp:8081 && react-native start",
|
|
8
|
+
"start": "hdc rport tcp:8081 tcp:8081 && react-native start",
|
|
9
|
+
"codegen": "react-native codegen-harmony --rnoh-module-path ./harmony/entry/oh_modules/@rnoh/react-native-openharmony",
|
|
10
|
+
"pack:pkg": "cd ../ && npm pack && cd ./example",
|
|
11
|
+
"install:pkg": "npm uninstall @react-native-ohos/slider && npm run pack:pkg && npm i @react-native-ohos/slider@file:../react-native-ohos-slider-5.0.1-rc.1.tgz",
|
|
12
|
+
"dev": "npm run codegen && react-native bundle-harmony --dev --minify=false",
|
|
13
|
+
"prod": "npm run codegen && react-native bundle-harmony --dev=false --minify=true",
|
|
14
|
+
"postinstall": "node ./scripts/create-build-profile",
|
|
15
|
+
"fast:pkg": "cd ../ && npm i --legacy-peer-deps && npm pack && cd ./example && npm i && npm run dev"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@react-native-ohos/slider": "file:../react-native-ohos-slider-5.0.1-rc.1.tgz",
|
|
19
|
+
"react": "18.3.1",
|
|
20
|
+
"react-native": "0.77.1",
|
|
21
|
+
"react-native-harmony": "file:../packages/rnoh-react-native-harmony-0.77.10.tgz"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@babel/core": "^7.25.2",
|
|
25
|
+
"@babel/preset-env": "^7.25.3",
|
|
26
|
+
"@babel/runtime": "^7.25.0",
|
|
27
|
+
"@react-native-community/cli": "15.0.1",
|
|
28
|
+
"@react-native-community/cli-platform-android": "15.0.1",
|
|
29
|
+
"@react-native-community/cli-platform-ios": "15.0.1",
|
|
30
|
+
"@react-native-community/eslint-config": "^3.2.0",
|
|
31
|
+
"@react-native/babel-preset": "0.77.1",
|
|
32
|
+
"@react-native/eslint-config": "0.77.1",
|
|
33
|
+
"@react-native/metro-config": "^0.77.1",
|
|
34
|
+
"@react-native/typescript-config": "0.77.1",
|
|
35
|
+
"@rnoh/react-native-harmony-cli": "file:../packages/rnoh-react-native-harmony-cli-0.77.10.tgz",
|
|
36
|
+
"@tsconfig/react-native": "^3.0.0",
|
|
37
|
+
"@types/d3-scale-chromatic": "^3.0.0",
|
|
38
|
+
"@types/jest": "^29.5.13",
|
|
39
|
+
"@types/react": "^18.2.6",
|
|
40
|
+
"@types/react-test-renderer": "^18.0.0",
|
|
41
|
+
"babel-jest": "^29.6.3",
|
|
42
|
+
"eslint": "^8.19.0",
|
|
43
|
+
"jest": "^29.7.0",
|
|
44
|
+
"metro-react-native-babel-preset": "0.76.8",
|
|
45
|
+
"prettier": "2.8.8",
|
|
46
|
+
"react-test-renderer": "18.3.1",
|
|
47
|
+
"typescript": "5.5.4"
|
|
48
|
+
},
|
|
49
|
+
"overrides": {
|
|
50
|
+
"@react-native-community/cli": "15.0.1"
|
|
51
|
+
},
|
|
52
|
+
"resolutions": {
|
|
53
|
+
"@react-native-community/cli": "15.0.1"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=18"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const JSON5 = require('json5');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
|
|
12
|
+
const templatePath = path.join(
|
|
13
|
+
__dirname,
|
|
14
|
+
'..',
|
|
15
|
+
'harmony',
|
|
16
|
+
'build-profile.template.json5',
|
|
17
|
+
);
|
|
18
|
+
const existingProfilePath = path.join(
|
|
19
|
+
__dirname,
|
|
20
|
+
'..',
|
|
21
|
+
'harmony',
|
|
22
|
+
'build-profile.json5',
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if (fs.existsSync(existingProfilePath)) {
|
|
26
|
+
let existingProfile = JSON5.parse(
|
|
27
|
+
fs.readFileSync(existingProfilePath, 'utf-8'),
|
|
28
|
+
);
|
|
29
|
+
let template = JSON5.parse(fs.readFileSync(templatePath, 'utf-8'));
|
|
30
|
+
let signingConfigs =
|
|
31
|
+
existingProfile.app && existingProfile.app.signingConfigs;
|
|
32
|
+
|
|
33
|
+
existingProfile = {...template};
|
|
34
|
+
|
|
35
|
+
if (signingConfigs) {
|
|
36
|
+
existingProfile.app.signingConfigs = signingConfigs;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
fs.writeFileSync(
|
|
40
|
+
existingProfilePath,
|
|
41
|
+
JSON5.stringify(existingProfile, null, 2),
|
|
42
|
+
);
|
|
43
|
+
} else {
|
|
44
|
+
// File doesn't exist, create a copy from the template
|
|
45
|
+
fs.copyFileSync(templatePath, existingProfilePath);
|
|
46
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import Slider from "@react-native-community/slider"
|
|
8
|
+
import { View } from 'react-native'
|
|
9
|
+
|
|
10
|
+
export default function SliderExample() {
|
|
11
|
+
return (
|
|
12
|
+
<View style={{ backgroundColor: 'red', width: 200, height: 100 ,margin:100 }}>
|
|
13
|
+
<Slider
|
|
14
|
+
style={{ width: 200, height: 40 }}
|
|
15
|
+
minimumValue={0}
|
|
16
|
+
maximumValue={1}
|
|
17
|
+
minimumTrackTintColor="#FFFFFF"
|
|
18
|
+
maximumTrackTintColor="#000000"
|
|
19
|
+
/>
|
|
20
|
+
</View>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
{
|
|
8
|
+
"extends": "@react-native/typescript-config/tsconfig.json",
|
|
9
|
+
"compilerOptions": {
|
|
10
|
+
"jsx": "react-native",
|
|
11
|
+
"paths": {
|
|
12
|
+
"react-native": [
|
|
13
|
+
"./node_modules/react-native-harmony"
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
"exclude": [
|
|
18
|
+
"harmony"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<configuration>
|
|
3
|
+
<oatconfig>
|
|
4
|
+
<licensefile>LICENSE</licensefile>
|
|
5
|
+
<filefilterlist>
|
|
6
|
+
<filefilter name="copyrightPolicyFilter" desc="Filters for compatibility,license header policies">
|
|
7
|
+
<filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加版权头"/>
|
|
8
|
+
<filteritem type="filename" name="*.json5" desc="hvigor工程配置文件,DevEco Studio自动生成,不需要添加版权头"/>
|
|
9
|
+
<filteritem type="filename" name="*.proto" desc="资源文件,不需要添加版权头"/>
|
|
10
|
+
<filteritem type="filename" name="*.json" desc="资源文件,不需要添加版权头"/>
|
|
11
|
+
<filteritem type="filename" name="*.test.ts" desc="测试文件,不需要添加版权头"/>
|
|
12
|
+
<filteritem type="filename" name="index.ets" desc="入口文件,不需要添加版权头"/>
|
|
13
|
+
<filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
14
|
+
<filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
15
|
+
<filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
16
|
+
<filteritem type="filename" name="LICENSE" desc="工程文件,不修改版权头"/>
|
|
17
|
+
</filefilter>
|
|
18
|
+
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
|
19
|
+
<filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加许可证头"/>
|
|
20
|
+
<filteritem type="filename" name="*.json5" desc="hvigor工程配置文件,DevEco Studio自动生成,不需要添加许可证头"/>
|
|
21
|
+
<filteritem type="filename" name="LICENSE" desc="原三方库证书文件无需更改,因此添加过滤"/>
|
|
22
|
+
<filteritem type="filename" name="*.proto" desc="资源文件,不需要添加许可证头"/>
|
|
23
|
+
<filteritem type="filename" name="*.json" desc="资源文件,不需要添加许可证头"/>
|
|
24
|
+
<filteritem type="filename" name="*.test.ts" desc="测试文件,不需要添加版权头"/>
|
|
25
|
+
<filteritem type="filename" name="index.ets" desc="入口文件,不需要添加版权头"/>
|
|
26
|
+
<filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
27
|
+
<filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
28
|
+
<filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
|
|
29
|
+
</filefilter>
|
|
30
|
+
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for resources files policies">
|
|
31
|
+
<filteritem type="filename" name="icon.png" desc="应用图标"/>
|
|
32
|
+
<filteritem type="filename" name="app_icon.png" desc="应用图标"/>
|
|
33
|
+
<filteritem type="filename" name="warn.png" desc="页面展示图标"/>
|
|
34
|
+
</filefilter>
|
|
35
|
+
</filefilterlist>
|
|
36
|
+
<policylist>
|
|
37
|
+
<policy name="projectPolicy" desc="">
|
|
38
|
+
<policyitem type="license" name="MIT" path=".*" desc="license under the MIT"/>
|
|
39
|
+
</policy>
|
|
40
|
+
</policylist>
|
|
41
|
+
</oatconfig>
|
|
42
|
+
</configuration>
|
package/harmony/slider/index.ets
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-ohos/slider",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "@react-native-community/slider for HarmonyOS",
|
|
5
5
|
"main": "index.ets",
|
|
6
6
|
"author": "Huawei",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@rnoh/react-native-openharmony": "file:../react_native_openharmony"
|
|
9
|
+
"@rnoh/react-native-openharmony": "file:../react_native_openharmony.har"
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
#define COMPONENTDESCRIPTOR_SLIDER_H
|
|
24
|
+
|
|
26
25
|
#pragma once
|
|
27
26
|
|
|
28
27
|
#include "ShadowNodes.h"
|
|
@@ -34,5 +33,4 @@ namespace react {
|
|
|
34
33
|
using RNCSliderComponentDescriptor = ConcreteComponentDescriptor<RNCSliderShadowNode>;
|
|
35
34
|
|
|
36
35
|
} // namespace react
|
|
37
|
-
} // namespace facebook
|
|
38
|
-
#endif
|
|
36
|
+
} // namespace facebook
|
|
@@ -28,38 +28,38 @@
|
|
|
28
28
|
namespace facebook {
|
|
29
29
|
namespace react {
|
|
30
30
|
|
|
31
|
-
void RNCSliderEventEmitter::onChange(OnChange event) const
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
void RNCSliderEventEmitter::onChange(OnChange event) const {
|
|
32
|
+
dispatchEvent("change", [event = std::move(event)](jsi::Runtime &runtime) {
|
|
33
|
+
auto payload = jsi::Object(runtime);
|
|
34
|
+
payload.setProperty(runtime, "value", event.value);
|
|
35
|
+
// payload.setProperty(runtime, "fromUser", event.fromUser);
|
|
36
|
+
return payload;
|
|
37
|
+
});
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
void RNCSliderEventEmitter::onRNCSliderSlidingStart(OnRNCSliderSlidingStart event) const
|
|
41
|
-
{
|
|
40
|
+
void RNCSliderEventEmitter::onRNCSliderSlidingStart(OnRNCSliderSlidingStart event) const {
|
|
42
41
|
dispatchEvent("rNCSliderSlidingStart", [event = std::move(event)](jsi::Runtime &runtime) {
|
|
43
42
|
auto payload = jsi::Object(runtime);
|
|
44
43
|
payload.setProperty(runtime, "value", event.value);
|
|
44
|
+
// payload.setProperty(runtime, "fromUser", event.fromUser);
|
|
45
45
|
return payload;
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
void RNCSliderEventEmitter::onRNCSliderSlidingComplete(OnRNCSliderSlidingComplete event) const
|
|
50
|
-
{
|
|
49
|
+
void RNCSliderEventEmitter::onRNCSliderSlidingComplete(OnRNCSliderSlidingComplete event) const {
|
|
51
50
|
dispatchEvent("rNCSliderSlidingComplete", [event = std::move(event)](jsi::Runtime &runtime) {
|
|
52
51
|
auto payload = jsi::Object(runtime);
|
|
53
52
|
payload.setProperty(runtime, "value", event.value);
|
|
53
|
+
// payload.setProperty(runtime, "fromUser", event.fromUser);
|
|
54
54
|
return payload;
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
void RNCSliderEventEmitter::onRNCSliderValueChange(OnRNCSliderValueChange event) const
|
|
59
|
-
{
|
|
58
|
+
void RNCSliderEventEmitter::onRNCSliderValueChange(OnRNCSliderValueChange event) const {
|
|
60
59
|
dispatchEvent("rNCSliderValueChange", [event = std::move(event)](jsi::Runtime &runtime) {
|
|
61
60
|
auto payload = jsi::Object(runtime);
|
|
62
61
|
payload.setProperty(runtime, "value", event.value);
|
|
62
|
+
// payload.setProperty(runtime, "fromUser", event.fromUser);
|
|
63
63
|
return payload;
|
|
64
64
|
});
|
|
65
65
|
}
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
#define EVENTEMITTERS_SLIDER_H
|
|
24
|
+
|
|
26
25
|
#pragma once
|
|
27
26
|
|
|
28
27
|
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
@@ -34,20 +33,28 @@ namespace react {
|
|
|
34
33
|
class JSI_EXPORT RNCSliderEventEmitter : public ViewEventEmitter {
|
|
35
34
|
public:
|
|
36
35
|
using ViewEventEmitter::ViewEventEmitter;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
|
|
37
|
+
struct OnChange {
|
|
38
|
+
Float value;
|
|
39
|
+
// bool fromUser;
|
|
40
|
+
};
|
|
41
|
+
|
|
40
42
|
struct OnRNCSliderSlidingStart {
|
|
41
43
|
Float value;
|
|
44
|
+
// bool fromUser;
|
|
42
45
|
};
|
|
46
|
+
|
|
43
47
|
struct OnRNCSliderSlidingComplete {
|
|
44
48
|
Float value;
|
|
49
|
+
// bool fromUser;
|
|
45
50
|
};
|
|
51
|
+
|
|
46
52
|
struct OnRNCSliderValueChange {
|
|
47
53
|
Float value;
|
|
54
|
+
// bool fromUser;
|
|
48
55
|
};
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
|
|
57
|
+
void onChange(OnChange value) const;
|
|
51
58
|
|
|
52
59
|
void onRNCSliderSlidingStart(OnRNCSliderSlidingStart value) const;
|
|
53
60
|
|
|
@@ -57,5 +64,4 @@ class JSI_EXPORT RNCSliderEventEmitter : public ViewEventEmitter {
|
|
|
57
64
|
};
|
|
58
65
|
|
|
59
66
|
} // namespace react
|
|
60
|
-
} // namespace facebook
|
|
61
|
-
#endif
|
|
67
|
+
} // namespace facebook
|
|
@@ -33,13 +33,17 @@ RNCSliderProps::RNCSliderProps(
|
|
|
33
33
|
const PropsParserContext &context,
|
|
34
34
|
const RNCSliderProps &sourceProps,
|
|
35
35
|
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
|
|
37
|
+
// accessibilityUnits(convertRawProp(context, rawProps, "accessibilityUnits", sourceProps.accessibilityUnits, {})),
|
|
38
|
+
// accessibilityIncrements(convertRawProp(context, rawProps, "accessibilityIncrements", sourceProps.accessibilityIncrements, {})),
|
|
39
|
+
// maximumTrackImage(convertRawProp(context, rawProps, "maximumTrackImage", sourceProps.maximumTrackImage, {})),
|
|
40
|
+
maximumTrackTintColor(convertRawProp(context, rawProps, "maximumTrackTintColor", sourceProps.maximumTrackTintColor, {})),
|
|
41
|
+
// minimumTrackImage(convertRawProp(context, rawProps, "minimumTrackImage", sourceProps.minimumTrackImage, {})),
|
|
42
|
+
minimumTrackTintColor(convertRawProp(context, rawProps, "minimumTrackTintColor", sourceProps.minimumTrackTintColor, {})),
|
|
40
43
|
thumbImage(convertRawProp(context, rawProps, "thumbImage", sourceProps.thumbImage, {})),
|
|
41
44
|
thumbTintColor(convertRawProp(context, rawProps, "thumbTintColor", sourceProps.thumbTintColor, {}))
|
|
42
|
-
{}
|
|
45
|
+
// trackImage(convertRawProp(context, rawProps, "trackImage", sourceProps.trackImage, {})),
|
|
46
|
+
{}
|
|
43
47
|
|
|
44
48
|
} // namespace react
|
|
45
49
|
} // namespace facebook
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
#define PROPS_SLIDER_H
|
|
24
|
+
|
|
26
25
|
#pragma once
|
|
27
26
|
|
|
28
27
|
#include <jsi/jsi.h>
|
|
@@ -37,15 +36,21 @@ namespace react {
|
|
|
37
36
|
|
|
38
37
|
class JSI_EXPORT RNCSliderProps final : public ViewProps {
|
|
39
38
|
public:
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
RNCSliderProps() = default;
|
|
40
|
+
RNCSliderProps(const PropsParserContext& context, const RNCSliderProps &sourceProps, const RawProps &rawProps);
|
|
42
41
|
|
|
43
42
|
#pragma mark - Props
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
|
|
44
|
+
// std::string accessibilityUnits{};
|
|
45
|
+
// std::vector<std::string> accessibilityIncrements{};
|
|
46
|
+
// ImageSource maximumTrackImage{};
|
|
47
|
+
SharedColor maximumTrackTintColor{};
|
|
48
|
+
// ImageSource minimumTrackImage{};
|
|
49
|
+
SharedColor minimumTrackTintColor{};
|
|
50
|
+
ImageSource thumbImage{};
|
|
51
|
+
SharedColor thumbTintColor{};
|
|
52
|
+
// ImageSource trackImage{};
|
|
48
53
|
};
|
|
54
|
+
|
|
49
55
|
} // namespace react
|
|
50
|
-
} // namespace facebook
|
|
51
|
-
#endif
|
|
56
|
+
} // namespace facebook
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
#ifndef SHADOWNODES_SLIDER_H
|
|
25
|
-
#define SHADOWNODES_SLIDER_H
|
|
26
24
|
#pragma once
|
|
27
25
|
|
|
28
26
|
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
@@ -34,13 +32,15 @@
|
|
|
34
32
|
namespace facebook {
|
|
35
33
|
namespace react {
|
|
36
34
|
|
|
37
|
-
JSI_EXPORT extern const char
|
|
35
|
+
JSI_EXPORT extern const char RNCSliderComponentName[];
|
|
38
36
|
|
|
37
|
+
/*
|
|
38
|
+
* `ShadowNode` for <RNCSlider> component.
|
|
39
|
+
*/
|
|
39
40
|
using RNCSliderShadowNode = ConcreteViewShadowNode<
|
|
40
|
-
|
|
41
|
+
RNCSliderComponentName,
|
|
41
42
|
RNCSliderProps,
|
|
42
43
|
RNCSliderEventEmitter>;
|
|
43
44
|
|
|
44
45
|
} // namespace react
|
|
45
|
-
} // namespace facebook
|
|
46
|
-
#endif
|
|
46
|
+
} // namespace facebook
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
#define SLIDEREVENTEMIREQUESTHANDLER_H
|
|
24
|
+
|
|
26
25
|
#pragma once
|
|
27
26
|
|
|
28
27
|
#include "RNOH/ArkJS.h"
|
|
@@ -39,8 +38,7 @@ enum SliderEventType {
|
|
|
39
38
|
SLIDING_COMPLETE = 2
|
|
40
39
|
};
|
|
41
40
|
|
|
42
|
-
SliderEventType getSliderEventType(ArkJS &arkJs, napi_value eventObject)
|
|
43
|
-
{
|
|
41
|
+
SliderEventType getSliderEventType(ArkJS &arkJs, napi_value eventObject) {
|
|
44
42
|
auto eventType = arkJs.getString(arkJs.getObjectProperty(eventObject, "type"));
|
|
45
43
|
if (eventType == "SliderValueChange") {
|
|
46
44
|
return SliderEventType::VALUE_CHANGE;
|
|
@@ -55,8 +53,7 @@ SliderEventType getSliderEventType(ArkJS &arkJs, napi_value eventObject)
|
|
|
55
53
|
|
|
56
54
|
class SliderEventEmitRequestHandler : public EventEmitRequestHandler {
|
|
57
55
|
public:
|
|
58
|
-
void handleEvent(EventEmitRequestHandler::Context const &ctx) override
|
|
59
|
-
{
|
|
56
|
+
void handleEvent(EventEmitRequestHandler::Context const &ctx) override {
|
|
60
57
|
if (ctx.eventName != "RNCSlider") {
|
|
61
58
|
return;
|
|
62
59
|
}
|
|
@@ -66,31 +63,31 @@ class SliderEventEmitRequestHandler : public EventEmitRequestHandler {
|
|
|
66
63
|
return;
|
|
67
64
|
}
|
|
68
65
|
auto eventType = getSliderEventType(arkJs, ctx.payload);
|
|
69
|
-
switch (eventType)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
66
|
+
switch (eventType)
|
|
67
|
+
{
|
|
68
|
+
case SliderEventType::VALUE_CHANGE: {
|
|
69
|
+
facebook::react::Float value = arkJs.getDouble(arkJs.getObjectProperty(ctx.payload, "value"));
|
|
70
|
+
react::RNCSliderEventEmitter::OnChange event1 = {value};
|
|
71
|
+
eventEmitter->onChange(event1);
|
|
72
|
+
react::RNCSliderEventEmitter::OnRNCSliderValueChange event2 = {value};
|
|
73
|
+
eventEmitter->onRNCSliderValueChange(event2);
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case SliderEventType::SLIDING_START: {
|
|
77
|
+
facebook::react::Float value = arkJs.getDouble(arkJs.getObjectProperty(ctx.payload, "value"));
|
|
78
|
+
react::RNCSliderEventEmitter::OnRNCSliderSlidingStart event = {value};
|
|
79
|
+
eventEmitter->onRNCSliderSlidingStart(event);
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case SliderEventType::SLIDING_COMPLETE: {
|
|
83
|
+
facebook::react::Float value = arkJs.getDouble(arkJs.getObjectProperty(ctx.payload, "value"));
|
|
84
|
+
react::RNCSliderEventEmitter::OnRNCSliderSlidingComplete event = {value};
|
|
85
|
+
eventEmitter->onRNCSliderSlidingComplete(event);
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
default:
|
|
89
|
+
break;
|
|
92
90
|
}
|
|
93
91
|
};
|
|
94
92
|
};
|
|
95
|
-
} // namespace rnoh
|
|
96
|
-
#endif
|
|
93
|
+
} // namespace rnoh
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
#define SLIDERJSIBINDER_H
|
|
24
|
+
|
|
26
25
|
#pragma once
|
|
27
26
|
|
|
28
27
|
#include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
|
|
@@ -30,8 +29,7 @@
|
|
|
30
29
|
namespace rnoh {
|
|
31
30
|
|
|
32
31
|
class SliderJSIBinder : public ViewComponentJSIBinder {
|
|
33
|
-
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override
|
|
34
|
-
{
|
|
32
|
+
facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override {
|
|
35
33
|
auto object = ViewComponentJSIBinder::createNativeProps(rt);
|
|
36
34
|
object.setProperty(rt, "disabled", "boolean");
|
|
37
35
|
object.setProperty(rt, "inverted", "boolean");
|
|
@@ -51,21 +49,19 @@ class SliderJSIBinder : public ViewComponentJSIBinder {
|
|
|
51
49
|
return object;
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override
|
|
55
|
-
{
|
|
52
|
+
facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override {
|
|
56
53
|
facebook::jsi::Object events(rt);
|
|
57
|
-
events.setProperty(rt, "topChange",
|
|
58
|
-
events.setProperty(rt, "topRNCSliderValueChange",
|
|
54
|
+
events.setProperty(rt, "topChange", createDirectEvent(rt, "onChange"));
|
|
55
|
+
events.setProperty(rt, "topRNCSliderValueChange", createDirectEvent(rt, "onRNCSliderValueChange"));
|
|
59
56
|
return events;
|
|
60
57
|
}
|
|
61
58
|
|
|
62
|
-
facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override
|
|
63
|
-
{
|
|
59
|
+
facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override {
|
|
64
60
|
facebook::jsi::Object events(rt);
|
|
65
61
|
events.setProperty(rt, "topRNCSliderSlidingStart", createDirectEvent(rt, "onRNCSliderSlidingStart"));
|
|
66
62
|
events.setProperty(rt, "topRNCSliderSlidingComplete", createDirectEvent(rt, "onRNCSliderSlidingComplete"));
|
|
67
63
|
return events;
|
|
68
64
|
}
|
|
65
|
+
|
|
69
66
|
};
|
|
70
|
-
} // namespace rnoh
|
|
71
|
-
#endif
|
|
67
|
+
} // namespace rnoh
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
#ifndef SLIDERNAPIBINDER_H
|
|
25
|
-
#define SLIDERNAPIBINDER_H
|
|
26
24
|
#pragma once
|
|
27
25
|
|
|
28
26
|
#include "RNOHCorePackage/ComponentBinders/ViewComponentNapiBinder.h"
|
|
@@ -32,8 +30,7 @@ namespace rnoh {
|
|
|
32
30
|
|
|
33
31
|
class SliderNapiBinder : public ViewComponentNapiBinder {
|
|
34
32
|
public:
|
|
35
|
-
napi_value createProps(napi_env env, facebook::react::ShadowView const shadowView) override
|
|
36
|
-
{
|
|
33
|
+
napi_value createProps(napi_env env, facebook::react::ShadowView const shadowView) override {
|
|
37
34
|
napi_value napiViewProps = ViewComponentNapiBinder::createProps(env, shadowView);
|
|
38
35
|
if (auto props = std::dynamic_pointer_cast<const facebook::react::RNCSliderProps>(shadowView.props)) {
|
|
39
36
|
return ArkJS(env)
|
|
@@ -47,5 +44,4 @@ public:
|
|
|
47
44
|
return napiViewProps;
|
|
48
45
|
};
|
|
49
46
|
};
|
|
50
|
-
} //namespace rnoh
|
|
51
|
-
#endif
|
|
47
|
+
} //namespace rnoh
|