idlize

Форк
0
/
common.d.ts 
487 строк · 10.5 Кб
1
/*
2
 * Copyright (c) 2024 Huawei Device Co., Ltd.
3
 * Licensed under the Apache License, Version 2.0 (the "License");
4
 * you may not use this file except in compliance with the License.
5
 * You may obtain a copy of the License at
6
 *
7
 *     http://www.apache.org/licenses/LICENSE-2.0
8
 *
9
 * Unless required by applicable law or agreed to in writing, software
10
 * distributed under the License is distributed on an "AS IS" BASIS,
11
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 * See the License for the specific language governing permissions and
13
 * limitations under the License.
14
 */
15

16
declare type PixelMap = import('../resource/image').default.PixelMap;
17

18
declare type SymbolGlyphModifier = import('../../resource/symbol').SymbolGlyphModifier;
19

20
declare type ComponentContent = import('../api/arkui/ComponentContent').ComponentContent;
21

22
declare type AnimationRange<T> = [from: T, to: T];
23

24
declare interface Callback<T> {}
25

26
declare interface BaseEvent {}
27

28
declare interface ClickEvent extends BaseEvent {
29

30
    displayX: number;
31

32
    displayY: number;
33
}
34

35
declare interface CommonConfiguration<T> {
36

37
  enabled: boolean,
38

39
  contentModifier: ContentModifier<T>
40
}
41

42
interface ICurve {
43

44
  interpolate(fraction: number): number;
45
}
46

47
declare interface StateStyles {
48

49
    normal?: any;
50
}
51

52
declare interface AttributeModifier<T>{}
53
declare interface ContentModifier<T>{}
54

55
declare interface SheetTitleOptions {
56
    title: ResourceStr;
57
    subtitle?: ResourceStr;
58
}
59

60
declare interface UICommonEvent {
61
    setOnClick(callback: Callback<ClickEvent> | undefined): void;
62
}
63

64
declare enum SheetSize {
65
    MEDIUM,
66
    LARGE,
67
    FIT_CONTENT = 2,
68
}
69

70
declare enum SheetType {
71
    BOTTOM = 0,
72
    CENTER = 1,
73
    POPUP = 2,
74
}
75

76
declare enum SheetMode {
77
    OVERLAY = 0,
78
    EMBEDDED = 1,
79
}
80

81
declare enum ShadowStyle {
82
    OUTER_DEFAULT_XS,
83
    OUTER_DEFAULT_SM,
84
    OUTER_DEFAULT_MD,
85
    OUTER_DEFAULT_LG,
86
    OUTER_FLOATING_SM,
87
    OUTER_FLOATING_MD,
88
}
89

90
declare enum ShadowType {
91
    COLOR,
92
    BLUR,
93
}
94

95
declare interface ShadowOptions {
96
    radius: number | Resource;
97
    type?: ShadowType;
98
    color?: Color | string | Resource | ColoringStrategy;
99
    offsetX?: number | Resource;
100
    offsetY?: number | Resource;
101
    fill?: boolean;
102
}
103

104
declare interface SheetDismiss {
105
    dismiss: () => void;
106
}
107

108
declare enum DismissReason {
109
    PRESS_BACK = 0,
110
    TOUCH_OUTSIDE = 1,
111
    CLOSE_BUTTON = 2,
112
    SLIDE_DOWN = 3
113
}
114

115
declare interface DismissSheetAction {
116
    dismiss: Callback<void>;
117
    reason: DismissReason;
118
}
119

120
declare interface SpringBackAction {
121
    springBack: Callback<void>;
122
}
123

124
declare type CustomBuilder = (() => any) | void;
125

126
declare interface BindOptions {
127
    backgroundColor?: ResourceColor;
128
    onAppear?: () => void;
129
    onDisappear?: () => void;
130
    onWillAppear?: () => void;
131
    onWillDisappear?: () => void;
132
}
133

134
declare type UIContext = import('../api/@ohos.arkui.UIContext').UIContext; // hack
135

136
declare interface SheetOptions extends BindOptions {
137
    height?: SheetSize | Length;
138
    dragBar?: boolean;
139
    maskColor?: ResourceColor;
140
    detents?: [(SheetSize | Length), (SheetSize | Length)?, (SheetSize | Length)?];
141
    blurStyle?: BlurStyle;
142
    showClose?: boolean | Resource;
143
    preferType?: SheetType;
144
    title?: SheetTitleOptions | CustomBuilder;
145
    shouldDismiss?: (sheetDismiss: SheetDismiss) => void;
146
    onWillDismiss?: Callback<DismissSheetAction>;
147
    onWillSpringBackWhenDismiss?: Callback<SpringBackAction>;
148
    enableOutsideInteractive?: boolean;
149
    width?: Dimension;
150
    borderWidth?: Dimension | EdgeWidths | LocalizedEdgeWidths;
151
    borderColor?: ResourceColor | EdgeColors | LocalizedEdgeColors;
152
    borderStyle?: BorderStyle | EdgeStyles;
153
    shadow?: ShadowOptions | ShadowStyle;
154
    onHeightDidChange?: Callback<number>;
155
    mode?: SheetMode;
156
    onDetentsDidChange?: Callback<number>;
157
    onWidthDidChange?: Callback<number>;
158
    onTypeDidChange?: Callback<SheetType>;
159
    uiContext?: UIContext;
160
}
161

