From 64973a5cc99de2c41eccf8ed763664d88118a5c2 Mon Sep 17 00:00:00 2001 From: erik-sn Date: Sat, 19 Sep 2020 20:33:46 -0400 Subject: [PATCH] first working UI --- .../apps/twitter/components/AddTweetModal.js | 108 ++++++++++++++++++ .../src/apps/twitter/components/TweetText.js | 33 ++++++ .../src/apps/twitter/components/TwitterApp.js | 66 +++++++++++ phone/src/locale/en.json | 6 +- phone/src/os/apps/hooks/useApps.js | 12 ++ resources/config.lua | 8 +- resources/html/index.html | 45 +++++++- 7 files changed, 275 insertions(+), 3 deletions(-) create mode 100644 phone/src/apps/twitter/components/AddTweetModal.js create mode 100644 phone/src/apps/twitter/components/TweetText.js create mode 100644 phone/src/apps/twitter/components/TwitterApp.js diff --git a/phone/src/apps/twitter/components/AddTweetModal.js b/phone/src/apps/twitter/components/AddTweetModal.js new file mode 100644 index 0000000..86a1227 --- /dev/null +++ b/phone/src/apps/twitter/components/AddTweetModal.js @@ -0,0 +1,108 @@ +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { makeStyles } from "@material-ui/core/styles"; +import { Button, TextField, Paper } from "@material-ui/core"; +import InsertPhotoIcon from "@material-ui/icons/InsertPhoto"; +import GifIcon from "@material-ui/icons/Gif"; +import CloseIcon from "@material-ui/icons/Close"; +import EmojiIcon from "@material-ui/icons/SentimentSatisfied"; + +import TweetText from "./TweetText"; + +const useStyles = makeStyles((theme) => ({ + button: { + margin: 5, + marginTop: 20, + }, + root: { + zIndex: 2, + background: "#232323", + marginTop: "15px", + width: "90%", + display: "flex", + flexFlow: "column nowrap", + }, + close: { + position: "absolute", + top: "12px", + right: "4px", + zIndex: 2, + }, + buttonsContainer: { + paddingBottom: "8px", + display: "flex", + flexFlow: "row nowrap", + justifyContent: "space-between", + flex: "1 0 45px", + }, + leftButtons: { + display: "flex", + flexFlow: "row nowrap", + justifyContent: "flex-start", + }, + rightButtons: { + display: "flex", + flexFlow: "row nowrap", + justifyContent: "flex-end", + alignItems: "justify-content", + marginRight: "15px", + }, + button: { + background: "transparent", + }, + displayBlock: { + /*Sets modal to center*/ + display: "flex", + flexFlow: "column nowrap", + justifyContent: "center", + alignItems: "center", + position: "relative", + }, + displayNone: { + display: "none", + }, +})); + +export const AddTweetModal = ({ visible, handleClose }) => { + const [text, setText] = useState(""); + const classes = useStyles(); + const { t } = useTranslation(); + const showHideClassName = visible + ? classes.displayBlock + : classes.displayNone; + + const submitTweet = () => { + console.log("submitting tweet"); + }; + + return ( +
+ + + setText(e.target.value)} /> +
+
+ + + +
+
+ +
+
+
+
+ ); +}; + +export default AddTweetModal; diff --git a/phone/src/apps/twitter/components/TweetText.js b/phone/src/apps/twitter/components/TweetText.js new file mode 100644 index 0000000..eafd261 --- /dev/null +++ b/phone/src/apps/twitter/components/TweetText.js @@ -0,0 +1,33 @@ +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { makeStyles } from "@material-ui/core/styles"; +import { TextField } from "@material-ui/core"; + +const useStyles = makeStyles((theme) => ({ + textField: { + flex: "1 1 100%", + padding: "10px 15px", + marginTop: "15px", + }, + textFieldInput: { + fontSize: "22px", + }, +})); + +export const TweetText = ({ text, setText }) => { + const classes = useStyles(); + const { t } = useTranslation(); + + return ( + setText(e.target.value)} + multiline + placeholder={t("APPS_TWITTER_PLACEHOLDER")} + /> + ); +}; + +export default TweetText; diff --git a/phone/src/apps/twitter/components/TwitterApp.js b/phone/src/apps/twitter/components/TwitterApp.js new file mode 100644 index 0000000..c3ee118 --- /dev/null +++ b/phone/src/apps/twitter/components/TwitterApp.js @@ -0,0 +1,66 @@ +import React, { useState, useCallback, useEffect } from "react"; +import { blue } from "@material-ui/core/colors"; +import { makeStyles, Button } from "@material-ui/core"; +import AddCircleIcon from "@material-ui/icons/AddCircle"; +import { AppTitle } from "../../../ui/components/AppTitle"; +import { AppWrapper } from "../../../ui/components"; +import { AppContent } from "../../../ui/components/AppContent"; +import { useTranslation } from "react-i18next"; +import { useApp } from "../../../os/apps/hooks/useApps"; + +import AddTweetModal from "./AddTweetModal"; + +const useStyles = makeStyles((theme) => ({ + root: { + height: "90px", + display: "flex", + justifyContent: "center", + backgroundColor: blue[600], + alignItems: "center", + }, + header: { + fontFamily: "'Bebas Neue', cursive", + textAlign: "center", + fontSize: 50, + }, +})); + +export const TwitterApp = () => { + const [modalVisible, setModalVisible] = useState(true); + const { t } = useTranslation(); + const classes = useStyles(); + const twitter = useApp("TWITTER"); + + const openModal = useCallback(() => setModalVisible(true), []); + const hideModal = useCallback(() => setModalVisible(false), []); + + useEffect(() => { + const listener = window.addEventListener( + "keydown", + (e) => { + if (e.key == "Escape" || e.key == "Esc") { + e.preventDefault(); + hideModal(); + } + }, + true + ); + return () => window.removeEventListener("keydown", listener); + }, []); + + return ( + + + + + + + + ); +}; diff --git a/phone/src/locale/en.json b/phone/src/locale/en.json index 8b55405..1caf2e9 100644 --- a/phone/src/locale/en.json +++ b/phone/src/locale/en.json @@ -11,6 +11,10 @@ "APPS_BANK_WITHDRAW": "Withdraw", "APPS_BANK_TRANSFER": "Transfer", "APPS_SETTINGS_OPTIONS_WALLPAPER": "Wallpaper", - "APPS_SETTINGS_OPTIONS_FRAME": "Frame" + "APPS_SETTINGS_OPTIONS_FRAME": "Frame", + "APPS_TWITTER": "Twitter", + "APPS_TWITTER_PLACEHOLDER": "What's happening?", + "APPS_TWITTER_TWEET": "Tweet", + "APPS_TWITTER_CLOSE": "Close" } } diff --git a/phone/src/os/apps/hooks/useApps.js b/phone/src/os/apps/hooks/useApps.js index a5a3d0c..289bc3d 100644 --- a/phone/src/os/apps/hooks/useApps.js +++ b/phone/src/os/apps/hooks/useApps.js @@ -2,6 +2,7 @@ import React from "react"; import { useConfig } from "../../../config/hooks/useConfig"; import { blue, + common, grey, green, orange, @@ -13,6 +14,7 @@ import SettingsIcon from "@material-ui/icons/Settings"; import PhoneIcon from "@material-ui/icons/Phone"; import AccountBalanceIcon from "@material-ui/icons/AccountBalance"; import MessageIcon from "@material-ui/icons/Message"; +import AccessibilityIcon from "@material-ui/icons/Accessibility"; import { atom } from "recoil"; import { CalculatorIcon } from "../../../apps/calculator/components/CalculatorIcon"; import { Route } from "react-router-dom"; @@ -22,6 +24,7 @@ import { CalculatorApp } from "../../../apps/calculator/components/CalculatorApp import { SettingsApp } from "../../../apps/settings/components/SettingsApp"; import { BankApp } from "../../../apps/bank/components/BankApp"; import { MessagesApp } from "../../../apps/messages/components/MessagesApp"; +import { TwitterApp } from "../../../apps/twitter/components/TwitterApp"; const appsState = atom({ key: "apps", @@ -81,6 +84,15 @@ const appsState = atom({ path: "/bank", Route: () => , }, + { + id: "TWITTER", + nameLocale: "APPS_TWITTER", + icon: , + backgroundColor: blue[600], + color: common.white, + path: "/twitter", + Route: () => , + }, ], }, }); diff --git a/resources/config.lua b/resources/config.lua index dd545a0..923f3ad 100644 --- a/resources/config.lua +++ b/resources/config.lua @@ -4,4 +4,10 @@ Config.Locale = 'en' Config.KeyTogglePhone = 288 -- F1 Config.KeyTakeCall = 38 -- E -Config.PhoneAsItem = true \ No newline at end of file +Config.PhoneAsItem = false + +Config.twitter = {} +Config.twitter.characterLimit = 240 +Config.twitter.renderImages = true -- whether or not links to images are automatically rendered on the UI +Config.twitter.renderGifs = true -- whether or not links to gifs are automatically rendered on the UI +Config.twitter.renderVideos = true -- whether or not links to videos are automatically rendered on the UI diff --git a/resources/html/index.html b/resources/html/index.html index 9c511ba..d196fe9 100644 --- a/resources/html/index.html +++ b/resources/html/index.html @@ -1 +1,44 @@ -React App
\ No newline at end of file + + + + + + + + + + + + + + React App + + + +
+ + +