diff --git a/phone/src/Phone.js b/phone/src/Phone.js index 4734295..0b77e0c 100644 --- a/phone/src/Phone.js +++ b/phone/src/Phone.js @@ -18,7 +18,6 @@ import { useApps } from "./os/apps/hooks/useApps"; import { useContactsService } from "./apps/contacts/hooks/useContactsService"; import { useTwitterService } from "./apps/twitter/hooks/useTwitterService"; -import { TwitterApp } from "./apps/twitter/components/TwitterApp"; // These events are just for testing. Comment it out before building. //setTimeout(() => { @@ -110,7 +109,7 @@ function Phone() { ]} />
- + {allApps.map((App) => ( ))} diff --git a/phone/src/apps/twitter/components/AddTweetModal.js b/phone/src/apps/twitter/components/AddTweetModal.js index cd75644..27fb934 100644 --- a/phone/src/apps/twitter/components/AddTweetModal.js +++ b/phone/src/apps/twitter/components/AddTweetModal.js @@ -6,6 +6,7 @@ import CloseIcon from "@material-ui/icons/Close"; import { v4 as uuidv4 } from "uuid"; import Nui from "../../../os/nui-events/utils/Nui"; +import Modal from "../../../ui/components/Modal"; import { IMAGE_DELIMITER } from "../utils/images"; import { withValidImage } from "../utils/images"; import { useModal } from "../hooks/useModal"; @@ -44,17 +45,6 @@ const useStyles = makeStyles((theme) => ({ justifyContent: "space-between", flex: "1 0 45px", }, - displayBlock: { - /*Sets modal to center*/ - display: "flex", - flexFlow: "column nowrap", - justifyContent: "center", - alignItems: "center", - position: "relative", - }, - displayNone: { - display: "none", - }, emojiPicker: { background: "none", border: "none", @@ -162,37 +152,35 @@ export const AddTweetModal = () => { }; return ( -
- - - - + + + + + 0} + images={images} + removeImage={removeImage} + /> +
+ - - 0} - images={images} - removeImage={removeImage} + -
- - -
- -
+
+ ); }; diff --git a/phone/src/apps/twitter/components/profile/TwitterProfile.js b/phone/src/apps/twitter/components/profile/TwitterProfile.js index fd75d42..da9efaf 100644 --- a/phone/src/apps/twitter/components/profile/TwitterProfile.js +++ b/phone/src/apps/twitter/components/profile/TwitterProfile.js @@ -66,7 +66,6 @@ export function TwitterProfile() { value={bio} handleChange={handleBioChange} multiline - inputRef={(input) => input && input.focus()} /> ({ + root: { + zIndex: 10, + background: "#424242", + marginTop: "15px", + width: "90%", + display: "flex", + flexFlow: "column nowrap", + position: "absolute", + top: "80px", + }, + displayBlock: { + /*Sets modal to center*/ + display: "flex", + flexFlow: "column nowrap", + justifyContent: "center", + alignItems: "center", + position: "relative", + }, + displayNone: { + display: "none", + }, +})); + +export const Modal = ({ children, visible, handleClose }) => { + const classes = useStyles(); + + // when the user presses escape we should close the modal + const _handleEscape = (e) => { + const isEscapeKey = e.key == "Escape" || e.key == "Esc"; + if (isEscapeKey) { + e.preventDefault(); + handleClose(); + } + }; + useEffect(() => { + const listener = window.addEventListener("keydown", _handleEscape, true); + return () => window.removeEventListener("keydown", listener); + }, []); + + const showHideClassName = visible + ? classes.displayBlock + : classes.displayNone; + + return ( +
+ {children} +
+ ); +}; + +export default Modal;