@react-native-ohos/slider 5.0.1-rc.1 → 5.1.2-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +188 -0
- package/COMMITTERS.md +6 -0
- package/OAT.xml +73 -0
- package/README.OpenSource +1 -1
- package/README.md +1 -1
- package/babel.config.json +3 -0
- package/dist/RNCSliderNativeComponent.js +1 -1
- package/dist/Slider.js +1 -1
- package/dist/components/StepNumber.js +1 -1
- package/dist/components/StepsIndicator.js +1 -1
- package/dist/components/TrackMark.js +1 -1
- package/dist/utils/styles.js +1 -1
- package/example/.eslintrc +19 -0
- package/example/.node-version +6 -0
- package/example/.prettierrc.js +7 -0
- package/example/.watchmanconfig +6 -0
- package/example/app.json +4 -0
- package/example/babel.config.js +9 -0
- package/example/contexts.ts +9 -0
- package/example/harmony/AppScope/app.json5 +10 -0
- package/example/harmony/AppScope/resources/base/element/string.json +8 -0
- package/example/harmony/AppScope/resources/base/media/app_icon.png +0 -0
- package/example/harmony/build-profile.template.json5 +36 -0
- package/example/harmony/codelinter.json +32 -0
- package/example/harmony/entry/build-profile.json5 +22 -0
- package/example/harmony/entry/hvigorfile.ts +8 -0
- package/example/harmony/entry/oh-package.json5 +11 -0
- package/example/harmony/entry/src/main/cpp/CMakeLists.txt +41 -0
- package/example/harmony/entry/src/main/cpp/PackageProvider.cpp +17 -0
- package/example/harmony/entry/src/main/ets/RNPackagesFactory.ets +13 -0
- package/example/harmony/entry/src/main/ets/assets/fonts/Pacifico-Regular.ttf +0 -0
- package/example/harmony/entry/src/main/ets/assets/fonts/StintUltraCondensed-Regular.ttf +0 -0
- package/example/harmony/entry/src/main/ets/entryability/EntryAbility.ets +27 -0
- package/example/harmony/entry/src/main/ets/pages/Index.ets +125 -0
- package/example/harmony/entry/src/main/ets/pages/SurfaceDeadlockTest.ets +135 -0
- package/example/harmony/entry/src/main/ets/pages/TouchDisplayer.ets +44 -0
- package/example/harmony/entry/src/main/module.json5 +52 -0
- package/example/harmony/entry/src/main/resources/base/element/color.json +8 -0
- package/example/harmony/entry/src/main/resources/base/element/string.json +16 -0
- package/example/harmony/entry/src/main/resources/base/media/icon.png +0 -0
- package/example/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
- package/example/harmony/entry/src/main/resources/rawfile/1.txt +1 -0
- package/example/harmony/format.ps1 +18 -0
- package/example/harmony/hvigor/hvigor-config.json5 +21 -0
- package/example/harmony/hvigorfile.ts +9 -0
- package/example/harmony/oh-package.json5 +12 -0
- package/example/index.js +11 -0
- package/example/jest.config.js +11 -0
- package/example/metro.config.js +30 -0
- package/example/package.json +58 -0
- package/example/react-native.config.js +11 -0
- package/example/scripts/create-build-profile.js +46 -0
- package/example/src/index.tsx +22 -0
- package/example/tsconfig.json +20 -0
- package/harmony/slider/oh-package.json5 +1 -1
- package/harmony/slider.har +0 -0
- package/package.json +16 -22
- package/react-native.config.js +11 -0
- package/src/RNCSliderNativeComponent.ts +7 -3
- package/src/Slider.tsx +10 -4
- package/src/components/StepNumber.tsx +6 -0
- package/src/components/StepsIndicator.tsx +6 -0
- package/src/components/TrackMark.tsx +12 -3
- package/src/index.ts +6 -0
- package/src/utils/constants.ts +6 -0
- package/src/utils/styles.ts +7 -1
- package/tsconfig.json +23 -0
- package/typings/index.d.ts +6 -0
- package/harmony/slider/.idea/misc.xml +0 -6
- package/harmony/slider/.idea/modules.xml +0 -8
- package/harmony/slider/.idea/slider.iml +0 -8
- package/harmony/slider/README.OpenSource +0 -11
- package/harmony/slider/oh-package-lock.json5 +0 -18
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
project(rnapp)
|
|
2
|
+
cmake_minimum_required(VERSION 3.4.1)
|
|
3
|
+
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
|
4
|
+
set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
5
|
+
set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
|
|
6
|
+
set(OH_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
|
|
7
|
+
set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp")
|
|
8
|
+
set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated")
|
|
9
|
+
set(LOG_VERBOSITY_LEVEL 1)
|
|
10
|
+
set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
|
|
11
|
+
set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
|
|
12
|
+
set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
|
|
13
|
+
|
|
14
|
+
set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
|
|
15
|
+
add_compile_definitions(WITH_HITRACE_SYSTRACE)
|
|
16
|
+
|
|
17
|
+
# (VM) Define a variable and assign it to the current module's cpp directory
|
|
18
|
+
set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
|
19
|
+
|
|
20
|
+
# Add the Header File directory, including cpp, cpp/include, and tell cmake to find the Header Files introduced by the code here
|
|
21
|
+
include_directories(${NATIVERENDER_ROOT_PATH}
|
|
22
|
+
${NATIVERENDER_ROOT_PATH}/include)
|
|
23
|
+
|
|
24
|
+
add_subdirectory("${RNOH_CPP_DIR}" ./rn)
|
|
25
|
+
|
|
26
|
+
# RNOH_BEGIN: manual_package_linking_1
|
|
27
|
+
add_subdirectory("${OH_MODULES}/@react-native-ohos/slider/src/main/cpp" ./slider)
|
|
28
|
+
# RNOH_END: manual_package_linking_1
|
|
29
|
+
|
|
30
|
+
file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1
|
|
31
|
+
|
|
32
|
+
add_library(rnoh_app SHARED
|
|
33
|
+
${GENERATED_CPP_FILES}
|
|
34
|
+
"./PackageProvider.cpp"
|
|
35
|
+
"${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
|
|
36
|
+
)
|
|
37
|
+
target_link_libraries(rnoh_app PUBLIC rnoh)
|
|
38
|
+
|
|
39
|
+
# RNOH_BEGIN: manual_package_linking_2
|
|
40
|
+
target_link_libraries(rnoh_app PUBLIC rnoh_slider)
|
|
41
|
+
# RNOH_END: manual_package_linking_2
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
#include "SliderPackage.h"
|
|
8
|
+
|
|
9
|
+
using namespace rnoh;
|
|
10
|
+
|
|
11
|
+
std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx)
|
|
12
|
+
{
|
|
13
|
+
return {
|
|
14
|
+
std::make_shared<RNOHGeneratedPackage>(ctx), // generated by codegen v1
|
|
15
|
+
std::make_shared<SliderPackage>(ctx)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
import type {RNPackageContext, RNPackage} from '@rnoh/react-native-openharmony/ts';
|
|
9
|
+
|
|
10
|
+
export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
|
|
11
|
+
return [
|
|
12
|
+
];
|
|
13
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {RNAbility} from '@rnoh/react-native-openharmony';
|
|
8
|
+
import { AbilityConstant, Want } from '@kit.AbilityKit';
|
|
9
|
+
|
|
10
|
+
export default class EntryAbility extends RNAbility {
|
|
11
|
+
|
|
12
|
+
onCreate(want: Want) {
|
|
13
|
+
super.onCreate(want)
|
|
14
|
+
this.handleWeChatCallIfNeed(want)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getPagePath() {
|
|
18
|
+
return 'pages/Index';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
onNewWant(want: Want, _launchParam: AbilityConstant.LaunchParam): void {
|
|
22
|
+
this.handleWeChatCallIfNeed(want)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private handleWeChatCallIfNeed(want: Want) {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
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 font from '@ohos.font';
|
|
20
|
+
import { createRNPackages } from '../RNPackagesFactory';
|
|
21
|
+
import { RNCSlider, SLIDER_TYPE } from "@react-native-ohos/slider"
|
|
22
|
+
const arkTsComponentNames: Array<string> = [
|
|
23
|
+
SLIDER_TYPE
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
@Builder
|
|
27
|
+
export function buildCustomRNComponent(ctx: ComponentBuilderContext) {
|
|
28
|
+
// There seems to be a problem with the placement of ArkTS components in mixed mode. Nested Stack temporarily avoided.
|
|
29
|
+
Stack() {
|
|
30
|
+
if (ctx.componentName === SLIDER_TYPE) {
|
|
31
|
+
RNCSlider({
|
|
32
|
+
ctx: ctx.rnComponentContext,
|
|
33
|
+
tag: ctx.tag,
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
.position({ x: 0, y: 0 })
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const wrappedCustomRNComponentBuilder = wrapBuilder(buildCustomRNComponent)
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* If you want to use custom fonts, you need to register them here.
|
|
45
|
+
* We should support react-native-asset to handle registering fonts automatically.
|
|
46
|
+
*/
|
|
47
|
+
const fonts: font.FontOptions[] = [
|
|
48
|
+
{
|
|
49
|
+
familyName: 'Pacifico-Regular',
|
|
50
|
+
familySrc: '/assets/fonts/Pacifico-Regular.ttf'
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
familyName: 'StintUltraCondensed-Regular',
|
|
54
|
+
familySrc: '/assets/fonts/StintUltraCondensed-Regular.ttf'
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
@Entry
|
|
59
|
+
@Component
|
|
60
|
+
struct Index {
|
|
61
|
+
@StorageLink('RNOHCoreContext') private rnohCoreContext: RNOHCoreContext | undefined = undefined
|
|
62
|
+
@State shouldShow: boolean = false
|
|
63
|
+
private logger!: RNOHLogger
|
|
64
|
+
bundlePath: string = 'bunlde.harmony.js'
|
|
65
|
+
@State hasBundle: boolean = false
|
|
66
|
+
|
|
67
|
+
aboutToAppear() {
|
|
68
|
+
this.logger = this.rnohCoreContext!.logger.clone("Index")
|
|
69
|
+
const stopTracing = this.logger.clone("aboutToAppear").startTracing()
|
|
70
|
+
for (const customFont of fonts) {
|
|
71
|
+
font.registerFont(customFont)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this.shouldShow = true
|
|
75
|
+
stopTracing()
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
onBackPress(): boolean | undefined {
|
|
79
|
+
// NOTE: this is required since `Ability`'s `onBackPressed` function always
|
|
80
|
+
// terminates or puts the app in the background, but we want Ark to ignore it completely
|
|
81
|
+
// when handled by RN
|
|
82
|
+
this.rnohCoreContext!.dispatchBackPress()
|
|
83
|
+
return true
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
build() {
|
|
87
|
+
Column() {
|
|
88
|
+
if (this.rnohCoreContext && this.shouldShow) {
|
|
89
|
+
if (this.rnohCoreContext?.isDebugModeEnabled) {
|
|
90
|
+
RNOHErrorDialog({ ctx: this.rnohCoreContext })
|
|
91
|
+
}
|
|
92
|
+
RNApp({
|
|
93
|
+
rnInstanceConfig: {
|
|
94
|
+
createRNPackages,
|
|
95
|
+
enableNDKTextMeasuring: true,
|
|
96
|
+
enableBackgroundExecutor: false,
|
|
97
|
+
enableCAPIArchitecture: true,
|
|
98
|
+
arkTsComponentNames: arkTsComponentNames,
|
|
99
|
+
},
|
|
100
|
+
initialProps: { "foo": "bar" } as Record<string, string>,
|
|
101
|
+
appKey: "app_name",
|
|
102
|
+
wrappedCustomRNComponentBuilder: wrappedCustomRNComponentBuilder,
|
|
103
|
+
onSetUp: (rnInstance) => {
|
|
104
|
+
rnInstance.enableFeatureFlag("ENABLE_RN_INSTANCE_CLEAN_UP")
|
|
105
|
+
},
|
|
106
|
+
jsBundleProvider: new TraceJSBundleProviderDecorator(
|
|
107
|
+
new AnyJSBundleProvider([
|
|
108
|
+
new MetroJSBundleProvider(),
|
|
109
|
+
// NOTE: to load the bundle from file, place it in
|
|
110
|
+
// `/data/app/el2/100/base/com.rnoh.tester/files/bundle.harmony.js`
|
|
111
|
+
// on your device. The path mismatch is due to app sandboxing on HarmonyOS
|
|
112
|
+
new FileJSBundleProvider('/data/storage/el2/base/files/bundle.harmony.js'),
|
|
113
|
+
// new FileJSBundleProvider(context.filesDir + '/' + this.bundlePath),
|
|
114
|
+
new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'),
|
|
115
|
+
new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'bundle.harmony.js')
|
|
116
|
+
]),
|
|
117
|
+
this.rnohCoreContext.logger),
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
Text("1233333333122 1212323")
|
|
121
|
+
}
|
|
122
|
+
.height('100%')
|
|
123
|
+
.width('100%')
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
import { RNInstance, JSBundleProvider, RNAbility, RNSurface } from '@rnoh/react-native-openharmony'
|
|
7
|
+
import { CustomComponentBuilder } from "@rnoh/react-native-openharmony/src/main/ets/RNOHCorePackage"
|
|
8
|
+
import { SurfaceConfig2 } from '@rnoh/react-native-openharmony/src/main/ets/RNSurface'
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@Component
|
|
12
|
+
export struct SurfaceDeadlockTest {
|
|
13
|
+
public jsBundleProvider: JSBundleProvider | undefined = undefined
|
|
14
|
+
public appKeys: string[] = []
|
|
15
|
+
public numberOfIterations: number = 1
|
|
16
|
+
@BuilderParam public buildCustomComponent!: CustomComponentBuilder
|
|
17
|
+
// -------------------------------------------------------------------------------------------------------------------
|
|
18
|
+
@StorageLink('RNAbility') private rnAbility: RNAbility = {} as RNAbility
|
|
19
|
+
private rnInstance!: RNInstance
|
|
20
|
+
@State private shouldShow: boolean = false
|
|
21
|
+
private shouldDestroyRNInstance: boolean = false
|
|
22
|
+
private cleanUpCallbacks: (() => void)[] = []
|
|
23
|
+
|
|
24
|
+
aboutToAppear() {
|
|
25
|
+
this.getOrCreateRNInstance().then(rnInstance => {
|
|
26
|
+
this.rnInstance = rnInstance
|
|
27
|
+
const jsBundleExecutionStatus = this.rnInstance.getBundleExecutionStatus(this.jsBundleProvider?.getURL())
|
|
28
|
+
if (this.jsBundleProvider && jsBundleExecutionStatus === undefined) {
|
|
29
|
+
this.rnInstance.runJSBundle(this.jsBundleProvider).then(() => {
|
|
30
|
+
this.shouldShow = true
|
|
31
|
+
})
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
}).catch((reason: string | Error) => {
|
|
35
|
+
if (typeof reason === "string")
|
|
36
|
+
this.rnAbility.getLogger().error(reason)
|
|
37
|
+
else if (reason instanceof Error) {
|
|
38
|
+
this.rnAbility.getLogger().error(reason.message)
|
|
39
|
+
} else {
|
|
40
|
+
this.rnAbility.getLogger().error("Fatal exception")
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
aboutToDisappear() {
|
|
46
|
+
if (this.shouldDestroyRNInstance)
|
|
47
|
+
this.rnAbility.destroyAndUnregisterRNInstance(this.rnInstance)
|
|
48
|
+
this.cleanUpCallbacks.forEach(cleanUp => cleanUp())
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private getOrCreateRNInstance(): Promise<RNInstance> {
|
|
52
|
+
return this.rnAbility.createAndRegisterRNInstance({ createRNPackages: () => [] })
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
build() {
|
|
56
|
+
Stack() {
|
|
57
|
+
if (this.shouldShow) {
|
|
58
|
+
ForEach(this.appKeys, (appKey: string, idx) => {
|
|
59
|
+
Stack() {
|
|
60
|
+
Blinker({
|
|
61
|
+
minDelayInMs: 1000,
|
|
62
|
+
maxDelayInMs: 2000,
|
|
63
|
+
blinksCount: this.numberOfIterations,
|
|
64
|
+
randomnessPrecisionInMs: 500
|
|
65
|
+
}) {
|
|
66
|
+
RNSurface({
|
|
67
|
+
ctx: this.rnAbility.createRNOHContext({ rnInstance: this.rnInstance }),
|
|
68
|
+
surfaceConfig: {
|
|
69
|
+
initialProps: {},
|
|
70
|
+
appKey: appKey,
|
|
71
|
+
} as SurfaceConfig2,
|
|
72
|
+
buildCustomComponent: this.buildCustomComponent,
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
}.height(`${100 / this.appKeys.length}%`)
|
|
76
|
+
.position({ x: 0, y: `${(idx / this.appKeys.length) * 100}%` })
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
}.width("100%")
|
|
80
|
+
.height("100%")
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@Component
|
|
86
|
+
struct Blinker {
|
|
87
|
+
public minDelayInMs: number = 0
|
|
88
|
+
public maxDelayInMs: number = 1000
|
|
89
|
+
public blinksCount: number = 0
|
|
90
|
+
public randomnessPrecisionInMs: number = 250
|
|
91
|
+
@BuilderParam public renderChildren: () => void
|
|
92
|
+
private currentBlinksCount = 0
|
|
93
|
+
@State private isVisible: boolean = false
|
|
94
|
+
private timeout: number = 0
|
|
95
|
+
|
|
96
|
+
aboutToAppear() {
|
|
97
|
+
this.blink(this.minDelayInMs)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
aboutToDisappear() {
|
|
101
|
+
clearTimeout(this.timeout)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private blink(ms: number) {
|
|
105
|
+
this.isVisible = !this.isVisible
|
|
106
|
+
this.currentBlinksCount += 1
|
|
107
|
+
if (this.currentBlinksCount >= this.blinksCount) {
|
|
108
|
+
if (this.timeout) {
|
|
109
|
+
clearTimeout(this.timeout)
|
|
110
|
+
}
|
|
111
|
+
this.isVisible = true
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this.timeout = setTimeout(() => {
|
|
115
|
+
this.blink(this.getNextDelay())
|
|
116
|
+
}, ms)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private getNextDelay(): number {
|
|
120
|
+
return ((Math.floor(Math.random() * (Number.MAX_VALUE / this.randomnessPrecisionInMs)) * this.randomnessPrecisionInMs) % this.maxDelayInMs) + this.minDelayInMs
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
build() {
|
|
124
|
+
Stack() {
|
|
125
|
+
if (this.isVisible) {
|
|
126
|
+
this.renderChildren()
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@Component
|
|
9
|
+
export struct TouchDisplayer {
|
|
10
|
+
@State currentTouches: TouchObject[] = []
|
|
11
|
+
@State touchIndicatorOpacity: number = 0
|
|
12
|
+
@BuilderParam buildChildren: () => void
|
|
13
|
+
build() {
|
|
14
|
+
Stack() {
|
|
15
|
+
this.buildChildren()
|
|
16
|
+
ForEach(this.currentTouches, (activeTouch: TouchObject) => {
|
|
17
|
+
Stack() {
|
|
18
|
+
}
|
|
19
|
+
.width(64)
|
|
20
|
+
.height(64)
|
|
21
|
+
.backgroundColor("blue")
|
|
22
|
+
.borderWidth(2)
|
|
23
|
+
.borderColor("white")
|
|
24
|
+
.opacity(this.touchIndicatorOpacity)
|
|
25
|
+
.position({ x: activeTouch.x - 32, y: activeTouch.y - 32 })
|
|
26
|
+
.borderRadius(1000)
|
|
27
|
+
.hitTestBehavior(HitTestMode.Transparent)
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
.width("100%")
|
|
31
|
+
.height("100%")
|
|
32
|
+
.hitTestBehavior(HitTestMode.Transparent)
|
|
33
|
+
.onTouch(e => {
|
|
34
|
+
this.currentTouches = e.touches
|
|
35
|
+
this.touchIndicatorOpacity = 0.5
|
|
36
|
+
animateTo({
|
|
37
|
+
duration: 500,
|
|
38
|
+
curve: Curve.Linear,
|
|
39
|
+
}, () => {
|
|
40
|
+
this.touchIndicatorOpacity = 0
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"module": {
|
|
3
|
+
"name": "entry",
|
|
4
|
+
"type": "entry",
|
|
5
|
+
"description": "$string:module_desc",
|
|
6
|
+
"mainElement": "EntryAbility",
|
|
7
|
+
"deviceTypes": [
|
|
8
|
+
"default"
|
|
9
|
+
],
|
|
10
|
+
"querySchemes": [
|
|
11
|
+
"weixin",
|
|
12
|
+
],
|
|
13
|
+
"deliveryWithInstall": true,
|
|
14
|
+
"installationFree": false,
|
|
15
|
+
"pages": "$profile:main_pages",
|
|
16
|
+
// below property is supported from 5.0.0 - it is needed by bundleManager.canOpenLink to check if the app can open some url
|
|
17
|
+
// "querySchemes": ["maps", "http", "https", "customDomain"],
|
|
18
|
+
"requestPermissions": [
|
|
19
|
+
{
|
|
20
|
+
"name": "ohos.permission.INTERNET"
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
"metadata": [
|
|
24
|
+
{
|
|
25
|
+
"name": "OPTLazyForEach",
|
|
26
|
+
"value": "true",
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"abilities": [
|
|
30
|
+
{
|
|
31
|
+
"name": "EntryAbility",
|
|
32
|
+
"srcEntry": "./ets/entryability/EntryAbility.ets",
|
|
33
|
+
"description": "$string:EntryAbility_desc",
|
|
34
|
+
"icon": "$media:icon",
|
|
35
|
+
"label": "$string:EntryAbility_label",
|
|
36
|
+
"startWindowIcon": "$media:icon",
|
|
37
|
+
"startWindowBackground": "$color:start_window_background",
|
|
38
|
+
"visible": true,
|
|
39
|
+
"skills": [
|
|
40
|
+
{
|
|
41
|
+
"entities": [
|
|
42
|
+
"entity.system.home"
|
|
43
|
+
],
|
|
44
|
+
"actions": [
|
|
45
|
+
"action.system.home"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
text test
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
$directoryPath = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
8
|
+
$filePaths = Get-ChildItem $directoryPath -Recurse -Include *.h, *.cpp |
|
|
9
|
+
Where-Object {
|
|
10
|
+
$_.DirectoryName -notmatch 'third-party' -and
|
|
11
|
+
$_.DirectoryName -notmatch 'patches' -and
|
|
12
|
+
$_.DirectoryName -notmatch 'node_modules' -and
|
|
13
|
+
$_.DirectoryName -notmatch '.cxx' -and
|
|
14
|
+
$_.DirectoryName -notmatch 'build'
|
|
15
|
+
}
|
|
16
|
+
foreach ($filePath in $filePaths) {
|
|
17
|
+
& "clang-format.exe" -style=file -i $filePath.FullName
|
|
18
|
+
}
|
|
@@ -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,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
|
|
9
|
+
export { appTasks } from '@ohos/hvigor-ohos-plugin';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"modelVersion": "5.0.0",
|
|
3
|
+
"license": "ISC",
|
|
4
|
+
"name": "rnoh",
|
|
5
|
+
"description": "example description",
|
|
6
|
+
"repository": {},
|
|
7
|
+
"version": "1.0.0",
|
|
8
|
+
"overrides": {
|
|
9
|
+
"@rnoh/react-native-openharmony": "file:./../node_modules/react-native-harmony/harmony/react_native_openharmony.har"
|
|
10
|
+
},
|
|
11
|
+
"dynamicDependencies": {}
|
|
12
|
+
}
|
package/example/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {AppRegistry, View, Text} from 'react-native';
|
|
8
|
+
import {name as appName} from './app.json';
|
|
9
|
+
import SliderExample from './src/index';
|
|
10
|
+
|
|
11
|
+
AppRegistry.registerComponent(appName, () => SliderExample);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
8
|
+
module.exports = {
|
|
9
|
+
preset: 'ts-jest',
|
|
10
|
+
testEnvironment: 'node',
|
|
11
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Huawei Device Co., Ltd. All rights reserved
|
|
3
|
+
* Use of this source code is governed by a MIT license that can be
|
|
4
|
+
* found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const {mergeConfig, getDefaultConfig} = require('@react-native/metro-config');
|
|
8
|
+
const {createHarmonyMetroConfig} = require('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-harmony',
|
|
28
|
+
}),
|
|
29
|
+
config,
|
|
30
|
+
);
|