• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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
16import Caller from '../bean/Caller';
17import ComponentPerson from '../components/ComponentPerson';
18import ComponentSingletonTimer from '../components/ComponentSingletonTimer';
19import FloatWindowController from '../controller/FloatWindowController';
20
21/**
22 * 通用背景组件,包含
23 *    悬浮窗切换按钮
24 *    头像名称
25 *    提示语/计时组件
26 *    单个@BuilderParam,可以以闭包形式传入按钮group,实现不同页面的不同操作按钮
27 */
28@Component
29export default struct ComponentVoiceBg {
30  @Link mPerson: Caller;
31  @BuilderParam options: () => void;
32  private showTimer?: boolean;
33  private tips?: string | Resource;
34
35  build() {
36    Column() {
37      Column() {
38        Row() {
39          Blank()
40          Button() {
41            Image($r('app.media.icon_openvalley_reduce'))
42              .width(40)
43              .height(40)
44          }
45          .width(64)
46          .height(64)
47          .id('switch_window_to_float')
48          .type(ButtonType.Circle)
49          .backgroundColor($r('app.color.color_transparent'))
50          .onClick(() => {
51            FloatWindowController.getInstance().hideMain();
52          })
53        }.width('80%')
54        .height(64)
55
56        ComponentPerson({ mPerson: $mPerson })
57
58        Column().height(24)
59
60        if (this.showTimer) {
61          ComponentSingletonTimer({ mTextColor: $r('app.color.color_fff'), mTextSize: 18 })
62        } else if (this.tips) {
63          Text(this.tips)
64            .fontColor($r('app.color.color_fff'))
65            .fontSize(18)
66            .fontWeight(FontWeight.Regular)
67            .fontFamily('HarmonyOS Sans SC')
68        }
69      }
70
71      this.options()
72    }
73    .padding({ bottom: 104, top: 56 })
74    .justifyContent(FlexAlign.SpaceBetween)
75    .backgroundColor($r('app.color.color_voice_background'))
76    .width('100%')
77    .height('100%')
78  }
79}