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 SystemAccount from '../model/usersAndAccounts/systemAccountModel';
17import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil';
18import ConfigData from '../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData';
19import { SubHeader } from '../../../../../../common/component/src/main/ets/default/textComponent';
20import HeadComponent from '../../../../../../common/component/src/main/ets/default/headComponent';
21import { SubEntryComponentWithEndText } from '../../../../../../common/component/src/main/ets/default/subEntryComponent';
22
23/**
24* System account home page.
25 */
26@Entry
27@Component
28struct UsersAccounts {
29  @StorageLink("accountName") accountName: string = "";
30
31  build() {
32    Column() {
33      GridContainer({ gutter: ConfigData.GRID_CONTAINER_GUTTER_24, margin: ConfigData.GRID_CONTAINER_MARGIN_24 }) {
34        Column() {
35          // head
36          HeadComponent({ headName: $r("app.string.usersAccountsTab"), isActive: true });
37
38          SubHeader({ titleContent: $r('app.string.user') });
39
40          // current user subEntry
41          SubEntryComponentWithEndText({
42            targetPage: "pages/multipleUsers",
43            title: $r("app.string.currentLogin"),
44            endText: $accountName
45          });
46        }
47        .useSizeType({
48          sm: { span: 4, offset: 0 },
49          md: { span: 6, offset: 1 },
50          lg: { span: 8, offset: 2 }
51        })
52      }
53      .width(ConfigData.WH_100_100)
54      .height(ConfigData.WH_100_100)
55    }
56    .backgroundColor($r("sys.color.ohos_id_color_sub_background"))
57    .width(ConfigData.WH_100_100)
58    .height(ConfigData.WH_100_100)
59  }
60
61  onPageShow() {
62    LogUtil.info("User account page on show.");
63    SystemAccount.updateAccountName(name => {
64      AppStorage.SetOrCreate("accountName", name)
65    });
66  }
67}