diff --git a/phone/src/apps/twitter/components/SearchButton.js b/phone/src/apps/twitter/components/SearchButton.js new file mode 100644 index 0000000..606ba0f --- /dev/null +++ b/phone/src/apps/twitter/components/SearchButton.js @@ -0,0 +1,29 @@ +import React, { useState, useEffect } from "react"; +import { makeStyles } from "@material-ui/core/styles"; +import Fab from "@material-ui/core/Fab"; +import SearchIcon from "@material-ui/icons/Search"; + +const useStyles = makeStyles((theme) => ({ + root: { + position: "absolute", + bottom: "15px", + right: "15px", + }, + button: { + background: "#00acee", + }, +})); + +export function ProfileUpdateButton({ handleClick }) { + const classes = useStyles(); + + return ( +
+ + + +
+ ); +} + +export default ProfileUpdateButton; diff --git a/phone/src/apps/twitter/components/Tweet.js b/phone/src/apps/twitter/components/Tweet.js index f7ed254..5b5dcdd 100644 --- a/phone/src/apps/twitter/components/Tweet.js +++ b/phone/src/apps/twitter/components/Tweet.js @@ -39,7 +39,7 @@ const useStyles = makeStyles(() => ({ fontSize: "16px", }, message: { - fontSize: "22px", + fontSize: "20px", }, buttonContainer: { display: "flex", @@ -61,19 +61,6 @@ export const Tweet = (tweet) => { const classes = useStyles(); const { t } = useTranslation(); - // this is a workaround to transfer string new lines and returns that - // are stored into the database into html for the UI to render - const formattedMessage = message.replace(/\n\r?/g, "
"); - const Message = () => ( - <> -
- - - ); - const Primary = () => ( <> {`@${profile_name}`} @@ -88,6 +75,19 @@ export const Tweet = (tweet) => { ); + // this is a workaround to transfer string new lines and returns that + // are stored into the database into html for the UI to render + const formattedMessage = message.replace(/\n\r?/g, "
"); + const Message = () => ( + <> +
+ + + ); + return ( diff --git a/phone/src/apps/twitter/components/TwitterApp.js b/phone/src/apps/twitter/components/TwitterApp.js index 6edaf9e..c00e668 100644 --- a/phone/src/apps/twitter/components/TwitterApp.js +++ b/phone/src/apps/twitter/components/TwitterApp.js @@ -6,7 +6,6 @@ import { AppWrapper } from "../../../ui/components"; import { AppContent } from "../../../ui/components/AppContent"; import TweetListContainer from "./TweetListContainer"; import AddTweetModal from "./AddTweetModal"; -import { AppLoader } from "../../../ui/components/AppLoader"; import { useModal } from "../hooks/useModal"; import { useProfile } from "../hooks/useProfile"; import TweetButton from "./TweetButton"; @@ -15,6 +14,7 @@ import BottomNavigation from "./BottomNavigation"; import TwitterProfile from "./profile/TwitterProfile"; import AlertBar from "./alerts/AlertBar"; import TwitterLoader from "./TwitterLoader"; +import TwitterSearch from "./TwitterSearch"; import "./twitter.css"; import "emoji-mart/css/emoji-mart.css"; @@ -36,7 +36,7 @@ const useStyles = makeStyles((theme) => ({ // TODO move this to the router so the application back button works const PAGE_COMPONENT_MAPPING = { 0: , - 1: , + 1: , 2: , }; const MINIMUM_LOAD_TIME = 750; diff --git a/phone/src/apps/twitter/components/TwitterSearch.js b/phone/src/apps/twitter/components/TwitterSearch.js new file mode 100644 index 0000000..17e1cb0 --- /dev/null +++ b/phone/src/apps/twitter/components/TwitterSearch.js @@ -0,0 +1,65 @@ +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { makeStyles } from "@material-ui/core/styles"; +import { TextField } from "@material-ui/core"; +import TweetList from "./TweetList"; + +import SearchButton from "./SearchButton"; +import { useTweets } from "../hooks/useTweets"; + +const useStyles = makeStyles({ + root: { + width: "100%", + }, + searchContainer: { + padding: "15px", + }, + search: { + width: "100%", + }, +}); + +function TwitterSearch() { + const classes = useStyles(); + const { t } = useTranslation(); + const { tweets } = useTweets(); + const [searchValue, setSearchValue] = useState(""); + const [filteredTweets, setFilteredTweets] = useState(tweets); + const handleChange = (e) => setSearchValue(e.target.value); + + const handleSubmit = () => { + if (!searchValue.trim()) return; + + setFilteredTweets( + tweets.filter((tweet) => { + const v = searchValue.toLowerCase(); + return ( + tweet.profile_name.toLowerCase().includes(v) || + tweet.message.toLowerCase().includes(v) + ); + }) + ); + }; + + return ( + <> +
+
+ input && input.focus()} + /> +
+ +
+ + + ); +} + +export default TwitterSearch; diff --git a/phone/src/apps/twitter/components/profile/ProfileField.js b/phone/src/apps/twitter/components/profile/ProfileField.js index c82711c..da7150c 100644 --- a/phone/src/apps/twitter/components/profile/ProfileField.js +++ b/phone/src/apps/twitter/components/profile/ProfileField.js @@ -12,7 +12,14 @@ const useStyles = makeStyles({ }, }); -function ProfileField({ label, value, handleChange, allowChange, multiline }) { +function ProfileField({ + label, + value, + handleChange, + allowChange, + multiline, + inputRef, +}) { const classes = useStyles(); const _handleChange = (e) => handleChange(e.target.value); @@ -25,6 +32,7 @@ function ProfileField({ label, value, handleChange, allowChange, multiline }) { onChange={_handleChange} disabled={!allowChange} multiline={multiline} + inputRef={inputRef} />
); @@ -33,6 +41,7 @@ function ProfileField({ label, value, handleChange, allowChange, multiline }) { ProfileField.defaultProps = { allowChange: true, multiline: false, + inputRef: null, }; export default ProfileField; diff --git a/phone/src/apps/twitter/components/profile/TwitterProfile.js b/phone/src/apps/twitter/components/profile/TwitterProfile.js index da9efaf..fd75d42 100644 --- a/phone/src/apps/twitter/components/profile/TwitterProfile.js +++ b/phone/src/apps/twitter/components/profile/TwitterProfile.js @@ -66,6 +66,7 @@ export function TwitterProfile() { value={bio} handleChange={handleBioChange} multiline + inputRef={(input) => input && input.focus()} /> , + icon: , backgroundColor: blue[600], color: common.white, path: "/twitter", diff --git a/resources/server/sv_twitter.lua b/resources/server/sv_twitter.lua index 982f8e3..cb74dcd 100644 --- a/resources/server/sv_twitter.lua +++ b/resources/server/sv_twitter.lua @@ -21,7 +21,7 @@ ESX.RegisterServerCallback('phone:fetchTweets', function(source, cb) LEFT OUTER JOIN npwd_twitter_profiles ON npwd_twitter_tweets.identifier = npwd_twitter_profiles.identifier WHERE visible = 1 ORDER BY npwd_twitter_tweets.createdAt DESC - LIMIT 75 + LIMIT 100 ]], {}, function(tweets) cb(tweets) end)