162
declare enum BlurStyle {
163
    Thin = 0,
164
}
165

166
declare enum ThemeColorMode {
167
    SYSTEM = 0,
168
    LIGHT = 1,
169
    DARK = 2
170
}
171

172
declare enum AdaptiveColor {
173
    DEFAULT = 0,
174
}
175

176
declare interface BlurOptions {
177
    grayscale: [number, number];
178
}
179

180

181

182
declare interface BlurStyleOptions {
183
    colorMode?: ThemeColorMode;
184
    adaptiveColor?: AdaptiveColor;
185
    scale?: number;
186
    blurOptions?: BlurOptions;
187
}
188

189
declare enum BlurStyleActivePolicy {
190
    /**
191
     * The component has the blur effect only when the window is focused.
192
     *
193
     * @syscap SystemCapability.ArkUI.ArkUI.Full
194
     * @crossplatform
195
     * @atomicservice
196
     * @since 12
197
     */
198
    FOLLOWS_WINDOW_ACTIVE_STATE = 0,
199

200
    /**
201
     * The component always has the blur effect, regardless of whether the window is focused.
202
     *
203
     * @syscap SystemCapability.ArkUI.ArkUI.Full
204
     * @crossplatform
205
     * @atomicservice
206
     * @since 12
207
     */
208
    ALWAYS_ACTIVE = 1,
209

210
    /**
211
     * The component does not have the blur effect, regardless of whether the window is focused.
212
     *
213
     * @syscap SystemCapability.ArkUI.ArkUI.Full
214
     * @crossplatform
215
     * @atomicservice
216
     * @since 12
217
     */
218
    ALWAYS_INACTIVE = 2,
219
}
220

221
declare enum BlurType {
222
    /**
223
     * The blur is applied within the window.
224
     *
225
     * @syscap SystemCapability.ArkUI.ArkUI.Full
226
     * @crossplatform
227
     * @atomicservice
228
     * @since 12
229
     */
230
    WITHIN_WINDOW = 0,
231
    /**
232
     * The blur is applied behind the window.
233
     *
234
     * @syscap SystemCapability.ArkUI.ArkUI.Full
235
     * @crossplatform
236
     * @atomicservice
237
     * @since 12
238
     */
239
    BEHIND_WINDOW = 1
240
}
241

242
declare interface BackgroundBlurStyleOptions extends BlurStyleOptions {}
243

244
declare interface SizeResult {
245
    width: number,
246
    height: number,
247
}
248

249
declare type EdgeWidths = {
250
    top?: Length;
251
    right?: Length;
252
    bottom?: Length;
253
    left?: Length;
254
};
255

256
declare type EdgeWidth = EdgeWidths;
257

258
declare type Padding = {
259
    top?: Length;
260
    right?: Length;
261
    bottom?: Length;
262
    left?: Length;
263
};
264

265
declare interface LocalizedEdgeWidths {
266
    top?: LengthMetrics;
267
    end?: LengthMetrics;
268
    bottom?: LengthMetrics;
269
    start?: LengthMetrics;
270
};
271

272
declare type EdgeColors = {
273
    top?: ResourceColor;
274
    right?: ResourceColor;
275
    bottom?: ResourceColor;
276
    left?: ResourceColor;
277
};
278

279
declare interface LocalizedEdgeColors  {
280
    top?: ResourceColor;
281
    end?: ResourceColor;
282
    bottom?: ResourceColor;
283
    start?: ResourceColor;
284
};
285

286
declare type BorderRadiuses = {
287
    topLeft?: Length;
288
    topRight?: Length;
289
    bottomLeft?: Length;
290
    bottomRight?: Length;
291
};
292

293
declare interface LocalizedBorderRadiuses  {
294
    topStart?: LengthMetrics;
295
    topEnd?: LengthMetrics;
296
    bottomStart?: LengthMetrics;
297
    bottomEnd?: LengthMetrics;
298
};
299

300
declare enum BorderStyle {
301
    Dotted,
302
    Dashed,
303
    Solid,
304
}
305

306
declare type EdgeStyles = {
307
    top?: BorderStyle;
308
    right?: BorderStyle;
309
    bottom?: BorderStyle;
310
    left?: BorderStyle;
311
};
312

313
declare interface BorderOptions {
314
    //width?: EdgeWidths | Length | LocalizedEdgeWidths;
315
    //color?: EdgeColors | ResourceColor | LocalizedEdgeColors;
316
    //radius?: BorderRadiuses | Length | LocalizedBorderRadiuses;
317
    //style?: EdgeStyles | BorderStyle;
318
}
319

