1/* 2 * Copyright (c) 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// @ts-nocheck 17 18import { LoadingDialog } from '../phoneView/LoadingDialog' 19import { myMedia } from '../model/myMedia' 20import Logger from '../model/Logger' 21 22const TAG = 'InputDialog: ' 23 24@Component 25export struct TitleBar { 26 @Link isPlaying: $isPlaying 27 @Link currentTime: number 28 @Link myMedia: myMedia 29 @Prop httpUrl: string 30 @Link isXComponent: boolean 31 @State search: boolean = true 32 @State isInputBg: string = 'rgba(255,255,255,1)' 33 private timer: number = undefined 34 private mXComponentController: XComponentController 35 private LoadingDialog: CustomDialogController = new CustomDialogController({ 36 builder: LoadingDialog(), 37 autoCancel: false, 38 alignment: DialogAlignment.Center, 39 customStyle: true 40 }) 41 42 build() { 43 Row() { 44 Button({ stateEffect: false }) { 45 TextInput({ text: this.httpUrl }) 46 .fontColor(this.isInputBg) 47 .backgroundColor('#343434') 48 .width('100%') 49 .height('100%') 50 .fontSize(18) 51 .align(Alignment.Center) 52 .onChange((value) => { 53 this.httpUrl = value 54 this.isXComponent = true 55 this.search = false 56 }) 57 .onEditChange(() => { 58 this.search = false 59 }) 60 .onSubmit(() => { 61 this.isInputBg = 'rgba(255,255,255,0.6)' 62 this.isPlaying = true 63 Logger.info(TAG + `${this.httpUrl}`) 64 let surfaceId = this.mXComponentController.getXComponentSurfaceId() 65 Logger.info(TAG + surfaceId) 66 this.myMedia.httpInit(this.httpUrl, surfaceId) 67 if (this.timer !== undefined) { 68 clearInterval(this.timer) 69 } 70 this.timer = setInterval(() => { 71 this.currentTime = this.myMedia.getCurrentTime() 72 if (this.currentTime < 1) { 73 this.LoadingDialog.open() 74 } else { 75 this.LoadingDialog.close() 76 } 77 }, 1000) 78 }) 79 } 80 .width('85%') 81 .backgroundColor('#343434') 82 .height('5%') 83 84 Image($r('app.media.phone_icon_setting')) 85 .width(24) 86 .height(24) 87 .opacity(0.4) 88 if (this.search) { 89 Image($r('app.media.phone_icon_search')) 90 .width(24) 91 .height(24) 92 .opacity(0.4) 93 .position({ x: '6%', y: '7' }) 94 } 95 } 96 .justifyContent(FlexAlign.SpaceEvenly) 97 .width('100%') 98 .margin({ top: 15, bottom: 15 }) 99 } 100}