@react-native-ohos/slider 4.4.4-rc.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/.eslintrc.json +20 -0
- package/.flowconfig +66 -0
- package/babel.config.json +3 -0
- package/dist/RNCSliderNativeComponent.js +1 -0
- package/dist/Slider.js +1 -0
- package/dist/index.js +1 -0
- package/harmony/slider/LICENSE +21 -0
- package/harmony/slider/README.OpenSource +11 -0
- package/harmony/slider/build-profile.json5 +8 -0
- package/harmony/slider/hvigorfile.ts +1 -0
- package/harmony/slider/index.ets +26 -0
- package/harmony/slider/obfuscation-rules.txt +18 -0
- package/harmony/slider/oh-package.json5 +11 -0
- package/harmony/slider/src/main/cpp/CMakeLists.txt +7 -0
- package/harmony/slider/src/main/cpp/ComponentDescriptor.h +38 -0
- package/harmony/slider/src/main/cpp/EventEmitters.cpp +68 -0
- package/harmony/slider/src/main/cpp/EventEmitters.h +61 -0
- package/harmony/slider/src/main/cpp/Props.cpp +45 -0
- package/harmony/slider/src/main/cpp/Props.h +51 -0
- package/harmony/slider/src/main/cpp/ShadowNodes.cpp +33 -0
- package/harmony/slider/src/main/cpp/ShadowNodes.h +46 -0
- package/harmony/slider/src/main/cpp/SliderEventEmiRequestHandler.h +96 -0
- package/harmony/slider/src/main/cpp/SliderJSIBinder.h +71 -0
- package/harmony/slider/src/main/cpp/SliderNapiBinder.h +51 -0
- package/harmony/slider/src/main/cpp/SliderPackage.h +59 -0
- package/harmony/slider/src/main/ets/Logger.ets +64 -0
- package/harmony/slider/src/main/ets/Slider.ets +182 -0
- package/harmony/slider/src/main/ets/SliderDescriptorWrapper.ets +78 -0
- package/harmony/slider/src/main/ets/SliderPackage.ets +34 -0
- package/harmony/slider/src/main/module.json5 +9 -0
- package/harmony/slider/src/main/resources/base/element/color.json +8 -0
- package/harmony/slider/src/main/resources/base/element/string.json +16 -0
- package/harmony/slider/src/main/resources/base/media/icon.png +0 -0
- package/harmony/slider/src/main/resources/base/profile/main_pages.json +5 -0
- package/harmony/slider/src/main/resources/en_US/element/string.json +16 -0
- package/harmony/slider/src/main/resources/zh_CN/element/string.json +16 -0
- package/harmony/slider.har +0 -0
- package/package.json +78 -0
- package/src/RNCSliderNativeComponent.ts +46 -0
- package/src/Slider.tsx +295 -0
- package/src/index.ts +3 -0
- package/tsconfig.json +22 -0
- package/typings/index.d.ts +180 -0
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@react-native-community",
|
|
3
|
+
"env": {
|
|
4
|
+
"es6": true,
|
|
5
|
+
"jest": true
|
|
6
|
+
},
|
|
7
|
+
"globals": {
|
|
8
|
+
"it": true,
|
|
9
|
+
"expect": true,
|
|
10
|
+
"element": true,
|
|
11
|
+
"describe": true,
|
|
12
|
+
"by": true,
|
|
13
|
+
"device": true,
|
|
14
|
+
"beforeAll": true,
|
|
15
|
+
"beforeEach": true,
|
|
16
|
+
"afterAll": true,
|
|
17
|
+
"jest": true,
|
|
18
|
+
"jasmine": true
|
|
19
|
+
}
|
|
20
|
+
}
|
package/.flowconfig
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
[ignore]
|
|
2
|
+
; We fork some components by platform
|
|
3
|
+
.*/*[.]android.js
|
|
4
|
+
|
|
5
|
+
; Ignore "BUCK" generated dirs
|
|
6
|
+
<PROJECT_ROOT>/\.buckd/
|
|
7
|
+
|
|
8
|
+
; Ignore node_modules
|
|
9
|
+
<PROJECT_ROOT>/node_modules/.*
|
|
10
|
+
|
|
11
|
+
; Flow doesn't support platforms
|
|
12
|
+
.*/Libraries/Utilities/LoadingView.js
|
|
13
|
+
|
|
14
|
+
.*/Libraries/Utilities/HMRLoadingView.js
|
|
15
|
+
|
|
16
|
+
[untyped]
|
|
17
|
+
.*/node_modules/@react-native-community/cli/.*/.*
|
|
18
|
+
|
|
19
|
+
[include]
|
|
20
|
+
|
|
21
|
+
[libs]
|
|
22
|
+
node_modules/react-native/interface.js
|
|
23
|
+
node_modules/react-native/flow/
|
|
24
|
+
|
|
25
|
+
[options]
|
|
26
|
+
module.system.node.resolve_dirname=node_modules
|
|
27
|
+
module.system.node.resolve_dirname=src
|
|
28
|
+
emoji=true
|
|
29
|
+
|
|
30
|
+
module.file_ext=.js
|
|
31
|
+
module.file_ext=.json
|
|
32
|
+
module.file_ext=.ios.js
|
|
33
|
+
|
|
34
|
+
munge_underscores=true
|
|
35
|
+
|
|
36
|
+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
|
|
37
|
+
module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
|
|
38
|
+
|
|
39
|
+
suppress_type=$FlowIssue
|
|
40
|
+
suppress_type=$FlowFixMe
|
|
41
|
+
suppress_type=$FlowFixMeProps
|
|
42
|
+
suppress_type=$FlowFixMeState
|
|
43
|
+
|
|
44
|
+
[lints]
|
|
45
|
+
sketchy-null-number=warn
|
|
46
|
+
sketchy-null-mixed=warn
|
|
47
|
+
sketchy-number=warn
|
|
48
|
+
untyped-type-import=warn
|
|
49
|
+
nonstrict-import=warn
|
|
50
|
+
deprecated-type=warn
|
|
51
|
+
unsafe-getters-setters=warn
|
|
52
|
+
unnecessary-invariant=warn
|
|
53
|
+
signature-verification-failure=warn
|
|
54
|
+
deprecated-utility=error
|
|
55
|
+
|
|
56
|
+
[strict]
|
|
57
|
+
deprecated-type
|
|
58
|
+
nonstrict-import
|
|
59
|
+
sketchy-null
|
|
60
|
+
unclear-type
|
|
61
|
+
unsafe-getters-setters
|
|
62
|
+
untyped-import
|
|
63
|
+
untyped-type-import
|
|
64
|
+
|
|
65
|
+
[version]
|
|
66
|
+
^0.163.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _codegenNativeComponent=_interopRequireDefault(require("react-native/Libraries/Utilities/codegenNativeComponent"));var _default=exports.default=(0,_codegenNativeComponent.default)('RNCSlider');
|
package/dist/Slider.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _extends2=_interopRequireDefault(require("@babel/runtime/helpers/extends"));var _objectWithoutProperties2=_interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _index=_interopRequireDefault(require("./index"));var _excluded=["onValueChange","onSlidingStart","onSlidingComplete","onAccessibilityAction"];var _this=this,_jsxFileName="D:\\fxxcode\\newThird\\rntpc_react-native-slider\\package\\src\\Slider.tsx";var LIMIT_MIN_VALUE=Number.MIN_SAFE_INTEGER;var LIMIT_MAX_VALUE=Number.MAX_SAFE_INTEGER;var SliderComponent=function SliderComponent(props,forwardedRef){var _props$accessibilityS;var style=_reactNative.StyleSheet.compose(props.style,styles.slider);var onValueChange=props.onValueChange,onSlidingStart=props.onSlidingStart,onSlidingComplete=props.onSlidingComplete,onAccessibilityAction=props.onAccessibilityAction,localProps=(0,_objectWithoutProperties2.default)(props,_excluded);var onValueChangeEvent=onValueChange?function(event){onValueChange(event.nativeEvent.value);}:null;var _disabled=typeof props.disabled==='boolean'?props.disabled:((_props$accessibilityS=props.accessibilityState)==null?void 0:_props$accessibilityS.disabled)===true;var _accessibilityState=typeof props.disabled==='boolean'?Object.assign({},props.accessibilityState,{disabled:props.disabled}):props.accessibilityState;var onSlidingStartEvent=onSlidingStart?function(event){onSlidingStart(event.nativeEvent.value);}:null;var onSlidingCompleteEvent=onSlidingComplete?function(event){onSlidingComplete(event.nativeEvent.value);}:null;var onAccessibilityActionEvent=onAccessibilityAction?function(event){onAccessibilityAction(event);}:null;var value=Number.isNaN(props.value)||!props.value?undefined:props.value;var lowerLimit=!!localProps.lowerLimit||localProps.lowerLimit===0?localProps.lowerLimit:LIMIT_MIN_VALUE;var upperLimit=!!localProps.upperLimit||localProps.upperLimit===0?localProps.upperLimit:LIMIT_MAX_VALUE;return _react.default.createElement(_index.default,(0,_extends2.default)({},localProps,{value:value,lowerLimit:lowerLimit,upperLimit:upperLimit,accessibilityState:_accessibilityState,thumbImage:_reactNative.Platform.OS==='web'?props.thumbImage:props.thumbImage?_reactNative.Image.resolveAssetSource(props.thumbImage):undefined,ref:forwardedRef,style:style,onChange:onValueChangeEvent,onRNCSliderSlidingStart:onSlidingStartEvent,onRNCSliderSlidingComplete:onSlidingCompleteEvent,onRNCSliderValueChange:onValueChangeEvent,disabled:_disabled,onStartShouldSetResponder:function onStartShouldSetResponder(){return true;},onResponderTerminationRequest:function onResponderTerminationRequest(){return false;},onRNCSliderAccessibilityAction:onAccessibilityActionEvent,__self:_this,__source:{fileName:_jsxFileName,lineNumber:251,columnNumber:5}}));};var SliderWithRef=_react.default.forwardRef(SliderComponent);SliderWithRef.defaultProps={value:0,minimumValue:0,maximumValue:1,step:0,inverted:false,tapToSeek:false,lowerLimit:LIMIT_MIN_VALUE,upperLimit:LIMIT_MAX_VALUE};var styles=_reactNative.StyleSheet.create(_reactNative.Platform.OS==='ios'||_reactNative.Platform.OS==='harmony'?{slider:{height:40}}:{slider:{}});var _default=exports.default=SliderWithRef;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var RNCSlider=require('./RNCSliderNativeComponent').default;var _default=exports.default=RNCSlider;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 react-native-community
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"Name": "react-native-slider",
|
|
4
|
+
"License": "MIT License",
|
|
5
|
+
"License File":"https://github.com/callstack/react-native-slider/blob/main/LICENSE.md",
|
|
6
|
+
"Version Number": "4.4.3-0.1.3",
|
|
7
|
+
"Owner" : ""
|
|
8
|
+
"Upstream URL": "https://github.com/callstack/react-native-slider",
|
|
9
|
+
"Description": "React Native component used to select a single value from a range of values."
|
|
10
|
+
}
|
|
11
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { harTasks } from '@ohos/hvigor-ohos-plugin';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANT KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import { SliderPackage } from './src/main/ets/SliderPackage'
|
|
25
|
+
export default SliderPackage
|
|
26
|
+
export * from './src/main/ets/Slider'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Define project specific obfuscation rules here.
|
|
2
|
+
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
|
3
|
+
#
|
|
4
|
+
# For more details, see
|
|
5
|
+
# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
|
|
6
|
+
|
|
7
|
+
# Obfuscation options:
|
|
8
|
+
# -disable-obfuscation: disable all obfuscations
|
|
9
|
+
# -enable-property-obfuscation: obfuscate the property names
|
|
10
|
+
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
|
11
|
+
# -compact: remove unnecessary blank spaces and all line feeds
|
|
12
|
+
# -remove-log: remove all console.* statements
|
|
13
|
+
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
|
14
|
+
# -apply-namecache: reuse the given cache file
|
|
15
|
+
|
|
16
|
+
# Keep options:
|
|
17
|
+
# -keep-property-name: specifies property names that you want to keep
|
|
18
|
+
# -keep-global-name: specifies names that you want to keep in the global scope
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@react-native-ohos/slider",
|
|
3
|
+
"version": "4.4.4-rc.1",
|
|
4
|
+
"description": "@react-native-community/slider for HarmonyOS",
|
|
5
|
+
"main": "index.ets",
|
|
6
|
+
"author": "Huawei",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@rnoh/react-native-openharmony": "file:../react_native_openharmony"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.13)
|
|
2
|
+
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
3
|
+
|
|
4
|
+
file(GLOB rnoh_slider_SRC CONFIGURE_DEPENDS *.cpp)
|
|
5
|
+
add_library(rnoh_slider SHARED ${rnoh_slider_SRC})
|
|
6
|
+
target_include_directories(rnoh_slider PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
|
7
|
+
target_link_libraries(rnoh_slider PUBLIC rnoh)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
#ifndef COMPONENTDESCRIPTOR_SLIDER_H
|
|
25
|
+
#define COMPONENTDESCRIPTOR_SLIDER_H
|
|
26
|
+
#pragma once
|
|
27
|
+
|
|
28
|
+
#include "ShadowNodes.h"
|
|
29
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
30
|
+
|
|
31
|
+
namespace facebook {
|
|
32
|
+
namespace react {
|
|
33
|
+
|
|
34
|
+
using RNCSliderComponentDescriptor = ConcreteComponentDescriptor<RNCSliderShadowNode>;
|
|
35
|
+
|
|
36
|
+
} // namespace react
|
|
37
|
+
} // namespace facebook
|
|
38
|
+
#endif
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#include <glog/logging.h>
|
|
26
|
+
#include "EventEmitters.h"
|
|
27
|
+
|
|
28
|
+
namespace facebook {
|
|
29
|
+
namespace react {
|
|
30
|
+
|
|
31
|
+
void RNCSliderEventEmitter::onChange(OnChange event) const
|
|
32
|
+
{
|
|
33
|
+
dispatchEvent("change", [event = std::move(event)](jsi::Runtime &runtime) {
|
|
34
|
+
auto payload = jsi::Object(runtime);
|
|
35
|
+
payload.setProperty(runtime, "value", event.value);
|
|
36
|
+
return payload;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void RNCSliderEventEmitter::onRNCSliderSlidingStart(OnRNCSliderSlidingStart event) const
|
|
41
|
+
{
|
|
42
|
+
dispatchEvent("rNCSliderSlidingStart", [event = std::move(event)](jsi::Runtime &runtime) {
|
|
43
|
+
auto payload = jsi::Object(runtime);
|
|
44
|
+
payload.setProperty(runtime, "value", event.value);
|
|
45
|
+
return payload;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void RNCSliderEventEmitter::onRNCSliderSlidingComplete(OnRNCSliderSlidingComplete event) const
|
|
50
|
+
{
|
|
51
|
+
dispatchEvent("rNCSliderSlidingComplete", [event = std::move(event)](jsi::Runtime &runtime) {
|
|
52
|
+
auto payload = jsi::Object(runtime);
|
|
53
|
+
payload.setProperty(runtime, "value", event.value);
|
|
54
|
+
return payload;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void RNCSliderEventEmitter::onRNCSliderValueChange(OnRNCSliderValueChange event) const
|
|
59
|
+
{
|
|
60
|
+
dispatchEvent("rNCSliderValueChange", [event = std::move(event)](jsi::Runtime &runtime) {
|
|
61
|
+
auto payload = jsi::Object(runtime);
|
|
62
|
+
payload.setProperty(runtime, "value", event.value);
|
|
63
|
+
return payload;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
} // namespace react
|
|
68
|
+
} // namespace facebook
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
#ifndef EVENTEMITTERS_SLIDER_H
|
|
25
|
+
#define EVENTEMITTERS_SLIDER_H
|
|
26
|
+
#pragma once
|
|
27
|
+
|
|
28
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
29
|
+
#include <jsi/jsi.h>
|
|
30
|
+
|
|
31
|
+
namespace facebook {
|
|
32
|
+
namespace react {
|
|
33
|
+
|
|
34
|
+
class JSI_EXPORT RNCSliderEventEmitter : public ViewEventEmitter {
|
|
35
|
+
public:
|
|
36
|
+
using ViewEventEmitter::ViewEventEmitter;
|
|
37
|
+
struct OnChange {
|
|
38
|
+
Float value;
|
|
39
|
+
};
|
|
40
|
+
struct OnRNCSliderSlidingStart {
|
|
41
|
+
Float value;
|
|
42
|
+
};
|
|
43
|
+
struct OnRNCSliderSlidingComplete {
|
|
44
|
+
Float value;
|
|
45
|
+
};
|
|
46
|
+
struct OnRNCSliderValueChange {
|
|
47
|
+
Float value;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
void onChange(OnChange value) const;
|
|
51
|
+
|
|
52
|
+
void onRNCSliderSlidingStart(OnRNCSliderSlidingStart value) const;
|
|
53
|
+
|
|
54
|
+
void onRNCSliderSlidingComplete(OnRNCSliderSlidingComplete value) const;
|
|
55
|
+
|
|
56
|
+
void onRNCSliderValueChange(OnRNCSliderValueChange value) const;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
} // namespace react
|
|
60
|
+
} // namespace facebook
|
|
61
|
+
#endif
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
26
|
+
#include <react/renderer/core/propsConversions.h>
|
|
27
|
+
#include "Props.h"
|
|
28
|
+
|
|
29
|
+
namespace facebook {
|
|
30
|
+
namespace react {
|
|
31
|
+
|
|
32
|
+
RNCSliderProps::RNCSliderProps(
|
|
33
|
+
const PropsParserContext &context,
|
|
34
|
+
const RNCSliderProps &sourceProps,
|
|
35
|
+
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
|
|
36
|
+
maximumTrackTintColor(
|
|
37
|
+
convertRawProp(context, rawProps, "maximumTrackTintColor", sourceProps.maximumTrackTintColor, {})),
|
|
38
|
+
minimumTrackTintColor(
|
|
39
|
+
convertRawProp(context, rawProps, "minimumTrackTintColor", sourceProps.minimumTrackTintColor, {})),
|
|
40
|
+
thumbImage(convertRawProp(context, rawProps, "thumbImage", sourceProps.thumbImage, {})),
|
|
41
|
+
thumbTintColor(convertRawProp(context, rawProps, "thumbTintColor", sourceProps.thumbTintColor, {}))
|
|
42
|
+
{}
|
|
43
|
+
|
|
44
|
+
} // namespace react
|
|
45
|
+
} // namespace facebook
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
#ifndef PROPS_SLIDER_H
|
|
25
|
+
#define PROPS_SLIDER_H
|
|
26
|
+
#pragma once
|
|
27
|
+
|
|
28
|
+
#include <jsi/jsi.h>
|
|
29
|
+
#include <react/renderer/components/image/conversions.h>
|
|
30
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
31
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
32
|
+
#include <react/renderer/imagemanager/primitives.h>
|
|
33
|
+
#include <vector>
|
|
34
|
+
|
|
35
|
+
namespace facebook {
|
|
36
|
+
namespace react {
|
|
37
|
+
|
|
38
|
+
class JSI_EXPORT RNCSliderProps final : public ViewProps {
|
|
39
|
+
public:
|
|
40
|
+
RNCSliderProps() = default;
|
|
41
|
+
RNCSliderProps(const PropsParserContext& context, const RNCSliderProps &sourceProps, const RawProps &rawProps);
|
|
42
|
+
|
|
43
|
+
#pragma mark - Props
|
|
44
|
+
SharedColor maximumTrackTintColor{};
|
|
45
|
+
SharedColor minimumTrackTintColor{};
|
|
46
|
+
ImageSource thumbImage{};
|
|
47
|
+
SharedColor thumbTintColor{};
|
|
48
|
+
};
|
|
49
|
+
} // namespace react
|
|
50
|
+
} // namespace facebook
|
|
51
|
+
#endif
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#include "ShadowNodes.h"
|
|
26
|
+
|
|
27
|
+
namespace facebook {
|
|
28
|
+
namespace react {
|
|
29
|
+
|
|
30
|
+
const char RNC_SLIDER_COMPONENT_NAME[] = "RNCSlider";
|
|
31
|
+
|
|
32
|
+
} // namespace react
|
|
33
|
+
} // namespace facebook
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
#ifndef SHADOWNODES_SLIDER_H
|
|
25
|
+
#define SHADOWNODES_SLIDER_H
|
|
26
|
+
#pragma once
|
|
27
|
+
|
|
28
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
29
|
+
#include <react/renderer/components/view/ViewShadowNode.h>
|
|
30
|
+
#include <jsi/jsi.h>
|
|
31
|
+
#include "EventEmitters.h"
|
|
32
|
+
#include "Props.h"
|
|
33
|
+
|
|
34
|
+
namespace facebook {
|
|
35
|
+
namespace react {
|
|
36
|
+
|
|
37
|
+
JSI_EXPORT extern const char RNC_SLIDER_COMPONENT_NAME[32];
|
|
38
|
+
|
|
39
|
+
using RNCSliderShadowNode = ConcreteViewShadowNode<
|
|
40
|
+
RNC_SLIDER_COMPONENT_NAME,
|
|
41
|
+
RNCSliderProps,
|
|
42
|
+
RNCSliderEventEmitter>;
|
|
43
|
+
|
|
44
|
+
} // namespace react
|
|
45
|
+
} // namespace facebook
|
|
46
|
+
#endif
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
#ifndef SLIDEREVENTEMIREQUESTHANDLER_H
|
|
25
|
+
#define SLIDEREVENTEMIREQUESTHANDLER_H
|
|
26
|
+
#pragma once
|
|
27
|
+
|
|
28
|
+
#include "RNOH/ArkJS.h"
|
|
29
|
+
#include "RNOH/EventEmitRequestHandler.h"
|
|
30
|
+
#include "EventEmitters.h"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
using namespace facebook;
|
|
34
|
+
namespace rnoh {
|
|
35
|
+
|
|
36
|
+
enum SliderEventType {
|
|
37
|
+
VALUE_CHANGE = 0,
|
|
38
|
+
SLIDING_START = 1,
|
|
39
|
+
SLIDING_COMPLETE = 2
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
SliderEventType getSliderEventType(ArkJS &arkJs, napi_value eventObject)
|
|
43
|
+
{
|
|
44
|
+
auto eventType = arkJs.getString(arkJs.getObjectProperty(eventObject, "type"));
|
|
45
|
+
if (eventType == "SliderValueChange") {
|
|
46
|
+
return SliderEventType::VALUE_CHANGE;
|
|
47
|
+
} else if (eventType == "SliderSlidingStart") {
|
|
48
|
+
return SliderEventType::SLIDING_START;
|
|
49
|
+
} else if (eventType == "SliderSlidingComplete") {
|
|
50
|
+
return SliderEventType::SLIDING_COMPLETE;
|
|
51
|
+
} else {
|
|
52
|
+
throw std::runtime_error("Unknown Slider event type");
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
class SliderEventEmitRequestHandler : public EventEmitRequestHandler {
|
|
57
|
+
public:
|
|
58
|
+
void handleEvent(EventEmitRequestHandler::Context const &ctx) override
|
|
59
|
+
{
|
|
60
|
+
if (ctx.eventName != "RNCSlider") {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
ArkJS arkJs(ctx.env);
|
|
64
|
+
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<react::RNCSliderEventEmitter>(ctx.tag);
|
|
65
|
+
if (eventEmitter == nullptr) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
auto eventType = getSliderEventType(arkJs, ctx.payload);
|
|
69
|
+
switch (eventType) {
|
|
70
|
+
case SliderEventType::VALUE_CHANGE: {
|
|
71
|
+
facebook::react::Float value = arkJs.getDouble(arkJs.getObjectProperty(ctx.payload, "value"));
|
|
72
|
+
react::RNCSliderEventEmitter::OnChange event1 = {value};
|
|
73
|
+
eventEmitter->onChange(event1);
|
|
74
|
+
react::RNCSliderEventEmitter::OnRNCSliderValueChange event2 = {value};
|
|
75
|
+
eventEmitter->onRNCSliderValueChange(event2);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
case SliderEventType::SLIDING_START: {
|
|
79
|
+
facebook::react::Float value = arkJs.getDouble(arkJs.getObjectProperty(ctx.payload, "value"));
|
|
80
|
+
react::RNCSliderEventEmitter::OnRNCSliderSlidingStart event = {value};
|
|
81
|
+
eventEmitter->onRNCSliderSlidingStart(event);
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case SliderEventType::SLIDING_COMPLETE: {
|
|
85
|
+
facebook::react::Float value = arkJs.getDouble(arkJs.getObjectProperty(ctx.payload, "value"));
|
|
86
|
+
react::RNCSliderEventEmitter::OnRNCSliderSlidingComplete event = {value};
|
|
87
|
+
eventEmitter->onRNCSliderSlidingComplete(event);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
default:
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
} // namespace rnoh
|
|
96
|
+
#endif
|