1/* 2 * Copyright (c) 2021-2023 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 */ 20/** 21 * Declare the type of status button 22 * @form 23 * @since 9 24 */ 25declare enum ToggleType { 26 /** 27 * Checkbox 28 * @since 8 29 */ 30 /** 31 * Checkbox 32 * @form 33 * @since 9 34 */ 35 Checkbox, 36 37 /** 38 * Switch 39 * @since 8 40 */ 41 /** 42 * Switch 43 * @form 44 * @since 9 45 */ 46 Switch, 47 48 /** 49 * Button 50 * @since 8 51 */ 52 /** 53 * Button 54 * @form 55 * @since 9 56 */ 57 Button, 58} 59 60/** 61 * Defines the toggle interface. 62 * @since 8 63 */ 64/** 65 * Defines the toggle interface. 66 * @form 67 * @since 9 68 */ 69interface ToggleInterface { 70 /** 71 * Set parameters to obtain the toggle. 72 * @since 8 73 */ 74 /** 75 * Set parameters to obtain the toggle. 76 * @form 77 * @since 9 78 */ 79 (options: { type: ToggleType; isOn?: boolean }): ToggleAttribute; 80} 81 82/** 83 * Defines the toggle attribute functions 84 * @since 8 85 */ 86/** 87 * Defines the toggle attribute functions 88 * @form 89 * @since 9 90 */ 91declare class ToggleAttribute extends CommonMethod<ToggleAttribute> { 92 /** 93 * Called when the selected state of the component changes. 94 * @since 8 95 */ 96 /** 97 * Called when the selected state of the component changes. 98 * @form 99 * @since 9 100 */ 101 onChange(callback: (isOn: boolean) => void): ToggleAttribute; 102 103 /** 104 * Called when the color of the selected button is set. 105 * @since 8 106 */ 107 /** 108 * Called when the color of the selected button is set. 109 * @form 110 * @since 9 111 */ 112 selectedColor(value: ResourceColor): ToggleAttribute; 113 114 /** 115 * Called when the color of the selected button is set. 116 * @since 8 117 */ 118 /** 119 * Called when the color of the selected button is set. 120 * @form 121 * @since 9 122 */ 123 switchPointColor(color: ResourceColor): ToggleAttribute; 124} 125 126/** 127 * Defines Toggle Component. 128 * @since 8 129 */ 130/** 131 * Defines Toggle Component. 132 * @form 133 * @since 9 134 */ 135declare const Toggle: ToggleInterface; 136 137/** 138 * Defines Toggle Component instance. 139 * @since 8 140 */ 141/** 142 * Defines Toggle Component instance. 143 * @form 144 * @since 9 145 */ 146declare const ToggleInstance: ToggleAttribute; 147