• 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 FolderData from '@ohos/utils/src/main/ets/default/model/databaseModel/FolderData'
17import NoteData from '@ohos/utils/src/main/ets/default/model/databaseModel/NoteData'
18import {
19  SysDefFolderUuid,
20  TableName,
21  FolderType,
22  FolderTableColumn,
23  NoteTableColumn,
24  Delete,
25  DeleteFileType
26} from '@ohos/utils/src/main/ets/default/model/databaseModel/EnumData'
27import { NewOrEditFolderDialog, DeleteDialog } from './CusDialogComp'
28import RdbStoreUtil from '@ohos/utils/src/main/ets/default/baseUtil/RdbStoreUtil'
29import FolderUtil from '@ohos/utils/src/main/ets/default/baseUtil/FolderUtil'
30import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil'
31import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil'
32import webview from '@ohos.web.webview';
33
34// Folder list component
35@Component
36export struct FolderListComp {
37  @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
38  @Consume('SectionStatus') sectionStatus: number
39  @Consume('ExpandStatus') expandStatus: boolean // 笔记本折叠展开状态
40  @StorageLink('breakPoint') breakPoints: string = 'lg'
41  controllerShow: webview.WebviewController = new webview.WebviewController();
42  TAG = "FolderListComp"
43  @Consume('AsideWidth') asideWidth: number
44
45  build() {
46    Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) {
47      Column() {
48        Column() {
49          Image($r("app.media.suojin"))
50            .height(24)
51            .width(24)
52            .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
53            .onClick(() => {
54              if (this.breakPoints == 'sm' || this.breakPoints == 'md') {
55                animateTo({ duration: 200 }, () => {
56                  this.expandStatus = !this.expandStatus
57                })
58              } else {
59                this.asideWidth = 0
60                this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3)
61                // save continue data
62                AppStorage.SetOrCreate<number>('ContinueSection', this.sectionStatus)
63                LogUtil.info(this.TAG, "FolderListComp, set continue section success")
64              }
65            })
66        }
67        .alignItems(HorizontalAlign.Start)
68        .width("100%")
69        .margin({ top: 28 })
70        .padding({ left: 24 })
71        .flexGrow(1)
72
73        NoteAndCreateComp()
74        // center
75        List() {
76          ForEach(this.AllFolderArray, (folderItem: FolderData) => {
77            ListItem() {
78              if (!FolderUtil.isBottomFixedFolder(folderItem)) {
79                FolderItemComp({ folderItem: folderItem, controllerShow: this.controllerShow })
80              }
81            }
82          }, (folderItem: FolderData) => folderItem.name.toString())
83        }
84        .width('100%')
85        .height(500)
86        .margin({ bottom: 120 })
87        .padding({ left: 12, right: 12 })
88        .flexGrow(1)
89      }
90
91
92      Column() {
93        FolderItemComp({
94          folderItem: FolderUtil.getFolderData(AppStorage.Get('AllFolderArray')!, SysDefFolderUuid.MyFavorites),
95          controllerShow: this.controllerShow
96        })
97        FolderItemComp({
98          folderItem: FolderUtil.getFolderData(AppStorage.Get('AllFolderArray')!, SysDefFolderUuid.RecentDeletes),
99          controllerShow: this.controllerShow
100        })
101      }
102      .backgroundColor($r("app.color.folderlist_bgcolor_f1f3f5"))
103      .flexGrow(0)
104      .width("100%")
105      .padding({ left: 12, right: 12, bottom: 60 })
106      .margin({ bottom: 65 })
107    }
108    .height("100%")
109    .backgroundColor($r('app.color.folder_color_d6d6d6'))
110    .backgroundBlurStyle(BlurStyle.Thick)
111  }
112
113  aboutToAppear(): void {
114    LogUtil.info(this.TAG, "aboutToAppear")
115  }
116
117  aboutToDisappear(): void {
118    LogUtil.info(this.TAG, "aboutToDisappear")
119  }
120}
121
122@Component
123export struct NoteAndCreateComp {
124  @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
125  @Consume('SelectedColor') selectedColor: string
126  @Consume('PortraitModel') portraitModel: boolean
127  folderCreateDialogCtl: CustomDialogController | null = new CustomDialogController({
128    builder: NewOrEditFolderDialog({ confirm: (color: string, name: string) => {
129      this.onCreateConfirm(color, name)
130    }, dialogType: 0 }),
131    alignment: DialogAlignment.Center,
132    autoCancel: false,
133    customStyle: true,
134  })
135  folderCreateDialogCtlBottom: CustomDialogController | null = new CustomDialogController({
136    builder: NewOrEditFolderDialog({ confirm: (color: string, name: string) => {
137      this.onCreateConfirm(color, name)
138    }, dialogType: 0 }),
139    alignment: DialogAlignment.Bottom,
140    autoCancel: false,
141    customStyle: true,
142  })
143
144  aboutToDisappear() {
145    this.folderCreateDialogCtl = null
146    this.folderCreateDialogCtlBottom = null
147  }
148
149  onCreateConfirm(color: string, name: string) {
150    let folderData = new FolderData(0, name, new Date().getTime() + "", color, FolderType.CusDef, Delete.No, new Date().getTime(), new Date().getTime()) // 新的的笔记本都是自定义类型 type为1
151    this.AllFolderArray.push(folderData)
152    // insert folder to db
153    RdbStoreUtil.insert(TableName.FolderTable, folderData.toFolderObject(), null);
154    AppStorage.SetOrCreate('isUpdate', true)
155  }
156
157  build() {
158    Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
159      Row() {
160        Text($r("app.string.note"))
161          .fontSize(20)
162          .fontWeight(FontWeight.Bold)
163      }.width(102)
164
165      Row() {
166        Text($r("app.string.create"))
167          .fontSize(14)
168          .fontColor($r("app.color.text_color_f86d05"))
169          .onClick(() => {
170            this.selectedColor = "#e84026" // 新建的时候选中第一个颜色
171            if (this.portraitModel) {
172              this.folderCreateDialogCtlBottom!.open();
173            } else {
174              this.folderCreateDialogCtl!.open();
175            }
176          }).padding({ right: 0 })
177      }.width(50)
178    }.width("100%")
179    .margin({ top: 8 })
180    .padding({ left: 24 })
181    .height(56)
182  }
183}
184
185@Component
186struct FolderItemComp {
187  @State folderItem: FolderData = new FolderData(0, "", new Date().getTime() + "", "", FolderType.CusDef, Delete.No, new Date().getTime(), new Date().getTime())
188  @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = []
189  @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = []
190  @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
191  @Consume('SelectedFolderData') selectedFolderData: FolderData
192  @Consume('SelectedNoteData') selectedNoteData: NoteData
193  @Consume('RefreshFlag') refreshFlag: number
194  @Consume('Longpress') longpress: boolean
195  @Consume('SelectedColor') selectedColor: string
196  @Consume('PortraitModel') portraitModel: boolean
197  controllerShow: webview.WebviewController = new webview.WebviewController();
198  @State isLongPress: boolean = false
199  TAG = "FolderItemComp"
200  @StorageLink('isUpdate') isUpdate: boolean = false
201  // Folder Edit Dialog
202  folderEditDialogCtl: CustomDialogController | null = new CustomDialogController({
203    builder: NewOrEditFolderDialog({
204      editFolderUuid: this.folderItem.uuid,
205      confirm: (color: string, name: string) => {
206        this.onEditConfirm(color, name);
207      },
208      dialogType: 1
209    }),
210    alignment: DialogAlignment.Center,
211    autoCancel: false,
212    customStyle: true,
213  })
214  // Folder Edit Dialog for portrait model
215  folderEditDialogCtlBottom: CustomDialogController | null = new CustomDialogController({
216    builder: NewOrEditFolderDialog({
217      editFolderUuid: this.folderItem.uuid,
218      confirm: (color: string, name: string) => {
219        this.onEditConfirm(color, name);
220      },
221      dialogType: 1
222    }),
223    alignment: DialogAlignment.Bottom,
224    autoCancel: false,
225    customStyle: true,
226  })
227
228  aboutToDisappear() {
229    this.folderEditDialogCtl = null
230    this.folderEditDialogCtlBottom = null
231    this.folderDeleteDialogCtl = null
232    this.folderDeleteDialogCtlBottom = null
233    this.folderCreateDialogCtl = null
234    this.folderCreateDialogCtlBottom = null
235  }
236
237  // Folder Edit Callback
238  onEditConfirm(color: string, name: string) {
239    this.folderItem.color = color
240    this.folderItem.name = name
241    this.folderItem.folder_type = FolderType.CusDef
242    // update folder to db
243    let predicates_folder = RdbStoreUtil.getRdbPredicates(TableName.FolderTable)
244    predicates_folder.equalTo(FolderTableColumn.Uuid, this.folderItem.uuid)
245    RdbStoreUtil.update(this.folderItem.toFolderObject(), predicates_folder, null);
246    this.isUpdate = true
247  }
248
249  // Folder Delete Dialog
250  folderDeleteDialogCtl: CustomDialogController | null = new CustomDialogController({
251    builder: DeleteDialog({ onConfirm: () => {
252      this.onDeleteConfirm();
253    }, deleteFileType: DeleteFileType.FolderData }),
254    alignment: DialogAlignment.Center,
255    autoCancel: false,
256    customStyle: true,
257  })
258  // Folder Delete Dialog for portrait model
259  folderDeleteDialogCtlBottom: CustomDialogController | null = new CustomDialogController({
260    builder: DeleteDialog({ onConfirm: () => {
261      this.onDeleteConfirm();
262    }, deleteFileType: DeleteFileType.FolderData }),
263    alignment: DialogAlignment.Bottom,
264    autoCancel: false,
265    customStyle: true,
266  })
267  // Folder Delete Callback
268  onDeleteConfirm() {
269    let currentFolder = FolderUtil.getFolderData(this.AllFolderArray, this.folderItem.uuid)
270    let index = this.AllFolderArray.indexOf(currentFolder)
271    let currentNoteDataArray = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, this.folderItem.uuid);
272    let deleteNoteDataArray = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray')!, 'sys_def_recentDeletes_uuid');
273    if (index > -1) {
274      this.AllFolderArray.splice(index, 1)
275      if (deleteNoteDataArray.length != 0) {
276        deleteNoteDataArray.forEach((noteItem: NoteData) => {
277          let folderData: FolderData = FolderUtil.getFolderData(this.AllFolderArray, noteItem.folder_uuid)
278          if (folderData == undefined) {
279            noteItem.folder_uuid = SysDefFolderUuid.UnClassified
280            // update note to db
281            let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
282            predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
283            RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
284          }
285        })
286      }
287      if (currentNoteDataArray.length != 0) {
288        currentNoteDataArray.forEach((noteItem: NoteData) => {
289          noteItem.is_deleted = Delete.Yes
290          noteItem.folder_uuid = SysDefFolderUuid.UnClassified
291          noteItem.deleted_time = new Date().getTime()
292          // update note to db
293          let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable)
294          predicates_note.equalTo(NoteTableColumn.Uuid, noteItem.uuid)
295          RdbStoreUtil.update(noteItem.toNoteObject(), predicates_note, null);
296        })
297      }
298      // delete folder from db
299      let predicates_folder = RdbStoreUtil.getRdbPredicates(TableName.FolderTable)
300      predicates_folder.equalTo(FolderTableColumn.Uuid, this.folderItem.uuid)
301      RdbStoreUtil.delete(predicates_folder, null);
302      // update selectedFolderData and selectedNoteData
303      this.selectedFolderData = FolderUtil.getFolderData(this.AllFolderArray, SysDefFolderUuid.AllNotes)
304      this.selectedNoteData = NoteUtil.getFirstNoteData(this.AllNoteArray, SysDefFolderUuid.AllNotes)!;
305      if (!this.selectedNoteData) {
306        return
307      }
308      // 刷新web界面
309      if (this.portraitModel == false) {
310        try {
311          this.controllerShow.runJavaScript(
312            "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
313          )
314          LogUtil.info(this.TAG, `runJavaScript success.`);
315        } catch (error) {
316          LogUtil.error(this.TAG, `runJavaScript failed.code:${JSON.stringify(error.code)},message:${JSON.stringify(error.message)}`);
317        }
318      }
319      // save continue data
320      let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
321      AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
322      LogUtil.info(this.TAG, "onDeleteConfirm, set continue note success")
323    }
324    this.isUpdate = true
325  }
326
327  // Folder Create Dialog
328  folderCreateDialogCtl: CustomDialogController | null = new CustomDialogController({
329    builder: NewOrEditFolderDialog({ confirm: (color: string, name: string) => {
330      this.onCreateConfirm(color, name);
331    }, dialogType: 0 }),
332    alignment: DialogAlignment.Center,
333    autoCancel: false,
334    customStyle: true,
335  })
336  // Folder Create Dialog for portrait model
337  folderCreateDialogCtlBottom: CustomDialogController | null = new CustomDialogController({
338    builder: NewOrEditFolderDialog({ confirm: (color: string, name: string) => {
339      this.onCreateConfirm(color, name);
340    }, dialogType: 0 }),
341    alignment: DialogAlignment.Bottom,
342    autoCancel: false,
343    customStyle: true,
344  })
345
346  // Folder Create Callback
347  onCreateConfirm(color: string, name: string) {
348    let folderData = new FolderData(0, name, new Date().getTime() + "", color, FolderType.CusDef, Delete.No, new Date().getTime(), new Date().getTime()) // 新的的笔记本都是自定义类型 type为1
349    this.AllFolderArray.push(folderData)
350    // insert folder to db
351    RdbStoreUtil.insert(TableName.FolderTable, folderData.toFolderObject(), null);
352    this.isUpdate = true
353  }
354
355  @Builder menuBuilder() {
356    Column({ space: 1 }) {
357      Text($r("app.string.editFolder"))
358        .width(124)
359        .height(48)
360        .padding({ top: 13, bottom: 13 })
361        .fontSize(16)
362        .fontColor($r("app.color.folder_color_182431"))
363        .onClick(() => {
364          this.selectedColor = this.folderItem.color
365          if (this.portraitModel) {
366            this.folderEditDialogCtlBottom!.open();
367          } else {
368            this.folderEditDialogCtl!.open();
369          }
370          ContextMenu.close()
371        })
372      Divider()
373        .color($r("app.color.divider_color_e4e4e4"))
374        .strokeWidth(1)
375      Text($r("app.string.deleteFolder"))
376        .width(124)
377        .height(48)
378        .padding({ top: 13, bottom: 14 })
379        .fontSize(16)
380        .fontColor($r("app.color.folder_color_182431"))
381        .onClick(() => {
382          if (this.portraitModel) {
383            this.folderDeleteDialogCtlBottom!.open();
384          } else {
385            this.folderDeleteDialogCtl!.open();
386          }
387          ContextMenu.close()
388        })
389      Divider()
390        .color($r("app.color.divider_color_e4e4e4"))
391        .strokeWidth(1)
392      Text($r("app.string.createFolder"))
393        .width(124)
394        .height(48)
395        .padding({ top: 13, bottom: 15 })
396        .fontSize(16)
397        .fontColor($r("app.color.folder_color_182431"))
398        .onClick(() => {
399          this.selectedColor = "#e84026" // 新建的时候选中第一个颜色
400          if (this.portraitModel) {
401            this.folderCreateDialogCtlBottom!.open();
402          } else {
403            this.folderCreateDialogCtl!.open();
404          }
405          ContextMenu.close()
406        })
407    }
408    .width(156)
409    .height(154)
410    .padding({ top: 4, bottom: 4, left: 16, right: 16 })
411    .borderRadius(16)
412    .backgroundColor($r("app.color.press_folder_bg_color"))
413  }
414
415  build() {
416    Flex() {
417      if (this.folderItem?.folder_type == FolderType.CusDef) {
418        Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) {
419          Row() {
420            Image(FolderUtil.getFolderIcon(this.folderItem.uuid))
421              .id(this.isUpdate + '')
422              .objectFit(ImageFit.Fill)
423              .width(24)
424              .height(24)
425              .fillColor(FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid, this.selectedFolderData.uuid == this.folderItem.uuid))
426              .margin({ right: 16 })
427            Text(FolderUtil.getFolderText(this.folderItem))
428              .id(this.isUpdate + '')
429              .fontWeight(FontWeight.Medium)
430              .fontSize(16)
431              .textAlign(TextAlign.Center)
432              .maxLines(1)
433              .textOverflow({ overflow: TextOverflow.Ellipsis })
434              .flexShrink(1)
435              .fontColor(FolderUtil.getFolderTextColor(this.selectedFolderData.uuid == this.folderItem.uuid))
436            Text(JSON.stringify(this.refreshFlag))
437              .visibility(Visibility.None) // 用于强制刷新使用
438          }.width(118)
439
440          Text(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.folderItem.uuid).toString())
441            .id(this.isUpdate + '')
442            .fontWeight(FontWeight.Regular)
443            .fontSize(14)
444            .textAlign(TextAlign.Center)
445        }
446        .width('100%')
447        .borderRadius(12)
448        .height(56)
449        .padding({ left: 12, right: 12 })
450        .backgroundColor(this.isLongPress ? $r("app.color.folder_color_19182431") : this.selectedFolderData.uuid == this.folderItem.uuid
451                                                                                      ? $r("app.color.folder_color_ffffff") : "#00FFFFFF")
452        .bindContextMenu(this.menuBuilder, ResponseType.LongPress)
453        .bindContextMenu(this.menuBuilder, ResponseType.RightClick)
454        .onClick(() => {
455          if (this.longpress) {
456            this.longpress = false
457            NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
458          } else {
459            this.selectedFolderData = this.folderItem
460            this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, this.folderItem.uuid)!;
461            if (!this.selectedNoteData) {
462              return
463            }
464            // 刷新web界面
465            if (this.portraitModel == false) {
466              try {
467                this.controllerShow.runJavaScript(
468                  "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
469                );
470                LogUtil.info(this.TAG, `onClick runJavaScript setHtml success.`);
471              } catch (error) {
472                LogUtil.error(this.TAG, `onClick runJavaScript setHtml failed,code:${JSON.stringify(error.code)},
473                  message:${JSON.stringify(error.message)}.`);
474              }
475            }
476            // save continue data
477            let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
478            AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
479            AppStorage.SetOrCreate('ContinueSection', 3)
480            LogUtil.info(this.TAG, "FolderItemComp, set continue note success")
481          }
482          NoteUtil.refreshAll()
483        })
484      } else {
485        Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) {
486          Row() {
487            Image(FolderUtil.getFolderIcon(this.folderItem.uuid))
488              .id(this.isUpdate + '')
489              .objectFit(ImageFit.Fill)
490              .width(24)
491              .height(24)
492              .fillColor(this.isUpdate ? FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid, this.selectedFolderData.uuid == this.folderItem.uuid) : FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid, this.selectedFolderData.uuid == this.folderItem.uuid))
493              .margin({ right: 16 })
494            Text(FolderUtil.getFolderText(this.folderItem))
495              .id(this.isUpdate + '')
496              .fontWeight(FontWeight.Medium)
497              .fontSize(16)
498              .textAlign(TextAlign.Center)
499              .maxLines(1)
500              .textOverflow({ overflow: TextOverflow.Ellipsis })
501              .flexShrink(1)
502              .fontColor(FolderUtil.getFolderTextColor(this.selectedFolderData.uuid == this.folderItem.uuid))
503            Text(JSON.stringify(this.refreshFlag))
504              .visibility(Visibility.None) // 用于强制刷新使用
505          }.width(118)
506
507          Text(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.folderItem.uuid).toString())
508            .id(this.isUpdate + '')
509            .fontWeight(FontWeight.Regular)
510            .fontSize(14)
511            .textAlign(TextAlign.Center)
512        }
513        .width('100%')
514        .borderRadius(12)
515        .height(56)
516        .padding({ left: 12, right: 12 })
517        .backgroundColor(this.isLongPress ? $r("app.color.folder_color_19182431") : this.selectedFolderData.uuid == this.folderItem.uuid
518          ? $r("app.color.folder_color_ffffff") : "#00FFFFFF")
519        .onClick(() => {
520          if (this.longpress) {
521            this.longpress = false
522            NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray)
523          } else {
524            this.selectedFolderData = this.folderItem
525            this.selectedNoteData = NoteUtil.getFirstNoteData(AppStorage.Get('AllNoteArray')!, this.folderItem.uuid)!;
526            if (!this.selectedNoteData) {
527              return
528            }
529            // 刷新web界面
530            if (this.portraitModel == false) {
531              try {
532                this.controllerShow.runJavaScript(
533                  "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')"
534                );
535                LogUtil.info(this.TAG, `else runJavaScript setHtml success.`);
536              } catch (error) {
537                LogUtil.info(this.TAG, `else runJavaScript setHtml failed.code:${JSON.stringify(error.code)},
538                  message:${JSON.stringify(error.message)}`);
539              }
540            }
541            // save continue data
542            let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
543            AppStorage.SetOrCreate<string>('ContinueNote', continueNote)
544            AppStorage.SetOrCreate('ContinueSection', 3)
545            LogUtil.info(this.TAG, "FolderItemComp, set continue note success")
546          }
547          NoteUtil.refreshAll()
548        })
549      }
550    }
551    .width('100%')
552    .height(56)
553    .parallelGesture(
554      GestureGroup(GestureMode.Exclusive,
555        LongPressGesture()
556          .onAction(() => {
557            this.isLongPress = true;
558            this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0);
559          })
560          .onActionEnd(() => {
561            this.isLongPress = false;
562            this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0);
563          })
564      )
565    )
566  }
567}