1/** 2 * Copyright (c) 2021-2022 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@Component 17export struct SubItemToggle { 18 @LocalStorageProp('currentBreakpoint') curBp: string = 'sm' 19 private title: string | Resource = ''; 20 private isOn: boolean = false 21 22 build() { 23 Row() { 24 Text(this.title) 25 .fontSize($r('sys.float.ohos_id_text_size_body1')) 26 .fontColor($r('sys.color.ohos_id_color_text_primary')) 27 .fontWeight(FontWeight.Medium) 28 .textAlign(TextAlign.Start) 29 30 Blank() 31 32 Toggle({ type: ToggleType.Switch, isOn: this.isOn }) 33 .id('ToggleSwitch') 34 .width(36) 35 .height(20) 36 .selectedColor('#007DFF') 37 } 38 .height(48) 39 .width('100%') 40 .padding({left: 8, right: 8}) 41 .borderRadius(24) 42 .backgroundColor($r('app.color.itemInactivated')) 43 } 44}