Notifications

This commit is contained in:
Max Lynch
2021-01-11 18:56:03 -06:00
parent d71b7eb173
commit c60f5b3dcc
4 changed files with 51 additions and 22 deletions
+13 -4
View File
@@ -3,21 +3,20 @@ import Link from '../../components/Link';
import Store from '../../store';
import * as selectors from '../../store/selectors';
import VirtualScroll from '../ui/VirtualScroll';
// import VirtualScroll from '../ui/VirtualScroll';
import {
IonPage,
IonHeader,
IonToolbar,
IonTitle,
IonContent,
IonList,
IonItem,
IonLabel,
} from '@ionic/react';
import { useEffect, useState } from 'react';
const ListEntry = ({ list, ...props }) => (
<IonItem href={`/tabs/lists/${list.id}`}>
<IonItem href={`/tabs/lists/${list.id}`} className="list-entry">
<IonLabel>{list.name}</IonLabel>
</IonItem>
);
@@ -25,14 +24,24 @@ const ListEntry = ({ list, ...props }) => (
const AllLists = ({ onSelect }) => {
const lists = Store.useState(selectors.getLists);
/*
return (
<VirtualScroll
data={lists}
totalCount={lists.length}
style={{ height: '100%', width: '100%' }}
style={{ height: '100%', width: '100%', minHeight: '1px' }}
itemContent={(i, list) => <ListEntry list={list} />}
/>
);
*/
return (
<>
{lists.map(list => (
<ListEntry list={list} />
))}
</>
);
};
const Lists = () => {
+33 -9
View File
@@ -1,12 +1,39 @@
import { IonModal, IonHeader, IonToolbar, IonTitle, IonContent, IonList } from '@ionic/react';
import VirtualScroll from '../ui/VirtualScroll';
import {
IonModal,
IonHeader,
IonToolbar,
IonTitle,
IonContent,
IonButton,
IonIcon,
IonList,
IonItem,
IonNote,
IonLabel,
} from '@ionic/react';
import Store from '../../store';
import { getNotifications } from '../../store/selectors';
import { close } from 'ionicons/icons';
const NotificationItem = ({ notification }) => (
<IonItem>
<IonLabel>{notification.title}</IonLabel>
<IonNote slot="end">{notification.when}</IonNote>
<IonButton slot="end" fill="clear" color="dark">
<IonIcon icon={close} />
</IonButton>
</IonItem>
);
const Notifications = ({ open, onDidDismiss }) => {
const notifications = Store.useState(getNotifications);
return (
<IonModal isOpen={open} onDidDismiss={onDidDismiss}>
<IonHeader>
<IonToolbar>
<IonTitle>Lists</IonTitle>
<IonTitle>Notifications</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent fullscreen>
@@ -16,12 +43,9 @@ const Notifications = ({ open, onDidDismiss }) => {
</IonToolbar>
</IonHeader>
<IonList>
<VirtualScroll
totalCount={1000}
overscan={200}
style={{ height: '100%', width: '100%' }}
itemContent={index => <NotificationItem i={index} />}
/>
{notifications.map(notification => (
<NotificationItem notification={notification} />
))}
</IonList>
</IonContent>
</IonModal>