mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
added UI for choosing a default profile name
This commit is contained in:
1 parent
9261025b4f
commit
8000cc3d3f
4 files changed
+89
-3
No files matched your search
@@ -157,7 +157,7 @@ export const MessageModal = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
) : null}
|
) : null}
|
||||||
{!activeMessageGroup?.isGroupChat &&
|
{!activeMessageGroup?.isGroupChat &&
|
||||||
getDisplayByNumber(targetNumber) == targetNumber ? (
|
getDisplayByNumber(targetNumber) === targetNumber ? (
|
||||||
<Button>
|
<Button>
|
||||||
<PersonAddIcon onClick={() => handleAddContact(targetNumber)} fontSize="large" />
|
<PersonAddIcon onClick={() => handleAddContact(targetNumber)} fontSize="large" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { useProfile } from '../hooks/useProfile';
|
|||||||
import ProfilePrompt from './profile/ProfilePrompt';
|
import ProfilePrompt from './profile/ProfilePrompt';
|
||||||
import InjectDebugData from '../../../os/debug/InjectDebugData';
|
import InjectDebugData from '../../../os/debug/InjectDebugData';
|
||||||
import { TwitterThemeProvider } from '../providers/TwitterThemeProvider';
|
import { TwitterThemeProvider } from '../providers/TwitterThemeProvider';
|
||||||
|
import DefaultProfilePrompt from './profile/DefaultProfilePrompt';
|
||||||
|
|
||||||
const useStyles = makeStyles(() => ({
|
const useStyles = makeStyles(() => ({
|
||||||
backgroundModal: {
|
backgroundModal: {
|
||||||
@@ -42,12 +43,15 @@ export const TwitterApp = () => {
|
|||||||
|
|
||||||
// before any other action can be taken by the user we force
|
// before any other action can be taken by the user we force
|
||||||
// them have a profile name
|
// them have a profile name
|
||||||
const promptProfileName = profile && (!profile.profile_name || !profile.profile_name.trim());
|
let promptProfileName = profile && (!profile.profile_name || !profile.profile_name.trim());
|
||||||
|
promptProfileName = true;
|
||||||
|
|
||||||
const openModal = () => setModalVisible(true);
|
const openModal = () => setModalVisible(true);
|
||||||
const handlePageChange = (e, page) => setActivePage(page);
|
const handlePageChange = (e, page) => setActivePage(page);
|
||||||
const showTweetButton = !promptProfileName && activePage === 0;
|
const showTweetButton = !promptProfileName && activePage === 0;
|
||||||
|
|
||||||
|
const defaultProfileNames = ['test_user', '123-456-7890'];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TwitterThemeProvider>
|
<TwitterThemeProvider>
|
||||||
<AppWrapper id="twitter-app">
|
<AppWrapper id="twitter-app">
|
||||||
@@ -56,7 +60,10 @@ export const TwitterApp = () => {
|
|||||||
<TwitterTitle />
|
<TwitterTitle />
|
||||||
<AppContent>
|
<AppContent>
|
||||||
{promptProfileName ? (
|
{promptProfileName ? (
|
||||||
<ProfilePrompt />
|
<DefaultProfilePrompt
|
||||||
|
updateEvent="phone:updateTwitterProfile"
|
||||||
|
defaultProfileNames={defaultProfileNames}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/twitter" exact component={TweetListContainer} />
|
<Route path="/twitter" exact component={TweetListContainer} />
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { makeStyles } from '@material-ui/core/styles';
|
||||||
|
import InputLabel from '@material-ui/core/InputLabel';
|
||||||
|
import MenuItem from '@material-ui/core/MenuItem';
|
||||||
|
import FormControl from '@material-ui/core/FormControl';
|
||||||
|
import Select from '@material-ui/core/Select';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||||
|
import { useProfile } from '../../hooks/useProfile';
|
||||||
|
import ProfileUpdateButton from '../buttons/ProfileUpdateButton';
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
defaultProfileNames: string[];
|
||||||
|
updateEvent: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
root: {
|
||||||
|
position: 'relative',
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
padding: '15px',
|
||||||
|
},
|
||||||
|
formControl: {
|
||||||
|
// margin: theme.spacing(1),
|
||||||
|
width: '100%',
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
export function DefaultProfilePrompt({ defaultProfileNames, updateEvent }: IProps): JSX.Element {
|
||||||
|
const classes = useStyles();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { profile } = useProfile();
|
||||||
|
|
||||||
|
const hasDefaults = defaultProfileNames.length > 0;
|
||||||
|
const defaultProfileName = hasDefaults ? defaultProfileNames[0] : '';
|
||||||
|
|
||||||
|
const [profileName, setProfileName] = useState(defaultProfileName);
|
||||||
|
|
||||||
|
const handleUpdate = () => {
|
||||||
|
const data = {
|
||||||
|
...profile,
|
||||||
|
profile_name: profileName,
|
||||||
|
};
|
||||||
|
Nui.send(updateEvent, data);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChange = (event: React.ChangeEvent<any>): void => {
|
||||||
|
setProfileName(event.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={classes.root}>
|
||||||
|
<FormControl className={classes.formControl}>
|
||||||
|
<InputLabel htmlFor="profile-name">
|
||||||
|
{t('APPS_TWITTER_EDIT_DEFAULT_PROFILE_NAME')}
|
||||||
|
</InputLabel>
|
||||||
|
<Select
|
||||||
|
value={profileName}
|
||||||
|
onChange={handleChange}
|
||||||
|
inputProps={{
|
||||||
|
name: 'profileName',
|
||||||
|
id: 'profile-name',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<option value="" />
|
||||||
|
{defaultProfileNames.map((profileName) => (
|
||||||
|
<option value={profileName}>{profileName}</option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
<ProfileUpdateButton handleClick={handleUpdate} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DefaultProfilePrompt;
|
||||||
@@ -77,6 +77,7 @@
|
|||||||
"APPS_TWITTER_CREATE_FAILED": "Failed to send your tweet",
|
"APPS_TWITTER_CREATE_FAILED": "Failed to send your tweet",
|
||||||
"APPS_TWITTER_EDIT_PROFILE_AVATAR": "Avatar URL",
|
"APPS_TWITTER_EDIT_PROFILE_AVATAR": "Avatar URL",
|
||||||
"APPS_TWITTER_EDIT_PROFILE_NAME": "Profile name",
|
"APPS_TWITTER_EDIT_PROFILE_NAME": "Profile name",
|
||||||
|
"APPS_TWITTER_EDIT_DEFAULT_PROFILE_NAME": "Choose Profile Name",
|
||||||
"APPS_TWITTER_EDIT_PROFILE_BIO": "Bio",
|
"APPS_TWITTER_EDIT_PROFILE_BIO": "Bio",
|
||||||
"APPS_TWITTER_EDIT_PROFILE_LOCATION": "Location",
|
"APPS_TWITTER_EDIT_PROFILE_LOCATION": "Location",
|
||||||
"APPS_TWITTER_EDIT_PROFILE_JOB": "Job",
|
"APPS_TWITTER_EDIT_PROFILE_JOB": "Job",
|
||||||
|
|||||||
Reference in new issue
Block a user