mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 06:28:51 +00:00
formatting
This commit is contained in:
1 parent
e48263838f
commit
3a1bd75f97
23 files changed
+309
-236
No files matched your search
@@ -69,6 +69,7 @@
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"watch": "cra-build-watch --disable-chunks --build-path ../resources/html --output-filename dev.js",
|
||||
"format": "prettier --write src/**/*.{js,jsx,ts,tsx,json,css,scss,md}",
|
||||
"build": "react-scripts build",
|
||||
"build:resources": "cross-env NODE_ENV=production webpack --config webpack/webpack.resources.js --color -p --progress --hide-modules --display-optimization-bailout",
|
||||
"test": "react-scripts test --watchAll=false --testMatch **/src/**/*.test.[jt]s?(x)",
|
||||
|
||||
+3
-3
@@ -44,19 +44,19 @@ setTimeout(() => {
|
||||
id: 1,
|
||||
number: "345-4366",
|
||||
display: "Gjelten",
|
||||
avatar: 'https://i.imgur.com/Qpw6j8D.png'
|
||||
avatar: "https://i.imgur.com/Qpw6j8D.png",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
number: "456-4366",
|
||||
display: "Loyd",
|
||||
avatar: ''
|
||||
avatar: "",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
number: "123-4366",
|
||||
display: "Fabian",
|
||||
avatar: 'https://i.imgur.com/B8ta5Aa.jpeg'
|
||||
avatar: "https://i.imgur.com/B8ta5Aa.jpeg",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -4,13 +4,12 @@ import { Button, TextField } from "@material-ui/core";
|
||||
import Nui from "../../../os/nui-events/utils/Nui";
|
||||
import List from "@material-ui/core/List";
|
||||
import ListItem from "@material-ui/core/ListItem";
|
||||
import Modal from '../../../ui/components/Modal';
|
||||
import { useModal } from '../hooks/useModal';
|
||||
import ClearIcon from '@material-ui/icons/Clear';
|
||||
import PersonIcon from '@material-ui/icons/Person';
|
||||
import PhoneIcon from '@material-ui/icons/Phone';
|
||||
import AccountCircleIcon from '@material-ui/icons/AccountCircle';
|
||||
|
||||
import Modal from "../../../ui/components/Modal";
|
||||
import { useModal } from "../hooks/useModal";
|
||||
import ClearIcon from "@material-ui/icons/Clear";
|
||||
import PersonIcon from "@material-ui/icons/Person";
|
||||
import PhoneIcon from "@material-ui/icons/Phone";
|
||||
import AccountCircleIcon from "@material-ui/icons/AccountCircle";
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
button: {
|
||||
@@ -26,32 +25,32 @@ const useStyles = makeStyles((theme: Theme) => ({
|
||||
height: "20%",
|
||||
},
|
||||
clearButton: {
|
||||
width: '10%',
|
||||
position: 'absolute',
|
||||
right: 0
|
||||
width: "10%",
|
||||
position: "absolute",
|
||||
right: 0,
|
||||
},
|
||||
textInputField: {
|
||||
fontSize: 20,
|
||||
borderBottomColor: 'red'
|
||||
borderBottomColor: "red",
|
||||
},
|
||||
addBtn: {
|
||||
margin: 'auto',
|
||||
margin: "auto",
|
||||
fontSize: 16,
|
||||
width: 150,
|
||||
background: "#2196f3",
|
||||
marginBottom: 10,
|
||||
padding: 8
|
||||
padding: 8,
|
||||
},
|
||||
cancelBtn: {
|
||||
margin: 'auto',
|
||||
margin: "auto",
|
||||
width: 150,
|
||||
background: "#232323",
|
||||
marginBottom: 20,
|
||||
padding: 8
|
||||
padding: 8,
|
||||
},
|
||||
icons: {
|
||||
marginRight: 5
|
||||
}
|
||||
marginRight: 5,
|
||||
},
|
||||
}));
|
||||
|
||||
export const AddContactModal = () => {
|
||||
@@ -69,25 +68,27 @@ export const AddContactModal = () => {
|
||||
Nui.send("contacts:add", {
|
||||
name,
|
||||
number,
|
||||
avatar
|
||||
avatar,
|
||||
});
|
||||
console.log(name, number, avatar);
|
||||
}
|
||||
};
|
||||
|
||||
const _handleClose = () => {
|
||||
setShowModal(false)
|
||||
}
|
||||
setShowModal(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal visible={showModal} handleClose={_handleClose}>
|
||||
<Button onClick={_handleClose} className={classes.clearButton}><ClearIcon /></Button>
|
||||
<Button onClick={_handleClose} className={classes.clearButton}>
|
||||
<ClearIcon />
|
||||
</Button>
|
||||
<List style={{ marginTop: 30 }}>
|
||||
<ListItem>
|
||||
<PersonIcon className={classes.icons} />
|
||||
<TextField
|
||||
value={name}
|
||||
inputProps={{ className: classes.textInputField}}
|
||||
inputProps={{ className: classes.textInputField }}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
fullWidth
|
||||
variant="standard"
|
||||
@@ -98,7 +99,7 @@ export const AddContactModal = () => {
|
||||
<PhoneIcon className={classes.icons} />
|
||||
<TextField
|
||||
value={number}
|
||||
inputProps={{ className: classes.textInputField}}
|
||||
inputProps={{ className: classes.textInputField }}
|
||||
onChange={(e) => setNumber(e.target.value)}
|
||||
fullWidth
|
||||
placeholder="Number"
|
||||
@@ -110,7 +111,7 @@ export const AddContactModal = () => {
|
||||
<AccountCircleIcon className={classes.icons} />
|
||||
<TextField
|
||||
value={avatar}
|
||||
inputProps={{ className: classes.textInputField}}
|
||||
inputProps={{ className: classes.textInputField }}
|
||||
onChange={(e) => setAvatar(e.target.value)}
|
||||
fullWidth
|
||||
placeholder="Avatar URL"
|
||||
@@ -118,8 +119,10 @@ export const AddContactModal = () => {
|
||||
type="text"
|
||||
/>
|
||||
</ListItem>
|
||||
</List>
|
||||
<Button className={classes.addBtn} onClick={addContact}>Add Contact</Button>
|
||||
</List>
|
||||
<Button className={classes.addBtn} onClick={addContact}>
|
||||
Add Contact
|
||||
</Button>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
@@ -1,9 +1,9 @@
|
||||
import React from 'react'
|
||||
import React from "react";
|
||||
import { makeStyles, createStyles, Theme } from "@material-ui/core/styles";
|
||||
import Paper from "@material-ui/core/Paper";
|
||||
import ContactsIcon from "@material-ui/icons/Contacts";
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
createStyles({
|
||||
root: {
|
||||
height: "60px",
|
||||
@@ -21,12 +21,11 @@ const useStyles = makeStyles((theme: Theme) =>
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
export const ContactTitle = () => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Paper className={classes.root} square variant="outlined" elevation={24}>
|
||||
<ContactsIcon className={classes.icon} />
|
||||
</Paper>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -6,14 +6,13 @@ import { AppContent } from "../../../ui/components/AppContent";
|
||||
import { ContactList } from "./List/ContactList";
|
||||
import { useApp } from "../../../os/apps/hooks/useApps";
|
||||
import { AddContactModal } from "./ContactModal";
|
||||
import { useModal } from '../hooks/useModal';
|
||||
import { useModal } from "../hooks/useModal";
|
||||
import { SearchContacts } from "./List/SearchContacts";
|
||||
import PersonAddIcon from '@material-ui/icons/PersonAdd'
|
||||
import PersonAddIcon from "@material-ui/icons/PersonAdd";
|
||||
|
||||
import Fab from '@material-ui/core/Fab';
|
||||
import Fab from "@material-ui/core/Fab";
|
||||
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
createStyles({
|
||||
backgroundModal: {
|
||||
background: "black",
|
||||
@@ -26,7 +25,7 @@ const useStyles = makeStyles((theme: Theme) =>
|
||||
zIndex: 5,
|
||||
},
|
||||
absolute: {
|
||||
position: 'sticky',
|
||||
position: "sticky",
|
||||
bottom: theme.spacing(2),
|
||||
left: theme.spacing(3),
|
||||
},
|
||||
@@ -34,7 +33,6 @@ const useStyles = makeStyles((theme: Theme) =>
|
||||
);
|
||||
|
||||
export const ContactsApp = () => {
|
||||
|
||||
const classes = useStyles();
|
||||
const { showModal, setShowModal } = useModal();
|
||||
const contacts = useApp("CONTACTS");
|
||||
@@ -43,16 +41,19 @@ export const ContactsApp = () => {
|
||||
setShowModal(true);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<AppWrapper id="contact-app">
|
||||
<AppTitle app={contacts}></AppTitle>
|
||||
<SearchContacts />
|
||||
<AddContactModal/>
|
||||
<AddContactModal />
|
||||
<div className={showModal ? classes.backgroundModal : undefined} />
|
||||
<AppContent>
|
||||
<ContactList />
|
||||
<Fab onClick={openModal} style={{backgroundColor: '#2196f3', color: '#fff'}} className={classes.absolute}>
|
||||
<Fab
|
||||
onClick={openModal}
|
||||
style={{ backgroundColor: "#2196f3", color: "#fff" }}
|
||||
className={classes.absolute}
|
||||
>
|
||||
<PersonAddIcon />
|
||||
</Fab>
|
||||
</AppContent>
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import React from "react";
|
||||
import ListItemText from "@material-ui/core/ListItemText";
|
||||
import {
|
||||
Button,
|
||||
ListItemAvatar,
|
||||
Avatar as MuiAvatar
|
||||
} from "@material-ui/core";
|
||||
import { Button, ListItemAvatar, Avatar as MuiAvatar } from "@material-ui/core";
|
||||
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faPen } from "@fortawesome/free-solid-svg-icons";
|
||||
|
||||
import { useFilteredContacts } from '../../hooks/useFilteredContacts';
|
||||
import { useFilteredContacts } from "../../hooks/useFilteredContacts";
|
||||
|
||||
import PhoneIcon from "@material-ui/icons/Phone";
|
||||
import ChatIcon from "@material-ui/icons/Chat";
|
||||
@@ -20,7 +16,6 @@ import { useContacts } from "../../hooks/useContacts";
|
||||
import Nui from "../../../../os/nui-events/utils/Nui";
|
||||
|
||||
export const ContactList = () => {
|
||||
|
||||
const { filteredContacts } = useFilteredContacts();
|
||||
|
||||
const contacts = useContacts();
|
||||
@@ -34,31 +29,40 @@ export const ContactList = () => {
|
||||
|
||||
return (
|
||||
<List>
|
||||
{contacts.contacts.filter(contact => contact.display.includes(filteredContacts) || contact.number.includes(filteredContacts)).map((contact) => (
|
||||
<ListItem key={contact.id} divider>
|
||||
<ListItemAvatar>
|
||||
{contact.avatar ? (
|
||||
<MuiAvatar src={contact.avatar} />
|
||||
): (
|
||||
<MuiAvatar>{contact.display.slice(0, 1)}</MuiAvatar>
|
||||
)}
|
||||
</ListItemAvatar>
|
||||
<ListItemText primary={contact.display} secondary={contact.number} />
|
||||
<Button onClick={() => startCall(contact.number)}>
|
||||
<PhoneIcon />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() =>
|
||||
console.log("Message: " + contact.display, contact.number)
|
||||
}
|
||||
>
|
||||
<ChatIcon />
|
||||
</Button>
|
||||
<Button>
|
||||
<FontAwesomeIcon icon={faPen} size="lg"/>
|
||||
</Button>
|
||||
</ListItem>
|
||||
))}
|
||||
{contacts.contacts
|
||||
.filter(
|
||||
(contact) =>
|
||||
contact.display.includes(filteredContacts) ||
|
||||
contact.number.includes(filteredContacts)
|
||||
)
|
||||
.map((contact) => (
|
||||
<ListItem key={contact.id} divider>
|
||||
<ListItemAvatar>
|
||||
{contact.avatar ? (
|
||||
<MuiAvatar src={contact.avatar} />
|
||||
) : (
|
||||
<MuiAvatar>{contact.display.slice(0, 1)}</MuiAvatar>
|
||||
)}
|
||||
</ListItemAvatar>
|
||||
<ListItemText
|
||||
primary={contact.display}
|
||||
secondary={contact.number}
|
||||
/>
|
||||
<Button onClick={() => startCall(contact.number)}>
|
||||
<PhoneIcon />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() =>
|
||||
console.log("Message: " + contact.display, contact.number)
|
||||
}
|
||||
>
|
||||
<ChatIcon />
|
||||
</Button>
|
||||
<Button>
|
||||
<FontAwesomeIcon icon={faPen} size="lg" />
|
||||
</Button>
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
);
|
||||
};
|
||||
@@ -1,95 +1,97 @@
|
||||
import React, { useState } from 'react'
|
||||
import React, { useState } from "react";
|
||||
import { InputBase } from "@material-ui/core";
|
||||
import SearchIcon from '@material-ui/icons/Search';
|
||||
import { createStyles, fade, Theme, makeStyles } from '@material-ui/core/styles';
|
||||
import SearchIcon from "@material-ui/icons/Search";
|
||||
import {
|
||||
createStyles,
|
||||
fade,
|
||||
Theme,
|
||||
makeStyles,
|
||||
} from "@material-ui/core/styles";
|
||||
|
||||
import { useFilteredContacts } from '../../hooks/useFilteredContacts';
|
||||
import { useFilteredContacts } from "../../hooks/useFilteredContacts";
|
||||
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
createStyles({
|
||||
bg: {
|
||||
backgroundColor: "#232323",
|
||||
display: 'flex',
|
||||
display: "flex",
|
||||
height: 60,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center'
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
},
|
||||
textFieldInput: {
|
||||
fontSize: 20
|
||||
fontSize: 20,
|
||||
},
|
||||
inputRoot: {
|
||||
color: '#fff',
|
||||
fontSize: 18
|
||||
color: "#fff",
|
||||
fontSize: 18,
|
||||
},
|
||||
inputInput: {
|
||||
padding: theme.spacing(1, 4, 1, 4),
|
||||
// vertical padding + font size from searchIcon
|
||||
transition: theme.transitions.create('width'),
|
||||
width: '100%',
|
||||
|
||||
[theme.breakpoints.up('sm')]: {
|
||||
width: '13ch',
|
||||
'&:focus': {
|
||||
width: '20ch',
|
||||
transition: theme.transitions.create("width"),
|
||||
width: "100%",
|
||||
|
||||
[theme.breakpoints.up("sm")]: {
|
||||
width: "13ch",
|
||||
"&:focus": {
|
||||
width: "20ch",
|
||||
},
|
||||
},
|
||||
},
|
||||
search: {
|
||||
position: 'relative',
|
||||
position: "relative",
|
||||
borderRadius: theme.shape.borderRadius,
|
||||
backgroundColor: fade(theme.palette.common.white, 0.15),
|
||||
'&:hover': {
|
||||
"&:hover": {
|
||||
backgroundColor: fade(theme.palette.common.white, 0.25),
|
||||
},
|
||||
marginLeft: 0,
|
||||
width: '100%',
|
||||
[theme.breakpoints.up('sm')]: {
|
||||
width: "100%",
|
||||
[theme.breakpoints.up("sm")]: {
|
||||
marginLeft: theme.spacing(1),
|
||||
width: 'auto',
|
||||
width: "auto",
|
||||
},
|
||||
},
|
||||
searchIcon: {
|
||||
padding: theme.spacing(0, 0.5),
|
||||
height: '100%',
|
||||
position: 'absolute',
|
||||
pointerEvents: 'none',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
height: "100%",
|
||||
position: "absolute",
|
||||
pointerEvents: "none",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
export const SearchContacts = () => {
|
||||
|
||||
const { setFilteredContacts } = useFilteredContacts();
|
||||
|
||||
const classes = useStyles();
|
||||
const [ searchValue, setSearchValue ] = useState('')
|
||||
|
||||
const [searchValue, setSearchValue] = useState("");
|
||||
|
||||
const handleChange = (e) => {
|
||||
setSearchValue(e.target.value)
|
||||
setFilteredContacts(e.target.value)
|
||||
}
|
||||
setSearchValue(e.target.value);
|
||||
setFilteredContacts(e.target.value);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={classes.bg}>
|
||||
<div className={classes.search}>
|
||||
<div className={classes.searchIcon}>
|
||||
<SearchIcon style={{ color: '#fff' }} />
|
||||
<SearchIcon style={{ color: "#fff" }} />
|
||||
</div>
|
||||
<InputBase
|
||||
onChange={handleChange}
|
||||
placeholder="Search contacts..."
|
||||
classes={{
|
||||
root: classes.inputRoot,
|
||||
input: classes.inputInput
|
||||
input: classes.inputInput,
|
||||
}}
|
||||
inputProps={{ 'aria-label': 'search' }}
|
||||
inputProps={{ "aria-label": "search" }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
@@ -6,11 +6,11 @@ export const contactsState = {
|
||||
default: [],
|
||||
}),
|
||||
showModal: atom({
|
||||
key: 'showModal',
|
||||
default: false
|
||||
key: "showModal",
|
||||
default: false,
|
||||
}),
|
||||
filterContacts: atom({
|
||||
key: 'filterContacts',
|
||||
default: ""
|
||||
})
|
||||
key: "filterContacts",
|
||||
default: "",
|
||||
}),
|
||||
};
|
||||
@@ -5,7 +5,7 @@ interface Contact {
|
||||
id: string;
|
||||
display: string;
|
||||
number: string;
|
||||
img?: string
|
||||
img?: string;
|
||||
}
|
||||
|
||||
interface IUseContacts {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { contactsState } from './state';
|
||||
import { useRecoilState } from "recoil";
|
||||
import { contactsState } from "./state";
|
||||
|
||||
export const useFilteredContacts = () => {
|
||||
const [ filteredContacts, setFilteredContacts ] = useRecoilState(contactsState.filterContacts);
|
||||
const [filteredContacts, setFilteredContacts] = useRecoilState(
|
||||
contactsState.filterContacts
|
||||
);
|
||||
return { filteredContacts, setFilteredContacts };
|
||||
}
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { contactsState } from './state';
|
||||
import { useRecoilState } from "recoil";
|
||||
import { contactsState } from "./state";
|
||||
|
||||
export const useModal = () => {
|
||||
const [ showModal, setShowModal ] = useRecoilState(contactsState.showModal);
|
||||
const [showModal, setShowModal] = useRecoilState(contactsState.showModal);
|
||||
return { showModal, setShowModal };
|
||||
}
|
||||
};
|
||||
@@ -1,42 +1,47 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import TwitterNotification from './TwitterNotification';
|
||||
import React from "react";
|
||||
import { shallow } from "enzyme";
|
||||
import TwitterNotification from "./TwitterNotification";
|
||||
|
||||
jest.mock('react-i18next', () => ({
|
||||
useTranslation: () => ({t: key => key})
|
||||
jest.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key) => key }),
|
||||
}));
|
||||
|
||||
jest.mock('../../../../os/phone/hooks/usePhone', () => ({
|
||||
usePhone: jest.fn().mockReturnValue({ config: {
|
||||
twitter: {
|
||||
showNotifications: true,
|
||||
}
|
||||
} })
|
||||
jest.mock("../../../../os/phone/hooks/usePhone", () => ({
|
||||
usePhone: jest.fn().mockReturnValue({
|
||||
config: {
|
||||
twitter: {
|
||||
showNotifications: true,
|
||||
},
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
jest.mock('../../hooks/useTwitterNotification', () => ({
|
||||
useTwitterNotification: jest.fn().mockReturnValue({ notification: {
|
||||
profile_name: 'test',
|
||||
message: 'test message'
|
||||
} })
|
||||
jest.mock("../../hooks/useTwitterNotification", () => ({
|
||||
useTwitterNotification: jest.fn().mockReturnValue({
|
||||
notification: {
|
||||
profile_name: "test",
|
||||
message: "test message",
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
describe("TwitterNotification", () => {
|
||||
let wrapper;
|
||||
|
||||
describe('TwitterNotification', () => {
|
||||
let wrapper;
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<TwitterNotification />);
|
||||
});
|
||||
it("renders", () => {
|
||||
expect(wrapper).toBeDefined();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<TwitterNotification />)
|
||||
})
|
||||
it('renders', () => {
|
||||
expect(wrapper).toBeDefined();
|
||||
});
|
||||
it("renders profile name", () => {
|
||||
expect(wrapper.find(".makeStyles-profileName-5").text()).toEqual("@test");
|
||||
});
|
||||
|
||||
it('renders profile name', () => {
|
||||
expect(wrapper.find('.makeStyles-profileName-5').text()).toEqual('@test');
|
||||
});
|
||||
|
||||
it('renders message', () => {
|
||||
expect(wrapper.find('.makeStyles-message-7').text()).toEqual('test message');
|
||||
});
|
||||
it("renders message", () => {
|
||||
expect(wrapper.find(".makeStyles-message-7").text()).toEqual(
|
||||
"test message"
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,48 +1,48 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { makeStyles, createStyles, Theme } from "@material-ui/core/styles";
|
||||
import TwitterIcon from '@material-ui/icons/Twitter';
|
||||
import { useTwitterNotification } from '../../hooks/useTwitterNotification';
|
||||
import Notification from '../../../../ui/components/Notification';
|
||||
import TwitterIcon from "@material-ui/icons/Twitter";
|
||||
import { useTwitterNotification } from "../../hooks/useTwitterNotification";
|
||||
import Notification from "../../../../ui/components/Notification";
|
||||
import { usePhone } from "../../../../os/phone/hooks/usePhone";
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
createStyles({
|
||||
content: {
|
||||
padding: theme.spacing(2),
|
||||
overflowY: 'hidden'
|
||||
overflowY: "hidden",
|
||||
},
|
||||
title: {
|
||||
display: 'flex',
|
||||
flexFlow: 'row nowrap',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center'
|
||||
display: "flex",
|
||||
flexFlow: "row nowrap",
|
||||
justifyContent: "space-between",
|
||||
alignItems: "center",
|
||||
},
|
||||
titleLeft: {
|
||||
display: 'flex',
|
||||
flexFlow: 'row nowrap',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'center'
|
||||
display: "flex",
|
||||
flexFlow: "row nowrap",
|
||||
justifyContent: "flex-start",
|
||||
alignItems: "center",
|
||||
},
|
||||
icon: {
|
||||
marginTop: '3px',
|
||||
marginRight: '5px'
|
||||
marginTop: "3px",
|
||||
marginRight: "5px",
|
||||
},
|
||||
profileName: {
|
||||
marginBottom: '3px',
|
||||
marginBottom: "3px",
|
||||
},
|
||||
justNow: {
|
||||
fontSize: '18px',
|
||||
fontStyle: 'italic',
|
||||
paddingRight: '3px',
|
||||
fontSize: "18px",
|
||||
fontStyle: "italic",
|
||||
paddingRight: "3px",
|
||||
},
|
||||
message: {
|
||||
fontSize: '16px',
|
||||
overflow: 'hidden',
|
||||
display: '-webkit-box',
|
||||
fontSize: "16px",
|
||||
overflow: "hidden",
|
||||
display: "-webkit-box",
|
||||
WebkitLineClamp: 2,
|
||||
WebkitBoxOrient: 'vertical',
|
||||
}
|
||||
WebkitBoxOrient: "vertical",
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
@@ -57,18 +57,24 @@ function TwitterNotification() {
|
||||
if (notification) {
|
||||
setVisible(true);
|
||||
}
|
||||
}, [notification?.id])
|
||||
}, [notification?.id]);
|
||||
|
||||
if (!config?.twitter.showNotifications || !notification) return null;
|
||||
|
||||
const profileName = `@${notification.profile_name?.trim()}`;
|
||||
|
||||
return (
|
||||
<Notification key={notification.id} open={visible} handleClose={() => setVisible(false)}>
|
||||
<Notification
|
||||
key={notification.id}
|
||||
open={visible}
|
||||
handleClose={() => setVisible(false)}
|
||||
>
|
||||
<div className={classes.content}>
|
||||
<div className={classes.title}>
|
||||
<div className={classes.titleLeft}>
|
||||
<div className={classes.icon}><TwitterIcon /></div>
|
||||
<div className={classes.icon}>
|
||||
<TwitterIcon />
|
||||
</div>
|
||||
<div className={classes.profileName}>{profileName}</div>
|
||||
</div>
|
||||
<div className={classes.justNow}>{t("APPS_TWITTER_JUST_NOW")}</div>
|
||||
@@ -79,5 +85,4 @@ function TwitterNotification() {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export default TwitterNotification;
|
||||
@@ -38,7 +38,7 @@ export const twitterState = {
|
||||
default: null,
|
||||
}),
|
||||
notification: atom({
|
||||
key: 'notification',
|
||||
key: "notification",
|
||||
default: null,
|
||||
})
|
||||
}),
|
||||
};
|
||||
@@ -4,7 +4,7 @@ import { Tweet } from "../interfaces";
|
||||
import { twitterState } from "./state";
|
||||
|
||||
interface ITwitterNotification {
|
||||
notification: Tweet | null;
|
||||
notification: Tweet | null;
|
||||
}
|
||||
|
||||
export const useTwitterNotification = (): ITwitterNotification => {
|
||||
|
||||
@@ -6,7 +6,6 @@ import { IMAGE_DELIMITER } from "../utils/images";
|
||||
import { APP_TWITTER } from "../utils/constants";
|
||||
import { twitterState } from "./state";
|
||||
|
||||
|
||||
/**
|
||||
* Perform all necessary processing/transforms from the raw database
|
||||
* data to what the frontend expects
|
||||
@@ -59,7 +58,7 @@ export const useTwitterService = () => {
|
||||
|
||||
const _setNotification = (tweet) => {
|
||||
setNotification(tweet);
|
||||
}
|
||||
};
|
||||
|
||||
const _setTweets = (tweets) => {
|
||||
setTweets(tweets.map(processTweet));
|
||||
@@ -75,5 +74,5 @@ export const useTwitterService = () => {
|
||||
useNuiEvent(APP_TWITTER, "fetchTweetsFiltered", _setFilteredTweets);
|
||||
useNuiEvent(APP_TWITTER, "createTweetLoading", setCreateLoading);
|
||||
useNuiEvent(APP_TWITTER, "createTweetResult", _setCreateSuccess);
|
||||
useNuiEvent(APP_TWITTER, 'createTweetBroadcast', _setNotification)
|
||||
useNuiEvent(APP_TWITTER, "createTweetBroadcast", _setNotification);
|
||||
};
|
||||
@@ -1,10 +1,10 @@
|
||||
export interface Tweet {
|
||||
id: number;
|
||||
profile_name?: string;
|
||||
avatar_url?: string;
|
||||
message: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
images?: string;
|
||||
likes?: number;
|
||||
}
|
||||
id: number;
|
||||
profile_name?: string;
|
||||
avatar_url?: string;
|
||||
message: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
images?: string;
|
||||
likes?: number;
|
||||
}
|
||||
+1
-1
@@ -7,7 +7,7 @@ import { RecoilRoot } from "recoil";
|
||||
import "./main.css";
|
||||
import Phone from "./Phone";
|
||||
import * as serviceWorker from "./serviceWorker";
|
||||
import TwitterNotification from './apps/twitter/components/notification/TwitterNotification';
|
||||
import TwitterNotification from "./apps/twitter/components/notification/TwitterNotification";
|
||||
|
||||
ReactDOM.render(
|
||||
<HashRouter>
|
||||
|
||||
+7
-4
@@ -1,6 +1,6 @@
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
|
||||
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
@@ -10,10 +10,13 @@ body {
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
|
||||
monospace;
|
||||
}
|
||||
|
||||
a, a:visited, a:hover, a:active {
|
||||
a,
|
||||
a:visited,
|
||||
a:hover,
|
||||
a:active {
|
||||
text-decoration: none;
|
||||
}
|
||||
@@ -10,8 +10,13 @@ import {
|
||||
amber,
|
||||
} from "@material-ui/core/colors";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faAd, faPlaneArrival, faPhoneAlt, faLandmark } from "@fortawesome/free-solid-svg-icons";
|
||||
import { faTwitter } from '@fortawesome/free-brands-svg-icons'
|
||||
import {
|
||||
faAd,
|
||||
faPlaneArrival,
|
||||
faPhoneAlt,
|
||||
faLandmark,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import { faTwitter } from "@fortawesome/free-brands-svg-icons";
|
||||
|
||||
import ContactsIcon from "@material-ui/icons/Contacts";
|
||||
import SettingsIcon from "@material-ui/icons/Settings";
|
||||
@@ -90,7 +95,7 @@ const appsState = atom({
|
||||
{
|
||||
id: "TWITTER",
|
||||
nameLocale: "APPS_TWITTER",
|
||||
icon: <FontAwesomeIcon icon={faTwitter} fixedWidth size="xs"/>,
|
||||
icon: <FontAwesomeIcon icon={faTwitter} fixedWidth size="xs" />,
|
||||
backgroundColor: blue[600],
|
||||
color: common.white,
|
||||
path: "/twitter",
|
||||
|
||||
@@ -10,8 +10,8 @@ interface TwitterConfig {
|
||||
}
|
||||
|
||||
interface NotificationConfig {
|
||||
horizontal: 'left' | 'center' | 'right';
|
||||
vertical: 'bottom' | 'top';
|
||||
horizontal: "left" | "center" | "right";
|
||||
vertical: "bottom" | "top";
|
||||
}
|
||||
|
||||
export interface ServerConfig {
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
import React from "react";
|
||||
import { ThemeProvider } from "@material-ui/core";
|
||||
import Paper from '@material-ui/core/Paper';
|
||||
import Snackbar from '@material-ui/core/Snackbar';
|
||||
import Fade from '@material-ui/core/Fade';
|
||||
import Paper from "@material-ui/core/Paper";
|
||||
import Snackbar from "@material-ui/core/Snackbar";
|
||||
import Fade from "@material-ui/core/Fade";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import { useSettings } from "../../apps/settings/hooks/useSettings";
|
||||
import { usePhone } from "../../os/phone/hooks/usePhone";
|
||||
|
||||
const useStyles = makeStyles({
|
||||
paper: {
|
||||
width: '350px',
|
||||
height: '100px',
|
||||
opacity: '0.93',
|
||||
}
|
||||
width: "350px",
|
||||
height: "100px",
|
||||
opacity: "0.93",
|
||||
},
|
||||
snackBar: {
|
||||
zIndex: -5, // we want this to appear behind other active NUI events...probably
|
||||
},
|
||||
});
|
||||
|
||||
function Notification({ children, handleClose, open }) {
|
||||
@@ -26,21 +29,19 @@ function Notification({ children, handleClose, open }) {
|
||||
|
||||
return (
|
||||
<ThemeProvider theme={currentTheme()}>
|
||||
<Snackbar
|
||||
anchorOrigin={{ horizontal, vertical }}
|
||||
ClickAwayListenerProps={{ onClickAway: () => null }}
|
||||
onClose={handleClose}
|
||||
open={open}
|
||||
TransitionComponent={Fade}
|
||||
autoHideDuration={6000}
|
||||
>
|
||||
<Paper className={classes.paper}>
|
||||
{children}
|
||||
</Paper>
|
||||
</Snackbar>
|
||||
<Snackbar
|
||||
className={classes.snackBar}
|
||||
anchorOrigin={{ horizontal, vertical }}
|
||||
ClickAwayListenerProps={{ onClickAway: () => null }}
|
||||
onClose={handleClose}
|
||||
open={open}
|
||||
TransitionComponent={Fade}
|
||||
autoHideDuration={6000}
|
||||
>
|
||||
<Paper className={classes.paper}>{children}</Paper>
|
||||
</Snackbar>
|
||||
</ThemeProvider>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export default Notification;
|
||||
@@ -1 +1,44 @@
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="%PUBLIC_URL%/favicon.ico"/><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"/><link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><title>React App</title></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script src="main.js"></script></body></html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
|
||||
<!--
|
||||
Notice the use of in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
<script src="dev.js"></script></body>
|
||||
</html>
|
||||
Reference in new issue
Block a user