• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 */
15import { BroadCast, BrowserConstants as PhotoConstants } from '@ohos/common';
16
17@Component
18export struct TipPopup {
19  @State isShowPop: boolean = false;
20  @Consume broadCast: BroadCast;
21  private popAppearFunc: Function = (): void => this.popAppear();
22  private popDisappearFunc: Function = (): void => this.popDisappear();
23
24  private popAppear(): void {
25    this.isShowPop = true;
26  }
27
28  private popDisappear(): void {
29    this.isShowPop = false;
30  }
31
32  aboutToAppear() {
33    this.broadCast.on(PhotoConstants.POP_APPEAR, this.popAppearFunc);
34    this.broadCast.on(PhotoConstants.POP_DISAPPEAR, this.popDisappearFunc);
35  }
36
37  aboutToDisappear(): void {
38    if (this.broadCast) {
39      this.broadCast.off(PhotoConstants.POP_APPEAR, this.popAppearFunc);
40      this.broadCast.off(PhotoConstants.POP_DISAPPEAR, this.popDisappearFunc);
41    }
42  }
43
44  build() {
45    if (this.isShowPop) {
46      Row() {
47        Text($r('app.string.video_pause'))
48          .fontSize($r('sys.float.ohos_id_text_size_headline7'))
49          .fontFamily($r('app.string.id_text_font_family_regular'))
50          .fontColor($r('app.color.white'))
51          .maxLines(1)
52          .textOverflow({ overflow: TextOverflow.Ellipsis })
53          .align(Alignment.Center)
54      }
55      .backgroundColor($r('app.color.detail_view_bg_color'))
56      .padding($r('app.float.popup_padding'))
57      .borderRadius(15)
58    }
59  }
60}
61