• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 DateUtil from '@ohos/utils/src/main/ets/default/baseUtil/DateUtil'
17import FolderData from '@ohos/utils/src/main/ets/default/model/databaseModel/FolderData'
18import NoteData from '@ohos/utils/src/main/ets/default/model/databaseModel/NoteData'
19import {
20  TableName,
21  NoteTableColumn,
22  SysDefFolderUuid,
23  Favorite,
24  Delete,
25  Top,
26  NoteType,
27  FolderType
28} from '@ohos/utils/src/main/ets/default/model/databaseModel/EnumData';
29import { NoteDataMoveDialog, DeleteDialog } from './CusDialogComp'
30import RdbStoreUtil from '@ohos/utils/src/main/ets/default/baseUtil/RdbStoreUtil'
31import { promptAction } from '@kit.ArkUI';
32import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil'
33import FolderUtil from '@ohos/utils/src/main/ets/default/baseUtil/FolderUtil'
34import SearchModel from '@ohos/utils/src/main/ets/default/model/searchModel/SearchModel'
35import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil'
36import router from '@ohos.router';
37import inputMethod from '@ohos.inputMethod';
38import webview from '@ohos.web.webview';
39import resourceManager from '@ohos.resourceManager';
40import common from '@ohos.app.ability.common';
41import { BusinessError } from '@ohos.base';
42
43const TAG = "NoteListComp"
44
45interface RouteOption {
46  url: string;
47}
48
49function routePage() {
50  let options: RouteOption = {
51    url: 'pages/NoteContentHome'
52  }
53  try {
54    router.pushUrl(options)
55  } catch (err) {
56    LogUtil.info(TAG, "fail callback")
57  }
58}
59
60interface TextSpan {
61  type: 0 | 1; // 0 表示正常文本,1 表示高亮关键词
62  text: string;
63}
64
65abstract class BasicDataSource<T> implements IDataSource {
66  private listeners: DataChangeListener[] = [];
67
68  public abstract totalCount(): number;
69
70  public getData(index: number): T | void {
71    LogUtil.info(TAG, 'getDataindex: '+index);
72  };
73
74  registerDataChangeListener(listener: DataChangeListener): void {
75    if (this.listeners.indexOf(listener) < 0) {
76      this.listeners.push(listener);
77    };
78  };
79
80  unregisterDataChangeListener(listener: DataChangeListener): void {
81    const pos = this.listeners.indexOf(listener);
82    if (pos >= 0) {
83      this.listeners.splice(pos, 1);
84    };
85  };
86
87  notifyDataReload(): void {
88    this.listeners.forEach((listener: DataChangeListener) => {
89      listener.onDataReloaded();
90    });
91  };
92
93  notifyDataAdd(index: number): void {
94    this.listeners.forEach((listener: DataChangeListener) => {
95      listener.onDataAdd(index);
96    });
97  };
98
99  notifyDataChange(index: number): void {
100    this.listeners.forEach((listener: DataChangeListener) => {
101      listener.onDataChange(index);
102    });
103  };
104
105  notifyDataDelete(index: number): void {
106    this.listeners.forEach((listener: DataChangeListener) => {
107      listener.onDataDelete(index);
108    });
109  };
110
111  notifyDataMove(from: number, to: number): void {
112    this.listeners.forEach((listener: DataChangeListener) => {
113      listener.onDataMove(from, to);
114    });
115  };
116};
117
118class noteListData extends BasicDataSource<NoteData> {
119  private noteList: Array<NoteData> = [];
120
121  public totalCount(): number {
122    return this.noteList.length;
123  };
124
125  public getData(index: number): NoteData {
126    LogUtil.info(TAG, 'getData, index=' + index);
127    return this.noteList[index];
128  };
129
130  public addData(index: number, data: NoteData): void {
131    this.noteList.splice(index, 0, data);
132    this.notifyDataAdd(index);
133  };
134
135  public pushData(data: NoteData): void {
136    this.noteList.push(data);
137    this.notifyDataAdd(this.noteList.length - 1);
138  };
139
140  // 查找列表中对象的index
141  public indexOf(data: NoteData): number {
142    LogUtil.info(TAG, `indexOf data , id = ${data.id} , name = ${data.title}`);
143    return this.noteList.indexOf(data);
144  };
145
146  // 删除列表中处于index位置的对象
147  public deleteDataByIndex(index: number): void {
148    LogUtil.info(TAG, `delete data , index = ${index}}`);
149    this.noteList.splice(index, 1);
150    this.notifyDataDelete(index);
151  };
152
153  // 删除列表中的对象
154  public deleteData(data: NoteData): void {
155    LogUtil.info(TAG, `delete data , data = ${data.id}}`);
156    let index = this.indexOf(data);
157    this.deleteDataByIndex(index);
158  };
159
160  // 修改列表中所有对象
161  public modifyAllData(data: NoteData[]): void {
162    LogUtil.info(TAG, `all data modified`);
163    this.noteList = data;
164    this.notifyDataReload();
165  }
166};
167
168// Note list component
169@Component
170export struct NoteListComp {
171  @StorageLink('topHeight') topHeight: number = 0;
172  @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
173  @Consume('SelectedFolderData') selectedFolderData: FolderData
174  @Consume('Search') search: boolean
175  controllerShow: webview.WebviewController = new webview.WebviewController();
176  @Consume('AsideWidth') asideWidth: number
177
178  build() {
179    Flex({ direction: FlexDirection.Column }) {
180      Flex({ direction: FlexDirection.Column }) {
181        NoteOverViewComp({ controllerShow: this.controllerShow })
182        Column() {
183        }
184        .height(this.search ? 15 : 0)
185
186        NoteItemListComp({ controllerShow: this.controllerShow })
187      }
188      .width('100%')
189      .flexShrink(1)
190
191      Column() {
192        OperateNoteCompForPortrait()
193      }
194      .flexShrink(0)
195      .padding({ bottom: 90})
196    }
197    .height('100%')
198    .width('100%')
199  }
200
201  aboutToAppear(): void {
202    AppStorage.SetOrCreate('isUpdate', false)
203    LogUtil.info(TAG, "aboutToAppear")
204  }
205
206  aboutToDisappear(): void {
207    LogUtil.info(TAG, "aboutToDisappear")
208  }
209}
210
211@Component
212struct NoteOverViewComp {
213  @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')!;
214  @StorageLink('breakPoint') breakPoints: string = AppStorage.Get('breakPoint')!;
215  @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
216  @Consume('SelectedFolderData') selectedFolderData: FolderData
217  @Consume('RefreshFlag') refreshFlag: number
218  @Consume('SectionStatus') sectionStatus: number
219  @Consume("Longpress") longpress: boolean
220  @Consume('ExpandStatus') expandStatus: boolean
221  @Consume('Search') search: boolean
222  @Consume('PortraitModel') portraitModel: boolean
223  controllerShow: webview.WebviewController = new webview.WebviewController();
224  @State noteNumber: number = 0;
225  @StorageLink('isUpdate') @Watch('notesNumberChange') isUpdate: boolean = false
226  @Consume('AsideWidth') asideWidth: number
227  @State isShow: boolean = false
228
229  notesNumberChange() {
230    let noteNumbers = FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid);
231    if (noteNumbers == 0) {
232      this.isShow = false
233    } else {
234      this.isShow = true
235    }
236  }
237
238  build() {
239    Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
240      Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
241        Column() {
242          Image($r("app.media.suojin_back"))
243            .height(24)
244            .width(24)
245            .responseRegion({
246              x: -15.0,
247              y: -15.0,
248              width: 54,
249              height: 54
250            })
251            .margin({ right: 24 }) // 两分栏时缩进图片与右边有个24的间距
252            .visibility(this.breakPoints == 'lg' && this.sectionStatus == 3 ? Visibility.None : Visibility.Visible)
253            .onClick(() => {
254              if (this.breakPoints == 'sm' || this.breakPoints == 'md') {
255                animateTo({ duration: 200 }, () => {
256                  this.expandStatus = !this.expandStatus
257                })
258              } else {
259                this.asideWidth = 200
260                this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3)
261                // save continue data
262                AppStorage.SetOrCreate<number>('ContinueSection', this.sectionStatus)
263                LogUtil.info(TAG, "NoteOverViewComp, set continue section success")
264              }
265            })
266        }.alignItems(HorizontalAlign.Center)
267
268        Flex({
269          direction: FlexDirection.Column,
270          wrap: FlexWrap.Wrap,
271          justifyContent: FlexAlign.Center,
272          alignItems: ItemAlign.Start
273        }) {
274          Text(FolderUtil.getFolderText(this.selectedFolderData))
275            .id(this.isUpdate + '')
276            .maxLines(1)
277            .fontSize(30)
278            .fontColor($r("app.color.all_notes_font_color"))
279            .fontWeight(FontWeight.Medium)
280            .textOverflow({ overflow: TextOverflow.Ellipsis })
281          Row() {
282            Text(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid).toString())
283              .id(this.isUpdate + '')
284              .maxLines(1)
285              .fontSize(14)
286              .fontColor($r("app.color.num_of_notes_font_color"))
287            Text($r("app.string.noteslist"))
288              .fontSize(14)
289              .fontColor($r("app.color.num_of_notes_font_color"))
290              .textOverflow({ overflow: TextOverflow.Ellipsis })
291          }
292          .margin({ top: 5 })
293          .visibility(this.isShow ? Visibility.Visible : Visibility.None)
294        }.visibility(this.longpress ? Visibility.None : Visibility.Visible)
295
296        Row() {
297          Image($r("app.media.cross"))
298            .height(24)
299            .width(24)
300            .responseRegion({
301              x: -15.0,
302              y: -15.0,
303              width: 54,
304              height: 54
305            })
306            .onClick(() => {
307              this.longpress = false
308              this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
309              NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
310            })
311          Text(this.CheckedNoteArray.length == 0 ? $r("app.string.none_selected") : $r("app.string.selected", this.CheckedNoteArray.length))
312            .fontSize(20)
313            .fontColor($r("app.color.note_selected_font_color"))
314            .margin({ left: 16 })
315            .textOverflow({ overflow: TextOverflow.Ellipsis })
316            .fontWeight(FontWeight.Medium)
317        }.alignItems(VerticalAlign.Center)
318        .visibility(this.longpress ? Visibility.Visible : Visibility.None)
319      }.padding({ top: 8, bottom: 8 })
320      .height('100%')
321
322      AddNoteComp({ controllerShow: this.controllerShow })
323      OperateNoteComp({ controllerShow: this.controllerShow })
324      Text(this.refreshFlag.toString()).visibility(Visibility.None)
325    }
326    .width('100%')
327    .height(82)
328    .padding({
329      left: this.sectionStatus == 2 ? 24 : 36,
330      right: 24
331    }) // 两分栏时缩进图标与左侧不需要间距
332    .visibility(this.search ? Visibility.None : Visibility.Visible)
333  }
334}
335
336@Component
337export struct NoteItemComp {
338  public noteItem: NoteData = new NoteData(0, '标题', new Date().getTime() + '', '', '', '', NoteType.SysDef, Top.No, Favorite.No, Delete.No, new Date().getTime(), new Date().getTime(), 0, 0);
339  public spans: TextSpan[] = [];
340  controllerShow: webview.WebviewController = new webview.WebviewController();
341  @Consume('SelectedFolderData') selectedFolderData: FolderData
342  @Consume('SelectedNoteData') selectedNoteData: NoteData
343  @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
344  @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
345  @Consume('ChooseNote') chooseNote: boolean
346  @Consume('RefreshFlag') refreshFlag: number
347  @Consume('Search') search: boolean
348  @Consume('selectedAll') selectedAll: boolean
349  @Consume('PortraitModel') portraitModel: boolean
350  @State isChecked: boolean = false;
351  @Consume('Longpress') @Watch('isLongPress') longpress: boolean
352  @StorageLink('isUpdate') isUpdate: boolean = false
353
354  isLongPress() {
355    if (this.longpress) {
356      this.isChecked = false
357    }
358  }
359
360  updateAndGetChecked() {
361    this.isChecked = NoteUtil.isNoteChecked(this.CheckedNoteArray, this.noteItem)
362    return this.isChecked
363  }
364
365  build() {
366    Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
367      Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
368        Text(JSON.stringify(this.refreshFlag)).visibility(Visibility.None) // 用于强制刷新使用
369        Column({ space: 2 }) {
370          Row({ space: 8 }) {
371            Image($r("app.media.verticalBar"))
372              .id(this.isUpdate + '')
373              .height(16)
374              .width(4)
375              .fillColor(NoteUtil.getVerticalBarBgColor(AppStorage.Get('AllFolderArray')!, this.noteItem.folder_uuid))
376            Text(this.noteItem.title)
377              .fontSize(16)
378              .maxLines(1)
379              .textOverflow({ overflow: TextOverflow.Ellipsis })
380          }
381
382          Row({ space: 4 }) {
383            Text(DateUtil.formateDateForNoteTitle(new Date(this.noteItem.modified_time)))
384              .id(this.isUpdate + '')
385              .maxLines(1)
386              .fontSize(14)
387              .fontColor($r("app.color.list_modified_time_font_color"))
388              .fontWeight(FontWeight.Regular)
389              .textOverflow({ overflow: TextOverflow.Ellipsis })
390            Image($r("app.media.favorite"))
391              .height(16)
392              .width(16)
393              .visibility(this.noteItem.is_favorite == Favorite.Yes ? Visibility.Visible : Visibility.None)
394            Image($r("app.media.topped"))
395              .height(16)
396              .width(16)
397              .visibility(this.noteItem.is_top == Top.Yes ? Visibility.Visible : Visibility.None)
398          }
399          .padding({ left: 12 })
400        }.alignItems(HorizontalAlign.Start)
401      }.flexShrink(1)
402
403      Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
404        Stack({ alignContent: Alignment.Center }) {
405          Image(this.noteItem.content_img)
406            .id(this.isUpdate + '')
407            .height(47)
408            .width(47)
409            .borderRadius(12)
410            .border({ width: 0.5, color: '#19182431' })
411            .visibility(this.noteItem.content_img ? Visibility.Visible : Visibility.None)
412        }
413
414        Stack({ alignContent: Alignment.Center }) {
415          Image($r("app.media.unChecked"))
416            .height(24)
417            .width(24)
418          Image($r("app.media.checked"))
419            .width(24)
420            .height(24)
421            .visibility(this.updateAndGetChecked() ? Visibility.Visible : Visibility.None)
422            .id(this.isUpdate + '')
423        }.width(24)
424        .height(24)
425        .visibility(this.longpress ? Visibility.Visible : Visibility.None)
426      }
427      .flexShrink(0)
428      .height(48)
429      .width(this.longpress ? 80 : 48)
430    }
431    .width('100%')
432    .height(72)
433    .padding({
434      left: 16,
435      right: 12,
436      top: 4,
437      bottom: 4
438    })
439    .borderRadius(24)
440    .linearGradient({
441      direction: GradientDirection.Right,
442      colors: this.selectedNoteData?.uuid == this.noteItem.uuid ? [[0xffcdae, 0.0], [0xFfece2, 1.0]] : [[0xffffff, 0.0], [0xffffff, 1.0]]
443    })
444    .onClick(() => {
445      if (this.search) {
446        this.search = false
447        AppStorage.SetOrCreate<boolean>('Search', this.search)
448        return
449      }
450      if (this.longpress) {
451        if (NoteUtil.isNoteChecked(this.CheckedNoteArray, this.noteItem)) {
452          NoteUtil.unsetNoteChecked(this.CheckedNoteArray, this.noteItem)
453          this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
454          this.isChecked = NoteUtil.isNoteChecked(this.CheckedNoteArray, this.noteItem)
455        } else {
456          NoteUtil.setNoteChecked(this.CheckedNoteArray, this.noteItem)
457          this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
458          this.isChecked = NoteUtil.isNoteChecked(this.CheckedNoteArray, this.noteItem)
459        }
460        return;
461      } else {
462        this.selectedNoteData = this.noteItem
463        this.chooseNote = true
464        // save continue data
465        let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
466        AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
467        LogUtil.info(TAG, "NoteItemComp, set continue note success")
468      }
469      if (this.portraitModel == false) {
470        try {
471          this.controllerShow.runJavaScript(
472            "RICH_EDITOR.setHtml('" + this.selectedNoteData?.content_text + "')"
473          )
474          this.controllerShow.runJavaScript(
475            "RICH_EDITOR.cancelSelection()"
476          )
477          LogUtil.info(TAG, `runJavaScript setHtml and cancelSelection success`);
478        } catch (error) {
479          LogUtil.error(TAG, `runJavaScript setHtml and cancelSelection failed.
480            code:${JSON.stringify(error.code)},message:${JSON.stringify(error.message)}`);
481        }
482      }
483      if (this.portraitModel == true) {
484        AppStorage.SetOrCreate<NoteData>('NewNote', this.selectedNoteData)
485        AppStorage.SetOrCreate<FolderData>('NewFolder', this.selectedFolderData)
486        routePage()
487      }
488      this.selectedAll = this.CheckedNoteArray.length ==
489      NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid).length;
490      this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
491    })
492    .gesture(
493    GestureGroup(GestureMode.Exclusive,
494      // 长按:对笔记列表进行操作
495    LongPressGesture()
496      .onAction(() => {
497        if (this.longpress == false) {
498          this.longpress = true
499          NoteUtil.setNoteChecked(this.CheckedNoteArray, this.noteItem)
500          this.isChecked = NoteUtil.isNoteChecked(this.CheckedNoteArray, this.noteItem)
501        }
502      })
503    )
504    )
505
506  }
507}
508
509@Component
510export struct NoteItemListComp {
511  @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
512  @Consume('SelectedFolderData') selectedFolderData: FolderData
513  @Consume('RefreshFlag') refreshFlag: number
514  @Consume('Longpress') longpress: boolean
515  @Consume('Search') search: boolean
516  @Consume @Watch('doSearch') inputKeyword: string
517  @Consume('SearchResultList') searchResultList: NoteData[]
518  @Consume('SelectedNoteData') selectedNoteData: NoteData
519  @Consume('PortraitModel') portraitModel: boolean
520  @State @Watch('setNoteListLazy') dateList: NoteData[] = [];
521  @State noteList: noteListData = new noteListData();
522  controllerShow: webview.WebviewController = new webview.WebviewController();
523  @StorageLink('isUpdate') @Watch('updateList') isUpdate: boolean = false
524
525  updateList() {
526    if (this.isUpdate) {
527      this.dateList = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid);
528    }
529    this.isUpdate = false
530    this.doSearch()
531  }
532
533  aboutToAppear() {
534    LogUtil.info(TAG, "inputKeyWord:" + this.inputKeyword)
535    this.inputKeyword = ''
536    this.dateList = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid);
537  }
538
539  doSearch() {
540    if (this.inputKeyword.length == 0) {
541      this.setNoteListLazy()
542      return;
543    };
544    SearchModel.search(NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid), this.inputKeyword)
545      .then((result: NoteData[]) => {
546        LogUtil.info(TAG, "result size " + result.length.toString())
547        this.searchResultList = result
548        this.setNoteListLazy()
549        if (this.searchResultList.length != 0) {
550          this.selectedNoteData = this.searchResultList[0]
551        } else {
552          this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid)!;
553        }
554        if (this.portraitModel == false) {
555          this.controllerShow.runJavaScript(
556            "RICH_EDITOR.setHtml('" + this.selectedNoteData?.content_text + "')"
557          )
558        }
559        // save continue data
560        let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
561        AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
562        LogUtil.info(TAG, "doSearch, set continue note success")
563        this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
564      })
565  }
566
567  setNoteListLazy() {
568    let noteLazySource: NoteData[];
569    this.inputKeyword.length === 0 ? noteLazySource = this.dateList : noteLazySource = this.searchResultList;
570    this.noteList.modifyAllData(noteLazySource);
571  }
572
573  build() {
574    Column() {
575      Text(this.refreshFlag.toString()).visibility(Visibility.None)
576      Flex() {
577        SearchComp()
578      }
579      .id(this.isUpdate + '')
580      .width("100%")
581      .padding({ left: 24, right: 24, bottom: 12 })
582      .visibility((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? Visibility.None : Visibility.Visible)
583
584      Stack() {
585        Flex({ direction: FlexDirection.Column }) {
586          Flex({ justifyContent: FlexAlign.Center }) {
587            Text($r("app.string.permanently_delete_tips"))
588              .fontSize(12)
589              .fontColor($r("app.color.Recently_delete_prompt_font_color"))
590          }
591          .padding({ bottom: this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? 12 : 0 })
592          .width('100%')
593          .visibility(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes
594                      && FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) > 0 ? Visibility.Visible : Visibility.None)
595
596          Column() {
597            List({ initialIndex: 0 }) {
598              ListItem() {
599                Column({ space: 8 }) {
600                  Image($r('app.media.emptyPage'))
601                    .width(120)
602                    .height(120)
603                  Text($r("app.string.Empty_page"))
604                    .fontSize(12)
605                    .fontColor($r("app.color.Empty_page_font_color"))
606                }
607              }
608              .id(this.isUpdate + '')
609              .width('100%')
610              .height('100%')
611              .padding({ bottom: 120 })
612              .visibility((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? Visibility.Visible : Visibility.None)
613
614              LazyForEach(this.noteList, (noteItem: NoteData) => {
615                ListItem() {
616                  Column() {
617                    NoteItemComp({
618                      noteItem: noteItem,
619                      spans: SearchModel.splitToHighlightText(noteItem.title, this.inputKeyword),
620                      controllerShow: this.controllerShow
621                    })
622                  }
623                  .padding({ left: 24, right: 24, bottom: 12 })
624                }
625                .visibility((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? Visibility.None : Visibility.Visible)
626              }, (noteItem: NoteData) => JSON.stringify(noteItem))
627            }
628            .id(this.isUpdate + '')
629            .margin((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? {
630                                                                                                                     bottom: 0
631                                                                                                                   } : {
632                                                                                                                         bottom: 56
633                                                                                                                       })
634            .layoutWeight(1)
635            .listDirection(Axis.Vertical)
636            .edgeEffect(EdgeEffect.Spring)
637            .cachedCount(10)
638          }
639          .layoutWeight(1)
640          .height("100%")
641          .margin({ top: this.search ? 8 : 0 })
642        }
643        .height("100%")
644        .width("100%")
645
646        // search input mask
647        Column() {
648        }
649        .height("100%")
650        .width("100%")
651        .backgroundColor("#18181A")
652        .opacity(0.1)
653        .visibility(this.search ? Visibility.Visible : Visibility.Hidden)
654      }
655    }
656    .onClick(() => {
657      this.search = false
658      inputMethod.getController().stopInputSession()
659      AppStorage.SetOrCreate<boolean>('Search', this.search)
660    })
661  }
662}
663
664@Component
665export struct OperateNoteComp {
666  @Consume('Longpress') longpress: boolean
667  @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
668  @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
669  @Consume('SelectedFolderData') selectedFolderData: FolderData
670  @Consume('RefreshFlag') refreshFlag: number
671  @Consume('SelectedNoteData') selectedNoteData: NoteData
672  @Consume('PortraitModel') portraitModel: boolean
673  @Consume('selectedAll') selectedAll: boolean
674  @StorageLink('isUpdate') isUpdate: boolean = false
675  controllerShow: webview.WebviewController = new webview.WebviewController();
676  noteDataMoveDialogCtl: CustomDialogController | null = new CustomDialogController({
677    builder: NoteDataMoveDialog({ onConfirm: (folderUuid: string) => {
678      this.onMoveConfirm(folderUuid);
679    } }),
680    alignment: DialogAlignment.Center,
681    autoCancel: false,
682    customStyle: true,
683  })
684
685  aboutToDisappear() {
686    this.noteDataMoveDialogCtl = null
687    this.noteDataDeleteDialogCtl = null
688  }
689
690  onMoveConfirm(folderUuid: string) {
691    this.CheckedNoteArray.forEach((noteItem) => {
692      noteItem.folder_uuid = folderUuid
693      // update note to db
694      let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
695      predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
696      RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
697    })
698    this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid)!;
699    // save continue data
700    let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
701    AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
702    LogUtil.info(TAG, "onMoveConfirm, set continue note success")
703    if (this.portraitModel == false) {
704      this.controllerShow.runJavaScript("RICH_EDITOR.setHtml('" + this.selectedNoteData?.content_text + "')")
705    }
706    this.longpress = false
707    this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
708    NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
709    NoteUtil.refreshAll()
710  }
711
712  noteDataDeleteDialogCtl: CustomDialogController | null = new CustomDialogController({
713    builder: DeleteDialog({ onConfirm: () => {
714      this.onDeleteConfirm();
715    }, multiSelect: true }),
716    alignment: DialogAlignment.Center,
717    autoCancel: false,
718    customStyle: true,
719  })
720
721  onDeleteConfirm() {
722    if (this.selectedFolderData.uuid != SysDefFolderUuid.RecentDeletes) {
723      this.CheckedNoteArray.forEach((noteItem: NoteData) => {
724        noteItem.is_deleted = Delete.Yes
725        noteItem.deleted_time = new Date().getTime()
726        // update note to db
727        let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
728        predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
729        RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
730      })
731    } else {
732      this.CheckedNoteArray.forEach((noteItem: NoteData) => {
733        NoteUtil.removeNoteData(this.AllNoteArray, noteItem.uuid)
734        // delete note from db
735        let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
736        predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
737        RdbStoreUtil.delete(predicates_note, null);
738      })
739    }
740    NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
741    this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
742    this.longpress = false
743    this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid)!;
744    if (this.portraitModel == false) {
745      this.controllerShow.runJavaScript("RICH_EDITOR.setHtml('" + this.selectedNoteData?.content_text + "')")
746    }
747    // save continue data
748    let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
749    AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
750    LogUtil.info(TAG, "OperateNoteComp, set continue note success")
751    NoteUtil.refreshAll()
752  }
753
754  build() {
755    Row() {
756      Image($r('app.media.set_top'))
757        .width(24)
758        .height(24)
759        .opacity(this.CheckedNoteArray.length == 0 ? 0.4 : 1)
760        .enabled(this.CheckedNoteArray.length == 0 ? false : true)
761        .margin({ right: this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? 0 : 18 })
762        .visibility(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible)
763        .onClick(() => {
764          this.CheckedNoteArray.forEach((noteItem) => {
765            noteItem.is_top = (noteItem.is_top == Top.Yes) ? Top.No : Top.Yes
766            // update note to db
767            let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
768            predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
769            RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
770          })
771          this.longpress = false
772          NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
773          NoteUtil.refreshAll()
774        })
775      Image($r('app.media.move'))
776        .width(24)
777        .height(24)
778        .opacity(this.CheckedNoteArray.length == 0 ? 0.4 : 1)
779        .enabled(this.CheckedNoteArray.length == 0 ? false : true)
780        .margin({ right: this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? 0 : 18 })
781        .visibility(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible)
782        .onClick(() => {
783          this.noteDataMoveDialogCtl!.open();
784        })
785      Image($r('app.media.delete'))
786        .width(24)
787        .height(24)
788        .margin({ right: 18 })
789        .opacity(this.CheckedNoteArray.length == 0 ? 0.4 : 1)
790        .enabled(this.CheckedNoteArray.length == 0 ? false : true)
791        .onClick(() => {
792          this.noteDataDeleteDialogCtl!.open();
793        })
794      Image($r('app.media.recover'))
795        .width(24)
796        .height(24)
797        .opacity(this.CheckedNoteArray.length == 0 ? 0.4 : 1)
798        .enabled(this.CheckedNoteArray.length == 0 ? false : true)
799        .margin({ right: this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? 18 : 0 })
800        .visibility(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.Visible : Visibility.None)
801        .onClick(() => {
802          this.CheckedNoteArray.forEach((noteItem) => {
803            noteItem.is_deleted = Delete.No
804            noteItem.deleted_time = 0
805            let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
806            let resource: resourceManager.Resource = {
807              bundleName: "com.ohos.note",
808              moduleName: "default",
809              id: $r('app.string.restore').id
810            };
811            context.resourceManager.getStringValue(resource, (error: BusinessError, value: string) => {
812              if (error != null) {
813                LogUtil.error(TAG, "error is " + error);
814              } else {
815                promptAction.showToast({ message: value, duration: 2000 });
816              }
817            });
818            // update note to db
819            let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
820            predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
821            RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
822          })
823          this.longpress = false
824          NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
825          NoteUtil.refreshAll()
826        })
827      Image(this.CheckedNoteArray.length == NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid)
828        .length ? $r('app.media.check_all1') : $r('app.media.check_all'))
829        .width(24)
830        .height(24)
831        .id(this.isUpdate + '')
832        .onClick(() => {
833          LogUtil.info(TAG, "select all click")
834          if (this.CheckedNoteArray.length <
835          NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid).length) {
836            NoteUtil.setAllNotesChecked(this.CheckedNoteArray, NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid));
837          } else {
838            NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
839          }
840          this.selectedAll = !this.selectedAll
841          this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
842          NoteUtil.refreshAll()
843        })
844    }
845    .width(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? 168 : 248)
846    .visibility(this.longpress && this.portraitModel == false ? Visibility.Visible : Visibility.None)
847  }
848}
849
850@Component
851export struct AddNoteComp {
852  @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
853  @Consume('Longpress') longpress: boolean
854  @Consume('SelectedFolderData') selectedFolderData: FolderData
855  @Consume('SelectedNoteData') selectedNoteData: NoteData
856  @Consume('SectionStatus') sectionStatus: number
857  @Consume('LastSectionStatus') lastSectionStatus: number
858  @Consume('EditModel') editModel: boolean
859  @Consume('ChooseNote') chooseNote: boolean
860  @Consume('PortraitModel') portraitModel: boolean
861  controllerShow: webview.WebviewController = new webview.WebviewController();
862
863  build() {
864    Image($r('app.media.addNote'))
865      .width(24)
866      .height(24)
867      .margin({ right: 12 })
868      .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
869      .onClick(() => {
870        let noteData: NoteData;
871        if (this.selectedFolderData.uuid == SysDefFolderUuid.AllNotes || this.selectedFolderData.uuid == SysDefFolderUuid.MyFavorites) {
872          noteData = new NoteData(0, "标题", new Date().getTime() + "", SysDefFolderUuid.UnClassified, "", "", NoteType.SysDef, Top.No, Favorite.No, Delete.No, new Date().getTime(), new Date().getTime(), 0, 0)
873        } else {
874          noteData = new NoteData(0, "标题", new Date().getTime() + "", this.selectedFolderData.uuid, "", "", NoteType.SysDef, Top.No, Favorite.No, Delete.No, new Date().getTime(), new Date().getTime(), 0, 0)
875        }
876
877        this.AllNoteArray.push(noteData)
878        RdbStoreUtil.insert(TableName.NoteTable, noteData.toNoteObject(), null);
879        LogUtil.info(TAG, 'insert new note is:' + noteData.uuid)
880
881        this.selectedNoteData = noteData
882        AppStorage.SetOrCreate<NoteData>('NewNote', noteData)
883        if (this.portraitModel == false) {
884          try {
885            this.controllerShow.runJavaScript(
886              "RICH_EDITOR.setHtml('" + this.selectedNoteData?.content_text + "')"
887            )
888          } catch (error) {
889            LogUtil.error(TAG, `runJavaScript setHtml content_text failed.
890            code:${JSON.stringify(error.code)},message:${JSON.stringify(error.message)}`);
891          }
892        }
893        if (this.portraitModel == true) {
894          this.editModel = true
895        }
896        this.chooseNote = true
897        // save continue data
898        let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
899        AppStorage.SetOrCreate<FolderData>('NewFolder', this.selectedFolderData)
900        AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
901        LogUtil.info(TAG, "addNote, set continue note success")
902        AppStorage.SetOrCreate('isUpdate', true)
903        routePage()
904      })
905      .visibility(this.longpress || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible)
906  }
907}
908
909@Component
910export struct SearchComp {
911  @Consume('Search') search: boolean
912  @Consume('InputKeyword') inputKeyword: string
913  @Consume('Longpress') longpress: boolean
914  @State text: string = ''
915  @StorageLink('isFocusOnSearch') isFocusOnSearch: boolean = true
916
917  build() {
918    Row() {
919      Image($r('app.media.back'))
920        .width(24)
921        .height(24)
922        .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
923        .margin({ right: this.search ? 16 : 0 })
924        .visibility(this.search ? Visibility.Visible : Visibility.None)
925        .onClick(() => {
926          focusControl.requestFocus('searchFocus')
927          this.search = false
928          // 退出键盘
929          inputMethod.getController().stopInputSession();
930          AppStorage.SetOrCreate<boolean>('Search', this.search)
931        })
932
933      Flex({ justifyContent: FlexAlign.Start }) {
934        Image($r('app.media.search'))
935          .width(20)
936          .height(20)
937          .focusable(true)
938          .key('searchFocus')
939          .defaultFocus(true)
940        TextInput({ placeholder: $r('app.string.searchNote'), text: this.text })
941          .backgroundColor(this.longpress ? $r("app.color.search_longpress_bgcolor_f7f8f9") : $r("app.color.color_ffffff"))
942          .caretColor($r("app.color.search_note_caret_color"))
943          .enabled(this.longpress ? false : true)
944          .padding({ left: 6, top: 0, bottom: 0, right: 0 })
945          .onEditChange((isEditing: boolean) => {
946            //            this.search = isEditing
947          })
948          .onChange((value: string) => {
949            if (!this.longpress) {
950              LogUtil.info(TAG, "Search value: " + value)
951              this.text = value
952              this.inputKeyword = value
953            }
954          })
955          .onClick(() => {
956            if (this.longpress) {
957              this.search = false
958              AppStorage.SetOrCreate<boolean>('Search', this.search)
959            } else {
960              this.search = true
961              AppStorage.SetOrCreate<boolean>('Search', this.search)
962            }
963          })
964            // whether the focus is on the search input before coutinue
965          .onFocus(() => {
966            this.isFocusOnSearch = true
967          })
968          .onBlur(() => {
969            this.isFocusOnSearch = false
970          })
971            // key for request focus after coutinue
972          .key('searchInput')
973          .restoreId(3)
974      }
975      .backgroundColor(this.longpress ? $r("app.color.search_longpress_bgcolor_f7f8f9") : $r("app.color.color_ffffff"))
976      .height(40)
977      .opacity(this.longpress ? 0.4 : 1)
978      .padding({ left: 6, right: 12, top: 9, bottom: 9 })
979      .borderRadius(20)
980      .border({ width: 1.5, color: $r("app.color.divider_color_e4e4e4") })
981      .margin({ right: this.search ? 40 : 0 })
982    }
983  }
984}
985
986@Component
987export struct OperateNoteCompForPortrait {
988  @Consume('Longpress') longpress: boolean
989  @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
990  @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
991  @Consume('SelectedFolderData') selectedFolderData: FolderData
992  @Consume('RefreshFlag') @Watch('opacityChange') refreshFlag: number
993  @Consume('SelectedNoteData') selectedNoteData: NoteData
994  @Consume('PortraitModel') portraitModel: boolean
995  @State greyOpacity: boolean = false
996  @StorageLink('isUpdate') isUpdate: boolean = false
997  noteDataMoveDialogCtlBottom: CustomDialogController | null = new CustomDialogController({
998    builder: NoteDataMoveDialog({ onConfirm: (folderUuid: string) => {
999      this.onMoveConfirm(folderUuid);
1000    } }),
1001    alignment: DialogAlignment.Bottom,
1002    autoCancel: false,
1003    customStyle: true,
1004  })
1005
1006  aboutToDisappear() {
1007    this.noteDataMoveDialogCtlBottom = null
1008    this.noteDataDeleteDialogCtlBottom = null
1009  }
1010
1011  opacityChange() {
1012    if (this.CheckedNoteArray.length == 0 && this.longpress == true) {
1013      this.greyOpacity = true
1014      LogUtil.info(TAG, "none checked array")
1015    } else {
1016      this.greyOpacity = false
1017      LogUtil.info(TAG, this.CheckedNoteArray.length.toString())
1018    }
1019  }
1020
1021  onMoveConfirm(folderUuid: string) {
1022    this.CheckedNoteArray.forEach((noteItem) => {
1023      noteItem.folder_uuid = folderUuid
1024      // update note to db
1025      let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
1026      predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
1027      RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
1028    })
1029    this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, this.selectedFolderData.uuid)!;
1030    // save continue data
1031    let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
1032    AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
1033    LogUtil.info(TAG, "onMoveConfirm, set continue note success")
1034    this.longpress = false
1035    this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
1036    NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
1037    NoteUtil.refreshAll()
1038  }
1039
1040  noteDataDeleteDialogCtlBottom: CustomDialogController | null = new CustomDialogController({
1041    builder: DeleteDialog({ onConfirm: () => {
1042      this.onDeleteConfirm();
1043    }, multiSelect: true }),
1044    alignment: DialogAlignment.Bottom,
1045    autoCancel: false,
1046    customStyle: true,
1047  })
1048
1049  onDeleteConfirm() {
1050    if (this.selectedFolderData.uuid != SysDefFolderUuid.RecentDeletes) {
1051      this.CheckedNoteArray.forEach((noteItem: NoteData) => {
1052        noteItem.is_deleted = Delete.Yes
1053        noteItem.deleted_time = new Date().getTime()
1054        // update note to db
1055        let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
1056        predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
1057        RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
1058      })
1059    } else {
1060      this.CheckedNoteArray.forEach((noteItem: NoteData) => {
1061        NoteUtil.removeNoteData(this.AllNoteArray, noteItem.uuid)
1062        // delete note from db
1063        let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
1064        predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
1065        RdbStoreUtil.delete(predicates_note, null);
1066      })
1067    }
1068    NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
1069    this.longpress = false
1070    this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
1071    this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid)!;
1072    // save continue data
1073    let continueNote: string = JSON.stringify(this.selectedNoteData?.toNoteObject())
1074    AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
1075    LogUtil.info(TAG, "OperateNoteCompForPortrait, set continue note success")
1076    NoteUtil.refreshAll()
1077  }
1078
1079  build() {
1080    Row() {
1081      if (this.selectedFolderData.uuid != SysDefFolderUuid.RecentDeletes) {
1082        Column() {
1083          Image($r("app.media.set_top"))
1084            .opacity(this.greyOpacity ? 0.4 : 1)
1085            .width(24)
1086            .height(24)
1087            .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
1088            .onClick(() => {
1089              this.CheckedNoteArray.forEach((noteItem) => {
1090                noteItem.is_top = (noteItem.is_top == Top.Yes) ? Top.No : Top.Yes
1091                // update note to db
1092                let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
1093                predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
1094                RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
1095              })
1096              this.longpress = false
1097              this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
1098              NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
1099              NoteUtil.refreshAll()
1100            })
1101          Text($r("app.string.set_top"))
1102            .opacity(this.greyOpacity ? 0.4 : 1)
1103            .fontSize(10)
1104            .fontColor($r("app.color.set_top_font_color"))
1105            .padding({ top: 5 })
1106        }
1107        .width("25%")
1108        .height("100%")
1109        .opacity(this.greyOpacity ? 0.4 : 1)
1110        .enabled(this.greyOpacity ? false : true)
1111        .alignItems(HorizontalAlign.Center)
1112        .justifyContent(FlexAlign.Center)
1113      }
1114
1115      Column() {
1116        Image($r('app.media.delete'))
1117          .opacity(this.greyOpacity ? 0.4 : 1)
1118          .width(24)
1119          .height(24)
1120          .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
1121          .onClick(() => {
1122            this.noteDataDeleteDialogCtlBottom!.open();
1123            AppStorage.SetOrCreate('isUpdate', true)
1124          })
1125        Text($r("app.string.delete"))
1126          .opacity(this.greyOpacity ? 0.4 : 1)
1127          .fontSize(10)
1128          .fontColor($r("app.color.delete_font_color"))
1129          .padding({ top: 5 })
1130      }
1131      .width(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? 120 : "25%")
1132      .height("100%")
1133      .opacity(this.greyOpacity ? 0.4 : 1)
1134      .enabled(this.greyOpacity ? false : true)
1135      .alignItems(HorizontalAlign.Center)
1136      .justifyContent(FlexAlign.Center)
1137
1138      if (this.selectedFolderData.uuid != SysDefFolderUuid.RecentDeletes) {
1139        Column() {
1140          Image($r('app.media.move'))
1141            .opacity(this.greyOpacity ? 0.4 : 1)
1142            .width(24)
1143            .height(24)
1144            .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
1145            .onClick(() => {
1146              this.noteDataMoveDialogCtlBottom!.open();
1147              AppStorage.SetOrCreate('isUpdate', true)
1148            })
1149          Text($r("app.string.move"))
1150            .opacity(this.greyOpacity ? 0.4 : 1)
1151            .fontSize(10)
1152            .fontColor($r("app.color.move_font_color"))
1153            .padding({ top: 5 })
1154        }
1155        .width("25%")
1156        .height("100%")
1157        .opacity(this.greyOpacity ? 0.4 : 1)
1158        .enabled(this.greyOpacity ? false : true)
1159        .alignItems(HorizontalAlign.Center)
1160        .justifyContent(FlexAlign.Center)
1161      }
1162
1163
1164      if (this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes) {
1165        Column() {
1166          Image($r('app.media.recover'))
1167            .width(24)
1168            .height(24)
1169            .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
1170            .onClick(() => {
1171              this.CheckedNoteArray.forEach((noteItem) => {
1172                noteItem.is_deleted = Delete.No
1173                noteItem.deleted_time = 0
1174                let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
1175                let resource: resourceManager.Resource = {
1176                  bundleName: "com.ohos.note",
1177                  moduleName: "default",
1178                  id: $r('app.string.restore').id
1179                };
1180                context.resourceManager.getStringValue(resource, (error: BusinessError, value: string) => {
1181                  if (error != null) {
1182                    LogUtil.error(TAG, "error is " + error);
1183                  } else {
1184                    promptAction.showToast({ message: value, duration: 2000 });
1185                  }
1186                });
1187                // update note to db
1188                let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
1189                predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
1190                RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
1191              })
1192              this.longpress = false
1193              NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
1194              this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
1195              AppStorage.SetOrCreate('isUpdate', true)
1196              NoteUtil.refreshAll()
1197            })
1198          Text($r("app.string.recover"))
1199            .fontSize(10)
1200            .fontColor($r("app.color.recover_font_color"))
1201            .padding({ top: 5 })
1202        }
1203        .width(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? 120 : "25%")
1204        .height("100%")
1205        .opacity(this.greyOpacity ? 0.4 : 1)
1206        .enabled(this.greyOpacity ? false : true)
1207        .alignItems(HorizontalAlign.Center)
1208        .justifyContent(FlexAlign.Center)
1209      }
1210
1211      Column() {
1212        Image($r('app.media.check_all'))
1213          .width(24)
1214          .height(24)
1215          .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
1216          .id(this.isUpdate + '')
1217          .onClick(() => {
1218            if (this.CheckedNoteArray.length < NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!,
1219              this.selectedFolderData.uuid).length) {
1220              NoteUtil.setAllNotesChecked(this.CheckedNoteArray, NoteUtil.getNoteDataArray(
1221                AppStorage.Get('AllNoteArray')!, this.selectedFolderData.uuid));
1222            } else {
1223              NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
1224            }
1225            this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0)
1226            NoteUtil.refreshAll()
1227          })
1228        Text($r("app.string.check_all"))
1229          .fontSize(10)
1230          .fontColor($r("app.color.check_all_font_color"))
1231          .padding({ top: 5 })
1232      }
1233      .width(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? 120 : "25%")
1234      .height("100%")
1235      .alignItems(HorizontalAlign.Center)
1236      .justifyContent(FlexAlign.Center)
1237    }
1238    .justifyContent(FlexAlign.Center)
1239    .width("100%")
1240    .height(56)
1241    .visibility(this.longpress && this.portraitModel == true ? Visibility.Visible : Visibility.None)
1242  }
1243}
1244