NotificationView.js 1.47 KB
Newer Older
陈帅's avatar
陈帅 committed
1
import React, { Component, Fragment } from 'react';
陈帅's avatar
陈帅 committed
2
import { formatMessage } from 'umi/locale';
陈帅's avatar
陈帅 committed
3 4
import { Switch, List } from 'antd';

张秀玲's avatar
张秀玲 committed
5
class NotificationView extends Component {
陈帅's avatar
陈帅 committed
6
  getData = () => {
张秀玲's avatar
张秀玲 committed
7 8
    const Action = (
      <Switch
陈帅's avatar
陈帅 committed
9 10
        checkedChildren={formatMessage({ id: 'app.settings.open' }, {})}
        unCheckedChildren={formatMessage({ id: 'app.settings.close' }, {})}
张秀玲's avatar
张秀玲 committed
11 12 13
        defaultChecked
      />
    );
陈帅's avatar
陈帅 committed
14 15
    return [
      {
陈帅's avatar
陈帅 committed
16 17
        title: formatMessage({ id: 'app.settings.notification.password' }, {}),
        description: formatMessage({ id: 'app.settings.notification.password-description' }, {}),
陈帅's avatar
陈帅 committed
18 19 20
        actions: [Action],
      },
      {
陈帅's avatar
陈帅 committed
21 22
        title: formatMessage({ id: 'app.settings.notification.messages' }, {}),
        description: formatMessage({ id: 'app.settings.notification.messages-description' }, {}),
陈帅's avatar
陈帅 committed
23 24 25
        actions: [Action],
      },
      {
陈帅's avatar
陈帅 committed
26 27
        title: formatMessage({ id: 'app.settings.notification.todo' }, {}),
        description: formatMessage({ id: 'app.settings.notification.todo-description' }, {}),
陈帅's avatar
陈帅 committed
28 29 30 31
        actions: [Action],
      },
    ];
  };
陈帅's avatar
陈帅 committed
32

陈帅's avatar
陈帅 committed
33 34 35 36 37 38 39 40
  render() {
    return (
      <Fragment>
        <List
          itemLayout="horizontal"
          dataSource={this.getData()}
          renderItem={item => (
            <List.Item actions={item.actions}>
jim's avatar
jim committed
41
              <List.Item.Meta title={item.title} description={item.description} />
陈帅's avatar
陈帅 committed
42 43 44 45 46 47 48
            </List.Item>
          )}
        />
      </Fragment>
    );
  }
}
陈帅's avatar
陈帅 committed
49
export default NotificationView;