• 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 */
15
16import router from '@system.router';
17import deviceInfo from '@ohos.deviceInfo';
18import InputMethod from '@ohos.inputMethod';
19import osAccount from '@ohos.account.osAccount';
20import SystemAccountModel, { MAX_LENGTH } from '../model/usersAndAccounts/systemAccountModel';
21import SystemAccountController from '../model/usersAndAccounts/SystemAccountController';
22import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil';
23import { TitleText } from '../../../../../../common/component/src/main/ets/default/textComponent';
24import ConfigData from '../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData';
25import HeadComponent from '../../../../../../common/component/src/main/ets/default/headComponent';
26import ResourceUtil from '../../../../../../common/search/src/main/ets/default/common/ResourceUtil';
27import {
28  DialogButtonLayout,
29  DialogButtonLayoutWithState
30} from '../../../../../../common/component/src/main/ets/default/dialogComponent';
31
32const deviceTypeInfo = deviceInfo.deviceType;
33
34class AccountInfo {
35  localId: number = 0;
36  localName: string = '';
37
38  constructor() {
39  }
40}
41
42@Entry
43@Component
44struct MultipleUsers {
45  @StorageLink("isShowAddUser") isShowAddUser: boolean = false;
46  @StorageLink("isShowAddGuest") isShowAddGuest: boolean = false;
47  @StorageLink("systemAccountList") userList: osAccount.OsAccountInfo[] = [];
48  @StorageLink("isShowDelete") isShowDelete: boolean = false;
49  addUserDialogController?: CustomDialogController;
50  waitDialogController?: CustomDialogController;
51
52  handleClickEvent(event: ClickEvent | undefined) {
53    AlertDialog.show({
54      message: $r("app.string.askAddGuest"),
55      primaryButton: {
56        value: $r("app.string.cancel"),
57        action: () => {
58          LogUtil.info("Cancel add guest.");
59        }
60      },
61      secondaryButton: {
62        value: $r("app.string.confirm"),
63        action: () => {
64          LogUtil.info("Confirm add guest user.");
65          if (this.waitDialogController) {
66            this.waitDialogController.open();
67          }
68          SystemAccountController.createQuest((() => {
69            if (this.waitDialogController) {
70              this.waitDialogController.close();
71            }
72          }));
73        }
74      },
75      alignment: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? DialogAlignment.Bottom : DialogAlignment.Center,
76      offset: ({ dx: 0, dy: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? '-24dp' : 0 }),
77      cancel: () => {
78        LogUtil.info("Cancel dialog.");
79      }
80    })
81  }
82
83  build() {
84    Column() {
85      GridContainer({ gutter: ConfigData.GRID_CONTAINER_GUTTER_24, margin: ConfigData.GRID_CONTAINER_MARGIN_24 }) {
86        Column() {
87          Flex({
88            direction: FlexDirection.Column,
89            alignItems: ItemAlign.Center,
90            justifyContent: FlexAlign.SpaceBetween
91          }) {
92            Column() {
93              // head
94              HeadComponent({ headName: $r('app.string.user'), isActive: true });
95
96              // user list
97              List() {
98                ForEach(this.userList, (userItem: osAccount.OsAccountInfo) => {
99                  ListItem() {
100                    UserItem({ user: userItem });
101                  }
102                })
103              }
104              .margin({ top: $r("app.float.distance_14") })
105              .divider({
106                strokeWidth: $r('app.float.divider_wh'),
107                color: $r('sys.color.ohos_id_color_list_separator'),
108                startMargin: $r('app.float.wh_value_20'),
109                endMargin: $r('app.float.wh_value_20')
110              })
111              .borderRadius($r("app.float.radius_24"))
112              .backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"))
113              .visibility(this.userList.length > 0 ? Visibility.Visible : Visibility.None)
114
115              // Add user, shown when is administrator
116              if (this.isShowAddUser) {
117                TitleText({
118                  title: $r("app.string.addUser"),
119                  color: $r("app.color.font_color_007DFF"),
120                  visible: this.isShowAddUser ? Visibility.Visible : Visibility.None,
121                  clickEvent: (event => {
122                    LogUtil.info("Add user.");
123                    if (this.addUserDialogController) {
124                      this.addUserDialogController.open();
125                    }
126                  })
127                })
128              }
129
130              /**
131               * Add guest, shown with conditions:
132               * 1. Current user is administrator
133               * 2. Guest is not created.
134               */
135              if (this.isShowAddGuest) {
136                TitleText({
137                  title: $r("app.string.addGuest"),
138                  color: $r("app.color.font_color_007DFF"),
139                  visible: this.isShowAddGuest ? Visibility.Visible : Visibility.None,
140                  clickEvent: (event: ClickEvent | undefined): void => {
141                    this.handleClickEvent(event);
142                  },
143                })
144              }
145            }
146            .backgroundColor($r("sys.color.ohos_id_color_sub_background"))
147            .height(ConfigData.WH_90_100)
148            .alignItems(HorizontalAlign.Start)
149
150            if (this.isShowDelete) {
151              Column() {
152                Image($r("app.media.ic_delete"))
153                  .height($r("app.float.wh_value_40"))
154                  .width($r("app.float.wh_value_40"))
155                  .fillColor($r("sys.color.ohos_id_color_primary"))
156                  .margin({ top: $r("app.float.wh_value_20"), bottom: $r("app.float.wh_value_10") })
157
158                Text($r("app.string.deleteButton"))
159                  .fontSize($r("app.float.font_20"))
160                  .fontColor($r("app.color.font_color_182431"))
161                  .margin({ bottom: $r("app.float.wh_value_10") })
162              }
163              .width(ConfigData.WH_100_100)
164              .alignItems(HorizontalAlign.Center)
165              .onClick(() => {
166                AlertDialog.show({
167                  message: $r("app.string.deleteUserWarn"),
168                  primaryButton: {
169                    value: $r("app.string.cancel"),
170                    action: () => {
171                      LogUtil.info("Cancel delete user.");
172                    }
173                  },
174                  secondaryButton: {
175                    value: $r("app.string.deleteButton"),
176                    action: () => {
177                      LogUtil.info("Confirm delete user.");
178                      SystemAccountController.removeAccount();
179                    }
180                  },
181                  alignment: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? DialogAlignment.Bottom : DialogAlignment.Center,
182                  offset: ({ dx: 0, dy: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? '-24dp' : 0 })
183                });
184              })
185            }
186          }
187        }
188        .useSizeType({
189          sm: { span: 4, offset: 0 },
190          md: { span: 6, offset: 1 },
191          lg: { span: 8, offset: 2 }
192        })
193      }
194      .width(ConfigData.WH_100_100)
195      .height(ConfigData.WH_100_100)
196    }
197    .backgroundColor($r("sys.color.ohos_id_color_sub_background"))
198    .width(ConfigData.WH_100_100)
199    .height(ConfigData.WH_100_100)
200  }
201
202  onConfirm(localName: string) {
203    LogUtil.info("Open creating wait dialog");
204    if (this.waitDialogController) {
205      this.waitDialogController.open();
206    }
207    SystemAccountController.createSystemAccount(localName, (() => {
208      if (this.waitDialogController) {
209        this.waitDialogController.close();
210      }
211      AlertDialog.show({
212        message: $r("app.string.askSwitchUser"),
213        primaryButton: {
214          value: $r("app.string.cancel"),
215          action: () => {
216            LogUtil.info("Cancel switch to new user.");
217          }
218        },
219        secondaryButton: {
220          value: $r("app.string.switchButton"),
221          action: () => {
222            LogUtil.info("Confirm switch to new user.");
223            SystemAccountController.switchToCreatedAccount();
224          }
225        },
226        alignment: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? DialogAlignment.Bottom : DialogAlignment.Center,
227        offset: ({ dx: 0, dy: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? '-24dp' : 0 }),
228        cancel: () => {
229          LogUtil.info("Cancel dialog.");
230        }
231      })
232    }));
233  }
234
235  onPageShow() {
236    LogUtil.info("Multiple user list about to appear.")
237    this.addUserDialogController = new CustomDialogController({
238      builder: AddUserDialog({
239        controller: this.addUserDialogController,
240        account: new AccountInfo(),
241        confirm: (localName: string): void => {
242          this.onConfirm(localName);
243        },
244      }),
245      alignment: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? DialogAlignment.Bottom : DialogAlignment.Center,
246      offset: ({ dx: 0, dy: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? '-24dp' : 0 }),
247      autoCancel: true
248    });
249    this.waitDialogController = new CustomDialogController({
250      builder: WaitDialog({ controller: this.waitDialogController, content: $r("app.string.isCreatingUser") }),
251      autoCancel: false,
252      alignment: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? DialogAlignment.Bottom : DialogAlignment.Center,
253      offset: ({ dx: 0, dy: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? '-24dp' : 0 }),
254    });
255    SystemAccountController.refreshSystemAccountList();
256    LogUtil.info("after appear.");
257  }
258
259  aboutToDisappear() {
260    LogUtil.info('multiple user about to disappear.');
261    AppStorage.SetOrCreate("systemAccountList", []);
262  }
263
264  onBackPress() {
265    LogUtil.info('settings MultipleUsers onBackPress');
266  }
267}
268
269@Component
270struct UserItem {
271  @State isTouched: boolean = false;
272  dialogController?: CustomDialogController;
273  private user: osAccount.OsAccountInfo | null = null;
274
275  aboutToAppear(): void {
276    this.dialogController = new CustomDialogController({
277      builder: UserItemDialog({ dialogController: this.dialogController, user: this.user }),
278      autoCancel: false,
279      alignment: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? DialogAlignment.Bottom : DialogAlignment.Center,
280      offset: ({ dx: 0, dy: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? '-24dp' : 0 })
281    });
282  }
283
284  build() {
285    Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
286      Row() {
287        Image("/res/image/ic_user_portrait.svg")
288          .width($r("app.float.wh_value_40"))
289          .height($r("app.float.wh_value_40"))
290          .margin({ left: $r("app.float.wh_value_12"), right: $r("app.float.wh_value_12") })
291
292        Column() {
293          Text(this.user?.localName)
294            .fontSize($r("app.float.font_16"))
295            .fontWeight(FontWeight.Medium)
296            .fontSize($r('sys.float.ohos_id_text_size_body1'))
297            .margin({ bottom: $r('sys.float.ohos_id_text_margin_vertical') })
298
299          if (SystemAccountController.isShowIdentity(this.user)) {
300            Text(SystemAccountModel.getIdentityFromMap(this.user?.type))
301              .fontSize($r('sys.float.ohos_id_text_size_body2'))
302              .fontWeight(FontWeight.Regular)
303              .fontColor($r('sys.color.ohos_id_color_text_secondary'))
304          }
305        }
306        .alignItems(HorizontalAlign.Start)
307      }
308
309      Image($r("app.media.ic_settings_arrow"))
310        .width($r("app.float.wh_value_12"))
311        .height($r("app.float.wh_value_24"))
312        .margin({ right: $r("app.float.distance_11") })
313        .fillColor($r("sys.color.ohos_id_color_primary"))
314        .opacity($r("app.float.opacity_0_2"))
315    }
316    .height($r("app.float.wh_value_80"))
317    .onClick((event) => {
318      LogUtil.info("Click the multiple user item.");
319      if (SystemAccountController.isCurrentAdministrator() ||
320        SystemAccountController.isCurrentUser(this.user) && !SystemAccountController.isGuestAccount(this.user)) {
321        if (this.dialogController) {
322          this.dialogController.open();
323        }
324        return;
325      }
326      if (!SystemAccountController.isCurrentQuest() || !SystemAccountController.isGuestAccount(this.user)) {
327        AlertDialog.show({
328          message: $r("app.string.switchUser"),
329          primaryButton: {
330            value: $r("app.string.cancel"),
331            action: () => {
332              LogUtil.info("Cancel switch to user.");
333            }
334          },
335          secondaryButton: {
336            value: $r("app.string.confirm"),
337            action: () => {
338              if (this.user) {
339                SystemAccountController.switchUser(this.user?.localId);
340              }
341            }
342          },
343          alignment: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? DialogAlignment.Bottom : DialogAlignment.Center,
344          offset: ({ dx: 0, dy: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? '-24dp' : 0 })
345        });
346      }
347    })
348    .borderRadius($r('app.float.radius_20'))
349    .linearGradient(this.isTouched ? {
350      angle: 90,
351      direction: GradientDirection.Right,
352      colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]]
353    } : {
354      angle: 90,
355      direction: GradientDirection.Right,
356      colors: [[$r("sys.color.ohos_id_color_foreground_contrary"), 1], [$r("sys.color.ohos_id_color_foreground_contrary"), 1]]
357    })
358    .onTouch((event?: TouchEvent | undefined) => {
359      if (event?.type === TouchType.Down) {
360        this.isTouched = true;
361      }
362
363      if (event?.type === TouchType.Up) {
364        this.isTouched = false;
365      }
366    });
367  }
368}
369
370// Current user item dialog, allow user to set user name and profile image.
371@CustomDialog
372struct UserItemDialog {
373  private user: osAccount.OsAccountInfo | null = null;
374  private dialogController?: CustomDialogController;
375
376  build() {
377    if (SystemAccountController.isCurrentUser(this.user)) {
378      CurrentDialogBuilder({
379        controller: this.dialogController,
380        user: this.user
381      });
382    } else {
383      UserDialogBuilder({
384        controller: this.dialogController,
385        user: this.user
386      });
387    }
388  }
389}
390
391@Component
392struct CurrentDialogBuilder {
393  private controller: CustomDialogController | null = null;
394  private user: AccountInfo | null = null;
395  private tempName: string = '';
396
397  build() {
398    Column() {
399      Image("/res/image/ic_user_portrait.svg")
400        .width($r("app.float.wh_value_40"))
401        .height($r("app.float.wh_value_40"))
402        .margin({ top: $r("app.float.wh_value_24"), bottom: $r("app.float.wh_value_13") })
403        .onClick((event: ClickEvent | undefined) => {
404          LogUtil.info("Click to modify user image.")
405          let chooseImageDialog = new CustomDialogController({
406            builder: ChooseImageDialog(),
407            alignment: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? DialogAlignment.Bottom : DialogAlignment.Center,
408            offset: ({ dx: 0, dy: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? '-24dp' : 0 })
409          });
410          chooseImageDialog.open();
411        })
412
413      Text($r("app.string.addUserImage"))
414        .fontFamily('HarmonyHeiTi')
415        .fontSize($r("app.float.font_16"))
416        .height($r("app.float.wh_value_22"))
417        .fontColor($r("sys.color.ohos_id_color_primary"))
418        .fontWeight(FontWeight.Medium)
419        .margin({ bottom: $r("app.float.wh_value_8") })
420
421      TextInput({ text: this.user?.localName })
422        .placeholderColor($r("app.color.font_color_182431"))
423        .placeholderFont({
424          size: $r("app.float.font_16"),
425          weight: FontWeight.Regular,
426          style: FontStyle.Normal
427        })
428        .width(ConfigData.WH_100_100)
429        .height($r("app.float.wh_value_48"))
430        .borderRadius($r("app.float.search_input_border_radius"))
431        .maxLength(MAX_LENGTH)
432        .padding({ left: $r("app.float.wh_value_12"), right: $r("app.float.wh_value_12") })
433        .backgroundColor($r('app.color.color_00000000_transparent'))
434        .onChange((value: string) => {
435          LogUtil.info("Set current account name, name: " + value);
436          this.tempName = value;
437        })
438        .onSubmit((enterKey) => {
439          InputMethod.getInputMethodController().stopInput()
440            .then((ret) => {
441              LogUtil.debug(`${ConfigData.TAG}, enterType: ${enterKey}, stopInput: ${ret}`);
442            });
443        })
444
445      Divider()
446        .margin({
447          left: $r("app.float.wh_value_12"),
448          right: $r("app.float.wh_value_12"),
449          bottom: $r("app.float.distance_9")
450        })
451        .color($r("sys.color.ohos_id_color_list_separator"))
452
453      DialogButtonLayout({
454        firstClickEvent: () => {
455          LogUtil.info("Cancel current user modify dialog.");
456          this.controller?.close();
457        },
458        secondClickEvent: () => {
459          LogUtil.info("Confirm current user modify dialog.");
460          this.controller?.close();
461          if (this.user?.localId) {
462            SystemAccountController.setAccountName(this.user.localId, this.tempName);
463          }
464        }
465      })
466    }
467    .padding({ left: $r("app.float.wh_value_12"), right: $r("app.float.wh_value_12") })
468    .borderRadius('24vp')
469    .height('220vp')
470  }
471}
472
473// Current user item dialog, allow user to set user name and profile image.
474@Component
475struct UserDialogBuilder {
476  waitController?: CustomDialogController;
477  private controller: CustomDialogController | null = null;
478  private user: osAccount.OsAccountInfo | null = null;
479
480  aboutToAppear(): void {
481    this.waitController = new CustomDialogController({
482      builder: WaitDialog({
483        controller: this.waitController,
484        content: $r("app.string.isRemoving")
485      }),
486      alignment: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? DialogAlignment.Bottom : DialogAlignment.Center,
487      offset: ({ dx: 0, dy: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? '-24dp' : 0 }),
488      autoCancel: false
489    });
490  }
491
492  build() {
493    Column() {
494      Text(this.user?.localName)
495        .fontSize($r("app.float.font_20"))
496        .fontWeight(FontWeight.Medium)
497        .fontColor($r("app.color.font_color_182431"))
498        .height($r("app.float.wh_value_56"))
499
500      Text($r("app.string.switchUser"))
501        .fontSize($r("app.float.font_16"))
502        .fontColor($r("app.color.font_color_182431"))
503        .height($r("app.float.wh_value_48"))
504        .width(ConfigData.WH_100_100)
505        .textAlign(TextAlign.Start)
506        .onClick((event) => {
507          this.controller?.close();
508          if (this.user) {
509            SystemAccountController.switchUser(this.user?.localId);
510          }
511        })
512
513      Divider()
514        .color($r("sys.color.ohos_id_color_list_separator"))
515
516      Text($r("app.string.removeUser"))
517        .fontSize($r("app.float.font_16"))
518        .fontColor($r("app.color.font_color_182431"))
519        .height($r("app.float.wh_value_48"))
520        .width(ConfigData.WH_100_100)
521        .textAlign(TextAlign.Start)
522        .onClick(() => {
523          AlertDialog.show({
524            message: $r("app.string.deleteUserWarn"),
525            primaryButton: {
526              value: $r("app.string.cancel"),
527              action: () => {
528                LogUtil.info("Cancel delete user.");
529              }
530            },
531            secondaryButton: {
532              value: $r("app.string.deleteButton"),
533              action: () => {
534                LogUtil.info("Confirm delete user.");
535                if (this.waitController) {
536                  this.waitController.open();
537                }
538                SystemAccountController.removeAccount(this.user?.localId, () => {
539                  if (this.waitController) {
540                    this.waitController.close();
541                  }
542                });
543              }
544            },
545            alignment: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? DialogAlignment.Bottom : DialogAlignment.Center,
546            offset: ({ dx: 0, dy: deviceTypeInfo === 'phone' || deviceTypeInfo === 'default' ? '-24dp' : 0 })
547          });
548          this.controller?.close();
549        })
550
551      Button($r("app.string.cancel"))
552        .fontSize($r("app.float.font_16"))
553        .fontColor($r("app.color.font_color_182431"))
554        .backgroundColor(Color.White)
555        .margin({ top: $r("app.float.wh_value_16"), bottom: $r("app.float.wh_value_16") })
556        .width(ConfigData.WH_100_100)
557        .onClick(() => {
558          LogUtil.info("Cancel user operation dialog.");
559          this.controller?.close();
560        })
561    }
562    .alignItems(HorizontalAlign.Start)
563    .margin({ left: $r("app.float.wh_value_24"), right: $r("app.float.wh_value_24") })
564  }
565}
566
567@CustomDialog
568struct AddUserDialog {
569  @State buttonState: boolean = false;
570  @State hintText: string = '';
571  @State isWarn: boolean = false;
572  private controller?: CustomDialogController;
573  private account: AccountInfo = new AccountInfo();
574
575  build() {
576    Column() {
577      Text($r("app.string.addNewUser"))
578        .fontSize($r("app.float.font_20"))
579        .fontWeight(FontWeight.Medium)
580        .fontColor($r("sys.color.ohos_id_color_primary"))
581        .height($r("app.float.wh_value_56"))
582        .width(ConfigData.WH_100_100)
583        .textAlign(TextAlign.Start)
584        .padding({ right: $r("app.float.wh_value_12"), left: $r("app.float.wh_value_12") })
585
586      Image("/res/image/ic_user_camera.svg")
587        .width($r("app.float.wh_value_40"))
588        .height($r("app.float.wh_value_40"))
589        .margin({ bottom: $r("app.float.wh_value_32") })
590
591      TextInput({ placeholder: this.hintText })
592        .placeholderFont({ size: $r("app.float.font_16") })
593        .placeholderColor($r("app.color.font_color_182431"))
594        .borderRadius($r("app.float.search_input_border_radius"))
595        .maxLength(MAX_LENGTH)
596        .width(ConfigData.WH_100_100)
597        .padding({ left: $r("app.float.wh_value_12"), right: $r("app.float.wh_value_12") })
598        .borderRadius(0)
599        .backgroundColor($r('app.color.color_00000000_transparent'))
600        .onChange((value: string) => {
601          LogUtil.info("Set the user name: " + value);
602          this.account.localName = value;
603          this.isWarn = SystemAccountController.isAlreadyCreated(value);
604          this.buttonState = value != "" && !this.isWarn;
605          LogUtil.info("Set the user name, name: " + this.account.localName);
606        })
607        .onSubmit((enterKey) => {
608          InputMethod.getInputMethodController().stopInput()
609            .then((ret) => {
610              LogUtil.debug(`${ConfigData.TAG}, enterType: ${enterKey}, stopInput: ${ret}`);
611            });
612        })
613
614      Divider()
615        .margin({ right: $r("app.float.wh_value_12"), left: $r("app.float.wh_value_12") })
616        .color($r("sys.color.ohos_id_color_list_separator"))
617
618      if (this.isWarn) {
619        Text($r("app.string.userCreatedWarn"))
620          .fontSize($r("app.float.font_14"))
621          .fontColor($r("sys.color.ohos_id_color_primary"))
622          .width(ConfigData.WH_100_100)
623          .textAlign(TextAlign.Start)
624          .margin({
625            top: $r("app.float.wh_value_8"),
626            bottom: $r("app.float.wh_value_18"),
627            left: $r("app.float.wh_value_12")
628          })
629      } else {
630        Text($r("app.string.addUserDescription"))
631          .fontSize($r("app.float.font_16"))
632          .fontColor($r("app.color.font_color_182431"))
633          .fontWeight(500)
634          .width(ConfigData.WH_100_100)
635          .textAlign(TextAlign.Start)
636          .padding({
637            top: $r("app.float.wh_value_8"),
638            bottom: $r("app.float.distance_9"),
639            left: $r("app.float.wh_value_12")
640          })
641      }
642
643      DialogButtonLayoutWithState({
644        firstClickEvent: () => {
645          LogUtil.info("Cancel add new user.");
646          this.controller?.close();
647        },
648        secondClickEvent: () => {
649          LogUtil.info("Confirm Add new user.");
650          this.controller?.close();
651          this.confirm(this.account.localName);
652        },
653        secondButtonState: this.buttonState
654      })
655    }
656    .borderRadius($r("app.float.wh_value_24"))
657    .height($r("app.float.wh_value_260"))
658    .margin({ left: $r("app.float.wh_value_12"), right: $r("app.float.wh_value_12") })
659  }
660
661  aboutToAppear() {
662    ResourceUtil.getString($r("app.string.nickname"))
663      .then(value => this.hintText = value);
664  }
665
666  private confirm: (localName: string) => void = () => {
667  };
668}
669
670@CustomDialog
671struct ChooseImageDialog {
672  private controller?: CustomDialogController;
673
674  build() {
675    Column() {
676      Text($r("app.string.takePhoto"))
677        .fontSize($r("app.float.font_24"))
678        .fontColor($r("app.color.font_color_182431"))
679        .onClick(() => {
680          router.push({ uri: "" });
681        })
682
683      Text($r("app.string.chooseFromShop"))
684        .fontSize($r("app.float.font_16"))
685        .fontColor($r("app.color.font_color_182431"))
686        .onClick(() => {
687          router.push({ uri: "" })
688        })
689    }
690  }
691}
692
693@CustomDialog
694struct WaitDialog {
695  private controller?: CustomDialogController;
696  private content: string | Resource = '';
697
698  build() {
699    Row() {
700      Text(this.content)
701        .fontSize($r("app.float.font_16"))
702        .fontColor($r("app.color.font_color_182431"))
703        .height($r("app.float.wh_value_48"))
704        .width(ConfigData.WH_100_100)
705        .textAlign(TextAlign.Start)
706        .fontWeight(FontWeight.Medium)
707        .padding({
708          top: $r("app.float.distance_8"),
709          bottom: $r("app.float.distance_8")
710        })
711    }
712    .alignItems(VerticalAlign.Center)
713    .height($r("app.float.wh_value_80"))
714    .padding({
715      left: $r("app.float.distance_24"),
716      right: $r("app.float.distance_24")
717    })
718  }
719}
720