mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
added search field
This commit is contained in:
1 parent
c414116b49
commit
660f534176
9 files changed
+126
-20
No files matched your search
@@ -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 (
|
||||
<div className={classes.root}>
|
||||
<Fab className={classes.button} color="primary" onClick={handleClick}>
|
||||
<SearchIcon />
|
||||
</Fab>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ProfileUpdateButton;
|
||||
@@ -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, "<br />");
|
||||
const Message = () => (
|
||||
<>
|
||||
<div
|
||||
className={classes.message}
|
||||
dangerouslySetInnerHTML={{ __html: formattedMessage }}
|
||||
/>
|
||||
<ImageDisplay visible images={images} small />
|
||||
</>
|
||||
);
|
||||
|
||||
const Primary = () => (
|
||||
<>
|
||||
<span className={classes.profile}>{`@${profile_name}`}</span>
|
||||
@@ -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, "<br />");
|
||||
const Message = () => (
|
||||
<>
|
||||
<div
|
||||
className={classes.message}
|
||||
dangerouslySetInnerHTML={{ __html: formattedMessage }}
|
||||
/>
|
||||
<ImageDisplay visible images={images} small />
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<ListItem className={classes.root} divider>
|
||||
<ListItemAvatar>
|
||||
|
||||
@@ -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: <TweetListContainer />,
|
||||
1: <TweetListContainer />,
|
||||
1: <TwitterSearch />,
|
||||
2: <TwitterProfile />,
|
||||
};
|
||||
const MINIMUM_LOAD_TIME = 750;
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
<div className={classes.root}>
|
||||
<div className={classes.searchContainer}>
|
||||
<TextField
|
||||
className={classes.search}
|
||||
placeholder={t("APPS_TWITTER_SEARCH_TWEETS_PLACEHOLDER")}
|
||||
label={t("APPS_TWITTER_SEARCH_TWEETS")}
|
||||
value={searchValue}
|
||||
onChange={handleChange}
|
||||
size="medium"
|
||||
inputRef={(input) => input && input.focus()}
|
||||
/>
|
||||
</div>
|
||||
<TweetList tweets={filteredTweets} />
|
||||
</div>
|
||||
<SearchButton handleClick={handleSubmit} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default TwitterSearch;
|
||||
@@ -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}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -33,6 +41,7 @@ function ProfileField({ label, value, handleChange, allowChange, multiline }) {
|
||||
ProfileField.defaultProps = {
|
||||
allowChange: true,
|
||||
multiline: false,
|
||||
inputRef: null,
|
||||
};
|
||||
|
||||
export default ProfileField;
|
||||
@@ -66,6 +66,7 @@ export function TwitterProfile() {
|
||||
value={bio}
|
||||
handleChange={handleBioChange}
|
||||
multiline
|
||||
inputRef={(input) => input && input.focus()}
|
||||
/>
|
||||
<ProfileField
|
||||
label={t("APPS_TWITTER_EDIT_PROFILE_LOCATION")}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
"APPS_TWITTER_SUBMIT_IMAGE": "Add Media",
|
||||
"APPS_TWITTER_CLOSE_IMAGE": "Close",
|
||||
"APPS_TWITTER_CLOSE": "Close",
|
||||
"APPS_TWITTER_SEARCH_TWEETS": "Search for tweets",
|
||||
"APPS_TWITTER_SEARCH_TWEETS_PLACEHOLDER": "Search by profile name or message",
|
||||
"APPS_TWITTER_CREATE_SUCCESS": "Successfully sent your tweet",
|
||||
"APPS_TWITTER_CREATE_FAILED": "Failed to send your tweet",
|
||||
"APPS_TWITTER_EDIT_PROFILE_AVATAR": "Avatar URL",
|
||||
|
||||
@@ -14,7 +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 TwitterIcon from "@material-ui/icons/Twitter";
|
||||
import { atom } from "recoil";
|
||||
import { CalculatorIcon } from "../../../apps/calculator/components/CalculatorIcon";
|
||||
import { Route } from "react-router-dom";
|
||||
@@ -87,7 +87,7 @@ const appsState = atom({
|
||||
{
|
||||
id: "TWITTER",
|
||||
nameLocale: "APPS_TWITTER",
|
||||
icon: <AccessibilityIcon />,
|
||||
icon: <TwitterIcon />,
|
||||
backgroundColor: blue[600],
|
||||
color: common.white,
|
||||
path: "/twitter",
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user