Notifications
This commit is contained in:
@@ -3,21 +3,20 @@ import Link from '../../components/Link';
|
|||||||
import Store from '../../store';
|
import Store from '../../store';
|
||||||
import * as selectors from '../../store/selectors';
|
import * as selectors from '../../store/selectors';
|
||||||
|
|
||||||
import VirtualScroll from '../ui/VirtualScroll';
|
// import VirtualScroll from '../ui/VirtualScroll';
|
||||||
import {
|
import {
|
||||||
IonPage,
|
IonPage,
|
||||||
IonHeader,
|
IonHeader,
|
||||||
IonToolbar,
|
IonToolbar,
|
||||||
IonTitle,
|
IonTitle,
|
||||||
IonContent,
|
IonContent,
|
||||||
IonList,
|
|
||||||
IonItem,
|
IonItem,
|
||||||
IonLabel,
|
IonLabel,
|
||||||
} from '@ionic/react';
|
} from '@ionic/react';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
const ListEntry = ({ list, ...props }) => (
|
const ListEntry = ({ list, ...props }) => (
|
||||||
<IonItem href={`/tabs/lists/${list.id}`}>
|
<IonItem href={`/tabs/lists/${list.id}`} className="list-entry">
|
||||||
<IonLabel>{list.name}</IonLabel>
|
<IonLabel>{list.name}</IonLabel>
|
||||||
</IonItem>
|
</IonItem>
|
||||||
);
|
);
|
||||||
@@ -25,14 +24,24 @@ const ListEntry = ({ list, ...props }) => (
|
|||||||
const AllLists = ({ onSelect }) => {
|
const AllLists = ({ onSelect }) => {
|
||||||
const lists = Store.useState(selectors.getLists);
|
const lists = Store.useState(selectors.getLists);
|
||||||
|
|
||||||
|
/*
|
||||||
return (
|
return (
|
||||||
<VirtualScroll
|
<VirtualScroll
|
||||||
data={lists}
|
data={lists}
|
||||||
totalCount={lists.length}
|
totalCount={lists.length}
|
||||||
style={{ height: '100%', width: '100%' }}
|
style={{ height: '100%', width: '100%', minHeight: '1px' }}
|
||||||
itemContent={(i, list) => <ListEntry list={list} />}
|
itemContent={(i, list) => <ListEntry list={list} />}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{lists.map(list => (
|
||||||
|
<ListEntry list={list} />
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const Lists = () => {
|
const Lists = () => {
|
||||||
|
|||||||
@@ -1,12 +1,39 @@
|
|||||||
import { IonModal, IonHeader, IonToolbar, IonTitle, IonContent, IonList } from '@ionic/react';
|
import {
|
||||||
import VirtualScroll from '../ui/VirtualScroll';
|
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 = ({ open, onDidDismiss }) => {
|
||||||
|
const notifications = Store.useState(getNotifications);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IonModal isOpen={open} onDidDismiss={onDidDismiss}>
|
<IonModal isOpen={open} onDidDismiss={onDidDismiss}>
|
||||||
<IonHeader>
|
<IonHeader>
|
||||||
<IonToolbar>
|
<IonToolbar>
|
||||||
<IonTitle>Lists</IonTitle>
|
<IonTitle>Notifications</IonTitle>
|
||||||
</IonToolbar>
|
</IonToolbar>
|
||||||
</IonHeader>
|
</IonHeader>
|
||||||
<IonContent fullscreen>
|
<IonContent fullscreen>
|
||||||
@@ -16,12 +43,9 @@ const Notifications = ({ open, onDidDismiss }) => {
|
|||||||
</IonToolbar>
|
</IonToolbar>
|
||||||
</IonHeader>
|
</IonHeader>
|
||||||
<IonList>
|
<IonList>
|
||||||
<VirtualScroll
|
{notifications.map(notification => (
|
||||||
totalCount={1000}
|
<NotificationItem notification={notification} />
|
||||||
overscan={200}
|
))}
|
||||||
style={{ height: '100%', width: '100%' }}
|
|
||||||
itemContent={index => <NotificationItem i={index} />}
|
|
||||||
/>
|
|
||||||
</IonList>
|
</IonList>
|
||||||
</IonContent>
|
</IonContent>
|
||||||
</IonModal>
|
</IonModal>
|
||||||
|
|||||||
+4
-4
@@ -34,10 +34,10 @@ export const homeItems = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const notifications = [
|
export const notifications = [
|
||||||
{ title: 'New friend request' },
|
{ title: 'New friend request', when: '6 hr' },
|
||||||
{ title: 'Please change your password' },
|
{ title: 'Please change your password', when: '1 day' },
|
||||||
{ title: 'You have a new message' },
|
{ title: 'You have a new message', when: '2 weeks' },
|
||||||
{ title: 'Welcome to the app!' },
|
{ title: 'Welcome to the app!', when: '1 month' },
|
||||||
];
|
];
|
||||||
|
|
||||||
// Some fake lists
|
// Some fake lists
|
||||||
|
|||||||
+1
-5
@@ -2,11 +2,7 @@ import { createSelector } from 'reselect';
|
|||||||
|
|
||||||
const getState = state => state;
|
const getState = state => state;
|
||||||
|
|
||||||
export const getMenuOpen = createSelector(getState, state => state.menuOpen);
|
|
||||||
export const getNotificationsOpen = createSelector(getState, state => state.notificationsOpen);
|
|
||||||
export const getCurrentPage = createSelector(getState, state => state.currentPage);
|
|
||||||
|
|
||||||
// App specific selectors
|
|
||||||
export const getHomeItems = createSelector(getState, state => state.homeItems);
|
export const getHomeItems = createSelector(getState, state => state.homeItems);
|
||||||
export const getLists = createSelector(getState, state => state.lists);
|
export const getLists = createSelector(getState, state => state.lists);
|
||||||
|
export const getNotifications = createSelector(getState, state => state.notifications);
|
||||||
export const getSettings = createSelector(getState, state => state.settings);
|
export const getSettings = createSelector(getState, state => state.settings);
|
||||||
|
|||||||
Reference in New Issue
Block a user