• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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 */
15let __decorate = this && this.__decorate || function (e, o, t, i) {
16    let n;
17    let r = arguments.length;
18    let l = r < 3 ? o : null === i ? i = Object.getOwnPropertyDescriptor(o,) : i;
19    if ('object' === typeof Reflect && 'function' === typeof Reflect.decorate) {
20        l = Reflect.decorate(e, o, t, i);
21    } else {
22        for (let s = e.length - 1; s >= 0; s--) {
23            (n = e[s]) && (l = (r < 3 ? n(l) : r > 3 ? n(o, t, l) : n(o, t)) || l);
24        }
25    }
26    return r > 3 && l && Object.defineProperty(o, t, l), l;
27};
28
29export class AlbumPickerComponent extends ViewPU {
30    constructor(e, o, n, t = -1, i = void 0) {
31        super(e, n, t);
32        'function' === typeof i && (this.paramsGenerator_ = i);
33        this.albumPickerOptions = void 0;
34        this.onAlbumClick = void 0;
35        this.onEmptyAreaClick = void 0;
36        this.__albumPickerController = new SynchedPropertyNesedObjectPU(o.albumPickerController, this, 'albumPickerController');
37        this.proxy = void 0;
38        this.setInitiallyProvidedValue(o);
39        this.declareWatch('albumPickerController', this.onChanged);
40    }
41
42    setInitiallyProvidedValue(e) {
43        void 0 !== e.albumPickerOptions && (this.albumPickerOptions = e.albumPickerOptions);
44        void 0 !== e.onAlbumClick && (this.onAlbumClick = e.onAlbumClick);
45        void 0 !== e.onEmptyAreaClick && (this.onEmptyAreaClick = e.onEmptyAreaClick);
46        this.__albumPickerController.set(e.albumPickerController);
47        void 0 !== e.proxy && (this.proxy = e.proxy);
48    }
49
50    updateStateVars(e) {
51        this.__albumPickerController.set(e.albumPickerController);
52    }
53
54    purgeVariableDependenciesOnElmtId(e) {
55        this.__albumPickerController.purgeDependencyOnElmtId(e);
56    }
57
58    purgeVariableDependenciesOnElmtId(e) {
59    }
60
61    aboutToBeDeleted() {
62        this.__albumPickerController.aboutToBeDeleted();
63        SubscriberManager.Get().delete(this.id__());
64        this.aboutToBeDeletedInternal();
65    }
66
67    get albumPickerController() {
68        return this.__albumPickerController.get();
69    }
70
71    initialRender() {
72        this.observeComponentCreation2(((e, o) => {
73            Row.create();
74            Row.height('100%');
75        }), Row);
76        this.observeComponentCreation2(((e, o) => {
77            Column.create();
78            Column.width('100%');
79        }), Column);
80        this.observeComponentCreation2(((e, o) => {
81            var n;
82            var m;
83            var i;
84            SecurityUIExtensionComponent.create({
85                parameters: {
86                    'ability.want.params.uiExtensionTargetType': 'photoPicker',
87                    targetPage: 'albumPage',
88                    themeColorMode: null === (n = this.albumPickerOptions) || void 0 === n ? void 0 : n.themeColorMode,
89                    filterType: null === (m = this.albumPickerOptions) || void 0 === m ? void 0 : m.filterType,
90                    fontSize: null === (i = this.albumPickerOptions) || void 0 === i ? void 0 : i.fontSize,
91                }
92            });
93            SecurityUIExtensionComponent.height('100%');
94            SecurityUIExtensionComponent.width('100%');
95            SecurityUIExtensionComponent.onRemoteReady((e => {
96                this.proxy = e;
97                console.info('AlbumPickerComponent onRemoteReady');
98            }));
99            SecurityUIExtensionComponent.onReceive((e => {
100                this.handleOnRecevie(e);
101            }));
102            SecurityUIExtensionComponent.onError((() => {
103                console.info('AlbumPickerComponent onError');
104            }));
105        }), SecurityUIExtensionComponent);
106        Column.pop();
107        Row.pop();
108    }
109
110    onChanged() {
111        let e;
112        if (!this.proxy) {
113            return;
114        }
115        let o = null === (e = this.albumPickerController) || void 0 === e ? void 0 : e.data;
116        if (null == o ? void 0 : o.has('SET_FONT_SIZE')) {
117            this.proxy.send({ fontSize: null == o ? void 0 : o.get('SET_FONT_SIZE') });
118            console.info('AlbumPickerComponent onChanged: SET_FONT_SIZE');
119        }
120    }
121
122    handleOnRecevie(e) {
123        let o = e;
124        let n = o.dataType;
125        if ('selectAlbum' === n) {
126            if (this.onAlbumClick) {
127                let e = new AlbumInfo;
128                e.uri = o.albumUri;
129                e.albumName = o.albumName;
130                this.onAlbumClick(e);
131            }
132        } else if ('emptyAreaClick' === n) {
133            if (this.onEmptyAreaClick) {
134                this.onEmptyAreaClick();
135            }
136        } else {
137            console.info('AlbumPickerComponent onReceive: other case');
138        }
139        console.info('AlbumPickerComponent onReceive ' + n);
140    }
141
142    rerender() {
143        this.updateDirtyElements();
144    }
145}
146
147let AlbumPickerController = class {
148    setFontSize(e) {
149        this.data = new Map([['SET_FONT_SIZE', e]]);
150        console.info('AlbumPickerComponent SET_FONT_SIZE ' + e);
151    }
152};
153AlbumPickerController = __decorate([Observed], AlbumPickerController);
154
155export class AlbumPickerOptions {
156}
157
158export class AlbumInfo {
159}
160
161export default { AlbumPickerComponent, AlbumPickerOptions, AlbumInfo, AlbumPickerController };