• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2021-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 */
15import { Log } from '@ohos/common';
16import { localEventManager } from '@ohos/common';
17import { EventConstants } from '@ohos/common';
18import { CommonConstants } from '@ohos/common';
19import RecentMissionCard from '../common/uicomponents/RecentMissionCard';
20import { RecentMissionsViewModel } from '../viewmodel/RecentMissionsViewModel';
21import { RecentsStyleConstants } from '../common/constants/RecentsStyleConstants';
22import { windowManager } from '@ohos/common';
23
24const TAG = 'RecentMissionsDoubleLayout';
25
26/**
27 * Double-line display of recent task list (pad adaptation).
28 */
29@Component
30export struct RecentMissionsDoubleLayout {
31  @Link recentMissionsDoubleList: [];
32  @Link isClickSubComponent: boolean;
33  private mRecentMissionsViewModel: RecentMissionsViewModel;
34
35  aboutToAppear(): void {
36    Log.showInfo(TAG, 'aboutToAppear start');
37    this.mRecentMissionsViewModel = RecentMissionsViewModel.getInstance();
38  }
39
40  aboutToDisappear(): void {
41    Log.showInfo(TAG, `aboutToDisappear start`);
42  }
43
44  itemChance(item: any): any {
45    item.snapShotTime = '';
46    return item;
47  }
48
49  build() {
50    Column() {
51      Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Center }) {
52        Grid() {
53          ForEach(this.recentMissionsDoubleList, (item) => {
54              GridItem() {
55                RecentMissionCard({
56                  missionId: item.missionId,
57                  appIconId: item.appIconId,
58                  appLabelId: item.appLabelId,
59                  appName: item.appName,
60                  bundleName: item.bundleName,
61                  moduleName: item.moduleName,
62                  abilityName: item.abilityName,
63                  lockedState: item.lockedState,
64                  isClickSubComponent: $isClickSubComponent,
65                  snapShotTime: item.snapShotTime
66                })
67              }
68              .align(Alignment.Center)
69          },(item) => JSON.stringify(this.itemChance(item)))
70        }
71        .width(RecentsStyleConstants.DEFAULT_LAYOUT_PERCENTAGE)
72        .rowsTemplate('1fr 1fr')
73        .direction(Direction.Rtl)
74        .columnsGap(RecentsStyleConstants.DOUBLE_LIST_LAYOUT_COLUMNSGAP)
75        .rowsGap(RecentsStyleConstants.DOUBLE_LIST_LAYOUT_ROWSGAP)
76      }
77      .margin({
78        top: RecentsStyleConstants.DOUBLE_LIST_TOP_MARGIN,
79      })
80      .width(RecentsStyleConstants.DEFAULT_LAYOUT_PERCENTAGE)
81      .height(RecentsStyleConstants.DOUBLE_LIST_GRID_HEIGHT_PERCENTAGE)
82
83      Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }){
84        Stack(){
85          Column(){
86          }
87          .width(RecentsStyleConstants.RECENT_DELETE_IMAGE_COLUMN_SIZE)
88          .height(RecentsStyleConstants.RECENT_DELETE_IMAGE_COLUMN_SIZE)
89          .opacity(RecentsStyleConstants.DEFAULT_DELETE_IMAGE_OPACITY)
90          .backgroundColor(RecentsStyleConstants.DEFAULT_FONT_COLOR)
91          .borderRadius(RecentsStyleConstants.RECENT_DELETE_IMAGE_RADIUS)
92          .padding(8)
93
94          Image(RecentsStyleConstants.DEFAULT_DELETE_IMAGE_FULL)
95            .width(RecentsStyleConstants.RECENT_DELETE_IMAGE_SIZE)
96            .height(RecentsStyleConstants.RECENT_DELETE_IMAGE_SIZE)
97        }
98        .onClick(() => {
99          this.isClickSubComponent = true;
100          Log.showDebug(TAG, 'onClick click delete button');
101          localEventManager.sendLocalEventSticky(EventConstants.EVENT_ANIMATION_CLOSE_APPLICATION, null);
102          this.mRecentMissionsViewModel.deleteRecentMission(true, CommonConstants.INVALID_VALUE);
103          this.mRecentMissionsViewModel.backView();
104          this.mRecentMissionsViewModel.getRecentMissionsList();
105        })
106      }
107      .width(RecentsStyleConstants.DEFAULT_LAYOUT_PERCENTAGE)
108    }
109    .width(RecentsStyleConstants.DEFAULT_LAYOUT_PERCENTAGE)
110    .height(RecentsStyleConstants.DEFAULT_LAYOUT_PERCENTAGE)
111  }
112}