Skip to content

Commit 14362a8

Browse files
authored
Merge pull request #4 from ajkshfjkaj/sig
feat: 优化代码提高代码容错
2 parents 55fb81b + ce7de3e commit 14362a8

File tree

8 files changed

+410
-224
lines changed

8 files changed

+410
-224
lines changed

harmony/picker/src/main/cpp/RTNPickerTurboModule.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ using namespace rnoh;
55
using namespace facebook;
66

77
static jsi::Value __hostFunction_RTNPickerTurboModule_init(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
8-
return static_cast<ArkTSTurboModule &>(turboModule).callAsync(rt, "init", args, count);
8+
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "init", args, count);
99
}
1010
static jsi::Value __hostFunction_RTNPickerTurboModule_toggle(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
11-
return static_cast<ArkTSTurboModule &>(turboModule).callAsync(rt, "toggle", args, count);
11+
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "toggle", args, count);
1212
}
1313
static jsi::Value __hostFunction_RTNPickerTurboModule_show(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
14-
return static_cast<ArkTSTurboModule &>(turboModule).callAsync(rt, "show", args, count);
14+
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "show", args, count);
1515
}
1616
static jsi::Value __hostFunction_RTNPickerTurboModule_hide(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
17-
return static_cast<ArkTSTurboModule &>(turboModule).callAsync(rt, "hide", args, count);
17+
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "hide", args, count);
1818
}
1919
static jsi::Value __hostFunction_RTNPickerTurboModule_select(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
20-
return static_cast<ArkTSTurboModule &>(turboModule).callAsync(rt, "select", args, count);
20+
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "select", args, count);
2121
}
2222
static jsi::Value __hostFunction_RTNPickerTurboModule_isPickerShow(jsi::Runtime &rt, react::TurboModule &turboModule, const jsi::Value *args, size_t count) {
23-
return static_cast<ArkTSTurboModule &>(turboModule).callAsync(rt, "isPickerShow", args, count);
23+
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "isPickerShow", args, count);
2424
}
2525

2626
RTNPickerTurboModule::RTNPickerTurboModule(const ArkTSTurboModule::Context ctx, const std::string name): ArkTSTurboModule(ctx, name) {

harmony/picker/src/main/ets/Logger.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
import hilog from '@ohos.hilog';
26+
27+
class Logger {
28+
private domain: number;
29+
private prefix: string;
30+
private format: string = '%{public}s, %{public}s';
31+
private isDebug: boolean;
32+
33+
/**
34+
* constructor.
35+
*
36+
* @param Prefix Identifies the log tag.
37+
* @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF.
38+
*/
39+
constructor(prefix: string = 'MyApp', domain: number = 0xFF00, isDebug = false) {
40+
this.prefix = prefix;
41+
this.domain = domain;
42+
this.isDebug = isDebug;
43+
}
44+
45+
debug(...args: string[]): void {
46+
if (this.isDebug) {
47+
hilog.debug(this.domain, this.prefix, this.format, args);
48+
}
49+
}
50+
51+
info(...args: string[]): void {
52+
hilog.info(this.domain, this.prefix, this.format, args);
53+
}
54+
55+
warn(...args: string[]): void {
56+
hilog.warn(this.domain, this.prefix, this.format, args);
57+
}
58+
59+
error(...args: string[]): void {
60+
hilog.error(this.domain, this.prefix, this.format, args);
61+
}
62+
}
63+
64+
export default new Logger('Picker', 0xFF00, false)

harmony/picker/src/main/ets/Magic.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
export interface initOptions {
2+
pickerData: string[] | string[][] | ResultItem[] | undefined,
3+
onPickerConfirm: (event: string) => string,
4+
onPickerCancel: () => void,
5+
onPickerSelect: () => void,
6+
selectedValue: string | string[] | undefined,
7+
pickerCancelBtnText: string,
8+
isLoop: boolean,
9+
pickerTextEllipsisLen: number,
10+
pickerConfirmBtnText: string,
11+
pickerConfirmBtnColor: Array<number>,
12+
pickerTitleText: string,
13+
pickerCancelBtnColor: Array<number>,
14+
pickerTitleColor: Array<number>,
15+
pickerToolBarBg: Array<number>,
16+
pickerBg: Array<number>,
17+
pickerToolBarFontSize: number,
18+
wheelFlex: Array<number>,
19+
pickerFontSize: number,
20+
pickerFontColor: Array<number>,
21+
pickerFontFamily: string,
22+
pickerRowHeight: number,
23+
}
24+
25+
export interface PickerTextStyle {
26+
color: string,
27+
font: FontStyle
28+
}
29+
30+
export interface FontStyle {
31+
size: number;
32+
}
33+
34+
export interface GlobalDialogParam {
35+
content: string;
36+
}
37+
38+
export interface ResultItem {
39+
text: string;
40+
children: ResultItem[];
41+
}
42+
43+
export const SELECTED: number = 1.1;
44+
45+
export const SIXTEEN: number = 16;
46+
47+
export const TWO: number = 2;
48+
49+
export const FIVE_PERCENT: string = '5%';
50+
51+
export const HUNDRED_PERCENT: string = '100%';
52+
53+
export const TWENTY_PERCENT: string = '20%';
54+
55+
export const THIRTY_PERCENT: string = '30%';
56+
57+
export const EVENT: string = 'pickerEvent';
58+
59+
export const CONFIRM: string = 'confirm';
60+
61+
export const CANCEL: string = 'cancel';
62+
63+
export const SELECT: string = 'select';
64+
65+
export const FALSE: boolean = false;
66+
67+
export const TRUE: boolean = true;

0 commit comments

Comments
 (0)