320
declare enum DragPreviewMode {
321
  AUTO = 1,
322
  DISABLE_SCALE = 2,
323
  ENABLE_DEFAULT_SHADOW = 3,
324
  ENABLE_DEFAULT_RADIUS = 4,
325
}
326

327
declare type ImageModifier = import('../api/arkui/ImageModifier').ImageModifier; // hack
328

329
declare interface DragPreviewOptions {
330
    mode?: DragPreviewMode | Array<DragPreviewMode>;
331
    modifier?: ImageModifier;
332
    numberBadge?: boolean | number;
333
}
334

335
declare interface DragInteractionOptions {
336

337
    isMultiSelectionEnabled?: boolean;
338

339
    defaultAnimationBeforeLifting?: boolean;
340
}
341

342
declare enum GradientDirection {
343
    Left,
344
    Top,
345
    Right,
346
    Bottom,
347
    LeftTop,
348
    LeftBottom,
349
    RightTop,
350
    RightBottom,
351
    None,
352
}
353

354
declare class AttributeModifier<T> {}
355

356
declare class CommonMethod<T> {
357

358
    constructor();
359

360
    stateStyles(value: StateStyles): T;
361

362
    backdropBlur(value: number, options?: BlurOptions): T;
363

364
    width(value: Length): T;
365

366
    height(value: Length): T;
367

368
    key(value: string): T;
369

370
    restoreId(value: number): T;
371

372
    padding(value: Padding | Dimension): T;
373

374
    bindSheet(isShow: boolean, builder: CustomBuilder, options?: SheetOptions): T;
375

376
    backgroundBlurStyle(value: BlurStyle, options?: BackgroundBlurStyleOptions): T;
377

378
    dragPreviewOptions(value: DragPreviewOptions, options?: DragInteractionOptions): T;
379

380
    linearGradient(value: {
381
        angle?: number | string;
382
        direction?: GradientDirection;
383
        colors: Array<[ResourceColor, number]>;
384
        repeating?: boolean;
385
    }): T;
386

387
    border(value: BorderOptions): T;
388

389
    onChildTouchTest(event: (value: Array<TouchTestInfo>) => string): T;
390

391
    attributeModifier(modifier: AttributeModifier<T>): T
392

393
    gestureModifier(modifier: GestureModifier): T;
394

395
    onGestureRecognizerJudgeBegin(callback: GestureRecognizerJudgeBeginCallback): T;
396
}
397

398
declare interface Rectangle {
399

400
    x?: Length;
401

402
    y?: Length;
403

404
    width?: Length;
405

406
    height?: Length;
407
}
408

409
declare interface RectResult {
410
    x: number;
411
    y: number;
412
    width: number;
413
    height: number;
414
}
415

416
declare class TouchTestInfo {
417
    windowX: number;
418
    windowY: number;
419
    parentX: number;
420
    parentY: number;
421
    x: number;
422
    y: number;
423
    rect: RectResult;
424
    id: string;
425
}
426
declare interface CommonInterface {
427
    (): CommonAttribute
428
}
429

430
declare class CommonAttribute extends CommonMethod<CommonAttribute> {
431
}
432

433
declare const Common: CommonInterface
434

435
declare class CustomComponent extends CommonAttribute {
436
    build(): void;
437
    aboutToAppear?(): void;
438
    aboutToDisappear?(): void;
439
    aboutToReuse?(params: { [key: string]: unknown }): void;
440
    aboutToRecycle?(): void;
441
}
442

443
declare class CommonShapeMethod<T> extends CommonMethod<T> {
444
    constructor();
445

446
    stroke(value: ResourceColor): T;
447
}
448

449
declare class ScrollableCommonMethod<T> extends CommonMethod<T> {
450
    scrollBarWidth(value: number | string): T;
451
}
452

453
declare enum SourceTool {
454
    Unknown,
455
    Finger,
456
    Pen,
457
    MOUSE,
458
    TOUCHPAD,
459
    JOYSTICK,
460
}
461

462
declare interface UIGestureEvent {
463

464
  addGesture<T>(gesture: GestureHandler<T>, priority?: GesturePriority, mask?: GestureMask): void;
465
}
466

467
declare interface GestureModifier {
468
  applyGesture(): void;
469
  applyGesture(event: UIGestureEvent): void;
470
}
471

472
declare type GestureRecognizerJudgeBeginCallback = (event: BaseGestureEvent, current: GestureRecognizer, recognizers: Array<GestureRecognizer>) => GestureJudgeResult;
473

474

475
declare module 'commonEvent' {
476
    module 'commonEvent' {
477
        // @ts-ignore
478
        export { UICommonEvent };
479
    }
480
}
481

482
declare module 'commonAttribute'{
483
    module 'commonAttribute' {
484
        // @ts-ignore
485
        export { CommonAttribute };
486
    }
487
}
488

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.