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 */
15
16import Log from '../../../../../../common/src/main/ets/default/Log';
17import ShotScreenModel from '../../../../../../features/screenshot/src/main/ets/com/ohos/model/screenShotModel';
18import Want from '@ohos.app.ability.Want';
19
20const TAG = 'ScreenShot-ViewModel';
21const GALLERY_BUNDLE = 'com.ohos.photos';
22const GALLERY_ABILITY = 'com.ohos.photos.MainAbility';
23
24export class ViewModel {
25  constructor() {
26    this.ViewModelInit();
27  }
28
29  ViewModelInit(): void {
30    Log.showInfo(TAG, 'ViewModelInit');
31  }
32
33  StartPhotosAbility(imageFileName: string): void {
34    Log.showInfo(TAG, `StartPhotosAbility imageFileName:${imageFileName}`);
35    const wantData: Want = {
36      bundleName: GALLERY_BUNDLE,
37      abilityName: GALLERY_ABILITY,
38      parameters: {
39        uri: imageFileName
40      }
41    };
42    ShotScreenModel.openAbility(wantData);
43    //close window
44    ShotScreenModel.dismiss();
45  }
46
47  CloseShotScreen(): void {
48    //close window
49    ShotScreenModel.dismiss();
50  }
51}
52
53let viewModel = new ViewModel();
54
55export default viewModel as ViewModel;