diff --git a/fxmanifest.lua b/fxmanifest.lua index 8cf45c4..ce3c352 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -6,7 +6,8 @@ author { "chip", "BTNGaming", "ROCKY_southpaw" } client_script { '@es_extended/locale.lua', 'resources/locales/*.lua', - 'resources/client/*lua' + 'resources/client/*lua', + 'resources/dist/client/*.client.js' } shared_script { @@ -17,7 +18,8 @@ server_script { "@mysql-async/lib/MySQL.lua", '@es_extended/locale.lua', 'resources/locales/*.lua', - 'resources/server/*.lua' + 'resources/server/*.lua', + 'resources/dist/server/*.server.js' } ui_page 'resources/html/index.html' diff --git a/phone/.babelrc b/phone/.babelrc index 3d4e1f6..58c3cd4 100644 --- a/phone/.babelrc +++ b/phone/.babelrc @@ -1,15 +1,15 @@ { "presets": [ - [ - "@babel/preset-env", - { - "modules": false - } - ], - "@babel/preset-react" + [ + "@babel/preset-env", + { + "modules": false + } + ], + "@babel/preset-react" ], "plugins": [ - "@babel/plugin-proposal-class-properties", - "@babel/plugin-syntax-dynamic-import" + "@babel/plugin-proposal-class-properties", + "@babel/plugin-syntax-dynamic-import" ] -} \ No newline at end of file +} diff --git a/phone/.env b/phone/.env new file mode 100644 index 0000000..7512f11 --- /dev/null +++ b/phone/.env @@ -0,0 +1 @@ +TSC_COMPILE_ON_ERROR=true \ No newline at end of file diff --git a/phone/package.json b/phone/package.json index 713d394..9010876 100644 --- a/phone/package.json +++ b/phone/package.json @@ -4,6 +4,10 @@ "private": true, "dependencies": { "@babel/polyfill": "^7.4.4", + "@fortawesome/fontawesome-free": "^5.15.1", + "@fortawesome/fontawesome-svg-core": "^1.2.32", + "@fortawesome/free-solid-svg-icons": "^5.15.1", + "@fortawesome/react-fontawesome": "^0.1.11", "@material-ui/core": "^4.11.0", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "^4.0.0-alpha.56", @@ -15,7 +19,7 @@ "emoji-mart": "^3.0.0", "enzyme": "^3.11.0", "enzyme-adapter-react-16": "^1.15.5", - "husky": "^4.2.5", + "husky": "4.2.5", "i18next": "^19.7.0", "prettier": "^2.0.5", "react": "^16.13.1", @@ -35,6 +39,9 @@ "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/preset-env": "^7.4.5", "@babel/preset-react": "^7.0.0", + "@types/node": "^14.11.5", + "@types/react": "^16.9.51", + "@types/react-dom": "^16.9.8", "babel-eslint": "^10.0.1", "babel-loader": "^8.1.0", "babel-plugin-styled-components": "^1.10.0", @@ -50,6 +57,8 @@ "style-loader": "^0.23.1", "svg-url-loader": "^2.3.2", "terser-webpack-plugin": "^1.3.0", + "ts-loader": "^8.0.4", + "typescript": "3.9.7", "url-loader": "^1.1.2", "webpack-cli": "^3.3.12" }, @@ -58,8 +67,8 @@ "watch": "cra-build-watch --disable-chunks --build-path ../resources/html --output-filename dev.js", "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.js", - "test:watch": "react-scripts test --watchAll --testMatch **/src/**/*.test.js", + "test": "react-scripts test --watchAll=false --testMatch **/src/**/*.test.[jt]s?(x)", + "test:watch": "react-scripts test --watchAll --testMatch **/src/**/*.test.[jt]s?(x)", "eject": "react-scripts eject" }, "eslintConfig": { diff --git a/phone/react-app-env.d.ts b/phone/react-app-env.d.ts new file mode 100644 index 0000000..6431bc5 --- /dev/null +++ b/phone/react-app-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/phone/src/Phone.test.js b/phone/src/Phone.test.tsx similarity index 100% rename from phone/src/Phone.test.js rename to phone/src/Phone.test.tsx diff --git a/phone/src/Phone.js b/phone/src/Phone.tsx similarity index 83% rename from phone/src/Phone.js rename to phone/src/Phone.tsx index c84c01d..26881e6 100644 --- a/phone/src/Phone.js +++ b/phone/src/Phone.tsx @@ -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,33 @@ 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 +104,7 @@ function Phone() { useContactsService(); useTwitterService(); useInitKeyboard(); + useSelloutService(); if (visibility === false) { return null; diff --git a/phone/src/apps/bank/components/BankApp.js b/phone/src/apps/bank/components/BankApp.tsx similarity index 100% rename from phone/src/apps/bank/components/BankApp.js rename to phone/src/apps/bank/components/BankApp.tsx diff --git a/phone/src/apps/bank/components/transactionList.js b/phone/src/apps/bank/components/transactionList.tsx similarity index 100% rename from phone/src/apps/bank/components/transactionList.js rename to phone/src/apps/bank/components/transactionList.tsx diff --git a/phone/src/apps/bank/hooks/useBank.js b/phone/src/apps/bank/hooks/useBank.js deleted file mode 100644 index ef206c4..0000000 --- a/phone/src/apps/bank/hooks/useBank.js +++ /dev/null @@ -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 }; -} \ No newline at end of file diff --git a/phone/src/apps/bank/hooks/useBank.ts b/phone/src/apps/bank/hooks/useBank.ts new file mode 100644 index 0000000..e4ee679 --- /dev/null +++ b/phone/src/apps/bank/hooks/useBank.ts @@ -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 }; +}; diff --git a/phone/src/apps/calculator/components/Calculator.js b/phone/src/apps/calculator/components/Calculator.tsx similarity index 100% rename from phone/src/apps/calculator/components/Calculator.js rename to phone/src/apps/calculator/components/Calculator.tsx diff --git a/phone/src/apps/calculator/components/CalculatorApp.js b/phone/src/apps/calculator/components/CalculatorApp.tsx similarity index 100% rename from phone/src/apps/calculator/components/CalculatorApp.js rename to phone/src/apps/calculator/components/CalculatorApp.tsx diff --git a/phone/src/apps/calculator/components/CalculatorIcon.js b/phone/src/apps/calculator/components/CalculatorIcon.tsx similarity index 100% rename from phone/src/apps/calculator/components/CalculatorIcon.js rename to phone/src/apps/calculator/components/CalculatorIcon.tsx diff --git a/phone/src/apps/calculator/hooks/useCalculator.js b/phone/src/apps/calculator/hooks/useCalculator.tsx similarity index 100% rename from phone/src/apps/calculator/hooks/useCalculator.js rename to phone/src/apps/calculator/hooks/useCalculator.tsx diff --git a/phone/src/apps/contacts/components/ContactList.js b/phone/src/apps/contacts/components/ContactList.tsx similarity index 100% rename from phone/src/apps/contacts/components/ContactList.js rename to phone/src/apps/contacts/components/ContactList.tsx diff --git a/phone/src/apps/contacts/components/ContactModal.js b/phone/src/apps/contacts/components/ContactModal.tsx similarity index 100% rename from phone/src/apps/contacts/components/ContactModal.js rename to phone/src/apps/contacts/components/ContactModal.tsx diff --git a/phone/src/apps/contacts/components/ContactsApp.js b/phone/src/apps/contacts/components/ContactsApp.tsx similarity index 100% rename from phone/src/apps/contacts/components/ContactsApp.js rename to phone/src/apps/contacts/components/ContactsApp.tsx diff --git a/phone/src/apps/contacts/hooks/state.js b/phone/src/apps/contacts/hooks/state.ts similarity index 100% rename from phone/src/apps/contacts/hooks/state.js rename to phone/src/apps/contacts/hooks/state.ts diff --git a/phone/src/apps/contacts/hooks/useContacts.js b/phone/src/apps/contacts/hooks/useContacts.ts similarity index 100% rename from phone/src/apps/contacts/hooks/useContacts.js rename to phone/src/apps/contacts/hooks/useContacts.ts diff --git a/phone/src/apps/contacts/hooks/useContactsService.js b/phone/src/apps/contacts/hooks/useContactsService.ts similarity index 100% rename from phone/src/apps/contacts/hooks/useContactsService.js rename to phone/src/apps/contacts/hooks/useContactsService.ts diff --git a/phone/src/apps/dialer/components/DialerApp.js b/phone/src/apps/dialer/components/DialerApp.tsx similarity index 100% rename from phone/src/apps/dialer/components/DialerApp.js rename to phone/src/apps/dialer/components/DialerApp.tsx diff --git a/phone/src/apps/dialer/components/DialerHistory.js b/phone/src/apps/dialer/components/DialerHistory.tsx similarity index 100% rename from phone/src/apps/dialer/components/DialerHistory.js rename to phone/src/apps/dialer/components/DialerHistory.tsx diff --git a/phone/src/apps/dialer/hooks/useDialerHistory.js b/phone/src/apps/dialer/hooks/useDialerHistory.ts similarity index 100% rename from phone/src/apps/dialer/hooks/useDialerHistory.js rename to phone/src/apps/dialer/hooks/useDialerHistory.ts diff --git a/phone/src/apps/example/components/ExampleApp.js b/phone/src/apps/example/components/ExampleApp.tsx similarity index 100% rename from phone/src/apps/example/components/ExampleApp.js rename to phone/src/apps/example/components/ExampleApp.tsx diff --git a/phone/src/apps/home/components/Home.js b/phone/src/apps/home/components/Home.tsx similarity index 100% rename from phone/src/apps/home/components/Home.js rename to phone/src/apps/home/components/Home.tsx diff --git a/phone/src/apps/messages/components/MessagesApp.js b/phone/src/apps/messages/components/MessagesApp.tsx similarity index 100% rename from phone/src/apps/messages/components/MessagesApp.js rename to phone/src/apps/messages/components/MessagesApp.tsx diff --git a/phone/src/apps/messages/hooks/useMessages.js b/phone/src/apps/messages/hooks/useMessages.ts similarity index 100% rename from phone/src/apps/messages/hooks/useMessages.js rename to phone/src/apps/messages/hooks/useMessages.ts diff --git a/phone/src/apps/messages/index.js b/phone/src/apps/messages/index.ts similarity index 100% rename from phone/src/apps/messages/index.js rename to phone/src/apps/messages/index.ts diff --git a/phone/src/apps/sellout/components/Sellout.css b/phone/src/apps/sellout/components/Sellout.css new file mode 100644 index 0000000..af2ac60 --- /dev/null +++ b/phone/src/apps/sellout/components/Sellout.css @@ -0,0 +1,3 @@ +#sellout-app .Mui-selected { + color: #f44336 !important; +} \ No newline at end of file diff --git a/phone/src/apps/sellout/components/SelloutApp.tsx b/phone/src/apps/sellout/components/SelloutApp.tsx new file mode 100644 index 0000000..da0a277 --- /dev/null +++ b/phone/src/apps/sellout/components/SelloutApp.tsx @@ -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 ( + + + + + + + + + + + ); +}; diff --git a/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx b/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx new file mode 100644 index 0000000..37869bd --- /dev/null +++ b/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx @@ -0,0 +1,81 @@ +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 ( + +
+ +
+ + {listing.name} + + + {listing.number} + +
+ + + {listing.description} + +
+ + +
+
+
+
+ ); +}; diff --git a/phone/src/apps/sellout/components/SelloutList/SelloutList.tsx b/phone/src/apps/sellout/components/SelloutList/SelloutList.tsx new file mode 100644 index 0000000..9c7df00 --- /dev/null +++ b/phone/src/apps/sellout/components/SelloutList/SelloutList.tsx @@ -0,0 +1,13 @@ +import React from "react"; +import { List } from "../../../../ui/components/List"; +import { SelloutItem } from "./SelloutItem"; + +export const SelloutList = ({ listings }) => { + return ( + + {listings.map((listing) => ( + + ))} + + ); +}; diff --git a/phone/src/apps/sellout/components/SelloutList/SelloutListContainer.tsx b/phone/src/apps/sellout/components/SelloutList/SelloutListContainer.tsx new file mode 100644 index 0000000..4117b89 --- /dev/null +++ b/phone/src/apps/sellout/components/SelloutList/SelloutListContainer.tsx @@ -0,0 +1,8 @@ +import React from "react"; +import { useListing } from "../../hooks/useListing"; +import { SelloutList } from "./SelloutList"; + +export const SelloutListContainer = () => { + const { listing } = useListing(); + return ; +}; diff --git a/phone/src/apps/sellout/components/SelloutTitle.tsx b/phone/src/apps/sellout/components/SelloutTitle.tsx new file mode 100644 index 0000000..99d6daa --- /dev/null +++ b/phone/src/apps/sellout/components/SelloutTitle.tsx @@ -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 ( + + + + ); +}; diff --git a/phone/src/apps/sellout/components/form/ListingForm.tsx b/phone/src/apps/sellout/components/form/ListingForm.tsx new file mode 100644 index 0000000..669a91f --- /dev/null +++ b/phone/src/apps/sellout/components/form/ListingForm.tsx @@ -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 ( +
+

New Listing

+ + + + + + + +
+ ); +}; diff --git a/phone/src/apps/sellout/components/form/ListingFormContainer.tsx b/phone/src/apps/sellout/components/form/ListingFormContainer.tsx new file mode 100644 index 0000000..de5cb54 --- /dev/null +++ b/phone/src/apps/sellout/components/form/ListingFormContainer.tsx @@ -0,0 +1,10 @@ +import React from 'react' +import { ListingForm } from './ListingForm'; + +export const ListingFormContainer = () => { + return ( +
+ +
+ ) +} diff --git a/phone/src/apps/sellout/components/images/ImageDisplay.tsx b/phone/src/apps/sellout/components/images/ImageDisplay.tsx new file mode 100644 index 0000000..d8a0b27 --- /dev/null +++ b/phone/src/apps/sellout/components/images/ImageDisplay.tsx @@ -0,0 +1,5 @@ +import React from 'react' + +export const ImageDisplay = ({ imgURL }) => { + return Image +} diff --git a/phone/src/apps/sellout/components/navigation/NavigationBar.tsx b/phone/src/apps/sellout/components/navigation/NavigationBar.tsx new file mode 100644 index 0000000..3b13dd6 --- /dev/null +++ b/phone/src/apps/sellout/components/navigation/NavigationBar.tsx @@ -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 ( + { + setActivePage(newPage) + }} + showLabels + className={classes.root} + > + } + to="/sellout" + /> + } + to="/sellout/new" + /> + } + to="/sellout/new" + /> + + ) +} diff --git a/phone/src/apps/sellout/hooks/state.ts b/phone/src/apps/sellout/hooks/state.ts new file mode 100644 index 0000000..a7b02f7 --- /dev/null +++ b/phone/src/apps/sellout/hooks/state.ts @@ -0,0 +1,8 @@ +import { atom } from 'recoil'; + +export const selloutState = { + listing: atom({ + key: 'listing', + default: null + }) +} \ No newline at end of file diff --git a/phone/src/apps/sellout/hooks/useListing.ts b/phone/src/apps/sellout/hooks/useListing.ts new file mode 100644 index 0000000..a090de0 --- /dev/null +++ b/phone/src/apps/sellout/hooks/useListing.ts @@ -0,0 +1,7 @@ +import { useRecoilValue } from 'recoil'; +import { selloutState } from './state'; + +export const useListing = () => { + const listing = useRecoilValue(selloutState.listing); + return { listing }; +} diff --git a/phone/src/apps/sellout/hooks/useSelloutService.ts b/phone/src/apps/sellout/hooks/useSelloutService.ts new file mode 100644 index 0000000..e191e51 --- /dev/null +++ b/phone/src/apps/sellout/hooks/useSelloutService.ts @@ -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() +} \ No newline at end of file diff --git a/phone/src/apps/settings/components/SettingItem.js b/phone/src/apps/settings/components/SettingItem.tsx similarity index 100% rename from phone/src/apps/settings/components/SettingItem.js rename to phone/src/apps/settings/components/SettingItem.tsx diff --git a/phone/src/apps/settings/components/SettingsApp.js b/phone/src/apps/settings/components/SettingsApp.tsx similarity index 100% rename from phone/src/apps/settings/components/SettingsApp.js rename to phone/src/apps/settings/components/SettingsApp.tsx diff --git a/phone/src/apps/settings/hooks/useSettings.js b/phone/src/apps/settings/hooks/useSettings.ts similarity index 100% rename from phone/src/apps/settings/hooks/useSettings.js rename to phone/src/apps/settings/hooks/useSettings.ts diff --git a/phone/src/apps/twitter/components/AddTweetModal.js b/phone/src/apps/twitter/components/AddTweetModal.tsx similarity index 97% rename from phone/src/apps/twitter/components/AddTweetModal.js rename to phone/src/apps/twitter/components/AddTweetModal.tsx index c6d6ea4..8e8b967 100644 --- a/phone/src/apps/twitter/components/AddTweetModal.js +++ b/phone/src/apps/twitter/components/AddTweetModal.tsx @@ -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 = () => { />
{ useEffect(() => { Nui.send("phone:getOrCreateTwitterProfile", {}); - Nui.send("phone:fetchTweets", {}); // this is a polling implementation. It is possible that // there is some interaction where, on a new tweet, all diff --git a/phone/src/apps/twitter/components/TwitterSearch.js b/phone/src/apps/twitter/components/TwitterSearch.tsx similarity index 100% rename from phone/src/apps/twitter/components/TwitterSearch.js rename to phone/src/apps/twitter/components/TwitterSearch.tsx diff --git a/phone/src/apps/twitter/components/TwitterTitle.js b/phone/src/apps/twitter/components/TwitterTitle.tsx similarity index 100% rename from phone/src/apps/twitter/components/TwitterTitle.js rename to phone/src/apps/twitter/components/TwitterTitle.tsx diff --git a/phone/src/apps/twitter/components/alerts/Alert.js b/phone/src/apps/twitter/components/alerts/Alert.tsx similarity index 100% rename from phone/src/apps/twitter/components/alerts/Alert.js rename to phone/src/apps/twitter/components/alerts/Alert.tsx diff --git a/phone/src/apps/twitter/components/alerts/AlertBar.js b/phone/src/apps/twitter/components/alerts/AlertBar.tsx similarity index 100% rename from phone/src/apps/twitter/components/alerts/AlertBar.js rename to phone/src/apps/twitter/components/alerts/AlertBar.tsx diff --git a/phone/src/apps/twitter/components/buttons/ControlButtons.js b/phone/src/apps/twitter/components/buttons/ControlButtons.tsx similarity index 100% rename from phone/src/apps/twitter/components/buttons/ControlButtons.js rename to phone/src/apps/twitter/components/buttons/ControlButtons.tsx diff --git a/phone/src/apps/twitter/components/buttons/IconButtons.js b/phone/src/apps/twitter/components/buttons/IconButtons.tsx similarity index 75% rename from phone/src/apps/twitter/components/buttons/IconButtons.js rename to phone/src/apps/twitter/components/buttons/IconButtons.tsx index 18053ca..519420b 100644 --- a/phone/src/apps/twitter/components/buttons/IconButtons.js +++ b/phone/src/apps/twitter/components/buttons/IconButtons.tsx @@ -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 (
- {enableImages && ()} - {enableEmojis && ()} + {enableImages && ( + + )} + {enableEmojis && ( + + )}
); }; diff --git a/phone/src/apps/twitter/components/buttons/LikeButton.tsx b/phone/src/apps/twitter/components/buttons/LikeButton.tsx new file mode 100644 index 0000000..d93bc49 --- /dev/null +++ b/phone/src/apps/twitter/components/buttons/LikeButton.tsx @@ -0,0 +1,38 @@ +import React, { useState } from "react"; +import { Button, CircularProgress } from "@material-ui/core"; +import FavoriteBorderIcon from "@material-ui/icons/FavoriteBorder"; +import FavoriteIcon from "@material-ui/icons/Favorite"; + +import Nui from "../../../../os/nui-events/utils/Nui"; + +const LOADING_TIME = 1250; + +function LikeButton({ tweetId, isLiked }) { + const [liked, setLiked] = useState(isLiked); + const [loading, setLoading] = useState(false); + + const handleClick = () => { + Nui.send("phone:toggleLike", tweetId); + setLoading(true); + window.setTimeout(() => { + setLiked(!liked); + setLoading(false); + }, LOADING_TIME); + }; + + if (loading) { + return ( + + ); + } + + return ( + + ); +} + +export default LikeButton; diff --git a/phone/src/apps/twitter/components/buttons/ProfileUpdateButton.js b/phone/src/apps/twitter/components/buttons/ProfileUpdateButton.tsx similarity index 100% rename from phone/src/apps/twitter/components/buttons/ProfileUpdateButton.js rename to phone/src/apps/twitter/components/buttons/ProfileUpdateButton.tsx diff --git a/phone/src/apps/twitter/components/buttons/QuoteButton.js b/phone/src/apps/twitter/components/buttons/QuoteButton.tsx similarity index 100% rename from phone/src/apps/twitter/components/buttons/QuoteButton.js rename to phone/src/apps/twitter/components/buttons/QuoteButton.tsx diff --git a/phone/src/apps/twitter/components/buttons/ReplyButton.js b/phone/src/apps/twitter/components/buttons/ReplyButton.tsx similarity index 100% rename from phone/src/apps/twitter/components/buttons/ReplyButton.js rename to phone/src/apps/twitter/components/buttons/ReplyButton.tsx diff --git a/phone/src/apps/twitter/components/buttons/SearchButton.js b/phone/src/apps/twitter/components/buttons/SearchButton.tsx similarity index 100% rename from phone/src/apps/twitter/components/buttons/SearchButton.js rename to phone/src/apps/twitter/components/buttons/SearchButton.tsx diff --git a/phone/src/apps/twitter/components/buttons/TweetButton.js b/phone/src/apps/twitter/components/buttons/TweetButton.tsx similarity index 100% rename from phone/src/apps/twitter/components/buttons/TweetButton.js rename to phone/src/apps/twitter/components/buttons/TweetButton.tsx diff --git a/phone/src/apps/twitter/components/images/Image.js b/phone/src/apps/twitter/components/images/Image.tsx similarity index 100% rename from phone/src/apps/twitter/components/images/Image.js rename to phone/src/apps/twitter/components/images/Image.tsx diff --git a/phone/src/apps/twitter/components/images/ImageDisplay.js b/phone/src/apps/twitter/components/images/ImageDisplay.tsx similarity index 100% rename from phone/src/apps/twitter/components/images/ImageDisplay.js rename to phone/src/apps/twitter/components/images/ImageDisplay.tsx diff --git a/phone/src/apps/twitter/components/images/ImagePrompt.js b/phone/src/apps/twitter/components/images/ImagePrompt.tsx similarity index 100% rename from phone/src/apps/twitter/components/images/ImagePrompt.js rename to phone/src/apps/twitter/components/images/ImagePrompt.tsx diff --git a/phone/src/apps/twitter/components/profile/Profile.js b/phone/src/apps/twitter/components/profile/Profile.tsx similarity index 97% rename from phone/src/apps/twitter/components/profile/Profile.js rename to phone/src/apps/twitter/components/profile/Profile.tsx index f14690c..292cceb 100644 --- a/phone/src/apps/twitter/components/profile/Profile.js +++ b/phone/src/apps/twitter/components/profile/Profile.tsx @@ -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; diff --git a/phone/src/apps/twitter/components/profile/ProfileField.js b/phone/src/apps/twitter/components/profile/ProfileField.tsx similarity index 100% rename from phone/src/apps/twitter/components/profile/ProfileField.js rename to phone/src/apps/twitter/components/profile/ProfileField.tsx diff --git a/phone/src/apps/twitter/components/profile/ProfilePrompt.js b/phone/src/apps/twitter/components/profile/ProfilePrompt.tsx similarity index 100% rename from phone/src/apps/twitter/components/profile/ProfilePrompt.js rename to phone/src/apps/twitter/components/profile/ProfilePrompt.tsx diff --git a/phone/src/apps/twitter/components/tweet/Tweet.js b/phone/src/apps/twitter/components/tweet/Tweet.tsx similarity index 96% rename from phone/src/apps/twitter/components/tweet/Tweet.js rename to phone/src/apps/twitter/components/tweet/Tweet.tsx index 5f87c9b..138f5b7 100644 --- a/phone/src/apps/twitter/components/tweet/Tweet.js +++ b/phone/src/apps/twitter/components/tweet/Tweet.tsx @@ -12,6 +12,7 @@ import MoreIcon from "@material-ui/icons/MoreVert"; import { ListItem } from "../../../../ui/components/ListItem"; import { secondsToHumanReadable } from "../../utils/time"; +import LikeButton from "../buttons/LikeButton"; import ReplyButton from "../buttons/ReplyButton"; import ImageDisplay from "../images/ImageDisplay"; import Avatar from "../Avatar"; @@ -63,11 +64,13 @@ const useStyles = makeStyles(() => ({ export const Tweet = (tweet) => { const { + id, message, images, avatar_url, profile_name, seconds_since_tweet, + isLiked, } = tweet; const classes = useStyles(); const { t } = useTranslation(); @@ -110,9 +113,7 @@ export const Tweet = (tweet) => { {enableImages && }
- +