• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2024-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 */
15
16import router from '@ohos.router';
17import Constants from '../common/constants/ComConstant';
18import Logger from '../common/utils/Logger';
19
20const TAG = 'UiExtensionPage'
21
22@Entry
23@Component
24struct UiExtensionPage {
25  @State routerParma: Record<string, string> = router.getParams() as Record<string, string>;
26  @State dstBundleName: string = this.routerParma['dstBundleName'];
27  @State dstAbilityName: string = this.routerParma['dstAbilityName'];
28
29  build() {
30    Row() {
31      UIExtensionComponent({
32        bundleName: this.dstBundleName,
33        abilityName: this.dstAbilityName,
34        parameters: {
35          'ability.want.params.uiExtensionType': 'sys/commonUI',
36        }
37      })
38        .onRemoteReady((data) => {
39          Logger.debug(TAG, 'UiExtensionPage onRemoteReady: ' + JSON.stringify(data));
40        })
41        .onResult((data) => {
42          Logger.debug(TAG, 'UiExtensionPage onResult: ' + JSON.stringify(data));
43        })
44        .onRelease((code) => {
45          Logger.debug(TAG, 'UiExtensionPage code: ' + JSON.stringify(code));
46        })
47        .onReceive((data) => {
48          //   update message
49          Logger.debug(TAG, 'UiExtensionPage onReceive: ' + JSON.stringify(data));
50          if (data['action'] === 'exit') {
51            router.back();
52          }
53        })
54        .height(Constants.WIDTH_HEIGHT_FULL_SCREEN)
55        .width(Constants.WIDTH_HEIGHT_FULL_SCREEN)
56    }
57    .height(Constants.WIDTH_HEIGHT_FULL_SCREEN)
58    .width(Constants.WIDTH_HEIGHT_FULL_SCREEN)
59  }
60}