已开启
fix:更新readme属性类型,移除opacity不需要的平台代码,增加库example #8
fix:更新readme属性类型,移除opacity不需要的平台代码,增加库example #8
已开启
yanPeng创建于 8月7日
共 51 个文件变更+1181-313
@@ -35,3 +35,7 @@ local.properties
35node_modules/35node_modules/
36npm-debug.log36npm-debug.log
37lib37lib
38+ 
39+#LOCK
40+package-lock.json
41+yarn.lock
@@ -25,3 +25,4 @@ DerivedData
25#25#
26node_modules/26node_modules/
27npm-debug.log27npm-debug.log
28+Example/
@@ -0,0 +1,6 @@
1+ 
2+[android]
3+ target = Google Inc.:Google APIs:23
4+ 
5+[maven_repositories]
6+ central = https://repo1.maven.org/maven2
@@ -0,0 +1,19 @@
1+/*
2+ * Copyright (c) 2026 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",
9+ "rules": {
10+ "react-native/no-inline-styles": "off",
11+ "react/no-unstable-nested-components": "off",
12+ "react/react-in-jsx-scope": "off",
13+ "@typescript-eslint/no-unused-vars": "warn",
14+ "react-hooks/exhaustive-deps": "off",
15+ "radix": "off",
16+ "prettier/prettier": "warn",
17+ "max-lines": "off"
18+ }
19+}
@@ -0,0 +1,75 @@
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 polyfills
9+node_modules/react-native/Libraries/polyfills/.*
10+ 
11+; These should not be required directly
12+; require from fbjs/lib instead: require('fbjs/lib/warning')
13+node_modules/warning/.*
14+ 
15+; Flow doesn't support platforms
16+.*/Libraries/Utilities/LoadingView.js
17+ 
18+[untyped]
19+.*/node_modules/@react-native-community/cli/.*/.*
20+ 
21+[include]
22+ 
23+[libs]
24+node_modules/react-native/Libraries/react-native/react-native-interface.js
25+node_modules/react-native/flow/
26+ 
27+[options]
28+emoji=true
29+ 
30+esproposal.optional_chaining=enable
31+esproposal.nullish_coalescing=enable
32+ 
33+module.file_ext=.js
34+module.file_ext=.json
35+module.file_ext=.ios.js
36+ 
37+munge_underscores=true
38+ 
39+module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
40+module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
41+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'
42+ 
43+suppress_type=$FlowIssue
44+suppress_type=$FlowFixMe
45+suppress_type=$FlowFixMeProps
46+suppress_type=$FlowFixMeState
47+ 
48+suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
49+suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
50+suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
51+ 
52+[lints]
53+sketchy-null-number=warn
54+sketchy-null-mixed=warn
55+sketchy-number=warn
56+untyped-type-import=warn
57+nonstrict-import=warn
58+deprecated-type=warn
59+unsafe-getters-setters=warn
60+inexact-spread=warn
61+unnecessary-invariant=warn
62+signature-verification-failure=warn
63+deprecated-utility=error
64+ 
65+[strict]
66+deprecated-type
67+nonstrict-import
68+sketchy-null
69+unclear-type
70+unsafe-getters-setters
71+untyped-import
72+untyped-type-import
73+ 
74+[version]
75+^0.105.0
@@ -0,0 +1 @@
1+*.pbxproj -text
@@ -0,0 +1,77 @@
1+.husky
2+bundle.harmony.js
3+package-lock.json
4+*.hbc
5+lintCppResult.txt
6+ 
7+# ---
8+ 
9+# OSX
10+#
11+.DS_Store
12+ 
13+# Xcode
14+#
15+build/
16+*.pbxuser
17+!default.pbxuser
18+*.mode1v3
19+!default.mode1v3
20+*.mode2v3
21+!default.mode2v3
22+*.perspectivev3
23+!default.perspectivev3
24+xcuserdata
25+*.xccheckout
26+*.moved-aside
27+DerivedData
28+*.hmap
29+*.ipa
30+*.xcuserstate
31+ 
32+# Android/IntelliJ
33+#
34+build/
35+.idea
36+.gradle
37+local.properties
38+*.iml
39+*.hprof
40+.cxx/
41+*.keystore
42+!debug.keystore
43+BuildProfile.ets
44+ 
45+# node.js
46+#
47+node_modules/
48+npm-debug.log
49+yarn-error.log
50+ 
51+# fastlane
52+#
53+# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
54+# screenshots whenever they are needed.
55+# For more information about the recommended setup visit:
56+# https://docs.fastlane.tools/best-practices/source-control/
57+ 
58+**/fastlane/report.xml
59+**/fastlane/Preview.html
60+**/fastlane/screenshots
61+**/fastlane/test_output
62+ 
63+# Bundle artifact
64+*.jsbundle
65+ 
66+# CocoaPods
67+/ios/Pods/
68+ 
69+# Harmony bundle (build output)
70+harmony/entry/src/main/resources/rawfile/bundle.harmony.js
71+ 
72+# Ruby / CocoaPods
73+/vendor/bundle/
74+ 
75+# Temporary files created by Metro to check the health of the file watcher
76+.metro-health-check*
77+*.htrace
@@ -0,0 +1,6 @@
1+module.exports = {
2+ bracketSpacing: false,
3+ jsxBracketSameLine: true,
4+ singleQuote: true,
5+ trailingComma: 'all',
6+};
@@ -2,24 +2,39 @@
2 2 
3var React = require('react');3var React = require('react');
4var ReactNative = require('react-native');4var ReactNative = require('react-native');
5-var Slider = require('../src/Slider');5+var SliderModule = require('@react-native-ohos/react-native-slider');
6+var Slider = SliderModule.default || SliderModule;
6var {7var {
7 AppRegistry,8 AppRegistry,
8 StyleSheet,9 StyleSheet,
9 Text,10 Text,
10 ScrollView,11 ScrollView,
11 View,12 View,
12- SliderIOS,
13} = ReactNative;13} = ReactNative;
14 14 
15var DEFAULT_VALUE = 0.2;15var DEFAULT_VALUE = 0.2;
16 16 
17-var SliderContainer = React.createClass({17+class SliderContainer extends React.Component {
18- getInitialState() {18+ constructor(props) {
19- return {19+ super(props);
20+ this.state = {
20 value: DEFAULT_VALUE,21 value: DEFAULT_VALUE,
21 };22 };
22- },23+ }
24+ 
25+ _renderChildren() {
26+ return React.Children.map(this.props.children, (child) => {
27+ if (child.type === Slider) {
28+ var value = this.state.value;
29+ return React.cloneElement(child, {
30+ value: value,
31+ onValueChange: (val) => this.setState({value: val}),
32+ });
33+ } else {
34+ return child;
35+ }
36+ });
37+ }
23 38 
24 render() {39 render() {
25 var value = this.state.value;40 var value = this.state.value;
@@ -33,38 +48,14 @@ var SliderContainer = React.createClass({
33 {this._renderChildren()}48 {this._renderChildren()}
34 </View>49 </View>
35 );50 );
36- },51+ }
37- 52+}
38- _renderChildren() {
39- return React.Children.map(this.props.children, (child) => {
40- if (child.type === Slider
41- || child.type === ReactNative.Slider) {
42- var value = this.state.value;
43- return React.cloneElement(child, {
44- value: value,
45- onValueChange: (val) => this.setState({value: val}),
46- });
47- } else {
48- return child;
49- }
50- });
51- },
52-});
53- 
54-var SliderExample = React.createClass({
55- getInitialState() {
56- return {
57- //value: 0.2,
58- };
59- },
60 53 
54+class SliderExample extends React.Component {
61 render() {55 render() {
62 return (56 return (
63 <ScrollView contentContainerStyle={styles.container}>57 <ScrollView contentContainerStyle={styles.container}>
64- <SliderContainer caption='<React.Slider/>'>58+ <SliderContainer caption='<Slider/> (default)'>
65- <ReactNative.Slider />
66- </SliderContainer>
67- <SliderContainer caption='<Slider/> with default style'>
68 <Slider />59 <Slider />
69 </SliderContainer>60 </SliderContainer>
70 <SliderContainer caption='<Slider/> with min, max and custom tints '>61 <SliderContainer caption='<Slider/> with min, max and custom tints '>
@@ -145,8 +136,8 @@ var SliderExample = React.createClass({
145 </SliderContainer>136 </SliderContainer>
146 </ScrollView>137 </ScrollView>
147 );138 );
148- },139+ }
149-});140+}
150 141 
151var styles = StyleSheet.create({142var styles = StyleSheet.create({
152 container: {143 container: {
@@ -319,3 +310,4 @@ var customStyles9 = StyleSheet.create({
319});310});
320 311 
321AppRegistry.registerComponent('Example', () => SliderExample);312AppRegistry.registerComponent('Example', () => SliderExample);
313+module.exports = SliderExample;
@@ -0,0 +1,4 @@
1+{
2+ "name": "Example",
3+ "displayName": "Example"
4+}
@@ -0,0 +1,3 @@
1+module.exports = {
2+ presets: ['module:@react-native/babel-preset'],
3+};
@@ -0,0 +1,9 @@
1+/*
2+ * Copyright (c) 2026 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 React from 'react';
8+ 
9+export const AppParamsContext = React.createContext(undefined);
@@ -0,0 +1,25 @@
1+# it may cause some issues when building the project when switching branches
2+package-lock.json
3+# we add this because we want to keep the signing configs out of git
4+/build-profile.json5
5+ 
6+rnoh_modules
7+ 
8+**/oh-package-lock.json5
9+# ---
10+ 
11+/node_modules
12+/local.properties
13+/.idea
14+**/build
15+/.hvigor
16+.cxx
17+/.clangd
18+/.clang-format
19+/.clang-tidy
20+/oh_modules
21+**/rawfile/bundle.harmony.js
22+**/rawfile/assets
23+hvigorw
24+hvigorw.bat
25+hvigor/hvigor-wrapper.js
@@ -0,0 +1,10 @@
1+{
2+ "app": {
3+ "bundleName": "com.example.jeanSlider",
4+ "vendor": "example",
5+ "versionCode": 1000000,
6+ "versionName": "1.0.0",
7+ "icon": "$media:app_icon",
8+ "label": "$string:app_name"
9+ }
10+}
@@ -0,0 +1,8 @@
1+{
2+ "string": [
3+ {
4+ "name": "app_name",
5+ "value": "Jean Slider Example"
6+ }
7+ ]
8+}
@@ -0,0 +1,35 @@
1+{
2+ "app": {
3+ "products": [
4+ {
5+ "name": 'default',
6+ "signingConfig": 'default',
7+ "compatibleSdkVersion": '5.0.0(12)',
8+ "runtimeOS": 'HarmonyOS'
9+ },
10+ ],
11+ "buildModeSet": [
12+ {
13+ "name": 'debug',
14+ },
15+ {
16+ "name": 'release',
17+ },
18+ ],
19+ "signingConfigs": []
20+ },
21+ "modules": [
22+ {
23+ "name": 'entry',
24+ "srcPath": './entry',
25+ "targets": [
26+ {
27+ "name": 'default',
28+ "applyToProducts": [
29+ 'default'
30+ ],
31+ },
32+ ],
33+ }
34+ ],
35+}
@@ -0,0 +1,32 @@
1+{
2+ "files": ["**/*.ts", "**/*.ets"],
3+ "ignore": [
4+ "**/ohosTest/**/*",
5+ "**/node_modules/**/*",
6+ "**/hvigorfile.ts",
7+ "**/node_modules/**/*",
8+ "**/oh_modules/**/*",
9+ "**/build/**/*",
10+ "**/.preview/**/*"
11+ ],
12+ "plugins": ["@typescript-eslint"],
13+ "ruleSet": [],
14+ "rules": {
15+ "@typescript-eslint/await-thenable": "warn",
16+ "@typescript-eslint/consistent-type-imports": "warn",
17+ "@typescript-eslint/explicit-function-return-type": "warn",
18+ "@typescript-eslint/explicit-module-boundary-types": "warn",
19+ "@typescript-eslint/no-dynamic-delete": "warn",
20+ "@typescript-eslint/no-explicit-any": "warn",
21+ "@typescript-eslint/no-for-in-array": "warn",
22+ "@typescript-eslint/no-this-alias": "warn",
23+ "@typescript-eslint/no-unnecessary-type-constraint": "warn",
24+ "@typescript-eslint/no-unsafe-argument": "warn",
25+ "@typescript-eslint/no-unsafe-assignment": "warn",
26+ "@typescript-eslint/no-unsafe-call": "warn",
27+ "@typescript-eslint/no-unsafe-member-access": "warn",
28+ "@typescript-eslint/no-unsafe-return": "warn",
29+ "@typescript-eslint/prefer-literal-enum-member": "warn"
30+ },
31+ "overrides": []
32+}
@@ -0,0 +1,8 @@
1+/node_modules
2+/oh_modules
3+/.preview
4+/build
5+/.cxx
6+/.test
7+package-lock.json
8+/assets
@@ -0,0 +1,23 @@
1+{
2+ "apiType": 'stageMode',
3+ "buildOption": {
4+ "externalNativeOptions": {
5+ "path": "./src/main/cpp/CMakeLists.txt",
6+ "arguments": "",
7+ "cppFlags": "-s",
8+ "abiFilters": [
9+ "arm64-v8a",
10+ "x86_64"
11+ ]
12+ },
13+ },
14+ "targets": [
15+ {
16+ "name": "default",
17+ "runtimeOS": "HarmonyOS"
18+ },
19+ {
20+ "name": "ohosTest",
21+ }
22+ ]
23+}
@@ -0,0 +1,8 @@
1+/*
2+ * Copyright (c) 2026 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+// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
8+export { hapTasks } from '@ohos/hvigor-ohos-plugin';
@@ -0,0 +1,10 @@
1+{
2+ "license": "ISC",
3+ "devDependencies": {},
4+ "name": "entry",
5+ "description": "example description",
6+ "version": "1.0.0",
7+ "dependencies": {
8+ "@rnoh/react-native-openharmony": "file:../../node_modules/@react-native-oh/react-native-harmony/react_native_openharmony.har"
9+ }
10+}
@@ -0,0 +1,2 @@
1+jsbundle.h
2+generated/
@@ -0,0 +1,28 @@
1+project(rnapp)
2+cmake_minimum_required(VERSION 3.4.1)
3+set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
4+set(OH_MODULES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
5+set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
6+set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
7+set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
8+set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp")
9+set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
10+add_compile_definitions(WITH_HITRACE_SYSTRACE)
11+ 
12+add_subdirectory("${RNOH_CPP_DIR}" ./rn)
13+ 
14+# RNOH_BEGIN: manual_package_linking_1
15+# RNOH_END: manual_package_linking_1
16+ 
17+file(GLOB GENERATED_CPP_FILES CONFIGURE_DEPENDS "./generated/*.cpp")
18+ 
19+add_library(rnoh_app SHARED
20+ ${GENERATED_CPP_FILES}
21+ "./PackageProvider.cpp"
22+ "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
23+)
24+ 
25+target_link_libraries(rnoh_app PUBLIC rnoh)
26+ 
27+# RNOH_BEGIN: manual_package_linking_2
28+# RNOH_END: link_packages
@@ -0,0 +1,15 @@
1+// Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
2+// Use of this source code is governed by a MIT license that can be
3+// found in the LICENSE file.
4+ 
5+#include "RNOH/PackageProvider.h"
6+#include "generated/RNOHGeneratedPackage.h"
7+ 
8+using namespace rnoh;
9+ 
10+std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx)
11+{
12+ return {
13+ std::make_shared<RNOHGeneratedPackage>(ctx), // generated by codegen v1
14+ };
15+}
@@ -0,0 +1,15 @@
1+/*
2+ * Copyright (c) 2026 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+import type {RNPackageContext, RNPackage} from '@rnoh/react-native-openharmony/ts';
9+ 
10+ 
11+export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
12+ return [
13+ 
14+ ];
15+}
@@ -0,0 +1,13 @@
1+/*
2+ * Copyright (c) 2026 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 { RNAbility } from '@rnoh/react-native-openharmony';
8+ 
9+export default class EntryAbility extends RNAbility {
10+ getPagePath() {
11+ return 'pages/Index';
12+ }
13+}
@@ -0,0 +1,92 @@
1+/*
2+ * Copyright (c) 2026 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 {
8+ AnyJSBundleProvider,
9+ ComponentBuilderContext,
10+ FileJSBundleProvider,
11+ MetroJSBundleProvider,
12+ ResourceJSBundleProvider,
13+ RNApp,
14+ RNOHErrorDialog,
15+ RNOHLogger,
16+ TraceJSBundleProviderDecorator,
17+ RNOHCoreContext
18+} from '@rnoh/react-native-openharmony';
19+import { createRNPackages } from '../RNPackagesFactory';
20+ 
21+ 
22+const arkTsComponentNames: Array<string> = [
23+ 
24+];
25+@Builder
26+export function buildCustomRNComponent(ctx: ComponentBuilderContext) {
27+ // There seems to be a problem with the placement of ArkTS components in mixed mode. Nested Stack temporarily avoided.
28+ Stack(){
29+ }
30+ .position({x:0, y: 0})
31+ 
32+}
33+ 
34+const wrappedCustomRNComponentBuilder = wrapBuilder(buildCustomRNComponent)
35+ 
36+@Entry
37+@Component
38+struct Index {
39+ @StorageLink('RNOHCoreContext') private rnohCoreContext: RNOHCoreContext | undefined = undefined
40+ @State shouldShow: boolean = false
41+ private logger!: RNOHLogger
42+ 
43+ aboutToAppear() {
44+ this.logger = this.rnohCoreContext!.logger.clone("Index")
45+ const stopTracing = this.logger.clone("aboutToAppear").startTracing()
46+ 
47+ this.shouldShow = true
48+ stopTracing()
49+ }
50+ 
51+ onBackPress(): boolean | undefined {
52+ // NOTE: this is required since `Ability`'s `onBackPressed` function always
53+ // terminates or puts the app in the background, but we want Ark to ignore it completely
54+ // when handled by RN
55+ this.rnohCoreContext!.dispatchBackPress()
56+ return true
57+ }
58+ 
59+ build() {
60+ Column() {
61+ if (this.rnohCoreContext && this.shouldShow) {
62+ if (this.rnohCoreContext?.isDebugModeEnabled) {
63+ RNOHErrorDialog({ ctx: this.rnohCoreContext })
64+ }
65+ RNApp({
66+ rnInstanceConfig: {
67+ createRNPackages,
68+ enableNDKTextMeasuring: true,
69+ enableBackgroundExecutor: false,
70+ enableCAPIArchitecture: true,
71+ arkTsComponentNames: arkTsComponentNames,
72+ },
73+ appKey: "Example",
74+ wrappedCustomRNComponentBuilder: wrappedCustomRNComponentBuilder,
75+ onSetUp: (rnInstance) => {
76+ rnInstance.enableFeatureFlag("ENABLE_RN_INSTANCE_CLEAN_UP")
77+ },
78+ jsBundleProvider: new TraceJSBundleProviderDecorator(
79+ new AnyJSBundleProvider([
80+ new MetroJSBundleProvider(),
81+ new FileJSBundleProvider('/data/storage/el2/base/files/bundle.harmony.js'),
82+ new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'),
83+ new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'bundle.harmony.js')
84+ ]),
85+ this.rnohCoreContext.logger),
86+ })
87+ }
88+ }
89+ .height('100%')
90+ .width('100%')
91+ }
92+}
@@ -0,0 +1,36 @@
1+{
2+ "module": {
3+ "name": "entry",
4+ "type": "entry",
5+ "description": "$string:module_desc",
6+ "mainElement": "EntryAbility",
7+ "deviceTypes": [
8+ "default"
9+ ],
10+ "deliveryWithInstall": true,
11+ "installationFree": false,
12+ "pages": "$profile:main_pages",
13+ "abilities": [
14+ {
15+ "name": "EntryAbility",
16+ "srcEntry": "./ets/entryability/EntryAbility.ets",
17+ "description": "$string:EntryAbility_desc",
18+ "icon": "$media:icon",
19+ "label": "$string:EntryAbility_label",
20+ "startWindowIcon": "$media:icon",
21+ "startWindowBackground": "$color:start_window_background",
22+ "visible": true,
23+ "skills": [
24+ {
25+ "entities": [
26+ "entity.system.home"
27+ ],
28+ "actions": [
29+ "action.system.home"
30+ ]
31+ }
32+ ]
33+ }
34+ ]
35+ }
36+}
@@ -0,0 +1,8 @@
1+{
2+ "color": [
3+ {
4+ "name": "start_window_background",
5+ "value": "#FFFFFF"
6+ }
7+ ]
8+}
@@ -0,0 +1,16 @@
1+{
2+ "string": [
3+ {
4+ "name": "module_desc",
5+ "value": "module description"
6+ },
7+ {
8+ "name": "EntryAbility_desc",
9+ "value": "description"
10+ },
11+ {
12+ "name": "EntryAbility_label",
13+ "value": "Jean Slider Example"
14+ }
15+ ]
16+}
@@ -0,0 +1,5 @@
1+{
2+ "src": [
3+ "pages/Index"
4+ ]
5+}
@@ -0,0 +1,12 @@
1+$directoryPath = Split-Path -Parent $MyInvocation.MyCommand.Path
2+$filePaths = Get-ChildItem $directoryPath -Recurse -Include *.h, *.cpp |
3+Where-Object {
4+ $_.DirectoryName -notmatch 'third-party' -and
5+ $_.DirectoryName -notmatch 'patches' -and
6+ $_.DirectoryName -notmatch 'node_modules' -and
7+ $_.DirectoryName -notmatch '.cxx' -and
8+ $_.DirectoryName -notmatch 'build'
9+}
10+foreach ($filePath in $filePaths) {
11+ & "clang-format.exe" -style=file -i $filePath.FullName
12+}
@@ -0,0 +1 @@
1+*.tgz
@@ -0,0 +1,21 @@
1+{
2+ "modelVersion": "5.0.0",
3+ "dependencies": {
4+ },
5+ "execution": {
6+ // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */
7+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
8+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
9+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
10+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
11+ },
12+ "logging": {
13+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
14+ },
15+ "debugging": {
16+ "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
17+ },
18+ "nodeOptions": {
19+ // "maxOldSpaceSize": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */
20+ }
21+}
@@ -0,0 +1,7 @@
1+/*
2+ * Copyright (c) 2026 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+export { appTasks } from '@ohos/hvigor-ohos-plugin';
@@ -0,0 +1,14 @@
1+{
2+ "modelVersion": "5.0.0",
3+ "license": "ISC",
4+ "devDependencies": {
5+ "@ohos/hypium": "1.0.6"
6+ },
7+ "name": "rnoh",
8+ "description": "example description",
9+ "version": "1.0.0",
10+ "overrides": {
11+ "@rnoh/react-native-openharmony": "file:../node_modules/@react-native-oh/react-native-harmony/react_native_openharmony.har"
12+ },
13+ "dynamicDependencies": {}
14+}
@@ -0,0 +1,11 @@
1+/*
2+ * Copyright (c) 2026 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 { AppRegistry } from 'react-native';
8+import App from './app';
9+import { name as appName } from './app.json';
10+ 
11+AppRegistry.registerComponent(appName, () => App);
@@ -0,0 +1,11 @@
1+/*
2+ * Copyright (c) 2026 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+/** @type {import('ts-jest').JestConfigWithTsJest} */
8+module.exports = {
9+ preset: 'ts-jest',
10+ testEnvironment: 'node',
11+};
@@ -0,0 +1,30 @@
1+/*
2+ * Copyright (c) 2026 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+const {mergeConfig, getDefaultConfig} = require('@react-native/metro-config');
8+const {createHarmonyMetroConfig} = require('@react-native-oh/react-native-harmony/metro.config');
9+ 
10+/**
11+ * @type {import("metro-config").ConfigT}
12+ */
13+const config = {
14+ transformer: {
15+ getTransformOptions: async () => ({
16+ transform: {
17+ experimentalImportSupport: false,
18+ inlineRequires: true,
19+ },
20+ }),
21+ },
22+};
23+ 
24+module.exports = mergeConfig(
25+ getDefaultConfig(__dirname),
26+ createHarmonyMetroConfig({
27+ reactNativeHarmonyPackageName: '@react-native-oh/react-native-harmony',
28+ }),
29+ config,
30+);
@@ -0,0 +1,58 @@
1+{
2+ "name": "Example",
3+ "version": "0.0.1",
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/react-native-slider && npm run pack:pkg && npm i @react-native-ohos/react-native-slider@file:../react-native-ohos-react-native-slider-0.12.0.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 --legacy-peer-deps && npm run dev"
16+ },
17+ "dependencies": {
18+ "@gorhom/portal": "^1.0.14",
19+ "@react-native-ohos/react-native-slider": "file:../react-native-ohos-react-native-slider-0.12.0.tgz",
20+ "react": "18.3.1",
21+ "react-native": "^0.77.1",
22+ "@react-native-oh/react-native-harmony": "npm:@react-native-oh/react-native-harmony@0.77.72"
23+ },
24+ "devDependencies": {
25+ "@babel/core": "^7.25.2",
26+ "@babel/preset-env": "^7.25.3",
27+ "@babel/runtime": "^7.25.0",
28+ "@react-native-community/cli": "15.0.1",
29+ "@react-native-community/eslint-config": "^3.2.0",
30+ "@react-native/babel-preset": "0.77.1",
31+ "@react-native/eslint-config": "0.77.1",
32+ "@react-native/metro-config": "^0.77.1",
33+ "@react-native/typescript-config": "0.77.1",
34+ "@react-native-oh/react-native-harmony-cli": "npm:@react-native-oh/react-native-harmony-cli@0.77.72",
35+ "@tsconfig/react-native": "^3.0.0",
36+ "@types/d3-scale-chromatic": "^3.0.0",
37+ "@types/jest": "^29.5.13",
38+ "@types/react": "^18.2.6",
39+ "@types/react-test-renderer": "^18.0.0",
40+ "babel-jest": "^29.6.3",
41+ "eslint": "^8.19.0",
42+ "jest": "^29.7.0",
43+ "metro-react-native-babel-preset": "0.76.8",
44+ "prettier": "2.8.8",
45+ "react-test-renderer": "18.3.1",
46+ "typescript": "5.5.4"
47+ },
48+ "overrides": {
49+ "@react-native-community/cli": "15.0.1"
50+ },
51+ "resolutions": {
52+ "@react-native-community/cli": "15.0.1"
53+ },
54+ "engines": {
55+ "node": ">=18"
56+ }
57+}
58+ 
@@ -0,0 +1,11 @@
1+/*
2+ * Copyright (c) 2026 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+module.exports = {
8+ project: {
9+ },
10+ assets: ['./assets/fonts/'],
11+};
@@ -0,0 +1,46 @@
1+/*
2+ * Copyright (c) 2026 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,14 @@
1+{
2+ "extends": "@react-native/typescript-config/tsconfig.json",
3+ "compilerOptions": {
4+ "jsx": "react-native",
5+ "paths": {
6+ "react-native": [
7+ "./node_modules/@react-native-oh/react-native-harmony"
8+ ],
9+ },
10+ },
11+ "exclude": [
12+ "harmony"
13+ ]
14+}
AOAT.xml+46-0
@@ -0,0 +1,46 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<configuration>
3+ <oatconfig>
4+ <licensefile>LICENSE</licensefile>
5+ <policylist>
6+ <policy name="projectPolicy" desc="">
7+ <policyitem type="license" name="MIT" path=".*" desc="license under the MIT"/>
8+ </policy>
9+ <policy name="projectPolicy" desc="">
10+ <policyitem type="compatibility" name="GPL-2.0+" path=".*" desc="Process that runs independently, invoked by the X process."/>
11+ <policyitem type="compatibility" name="Apache-2.0" path=".*" desc="不影响兼容性"/>
12+ <policyitem type="compatibility" name="BSDStyleLicense" path=".*" desc="不影响兼容性" />
13+ <policyitem type="compatibility" name="MIT" path=".*" desc="不影响兼容性" />
14+ <policyitem type="compatibility" name="GPLStyleLicense" path=".*" desc="不影响兼容性" />
15+ </policy>
16+ </policylist>
17+ <filefilterlist>
18+ <filefilter name="copyrightPolicyFilter" desc="Filters for compatibility,license header policies">
19+ <filteritem type="filename" name="LICENSE" desc="版权文件,不添加许可证头"/>
20+ <filteritem type="filepath" name="src/**/*" desc="上游源文件,不添加许可证头"/>
21+ <filteritem type="filepath" name="Example/**/*" desc="上游源文件,不添加许可证头"/>
22+ <filteritem type="filepath" name="packages/**/*" desc="上游源文件,不添加许可证头"/>
23+ <filteritem type="filename" name=".npmignore" desc="工程配置文件,不手动修改"/>
24+ <filteritem type="filename" name=".eslintrc" desc="工程配置文件,不手动修改"/>
25+ <filteritem type="filepath" name="buildEnv.sh" desc="工程模板,不修改版权头,以防有修改版权风险" />
26+ </filefilter>
27+ <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
28+ <filteritem type="filename" name="LICENSE" desc="版权文件,不添加许可证头"/>
29+ <filteritem type="filepath" name="src/**/*" desc="上游源文件,不添加许可证头"/>
30+ <filteritem type="filepath" name="Example/**/*" desc="上游源文件,不添加许可证头"/>
31+ <filteritem type="filepath" name="packages/**/*" desc="上游源文件,不添加许可证头"/>
32+ <filteritem type="filename" name=".npmignore" desc="工程配置文件,不手动修改"/>
33+ <filteritem type="filename" name=".eslintrc" desc="工程配置文件,不手动修改"/>
34+ <filteritem type="filepath" name="buildEnv.sh" desc="工程模板,不修改版权头,以防有修改版权风险" />
35+ </filefilter>
36+ 
37+ <filefilter name="binaryFileTypePolicyFilter" desc="Filters for copyright header policies">
38+ <filteritem type="filename" name="*.gif" desc="上游资源文件"/>
39+ <filteritem type="filename" name="*.jar" desc="上游资源文件" />
40+ <filteritem type="filename" name="*.png" desc="上游资源文件" />
41+ <filteritem type="filename" name="*.keystore" desc="上游资源文件" />
42+ <filteritem type="filename" name="*.ico" desc="上游资源文件" />
43+ </filefilter>
44+ </filefilterlist>
45+ </oatconfig>
46+</configuration>
MREADME.md+64-66
@@ -1,52 +1,52 @@
1-> 文档模板:v0.4.11+> Document Template:v0.4.2
2 2 
3<p align="center">3<p align="center">
4 <h1 align="center"> <code>react-native-slider</code> </h1>4 <h1 align="center"> <code>react-native-slider</code> </h1>
5</p>5</p>
6 6 
7-本项目基于 [react-native-slider](https://github.com/jeanregisser/react-native-slider) 开发。7+This project is based on [react-native-slider](https://github.com/jeanregisser/react-native-slider).
8 8 
9-该第三方库的仓库已迁移至 Gitcode,且支持直接从 npm 下载,新的包名为:`@react-native-ohos/react-native-slider`, 版本所属关系如下:9+This third-party library has been migrated to Gitcode and is now available for direct download from npm, the new package name is: `@react-native-ohos/react-native-slider`, The version correspondence details are as follows:
10 10 
11-| 三方库名称 | 三方库版本 | 发布信息 | 支持RN版本 | Autolink | 编译API版本 | 社区基线版本 | npm地址 |11+| Name | Version(Npm Address) | Release Information | Supported RN Version | Supported Autolink | Compile API Version | Community Baseline Version | Source code address |
12-| ------------ | ------------ | ------------------------------ | ------------- | ------------- |------------------------ | ------------- | ------------- |12+| --------------| -------------- | ------------------------------ | ------------- | ------------- |------------------------ | ------------ | ------------- |
13-| @react-native-ohos/react-native-slider | [~0.12.0](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/tree/br_rnoh0.77) | [Gitcode Releases](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/releases) | 0.77.* | 否 | API12+ | 0.11.0 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/react-native-slider) |13+| @react-native-ohos/react-native-slider | [~0.12.0](https://www.npmjs.com/package/@react-native-ohos/react-native-slider) | [Gitcode Releases](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/releases) | 0.77.* | No | API12+ | 0.11.0 | [br_rnoh0.77](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/tree/br_rnoh0.77) |
14 14 
15-## 简介15+## Introduction
16 16 
17-Slider 组件用于 React Native。<br/>17+Slider component for React Native.<br/>
18-Slider 是一个纯 JavaScript 实现的滑动条组件,用于在指定范围内选择数值,并支持自定义轨道、滑块样式与交互回调!<br/>18+Slider is a pure JavaScript slider component for selecting a value within a specified range, with customizable track, thumb styles, and interaction callbacks!<br/>
19-开发者可以在无需依赖平台原生 Slider 的情况下,创造并交付一致的可视化数值选择体验。19+Developers can create and ship a consistent visual value selection experience across platforms without relying on platform-native Slider components.
20 20 
21-## 下载安装21+## Installation
22 22 
23-进入到工程目录并输入以下命令:23+Go to the project directory and execute the following instruction:
24 24 
25-#### **npm**25+**npm**
26 26 
27```bash27```bash
28npm i @react-native-ohos/react-native-slider28npm i @react-native-ohos/react-native-slider
29```29```
30 30 
31-#### **yarn**31+**yarn**
32 32 
33```bash33```bash
34yarn add @react-native-ohos/react-native-slider34yarn add @react-native-ohos/react-native-slider
35```35```
36 36 
37-## 约束与限制37+## Constraints & Limitations
38 38 
39-### 兼容性39+### Compatibility
40 40 
41-本文档内容基于以下版本验证通过:41+This document is verified based on the following versions:
42 42 
431. RNOH: 0.77.18; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.868; ROM: 6.0.0.112;431. RNOH: 0.77.18; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.868; ROM: 6.0.0.112;
44 44 
45-## 使用示例45+## Example
46 46 
47-下面的代码展示了这个库的基本使用场景:47+The following code shows the basic use scenario of the repository:
48 48 
49-> [!WARNING] 使用时 import 的库名不变。49+> [!WARNING] The name of the imported repository remains unchanged.
50 50 
51```tsx51```tsx
52import React, { useState} from 'react';52import React, { useState} from 'react';
@@ -55,7 +55,6 @@ import Slider from 'react-native-slider';
55 55 
56 56 
57export function SliderExample() {57export function SliderExample() {
58- const [isCheckerboardVisible, setIsCheckerboardVisible] = useState(false);
59 const [value, setValue] = useState(0.200);58 const [value, setValue] = useState(0.200);
60 return (59 return (
61 <View style={styles.sectionContainer}>60 <View style={styles.sectionContainer}>
@@ -86,7 +85,7 @@ export function SliderExample() {
86 thumbTintColor = '#1A9FF4'85 thumbTintColor = '#1A9FF4'
87 thumbTouchSize = {{width: 40, height: 40}}86 thumbTouchSize = {{width: 40, height: 40}}
88 onValueChange={(val: number) => {87 onValueChange={(val: number) => {
89- console.log('===Slider onValueChange: ' + value);88+ console.log('===Slider onValueChange: ' + val);
90 }}89 }}
91 90 
92 onSlidingStart={() => {91 onSlidingStart={() => {
@@ -125,7 +124,7 @@ export function SliderExample() {
125 <Button onPress={()=>{124 <Button onPress={()=>{
126 setValue(0.9);125 setValue(0.9);
127 }}126 }}
128- title="动画测试"127+ title="Animation test"
129 color="#841584"128 color="#841584"
130 />129 />
131 </View>130 </View>
@@ -153,59 +152,58 @@ const styles = StyleSheet.create({
153 });152 });
154```153```
155 154 
156-## 属性155+## Properties
157 156 
158-> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。157+> [!TIP] The **Platform** column indicates the platform where the properties are supported in the original third-party library.
159->
160-> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
161 158 
162-| Name | Description | Type | Required | Platform | HarmonyOS Support |159+> [!TIP] If the value of **HarmonyOS Support** is **yes**, it means that the HarmonyOS platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android.
163-| --------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | ----------- | ----------------- |
164-| value | 滑块的初始值。 | number | No | iOS Android | yes |
165-| disabled | 如果为 true,用户将无法移动滑块。 | bool | No | iOS Android | yes |
166-| minimumValue | 滑块的初始最小值。 | number | No | iOS Android | yes |
167-| maximumValue | 滑块的初始最大值。 | number | No | iOS Android | yes |
168-| step | 滑块的步长值。该值应在 0 到 (maximumValue - minimumValue) 之间。 | number | No | iOS Android | yes |
169-| minimumTrackTintColor | 滑块按钮左侧轨道的颜色。 | string | No | iOS Android | yes |
170-| maximumTrackTintColor | 滑块按钮右侧轨道的颜色。 | string | No | iOS Android | yes |
171-| thumbTintColor | 滑块按钮(thumb)的颜色。 | string | No | iOS Android | yes |
172-| thumbTouchSize | 允许移动滑块按钮的触摸区域大小。触摸区域的中心与可见的滑块按钮相同。这使得滑块按钮在视觉上可以很小,同时仍允许用户轻松移动它。 | object | No | iOS Android | yes |
173-| onValueChange | 当用户拖动滑块时持续调用的回调函数。 | function | No | iOS Android | yes |
174-| onSlidingStart | 当用户开始更改值时调用的回调函数(例如,当滑块被按下时)。 | function | No | iOS Android | yes |
175-| onSlidingComplete | 当用户完成更改值时调用的回调函数(例如,当滑块被释放时)。 | function | No | iOS Android | yes |
176-| style | 应用于滑块容器的样式。 | [style](http://facebook.github.io/react-native/docs/view.html#style) | No | iOS Android | yes |
177-| trackStyle | 应用于轨道的样式。 | [style](http://facebook.github.io/react-native/docs/view.html#style) | No | iOS Android | yes |
178-| thumbStyle | 应用于滑块按钮的样式。 | [style](http://facebook.github.io/react-native/docs/view.html#style) | No | iOS Android | yes |
179-| thumbImage | 为滑块按钮设置一张图片。 | [source](http://facebook.github.io/react-native/docs/image.html#source) | No | iOS Android | yes |
180-| debugTouchArea | 设置为 true 可以在视觉上看到绿色的滑块按钮触摸矩形区域。 | bool | No | iOS Android | yes |
181-| animateTransitions | 设置是否开启动画,为 true 时默认值'timing'。 | bool | No | iOS Android | yes |
182-| animationType | 设置为'spring' 或 'timing',以使用这两种动画类型之一,并使用默认的 [动画属性](https://facebook.github.io/react-native/docs/animations.html)。 | string | No | iOS Android | yes |
183-| animationConfig | 用于配置动画参数。这些参数与 [Animated 库](https://facebook.github.io/react-native/docs/animations.html) 中的参数相同。 | object | No | iOS Android | yes |
184 160 
185-## 遗留问题161+| Name | Description | Type | Required | Platform | HarmonyOS Support |
186-无162+|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------|----------|-------------|-------------------|
163+| value | Initial value of the slider. | number | No | iOS Android | yes |
164+| disabled | If true the user won't be able to move the slider. | boolean | No | iOS Android | yes |
165+| minimumValue | Initial minimum value of the slider. | number | No | iOS Android | yes |
166+| maximumValue | Initial maximum value of the slider. | number | No | iOS Android | yes |
167+| step | Step value of the slider. The value should be between 0 and (maximumValue - minimumValue). | number | No | iOS Android | yes |
168+| minimumTrackTintColor | The color used for the track to the left of the button. | string | No | iOS Android | yes |
169+| maximumTrackTintColor | The color used for the track to the right of the button. | string | No | iOS Android | yes |
170+| thumbTintColor | The color used for the thumb. | string | No | iOS Android | yes |
171+| thumbTouchSize | The size of the touch area that allows moving the thumb. The touch area has the same center as the visible thumb. This allows to have a visually small thumb while still allowing the user to move it easily. | object | No | iOS Android | yes |
172+| onValueChange | Callback continuously called while the user is dragging the slider. | function | No | iOS Android | yes |
173+| onSlidingStart | Callback called when the user starts changing the value (e.g. when the slider is pressed). | function | No | iOS Android | yes |
174+| onSlidingComplete | Callback called when the user finishes changing the value (e.g. when the slider is released). | function | No | iOS Android | yes |
175+| style | The style applied to the slider container. | ViewStyle | No | iOS Android | yes |
176+| trackStyle | The style applied to the track. | ViewStyle | No | iOS Android | yes |
177+| thumbStyle | The style applied to the thumb. | ViewStyle | No | iOS Android | yes |
178+| thumbImage | Sets an image for the thumb. | [source](https://reactnative.dev/docs/image#source) | No | iOS Android | yes |
179+| debugTouchArea | Set this to true to visually see the thumb touch rect in green. | boolean | No | iOS Android | yes |
180+| animateTransitions | Set whether to enable animations, with the default value 'timing' when set to true. | boolean | No | iOS Android | yes |
181+| animationType | Set to 'spring' or 'timing' to use one of those two types of animations with the default [animation properties](https://reactnative.dev/docs/animations.html). | 'spring' \| 'timing' | No | iOS Android | yes |
182+| animationConfig | Used to configure the animation parameters. These are the same parameters in the [Animated library](https://reactnative.dev/docs/animations.html). | SpringAnimationConfig \| TimingAnimationConfig | No | iOS Android | yes |
187 183 
188-## 其他184+## Known Issues
189-无185+None
190 186 
191-## 目录结构187+## Other
188+None
189+
190+## Directory Structure
192 191 
193````192````
194-/jeanregisser-react-native-slider # 项目根目录193+/jeanregisser-react-native-slider # Project root directory
195├── src/194├── src/
196-│ └── Slider.js # RN 组件源码195+│ └── Slider.js # React Native component source
197-├── harmony/ # 鸿蒙适配占位(纯 JS 实现,无原生代码)196+├── harmony/ # HarmonyOS adaptation placeholder (pure JS, no native code)
198-├── index.d.ts # TypeScript 类型定义197+├── index.d.ts # TypeScript type definitions
199-├── package.json # 包配置198+├── package.json # Package config
200-├── README.md # 中文安装使用方法199+├── README.md # English documentation
201-└── README_en.md # 英文安装使用方法200+└── README_zh.md # Chinese documentation
202````201````
203 202 
204-## 贡献代码203+## How to Contribute
205 204 
206-使用过程中发现任何问题都可以提交 [Issue](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/issues),当然,也非常欢迎提交 [PR](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/pulls)。205+If you find any problem when using react-native-slider, submit an [Issue](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/issues) or a [PR](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/pulls).
207 206 
208-## 开源协议207+## License
209- 
210-本项目基于 [The MIT License (MIT)](https://github.com/jeanregisser/react-native-slider/blob/master/LICENSE) ,请自由地享受和参与开源。
211 208 
209+This project is licensed under [The MIT License (MIT)](https://github.com/jeanregisser/react-native-slider/blob/master/LICENSE).
@@ -1,210 +0,0 @@
1-> Document Template:v0.4.1
2- 
3-<p align="center">
4- <h1 align="center"> <code>react-native-slider</code> </h1>
5-</p>
6- 
7-This project is based on [react-native-slider](https://github.com/jeanregisser/react-native-slider).
8- 
9-This third-party library has been migrated to Gitcode and is now available for direct download from npm, the new package name is: `@react-native-ohos/react-native-slider`, The version correspondence details are as follows:
10- 
11-| Name | Version | Release Information | Supported RN Version | Supported Autolink | Compile API Version | Community Baseline Version | npm Address |
12-| ------------ | ------------ | ------------------------------ | ------------- | ------------- |------------------------ | ------------- | ------------- |
13-| @react-native-ohos/react-native-slider | [~0.12.0](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/tree/br_rnoh0.77) | [Gitcode Releases](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/releases) | 0.77.* | No | API12+ | 0.11.0 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/react-native-slider) |
14- 
15-## Introduction
16- 
17-Slider component for React Native.<br/>
18-Slider is a pure JavaScript slider component for selecting a value within a specified range, with customizable track, thumb styles, and interaction callbacks!<br/>
19-Developers can create and ship a consistent visual value selection experience across platforms without relying on platform-native Slider components.
20- 
21-## Installation
22- 
23-Go to the project directory and execute the following instruction:
24- 
25-**npm**
26- 
27-```bash
28-npm i @react-native-ohos/react-native-slider
29-```
30- 
31-**yarn**
32- 
33-```bash
34-yarn add @react-native-ohos/react-native-slider
35-```
36- 
37-## Constraints & Limitations
38- 
39-### Compatibility
40- 
41-This document is verified based on the following versions:
42- 
43-1. RNOH: 0.77.18; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.868; ROM: 6.0.0.112;
44- 
45-## Example
46- 
47-The following code shows the basic use scenario of the repository:
48- 
49-> [!WARNING] The name of the imported repository remains unchanged.
50- 
51-```tsx
52-import React, { useState} from 'react';
53-import {Button, View, StyleSheet, Text } from 'react-native';
54-import Slider from 'react-native-slider';
55- 
56- 
57-export function SliderExample() {
58- const [isCheckerboardVisible, setIsCheckerboardVisible] = useState(false);
59- const [value, setValue] = useState(0.200);
60- return (
61- <View style={styles.sectionContainer}>
62- <Text>default style</Text>
63- <Slider value={0.2}/>
64- 
65- <Text>with min,max and custom tints</Text>
66- <Slider
67- value={0.2}
68- minimumTrackTintColor = '#1A9274'
69- maximumTrackTintColor = '#D3D3D3'
70- thumbTintColor = '#1A9274'
71- />
72- 
73- <Text>with style,thumbStyle,thumbStyle</Text>
74- <Slider
75- value={0.2}
76- minimumTrackTintColor = '#1073FF'
77- thumbTintColor = '#FFFFFF'
78- style = {styles.style}
79- trackStyle = {styles.trackStyle}
80- thumbStyle = {styles.thumbStyle}
81- />
82- 
83- <Text>with thumbTouchSize,event</Text>
84- <Slider
85- value={0.2}
86- thumbTintColor = '#1A9FF4'
87- thumbTouchSize = {{width: 40, height: 40}}
88- onValueChange={(val: number) => {
89- console.log('===Slider onValueChange: ' + value);
90- }}
91- 
92- onSlidingStart={() => {
93- console.log('===Slider onSlidingStart');
94- }}
95- 
96- onSlidingComplete={() => {
97- console.log('===Slider onSlidingComplete');
98- }}
99- />
100- 
101- <Text>with thumbImage</Text>
102- <Slider
103- value={0.2}
104- thumbTouchSize = {{width: 40, height: 40}}
105- thumbStyle = {styles.thumbStyle}
106- thumbImage = {require('./resources/slider.png')}
107- />
108- 
109- <Text>with animateTransitions</Text>
110- <Slider
111- value={value}
112- thumbTouchSize = {{width: 40, height: 40}}
113- trackStyle = {styles.trackStyle}
114- thumbStyle = {styles.thumbStyle}
115- // thumbImage = {{uri: 'https://developer.harmonyos.com/assets/image/diqiu.png'}}
116- animateTransitions = {true}
117- animationType = 'timing'
118- animationConfig = {{
119- toValue: 1,
120- duration: 1500,
121- useNativeDriver: false,
122- }}
123- />
124- 
125- <Button onPress={()=>{
126- setValue(0.9);
127- }}
128- title="Animation test"
129- color="#841584"
130- />
131- </View>
132- );
133-}
134- 
135-const styles = StyleSheet.create({
136- sectionContainer: {
137- marginTop: 32,
138- paddingHorizontal: 24,
139- },
140- style: {
141- backgroundColor: '#EECBA8',
142- },
143- trackStyle: {
144- backgroundColor: '#D2D2D2',
145- height:3
146- },
147- thumbStyle: {
148- backgroundColor: '#F3F3F3',
149- width: 30,
150- height: 30,
151- borderRadius: 15,
152- }
153- });
154-```
155- 
156-## Properties
157- 
158-> [!TIP] The **Platform** column indicates the platform where the properties are supported in the original third-party library.
159- 
160-> [!TIP] If the value of **HarmonyOS Support** is **yes**, it means that the HarmonyOS platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android.
161- 
162-| Name | Description | Type | Required | Platform | HarmonyOS Support |
163-|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------|----------|-------------|-------------------|
164-| value | Initial value of the slider. | number | No | iOS Android | yes |
165-| disabled | If true the user won't be able to move the slider. | bool | No | iOS Android | yes |
166-| minimumValue | Initial minimum value of the slider. | number | No | iOS Android | yes |
167-| maximumValue | Initial maximum value of the slider. | number | No | iOS Android | yes |
168-| step | Step value of the slider. The value should be between 0 and maximumValue - minimumValue). | number | No | iOS Android | yes |
169-| minimumTrackTintColor | The color used for the track to the left of the button. | string | No | iOS Android | yes |
170-| maximumTrackTintColor | The color used for the track to the right of the button. | string | No | iOS Android | yes |
171-| thumbTintColor | The color used for the thumb. | string | No | iOS Android | yes |
172-| thumbTouchSize | The size of the touch area that allows moving the thumb. The touch area has the same center as the visible thumb. This allows to have a visually small thumb while still allowing the user to move it easily. | object | No | iOS Android | yes |
173-| onValueChange | Callback continuously called while the user is dragging the slider. | function | No | iOS Android | yes |
174-| onSlidingStart | Callback called when the user starts changing the value (e.g. when the slider is pressed). | function | No | iOS Android | yes |
175-| onSlidingComplete | Callback called when the user finishes changing the value (e.g. when the slider is released). | function | No | iOS Android | yes |
176-| style | The style applied to the slider container. | [style](http://facebook.github.io/react-native/docs/view.html#style) | No | iOS Android | yes |
177-| trackStyle | The style applied to the track. | [style](http://facebook.github.io/react-native/docs/view.html#style) | No | iOS Android | yes |
178-| thumbStyle | The style applied to the thumb. | [style](http://facebook.github.io/react-native/docs/view.html#style) | No | iOS Android | yes |
179-| thumbImage | Sets an image for the thumb. | [source](http://facebook.github.io/react-native/docs/image.html#source) | No | iOS Android | yes |
180-| debugTouchArea | Set this to true to visually see the thumb touch rect in green. | bool | No | iOS Android | yes |
181-| animateTransitions | Set whether to enable animations, with the default value 'timing' when set to true. | bool | No | iOS Android | yes |
182-| animationType | Set to 'spring' or 'timing' to use one of those two types of animations with the default [animation properties](https://facebook.github.io/react-native/docs/animations.html). | string | No | iOS Android | yes |
183-| animationConfig | Used to configure the animation parameters. These are the same parameters in the [Animated library](https://facebook.github.io/react-native/docs/animations.html). | object | No | iOS Android | yes |
184- 
185-## Known Issues
186-None
187- 
188-## Other
189-None
190-
191-## Directory Structure
192- 
193-````
194-/jeanregisser-react-native-slider # Project root directory
195-├── src/
196-│ └── Slider.js # React Native component source
197-├── harmony/ # HarmonyOS adaptation placeholder (pure JS, no native code)
198-├── index.d.ts # TypeScript type definitions
199-├── package.json # Package config
200-├── README.md # Chinese documentation
201-└── README_en.md # English documentation
202-````
203- 
204-## How to Contribute
205- 
206-If you find any problem when using react-native-slider, submit an [Issue](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/issues) or a [PR](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/pulls).
207- 
208-## License
209- 
210-This project is licensed under [The MIT License (MIT)](https://github.com/jeanregisser/react-native-slider/blob/master/LICENSE).
@@ -0,0 +1,210 @@
1+> 文档模板:v0.4.2
2+ 
3+ <p align="center">
4+ <h1 align="center"> <code>react-native-slider</code> </h1>
5+ </p>
6+ 
7+本项目基于 [react-native-slider](https://github.com/jeanregisser/react-native-slider) 开发。
8+ 
9+该第三方库的仓库已迁移至 Gitcode,且支持直接从 npm 下载,新的包名为:`@react-native-ohos/react-native-slider`, 版本所属关系如下:
10+ 
11+| 三方库名称 | 三方库版本(npm地址) | 发布信息 | 支持RN版本 | Autolink | 编译API版本 | 社区基线版本 | 源码地址 |
12+| ------------ | ------------ | ------------------------------ | ------------- | ------------- |------------------------ | ------------- | ------------- |
13+| @react-native-ohos/react-native-slider | [~0.12.0](https://www.npmjs.com/package/@react-native-ohos/react-native-slider) | [Gitcode Releases](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/releases) | 0.77.* | 否 | API12+ | 0.11.0 | [br_rnoh0.77](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/tree/br_rnoh0.77) |
14+ 
15+## 简介
16+ 
17+Slider 组件用于 React Native。<br/>
18+Slider 是一个纯 JavaScript 实现的滑动条组件,用于在指定范围内选择数值,并支持自定义轨道、滑块样式与交互回调!<br/>
19+开发者可以在无需依赖平台原生 Slider 的情况下,创造并交付一致的可视化数值选择体验。
20+ 
21+## 下载安装
22+ 
23+进入到工程目录并输入以下命令:
24+ 
25+#### **npm**
26+ 
27+```bash
28+npm i @react-native-ohos/react-native-slider
29+```
30+ 
31+#### **yarn**
32+ 
33+```bash
34+yarn add @react-native-ohos/react-native-slider
35+```
36+ 
37+## 约束与限制
38+ 
39+### 兼容性
40+ 
41+本文档内容基于以下版本验证通过:
42+ 
43+1. RNOH: 0.77.18; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.868; ROM: 6.0.0.112;
44+ 
45+## 使用示例
46+ 
47+下面的代码展示了这个库的基本使用场景:
48+ 
49+> [!WARNING] 使用时 import 的库名不变。
50+ 
51+```tsx
52+import React, { useState} from 'react';
53+import {Button, View, StyleSheet, Text } from 'react-native';
54+import Slider from 'react-native-slider';
55+ 
56+ 
57+export function SliderExample() {
58+ const [value, setValue] = useState(0.200);
59+ return (
60+ <View style={styles.sectionContainer}>
61+ <Text>default style</Text>
62+ <Slider value={0.2}/>
63+ 
64+ <Text>with min,max and custom tints</Text>
65+ <Slider
66+ value={0.2}
67+ minimumTrackTintColor = '#1A9274'
68+ maximumTrackTintColor = '#D3D3D3'
69+ thumbTintColor = '#1A9274'
70+ />
71+ 
72+ <Text>with style,thumbStyle,thumbStyle</Text>
73+ <Slider
74+ value={0.2}
75+ minimumTrackTintColor = '#1073FF'
76+ thumbTintColor = '#FFFFFF'
77+ style = {styles.style}
78+ trackStyle = {styles.trackStyle}
79+ thumbStyle = {styles.thumbStyle}
80+ />
81+ 
82+ <Text>with thumbTouchSize,event</Text>
83+ <Slider
84+ value={0.2}
85+ thumbTintColor = '#1A9FF4'
86+ thumbTouchSize = {{width: 40, height: 40}}
87+ onValueChange={(val: number) => {
88+ console.log('===Slider onValueChange: ' + val);
89+ }}
90+ 
91+ onSlidingStart={() => {
92+ console.log('===Slider onSlidingStart');
93+ }}
94+ 
95+ onSlidingComplete={() => {
96+ console.log('===Slider onSlidingComplete');
97+ }}
98+ />
99+ 
100+ <Text>with thumbImage</Text>
101+ <Slider
102+ value={0.2}
103+ thumbTouchSize = {{width: 40, height: 40}}
104+ thumbStyle = {styles.thumbStyle}
105+ thumbImage = {require('./resources/slider.png')}
106+ />
107+ 
108+ <Text>with animateTransitions</Text>
109+ <Slider
110+ value={value}
111+ thumbTouchSize = {{width: 40, height: 40}}
112+ trackStyle = {styles.trackStyle}
113+ thumbStyle = {styles.thumbStyle}
114+ // thumbImage = {{uri: 'https://developer.harmonyos.com/assets/image/diqiu.png'}}
115+ animateTransitions = {true}
116+ animationType = 'timing'
117+ animationConfig = {{
118+ toValue: 1,
119+ duration: 1500,
120+ useNativeDriver: false,
121+ }}
122+ />
123+ 
124+ <Button onPress={()=>{
125+ setValue(0.9);
126+ }}
127+ title="动画测试"
128+ color="#841584"
129+ />
130+ </View>
131+ );
132+}
133+ 
134+const styles = StyleSheet.create({
135+ sectionContainer: {
136+ marginTop: 32,
137+ paddingHorizontal: 24,
138+ },
139+ style: {
140+ backgroundColor: '#EECBA8',
141+ },
142+ trackStyle: {
143+ backgroundColor: '#D2D2D2',
144+ height:3
145+ },
146+ thumbStyle: {
147+ backgroundColor: '#F3F3F3',
148+ width: 30,
149+ height: 30,
150+ borderRadius: 15,
151+ }
152+ });
153+```
154+ 
155+## 属性
156+ 
157+> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。
158+>
159+> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
160+ 
161+| Name | Description | Type | Required | Platform | HarmonyOS Support |
162+| --------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | ----------- | ----------------- |
163+| value | 滑块的初始值。 | number | No | iOS Android | yes |
164+| disabled | 如果为 true,用户将无法移动滑块。 | boolean | No | iOS Android | yes |
165+| minimumValue | 滑块的初始最小值。 | number | No | iOS Android | yes |
166+| maximumValue | 滑块的初始最大值。 | number | No | iOS Android | yes |
167+| step | 滑块的步长值。该值应在 0 到 (maximumValue - minimumValue) 之间。 | number | No | iOS Android | yes |
168+| minimumTrackTintColor | 滑块按钮左侧轨道的颜色。 | string | No | iOS Android | yes |
169+| maximumTrackTintColor | 滑块按钮右侧轨道的颜色。 | string | No | iOS Android | yes |
170+| thumbTintColor | 滑块按钮(thumb)的颜色。 | string | No | iOS Android | yes |
171+| thumbTouchSize | 允许移动滑块按钮的触摸区域大小。触摸区域的中心与可见的滑块按钮相同。这使得滑块按钮在视觉上可以很小,同时仍允许用户轻松移动它。 | object | No | iOS Android | yes |
172+| onValueChange | 当用户拖动滑块时持续调用的回调函数。 | function | No | iOS Android | yes |
173+| onSlidingStart | 当用户开始更改值时调用的回调函数(例如,当滑块被按下时)。 | function | No | iOS Android | yes |
174+| onSlidingComplete | 当用户完成更改值时调用的回调函数(例如,当滑块被释放时)。 | function | No | iOS Android | yes |
175+| style | 应用于滑块容器的样式。 | ViewStyle | No | iOS Android | yes |
176+| trackStyle | 应用于轨道的样式。 | ViewStyle | No | iOS Android | yes |
177+| thumbStyle | 应用于滑块按钮的样式。 | ViewStyle | No | iOS Android | yes |
178+| thumbImage | 为滑块按钮设置一张图片。 | [source](https://reactnative.dev/docs/image#source) | No | iOS Android | yes |
179+| debugTouchArea | 设置为 true 可以在视觉上看到绿色的滑块按钮触摸矩形区域。 | boolean | No | iOS Android | yes |
180+| animateTransitions | 设置是否开启动画,为 true 时默认值'timing'。 | boolean | No | iOS Android | yes |
181+| animationType | 设置为'spring' 或 'timing',以使用这两种动画类型之一,并使用默认的 [动画属性](https://reactnative.dev/docs/animations.html)。 | 'spring' \| 'timing' | No | iOS Android | yes |
182+| animationConfig | 用于配置动画参数。这些参数与 [Animated 库](https://reactnative.dev/docs/animations.html) 中的参数相同。 | SpringAnimationConfig \| TimingAnimationConfig | No | iOS Android | yes |
183+ 
184+## 遗留问题
185+无
186+ 
187+## 其他
188+无
189+ 
190+## 目录结构
191+ 
192+````
193+/jeanregisser-react-native-slider # 项目根目录
194+├── src/
195+│ └── Slider.js # RN 组件源码
196+├── harmony/ # 鸿蒙适配占位(纯 JS 实现,无原生代码)
cpf-manager
cpf-managercpf-manager8月8日

【AI-Review】【一般】【基础代码问题】【可读性问题】目录结构与实际仓库布局不符

● 问题: README_zh.md 第196-200行将 harmony/、index.d.ts、package.json、README.md、README_zh.md 显示为 src/ 的子目录(缩进在 "├── src/" 之下),但实际仓库结构中 src/ 目录仅包含 Slider.js 一个文件。通过 GitCode API 验证 base 分支 br_rnoh0.77 的实际结构:根目录包含目录 .github、Example、Screenshots、harmony、src,以及文件 index.d.ts、package.json、README.md、README_en.md 等;src/ 目录下仅有 Slider.js。因此 harmony/、index.d.ts、package.json、README.md、README_zh.md 均位于项目根目录,而非 src/ 下。README.md(英文版)第196-200行存在同样的问题。

● 影响: 开发者按照 README 中的目录结构定位文件时会被误导,在 src/ 目录下找不到 harmony/、index.d.ts、package.json 等文件。对于需要查看类型定义(index.d.ts)或包配置(package.json)的开发者,错误的路径指引会增加不必要的查找成本,影响接入体验。

● 建议: 将目录结构修正为实际布局,把 harmony/、index.d.ts、package.json、README.md、README_zh.md 从 src/ 下移出至根目录层级,例如:

/jeanregisser-react-native-slider # 项目根目录 ├── src/ │ └── Slider.js # RN 组件源码 ├── harmony/ # 鸿蒙适配占位(纯 JS 实现,无原生代码) ├── index.d.ts # TypeScript 类型定义 ├── package.json # 包配置 ├── README.md # 英文安装使用方法 └── README_zh.md # 中文安装使用方法

likedislike
yanPeng
yanPeng
8月8日 评论:
197+├── index.d.ts # TypeScript 类型定义
198+├── package.json # 包配置
199+├── README.md # 英文安装使用方法
200+└── README_zh.md # 中文安装使用方法
201+````
202+ 
203+## 贡献代码
204+ 
205+使用过程中发现任何问题都可以提交 [Issue](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/issues),当然,也非常欢迎提交 [PR](https://gitcode.com/CPF-RN/jeanregisser-react-native-slider/pulls)。
206+ 
207+## 开源协议
208+ 
209+本项目基于 [The MIT License (MIT)](https://github.com/jeanregisser/react-native-slider/blob/master/LICENSE) ,请自由地享受和参与开源。
210+ 
@@ -0,0 +1,3 @@
1+#!/bin/bash
2+BUILD_PKG_DIR=Example
3+BUILD_SAMPLE_DIR=Example/harmony
@@ -497,7 +497,6 @@ export default class Slider extends PureComponent {
497 const { width, height } = this._getTouchOverflowSize();497 const { width, height } = this._getTouchOverflowSize();
498 498 
499 const touchOverflowStyle = {};499 const touchOverflowStyle = {};
500- touchOverflowStyle.opacity = 0.5;
501 if (width !== undefined && height !== undefined) {500 if (width !== undefined && height !== undefined) {
502 const verticalMargin = -height / 2;501 const verticalMargin = -height / 2;
503 touchOverflowStyle.marginTop = verticalMargin;502 touchOverflowStyle.marginTop = verticalMargin;