Merge branch 'master' of github.com:Re-Ignited-Development/new-phone-who-dis into feature/twitter_likes

This commit is contained in:
erik-sn committed 2020-10-11 14:04:37 -04:00
commit 54d0637e15
145 files changed
+4944 -489

No files matched your search

File renamed without changes.
@@ -18,6 +18,7 @@ import { useApps } from "./os/apps/hooks/useApps";
import { useContactsService } from "./apps/contacts/hooks/useContactsService";
import { useTwitterService } from "./apps/twitter/hooks/useTwitterService";
import { useSelloutService } from "./apps/sellout/hooks/useSelloutService";
//These events are just for testing. Comment it out before building.
setTimeout(() => {
@@ -67,6 +68,34 @@ setTimeout(() => {
);
}, 1000);
setTimeout(() => {
window.dispatchEvent(
new MessageEvent("message", {
data: {
app: "SELLOUT",
method: "setListings",
data: [
{
id: 1,
name: "Donald Trump",
number: "123-4567",
description:
"This is me just selling the whole country, because like why not dude",
img: "some shady link?",
},
{
id: 2,
name: "Joe Biden",
number: "666-6666",
description: "I think I might buy it Trump!",
img: "even shadier link?",
},
],
},
})
);
});
function Phone() {
useNuiService();
const { visibility } = usePhoneService();
@@ -76,6 +105,7 @@ function Phone() {
useContactsService();
useTwitterService();
useInitKeyboard();
useSelloutService();
if (visibility === false) {
return null;
-31
View File
@@ -1,31 +0,0 @@
import { useRecoilState, atom } from 'recoil';
const transactionListState = atom({
key: 'transactionList',
default: [
{
id: 0,
amount: 300,
type: 'withdraw',
date: '3'
},
{
id: 1,
amount: 1000,
type: 'withdraw',
date: '3'
},
{
id: 2,
amount: 50,
type: 'transfer',
date: '2'
},
],
});
export const useBank = () => {
const [transactionList, setTransactionList] = useRecoilState
(transactionListState);
return { transactionList, setTransactionList };
}
+32
View File
@@ -0,0 +1,32 @@
import { useRecoilState, atom } from "recoil";
const transactionListState = atom({
key: "transactionList",
default: [
{
id: 0,
amount: 300,
type: "withdraw",
date: "3",
},
{
id: 1,
amount: 1000,
type: "withdraw",
date: "3",
},
{
id: 2,
amount: 50,
type: "transfer",
date: "2",
},
],
});
export const useBank = () => {
const [transactionList, setTransactionList] = useRecoilState(
transactionListState
);
return { transactionList, setTransactionList };
};
File renamed without changes.
@@ -0,0 +1,3 @@
#sellout-app .Mui-selected {
color: #f44336 !important;
}
@@ -0,0 +1,25 @@
import React from "react";
import { AppWrapper } from "../../../ui/components/AppWrapper";
import { AppContent } from "../../../ui/components/AppContent";
import { SelloutTitle } from "./SelloutTitle";
import { SelloutListContainer } from "./SelloutList/SelloutListContainer";
import { NavigationBar } from "./navigation/NavigationBar";
import { Switch, Route } from "react-router-dom";
import "./Sellout.css";
import { ListingFormContainer } from "./form/ListingFormContainer";
export const SelloutApp = () => {
return (
<AppWrapper id="sellout-app">
<SelloutTitle />
<AppContent>
<Switch>
<Route path="/sellout" exact component={SelloutListContainer} />
<Route path="/sellout/new" component={ListingFormContainer} />
</Switch>
</AppContent>
<NavigationBar />
</AppWrapper>
);
};
@@ -0,0 +1,77 @@
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import { Button, Typography, Paper } from "@material-ui/core";
import { ImageDisplay } from "../images/ImageDisplay";
import { ListItem } from "../../../../ui/components/ListItem";
import ChatIcon from "@material-ui/icons/Chat";
import PhoneIcon from "@material-ui/icons/Phone";
const useStyles = makeStyles((theme) => ({
root: {
overflowX: "hidden",
display: "flex",
flexFlow: "row nowrap",
alignItems: "flex-start",
width: "100%",
marginTop: "3px",
},
content: {
display: "flex",
marginTop: "-10px",
flexFlow: "column nowrap",
width: "100%",
},
paper: {
overflow: "auto",
display: "flex",
flexFlow: "column",
alignItems: "flex",
height: "auto",
background: "#232323",
marginBottom: 20,
},
header: {
margin: 10,
},
headerTypo: {
margin: 5,
},
desc: {
padding: 10,
},
}));
export const SelloutItem = (listing) => {
const classes = useStyles();
return (
<ListItem className={classes.root}>
<div className={classes.content}>
<Paper elevation={2} className={classes.paper}>
<div className={classes.header}>
<Typography className={classes.headerTypo} variant="h5">
{listing.name}
</Typography>
<Typography
className={classes.headerTypo}
style={{ borderBottom: "1px solid #f44336" }}
>
{listing.number}
</Typography>
</div>
<ImageDisplay imgURL={listing.img} />
<Typography variant="h7" className={classes.desc}>
{listing.description}
</Typography>
<div className={classes.postActions}>
<Button>
<ChatIcon style={{ color: "#f44336" }} />
</Button>
<Button>
<PhoneIcon style={{ color: "#f44336" }} />
</Button>
</div>
</Paper>
</div>
</ListItem>
);
};
@@ -0,0 +1,13 @@
import React from "react";
import { List } from "../../../../ui/components/List";
import { SelloutItem } from "./SelloutItem";
export const SelloutList = ({ listings }) => {
return (
<List>
{listings.map((listing) => (
<SelloutItem key={listing.id} {...listing} />
))}
</List>
);
};
@@ -0,0 +1,8 @@
import React from "react";
import { useListing } from "../../hooks/useListing";
import { SelloutList } from "./SelloutList";
export const SelloutListContainer = () => {
const { listing } = useListing();
return <SelloutList listings={listing} />;
};
@@ -0,0 +1,31 @@
import React from "react";
import Paper from "@material-ui/core/Paper";
import { makeStyles } from "@material-ui/core";
import LinkedInIcon from "@material-ui/icons/LinkedIn";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faAd } from "@fortawesome/free-solid-svg-icons";
const useStyles = makeStyles((theme) => ({
root: {
height: "60px",
width: "100%",
display: "flex",
flexFlow: "row nowrap",
justifyContent: "center",
alignItems: "center",
background: "#424242",
},
icon: {
color: "#f44336",
fontSize: 40,
},
}));
export const SelloutTitle = () => {
const classes = useStyles();
return (
<Paper className={classes.root} square variant="outlined" elevation={24}>
<FontAwesomeIcon icon={faAd} className={classes.icon} />
</Paper>
);
};
@@ -0,0 +1,64 @@
import React from "react";
import { makeStyles, Button, TextField } from "@material-ui/core";
const useStyles = makeStyles((theme) => ({
root: {
width: "100%",
margin: "auto",
textAlign: "center",
},
input: {
marginBottom: 25,
},
textFieldInput: {
fontSize: 22,
},
multilineFieldInput: {
fontSize: 20,
},
postButton: {
display: "block",
margin: "auto",
background: "#f44336",
width: "80%",
fontSize: 20,
},
}));
export const ListingForm = () => {
const classes = useStyles();
return (
<div className={classes.root}>
<h1>New Listing</h1>
<TextField
className={classes.input}
placeholder="Title on listing.."
inputProps={{ className: classes.textFieldInput }}
style={{ width: "80%" }}
size="medium"
/>
<TextField
className={classes.input}
placeholder="Image URL"
inputProps={{ className: classes.textFieldInput }}
style={{ width: "80%" }}
size="medium"
variant="outlined"
/>
<TextField
className={classes.input}
placeholder="Description"
inputProps={{ className: classes.multilineFieldInput }}
style={{ width: "80%" }}
size="medium"
multiline
rows={4}
variant="outlined"
/>
<Button className={classes.postButton}>Post</Button>
</div>
);
};
@@ -0,0 +1,10 @@
import React from "react";
import { ListingForm } from "./ListingForm";
export const ListingFormContainer = () => {
return (
<div>
<ListingForm />
</div>
);
};
@@ -0,0 +1,11 @@
import React from "react";
export const ImageDisplay = ({ imgURL }) => {
return (
<img
src={imgURL}
alt="Image"
style={{ height: 200, width: 350, margin: "auto" }}
/>
);
};
@@ -0,0 +1,48 @@
import React, { useState } from "react";
import { makeStyles } from "@material-ui/core/styles";
import { Link } from "react-router-dom";
import { BottomNavigation, BottomNavigationAction } from "@material-ui/core";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faHome } from "@fortawesome/free-solid-svg-icons";
import AddCircleIcon from "@material-ui/icons/AddCircle";
import FaceIcon from "@material-ui/icons/Face";
const useStyles = makeStyles((theme) => ({
root: {
width: "100%",
},
icon: {
color: "#f44336",
},
}));
export const NavigationBar = () => {
const classes = useStyles();
const [activePage, setActivePage] = useState(0);
return (
<BottomNavigation
value={activePage}
onChange={(event, newPage) => {
setActivePage(newPage);
}}
showLabels
className={classes.root}
>
<BottomNavigationAction
component={Link}
icon={<FontAwesomeIcon icon={faHome} />}
to="/sellout"
/>
<BottomNavigationAction
component={Link}
icon={<AddCircleIcon />}
to="/sellout/new"
/>
<BottomNavigationAction
component={Link}
icon={<FaceIcon />}
to="/sellout/new"
/>
</BottomNavigation>
);
};
+8
View File
@@ -0,0 +1,8 @@
import { atom } from "recoil";
export const selloutState = {
listing: atom({
key: "listing",
default: null,
}),
};
@@ -0,0 +1,7 @@
import { useRecoilValue } from "recoil";
import { selloutState } from "./state";
export const useListing = () => {
const listing = useRecoilValue(selloutState.listing);
return { listing };
};
@@ -0,0 +1,10 @@
import { useNuiEvent } from "../../../os/nui-events/hooks/useNuiEvent";
import { selloutState } from "./state";
import { useListing } from "./useListing";
import { useSetRecoilState } from "recoil";
export const useSelloutService = () => {
const setSellout = useSetRecoilState(selloutState.listing);
useNuiEvent("SELLOUT", "setListings", setSellout);
return useListing();
};
@@ -127,7 +127,7 @@ export const AddTweetModal = () => {
withValidImage(cleanedLink, () => setImages([...images, image]));
setShowImagePrompt(false);
setLink('')
setLink("");
};
const removeImage = (id) =>
setImages(images.filter((image) => id !== image.id));
@@ -171,7 +171,11 @@ export const AddTweetModal = () => {
/>
<div className={classes.buttonsContainer}>
<IconButtons
onImageClick={images.length < config.twitter.maxImages ? toggleShowImagePrompt : null}
onImageClick={
images.length < config.twitter.maxImages
? toggleShowImagePrompt
: null
}
onEmojiClick={toggleShowEmoji}
/>
<ControlButtons
@@ -21,18 +21,22 @@ const useStyles = makeStyles((theme) => ({
export const IconButtons = ({ onImageClick, onEmojiClick }) => {
const classes = useStyles();
const { config } = usePhone();
if (!config) return null;
const { enableImages, enableEmojis } = config.twitter;
return (
<div className={classes.buttons}>
{enableImages && (<Button className={classes.button} onClick={onImageClick}>
<InsertPhotoIcon color="action" />
</Button>)}
{enableEmojis && (<Button className={classes.button} onClick={onEmojiClick}>
<EmojiIcon color="action" />
</Button>)}
{enableImages && (
<Button className={classes.button} onClick={onImageClick}>
<InsertPhotoIcon color="action" />
</Button>
)}
{enableEmojis && (
<Button className={classes.button} onClick={onEmojiClick}>
<EmojiIcon color="action" />
</Button>
)}
</div>
);
};
@@ -27,7 +27,6 @@ export function Profile() {
const { profile } = useProfile();
const { config } = usePhone();
// note that this assumes we are defensively checking
// that profile is not null in a parent above this component.
// Annoyingling adding conditionals above this line to not render
@@ -50,7 +49,7 @@ export function Profile() {
Nui.send("phone:updateTwitterProfile", data);
};
// fetching the config is an asynchronous call so defend against it
// fetching the config is an asynchronous call so defend against it
if (!config) return null;
const { enableAvatars, allowEdtiableProfileName } = config.twitter;
@@ -23,8 +23,11 @@ export const TweetMessage = ({ message, handleChange }) => {
const { config } = usePhone();
const { t } = useTranslation();
const overCharacterLimit = message.trim().length > config.twitter.characterLimit;
const characterWarningPrompt = `${t("APPS_TWITTER_TWEET_MESSAGE_CHAR_LIMIT")} (${config.twitter.characterLimit})`;
const overCharacterLimit =
message.trim().length > config.twitter.characterLimit;
const characterWarningPrompt = `${t(
"APPS_TWITTER_TWEET_MESSAGE_CHAR_LIMIT"
)} (${config.twitter.characterLimit})`;
return (
<TextField
File renamed without changes.
@@ -12,7 +12,10 @@ const DAYS = "APPS_TWITTER_TIME_DAYS";
* @param {function} t - translation object passed from a component implementing the hook
* @param {number} seconds - seconds to translate to a string
*/
export function secondsToHumanReadable(t, seconds) {
export function secondsToHumanReadable(
t: (input: string) => string,
seconds: number
): string {
if (seconds < 60) {
return t(JUST_NOW);
} else if (seconds < ONE_HOUR) {
@@ -2,17 +2,17 @@ import Default from "../default.json";
import { atom, useRecoilState } from "recoil";
const configState = atom({
key: 'config',
default: Default
})
key: "config",
default: Default,
});
export const useConfig = (state = configState) => {
const [config, _setConfig] = useRecoilState(state)
const [config, _setConfig] = useRecoilState(state);
const setConfig = (key, value) => {
_setConfig(oldConfig => ({
_setConfig((oldConfig) => ({
...oldConfig,
[key]: value
[key]: value,
}));
};
+1 -1
View File
@@ -3,7 +3,7 @@ import { initReactI18next } from "react-i18next";
import en from "./locale/en.json";
const resources = {
en
en,
};
i18n
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -7,8 +7,12 @@ import {
green,
orange,
purple,
red,
amber,
} from "@material-ui/core/colors";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faAd } from "@fortawesome/free-solid-svg-icons";
import ContactsIcon from "@material-ui/icons/Contacts";
import SettingsIcon from "@material-ui/icons/Settings";
import PhoneIcon from "@material-ui/icons/Phone";
@@ -27,6 +31,7 @@ import { BankApp } from "../../../apps/bank/components/BankApp";
import { MessagesApp } from "../../../apps/messages/components/MessagesApp";
import { TwitterApp } from "../../../apps/twitter/components/TwitterApp";
import { ExampleApp } from "../../../apps/example/components/ExampleApp";
import { SelloutApp } from "../../../apps/sellout/components/SelloutApp";
const appsState = atom({
key: "apps",
@@ -95,6 +100,15 @@ const appsState = atom({
path: "/twitter",
Route: () => <Route path="/twitter" component={TwitterApp} />,
},
{
id: "SELLOUT",
nameLocale: "APPS_SELLOUT",
icon: <FontAwesomeIcon icon={faAd} fixedWidth />,
backgroundColor: red[500],
color: common.white,
path: "/sellout",
Route: () => <Route path="/sellout" component={SelloutApp} />,
},
{
id: "EXAMPLE",
nameLocale: "APPS_EXAMPLE",
@@ -78,9 +78,12 @@ export const useInitKeyboard = () => {
[getters]
);
useEffect(function registerEscapeHandler() {
setEscape({ handler: () => console.log("close phone") });
}, [setEscape]);
useEffect(
function registerEscapeHandler() {
setEscape({ handler: () => console.log("close phone") });
},
[setEscape]
);
};
export const useKeyboard = () => {
@@ -20,7 +20,7 @@ const useStyles = makeStyles((theme) => ({
color: theme.palette.text.primary,
},
icon: {
padding: '4px',
padding: "4px",
color: theme.palette.text.primary,
},
}));
@@ -36,7 +36,12 @@ export const NotificationBar = ({ notifications = [] }) => {
>
<Grid container item wrap="nowrap">
{notifications.map((notification) => (
<Grid item key={notification.key} component={IconButton} className={classes.icon}>
<Grid
item
key={notification.key}
component={IconButton}
className={classes.icon}
>
{notification.icon}
</Grid>
))}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 145 files, more files were not shown because too many files have changed in this diff. Show more