• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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
16const TAG = 'avcastpicker_component ';
17
18export var AVCastPickerState;
19!function(e) {
20  e[e.STATE_APPEARING = 0] = 'STATE_APPEARING';
21  e[e.STATE_DISAPPEARING = 1] = 'STATE_DISAPPEARING';
22}(AVCastPickerState || (AVCastPickerState = {}));
23
24export class AVCastPicker extends ViewPU {
25  constructor(e, t, o, n = -1) {
26    super(e, o, n);
27    this.__normalColor = new SynchedPropertySimpleOneWayPU(t.normalColor, this, 'normalColor');
28    this.__activeColor = new SynchedPropertySimpleOneWayPU(t.activeColor, this, 'activeColor');
29    this.onStateChange = void 0;
30    this.setInitiallyProvidedValue(t);
31  }
32
33  setInitiallyProvidedValue(e) {
34    void 0 === e.normalColor && this.__normalColor.set('#000000');
35    void 0 === e.activeColor && this.__activeColor.set('#000000');
36    void 0 !== e.onStateChange && (this.onStateChange = e.onStateChange);
37  }
38
39  updateStateVars(e) {
40    this.__normalColor.reset(e.normalColor);
41    this.__activeColor.reset(e.activeColor);
42  }
43
44  purgeVariableDependenciesOnElmtId(e) {
45    this.__normalColor.purgeDependencyOnElmtId(e);
46    this.__activeColor.purgeDependencyOnElmtId(e);
47  }
48
49  aboutToBeDeleted() {
50    this.__normalColor.aboutToBeDeleted();
51    this.__activeColor.aboutToBeDeleted();
52    SubscriberManager.Get().delete(this.id__());
53    this.aboutToBeDeletedInternal();
54  }
55
56  get normalColor() {
57    return this.__normalColor.get();
58  }
59
60  set normalColor(e) {
61    this.__normalColor.set(e);
62  }
63
64  get activeColor() {
65    return this.__activeColor.get();
66  }
67
68  set activeColor(e) {
69    this.__activeColor.set(e);
70  }
71
72  initialRender() {
73    this.observeComponentCreation2(((e, t) => {
74      Column.create();
75      Column.size({ width: '100%', height: '100%' });
76    }), Column);
77    this.observeComponentCreation2(((e, t) => {
78      UIExtensionComponent.create({
79        abilityName: 'UIExtAbility',
80        bundleName: 'com.hmos.mediacontroller',
81        parameters: { normalColor: this.normalColor }
82      });
83      UIExtensionComponent.onReceive((e => {
84        console.info(TAG, `picker state change : ${JSON.stringify(e.state)}`);
85        null != this.onStateChange && (parseInt(JSON.stringify(e.state)) === AVCastPickerState.STATE_APPEARING ?
86          this.onStateChange(AVCastPickerState.STATE_APPEARING) :
87          this.onStateChange(AVCastPickerState.STATE_DISAPPEARING));
88      }));
89      UIExtensionComponent.size({ width: '100%', height: '100%' });
90    }), UIExtensionComponent);
91    Column.pop();
92  }
93
94  rerender() {
95    this.updateDirtyElements();
96  }
97}
98export default AVCastPicker;