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 sliderstyle 18 * @since 7 19 */ 20declare enum SliderStyle { 21 /** 22 * The slider is on the slide rail. 23 * @since 7 24 */ 25 OutSet, 26 27 /** 28 * The slider is in the slide rail. 29 * @since 7 30 */ 31 InSet, 32} 33 34/** 35 * Declare SliderChangeMode 36 * @since 7 37 */ 38declare enum SliderChangeMode { 39 /** 40 * Start dragging the slider. 41 * @since 7 42 */ 43 Begin, 44 45 /** 46 * Drag the slider. 47 * @since 7 48 */ 49 Moving, 50 51 /** 52 * End dragging the slider. 53 * @since 7 54 */ 55 End, 56 57 /** 58 * Click the slider. 59 * @since 8 60 */ 61 Click, 62} 63 64/** 65 * Defines the options of Slider. 66 * @since 7 67 */ 68declare interface SliderOptions { 69 /** 70 * Current value of Slider. 71 * @since 7 72 */ 73 value?: number; 74 75 /** 76 * Sets the min value of Slider. 77 * @since 7 78 */ 79 min?: number; 80 81 /** 82 * Sets the max value of Slider. 83 * @since 7 84 */ 85 max?: number; 86 87 /** 88 * Sets the step of each slide value. 89 * @since 7 90 */ 91 step?: number; 92 93 /** 94 * Sets the slider style. 95 * @since 7 96 */ 97 style?: SliderStyle; 98 99 /** 100 * Sets the slider direction style. 101 * @since 8 102 */ 103 direction?: Axis; 104 105 /** 106 * Set whether the direction of the slider needs to be reversed. 107 * @since 8 108 */ 109 reverse?: boolean; 110} 111 112/** 113 * Provides an interface for the slide bar component. 114 * @since 7 115 */ 116interface SliderInterface { 117 /** 118 * Called when the slider bar component is used. 119 * @since 7 120 */ 121 (options?: SliderOptions): SliderAttribute; 122} 123 124/** 125 * Defines the attribute functions of Slider. 126 * @since 7 127 */ 128declare class SliderAttribute extends CommonMethod<SliderAttribute> { 129 /** 130 * Called when the slider color of the slider bar is set. 131 * @since 7 132 */ 133 blockColor(value: ResourceColor): SliderAttribute; 134 135 /** 136 * Called when the track color of the slider is set. 137 * @since 7 138 */ 139 trackColor(value: ResourceColor): SliderAttribute; 140 141 /** 142 * Called when the slider of the slider bar is set to slide over the area color. 143 * @since 7 144 */ 145 selectedColor(value: ResourceColor): SliderAttribute; 146 147 /** 148 * Called when the minimum label is set. 149 * @since 7 150 */ 151 minLabel(value: string): SliderAttribute; 152 153 /** 154 * Called when the maximum label is set. 155 * @since 7 156 */ 157 maxLabel(value: string): SliderAttribute; 158 159 /** 160 * Called when setting whether to display step size. 161 * @since 7 162 */ 163 showSteps(value: boolean): SliderAttribute; 164 165 /** 166 * Called when the percentage of bubble prompt is set when sliding. 167 * @since 7 168 */ 169 showTips(value: boolean): SliderAttribute; 170 171 /** 172 * Called when the thickness of track is set. 173 * @since 8 174 */ 175 trackThickness(value: Length): SliderAttribute; 176 177 /** 178 * Called when the selection value changes. 179 * @since 7 180 */ 181 onChange(callback: (value: number, mode: SliderChangeMode) => void): SliderAttribute; 182} 183 184declare const Slider: SliderInterface; 185declare const SliderInstance: SliderAttribute; 186