• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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/**
17 * Declare the type of status button
18 * @since 8
19 */
20declare enum ToggleType {
21  /**
22   * Checkbox
23   * @since 8
24   */
25  Checkbox,
26
27  /**
28   * Switch
29   * @since 8
30   */
31  Switch,
32
33  /**
34   * Button
35   * @since 8
36   */
37  Button,
38}
39
40/**
41 * Defines the toggle interface.
42 * @since 8
43 */
44interface ToggleInterface {
45  /**
46   * Set parameters to obtain the toggle.
47   * @since 8
48   */
49  (options: { type: ToggleType; isOn?: boolean }): ToggleAttribute;
50}
51
52/**
53 * Defines the toggle attibute functions
54 * @since 8
55 */
56declare class ToggleAttribute extends CommonMethod<ToggleAttribute> {
57  /**
58   * Called when the selected state of the component changes.
59   * @since 8
60   */
61  onChange(callback: (isOn: boolean) => void): ToggleAttribute;
62
63  /**
64   * Called when the color of the selected button is set.
65   * @since 8
66   */
67  selectedColor(value: ResourceColor): ToggleAttribute;
68
69  /**
70   * Called when the color of the selected button is set.
71   * @since 8
72   */
73  switchPointColor(color: ResourceColor): ToggleAttribute;
74}
75
76declare const Toggle: ToggleInterface;
77declare const ToggleInstance: ToggleAttribute;
78