Feature / Streamer Mode (#159)

* feat(phone/settings): Add streamer mode setting and PictureReveal component :)

* feat(phone/settings): Add PictureReveal streamer mode to twitter and improve its theme a bit
This commit is contained in:
J Francisco Rader authored and GitHub committed 2021-03-11 16:00:04 -05:00
1 parent d841ee0958
commit 75a4eb176e
27 files changed
+175 -92

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React from 'react';
import './Phone.css';
import './i18n';
import { Route } from 'react-router-dom';
@@ -130,6 +130,19 @@ InjectDebugData(
isMine: false,
updatedAt: Date.now(),
},
{
id: 4,
message:
'https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/Hadena_albimacula.jpg/800px-Hadena_albimacula.jpg',
user_identifier: '123',
phone_number: '444-4444',
display: 'kidz',
avatar: null,
groupId: '2',
isRead: true,
isMine: false,
updatedAt: Date.now(),
},
],
},
{
@@ -1,6 +1,8 @@
import { Box, Link, makeStyles, Paper, Typography } from '@material-ui/core';
import React from 'react';
import { Message } from '../../../../common/typings/messages';
import { PictureResponsive } from '../../../../ui/components/PictureResponsive';
import { PictureReveal } from '../../../../ui/components/PictureReveal';
const useStyles = makeStyles((theme) => ({
root: {
@@ -8,12 +10,6 @@ const useStyles = makeStyles((theme) => ({
marginTop: 'auto',
},
},
imageMessage: {
width: '80%',
maxWidth: '80%',
height: '80%',
maxHeight: '80%',
},
mySms: {
float: 'right',
margin: theme.spacing(1),
@@ -64,7 +60,9 @@ export const MessageBubble = ({
<Paper className={message.isMine ? classes.mySms : classes.sms} variant="outlined">
<Box className={classes.message}>
{isImage(message.message) ? (
<img src={message.message} className={classes.imageMessage} alt="multimedia" />
<PictureReveal>
<PictureResponsive src={message.message} alt="message multimedia" />
</PictureReveal>
) : (
<div>{message.message}</div>
)}
@@ -5,6 +5,7 @@ import { ListItem } from '../../../../ui/components/ListItem';
import { PictureResponsive } from '../../../../ui/components/PictureResponsive';
import { MarketplaceListing } from '../../../../common/typings/marketplace';
import { ListingActions } from './ListingActions';
import { PictureReveal } from '../../../../ui/components/PictureReveal';
const useStyles = makeStyles((theme) => ({
root: {
@@ -49,7 +50,9 @@ export const SelloutItem = (listing: MarketplaceListing) => {
</div>
{listing.url ? (
<PictureResponsive src={listing.url} alt={`${listing.name}`} />
<PictureReveal>
<PictureResponsive src={listing.url} alt={`${listing.name}`} />
</PictureReveal>
) : (
<Typography style={{ margin: 10 }}>
No image provided{' '}
@@ -9,6 +9,7 @@ import {
IconButton,
Tooltip,
Typography,
Switch,
} from '@material-ui/core';
interface ISettingItem {
@@ -61,6 +62,23 @@ interface ISettingItemIconAction {
actionLabel: string;
}
interface ISettingSwitch {
label: string;
value: boolean;
onClick: any;
icon: JSX.Element;
}
export const SettingSwitch = ({ label, value, onClick, icon }: ISettingSwitch) => (
<ListItem divider button>
<ListItemIcon>{icon}</ListItemIcon>
<ListItemText primary={label} />
<ListItemSecondaryAction>
<Switch color="primary" checked={value} onChange={() => onClick(value)} />
</ListItemSecondaryAction>
</ListItem>
);
export const SettingItemIconAction = ({
icon,
label,
@@ -7,9 +7,14 @@ import { useConfig } from '../../../config/hooks/useConfig';
import { List } from '../../../ui/components/List';
import { useSimcard } from '../../../os/simcard/hooks/useSimcard';
import { useApp } from '../../../os/apps/hooks/useApps';
import { SettingItem, SettingItemIconAction, SettingItemSlider } from './SettingItem';
import {
SettingItem,
SettingItemIconAction,
SettingItemSlider,
SettingSwitch,
} from './SettingItem';
import { useTranslation } from 'react-i18next';
import VisibilityOffIcon from '@material-ui/icons/VisibilityOff';
import {
FilterList,
Brush,
@@ -133,6 +138,12 @@ export const SettingsApp = () => {
value={settings.notiSoundVol}
onCommit={(e, val) => handleSettingChange('notiSoundVol', val)}
/>
<SettingSwitch
label={t('APPS_SETTINGS_OPTION_STREAMER_MODE')}
icon={<VisibilityOffIcon />}
value={settings.streamerMode}
onClick={(curr) => handleSettingChange('streamerMode', !curr)}
/>
</List>
<List disablePadding subheader={<SubHeaderComp text="Appearance" />}>
<SettingItem
@@ -30,6 +30,7 @@ export interface IPhoneSettings {
frame: SettingOption;
theme: SettingOption;
zoom: SettingOption;
streamerMode: boolean;
ringtone: SettingOption;
ringtoneVol: number;
notiSound: SettingOption;
@@ -1,10 +1,15 @@
import React, { memo } from 'react';
import { Picker } from 'emoji-mart';
import { useTheme } from '@material-ui/core';
export const EmojiSelect = ({ visible, onEmojiClick }) => {
const theme = useTheme();
if (!visible) return null;
return <Picker onClick={onEmojiClick} set="google" theme="dark" showPreview={false} />;
return (
<Picker onClick={onEmojiClick} set="google" theme={theme.palette.type} showPreview={false} />
);
};
export default memo(EmojiSelect); // The picker is an expensive render
@@ -43,7 +43,6 @@ export const TwitterApp = () => {
const { profile } = useProfile();
useEffect(() => {
// this is a polling implementation. It is possible that
// there is some interaction where, on a new tweet, all
// clients are sent the updated query data. Until that can
@@ -113,6 +112,7 @@ InjectDebugData([
avatar_url: 'http://i.tasoagc.dev/jtKL',
seconds_since_tweet: 500,
isMine: false,
isRetweetedByPlayer: true,
updateAt: '2021-02-08 14:37:46',
visible: 1,
likes: 50000,
@@ -2,6 +2,7 @@ import React from 'react';
import { useTranslation } from 'react-i18next';
import { makeStyles } from '@material-ui/core/styles';
import { Button } from '@material-ui/core';
import { StatusButton } from '../../../../ui/components/StatusButton';
const useStyles = makeStyles((theme) => ({
buttons: {
@@ -32,14 +33,14 @@ export const ControlButtons = ({ showImagePrompt, showEmoji, onCloseClick, onPri
{primaryButtonText}
</Button>
{showCloseButton && (
<Button
<StatusButton
className={classes.close}
variant="contained"
color="secondary"
color="error"
onClick={onCloseClick}
>
{t('APPS_TWITTER_CLOSE_IMAGE')}
</Button>
</StatusButton>
)}
</div>
);
@@ -28,7 +28,11 @@ function LikeButton({ tweetId, isLiked }) {
);
}
return <Button onClick={handleClick}>{liked ? <FavoriteIcon /> : <FavoriteBorderIcon />}</Button>;
return (
<Button onClick={handleClick}>
{liked ? <FavoriteIcon color="primary" /> : <FavoriteBorderIcon />}
</Button>
);
}
export default LikeButton;
@@ -2,8 +2,6 @@ import React, { useState } from 'react';
import { CircularProgress, makeStyles, Button } from '@material-ui/core';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faRetweet } from '@fortawesome/free-solid-svg-icons';
import { ITwitterTheme } from '../../twitter.theme';
import Nui from '../../../../os/nui-events/utils/Nui';
interface IProps {
@@ -12,11 +10,10 @@ interface IProps {
isRetweet: boolean | number;
}
const useStyles = makeStyles((theme: ITwitterTheme) => ({
icon: {}, // no styles on default icon
const useStyles = makeStyles((theme) => ({
iconFilled: {
color: theme.palette.twitter.main,
}
color: theme.palette.primary.main,
},
}));
const LOADING_TIME = 1250;
@@ -43,7 +40,6 @@ export const RetweetButton = ({ tweetId, isRetweet, retweetId }: IProps) => {
setLoading(false);
}, LOADING_TIME);
};
if (loading) {
return (
@@ -53,7 +49,7 @@ export const RetweetButton = ({ tweetId, isRetweet, retweetId }: IProps) => {
);
}
const className = retweeted ? classes.iconFilled : classes.icon;
const className = retweeted ? classes.iconFilled : '';
return (
<Button onClick={handleClick}>
@@ -9,9 +9,6 @@ const useStyles = makeStyles((theme) => ({
bottom: '15px',
right: '15px',
},
button: {
background: '#00acee',
},
}));
export function ProfileUpdateButton({ handleClick }) {
@@ -19,7 +16,7 @@ export function ProfileUpdateButton({ handleClick }) {
return (
<div className={classes.root}>
<Fab className={classes.button} color="primary" onClick={handleClick}>
<Fab color="primary" onClick={handleClick}>
<SearchIcon />
</Fab>
</div>
@@ -2,6 +2,8 @@ import React from 'react';
import { IconButton } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import CloseIcon from '@material-ui/icons/Close';
import { PictureReveal } from '../../../../ui/components/PictureReveal';
import { PictureResponsive } from '../../../../ui/components/PictureResponsive';
const useStyles = makeStyles(() => ({
root: {
@@ -24,19 +26,9 @@ const useStyles = makeStyles(() => ({
backgroundColor: '#000',
},
},
img: {
maxHeight: '125px', // constrain images so we don't overwhelm the UI
maxWidth: '300px',
padding: '0px 3px 3px 0px',
},
imgSmall: {
maxHeight: '200px', // constrain images so we don't overwhelm the UI
maxWidth: '100%',
padding: '0px 1px 1px 0px',
},
}));
export const Image = ({ link, handleClick, small }) => {
export const Image = ({ link, handleClick }) => {
const classes = useStyles();
return (
<div className={classes.imageContainer}>
@@ -45,7 +37,9 @@ export const Image = ({ link, handleClick, small }) => {
<CloseIcon />
</IconButton>
)}
<img alt="small avatar" className={small ? classes.imgSmall : classes.img} src={link} />
<PictureReveal>
<PictureResponsive alt="small avatar" src={link} />
</PictureReveal>
</div>
);
};
@@ -1,3 +1,4 @@
import { Box } from '@material-ui/core';
import React from 'react';
import Image from './Image';
@@ -5,19 +6,16 @@ import Image from './Image';
export const ImageDisplay = ({ visible, images, removeImage, small }) => {
if (!visible || !images || images.length === 0) return null;
const styles = { margin: small ? '2px 0px' : '2px 15px' };
return (
<div style={styles}>
<Box p={1}>
{images.map((image) => (
<Image
key={image.id}
link={image.link}
handleClick={removeImage ? () => removeImage(image.id) : null}
small={small}
/>
))}
</div>
</Box>
);
};
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React, { useState } from 'react';
import { makeStyles } from '@material-ui/core/styles';
import { useTranslation } from 'react-i18next';
@@ -4,13 +4,11 @@ import { makeStyles } from '@material-ui/core/styles';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faRetweet } from '@fortawesome/free-solid-svg-icons';
import { ITwitterTheme } from '../../twitter.theme';
interface IProps {
profileName: string;
profileName: string;
}
const useStyles = makeStyles((theme: ITwitterTheme) => ({
const useStyles = makeStyles((theme) => ({
root: {
color: theme.palette.secondary.main,
fontSize: '16px',
@@ -18,18 +16,18 @@ const useStyles = makeStyles((theme: ITwitterTheme) => ({
width: '100%',
paddingBottom: '8px',
marginBottom: '6px',
marginTop: '-6px'
marginTop: '-6px',
},
}));
function Retweet({ profileName }: IProps) {
const { t } = useTranslation();
const classes = useStyles();
return (
<div className={classes.root}>
<FontAwesomeIcon icon={faRetweet} /> {profileName} {t('APPS_TWITTER_RETWEETED')}
</div>
)
const { t } = useTranslation();
const classes = useStyles();
return (
<div className={classes.root}>
<FontAwesomeIcon icon={faRetweet} /> {profileName} {t('APPS_TWITTER_RETWEETED')}
</div>
);
}
export default Retweet;
export default Retweet;
@@ -78,7 +78,6 @@ export const Tweet = (tweet: ITweet) => {
isMine,
isReported,
isRetweet,
isRetweetedByPlayer,
} = tweet;
const classes = useStyles();
const { t } = useTranslation();
@@ -137,12 +136,7 @@ export const Tweet = (tweet: ITweet) => {
<div className={classes.buttonContainer}>
<ReplyButton profile_name={profile_name} />
<LikeButton tweetId={id} isLiked={isLiked} />
{!isMine && (
<RetweetButton
tweetId={id}
retweetId={retweetId}
isRetweet={isRetweet}
/>)}
{!isMine && <RetweetButton tweetId={id} retweetId={retweetId} isRetweet={isRetweet} />}
<ShowMore isMine={isMine} isReported={isReported} id={id} />
</div>
</div>
@@ -1,6 +1,5 @@
import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
import { Tweet } from '../../../common/typings/twitter';
import { useRecoilState, useRecoilValue } from 'recoil';
import { useApp } from '../../../os/apps/hooks/useApps';
@@ -1,9 +1,7 @@
import { useEffect } from 'react';
import { useSetRecoilState } from 'recoil';
import { v4 as uuidv4 } from 'uuid';
import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
import Nui from '../../../os/nui-events/utils/Nui';
import { IMAGE_DELIMITER } from '../utils/images';
import { APP_TWITTER } from '../utils/constants';
import { twitterState } from './state';
+10 -18
View File
@@ -1,27 +1,19 @@
import { blue, common } from '@material-ui/core/colors';
import { common } from '@material-ui/core/colors';
export const CONTACTS_APP_PRIMARY_COLOR = blue[500];
export const CONTACTS_APP_TEXT_COLOR = common.white;
export const TWITTER_APP_PRIMARY_COLOR = '#00acee';
export const TWITTER_APP_TEXT_COLOR = common.white;
export interface ITwitterTheme {
const theme = {
palette: {
twitter: {
main: string;
},
secondary: {
main: string;
}
}
}
const theme: ITwitterTheme = {
palette: {
twitter: {
main: "#00acee",
primary: {
main: TWITTER_APP_PRIMARY_COLOR,
dark: '#0488ba',
light: '#3dbbeb',
contrastText: TWITTER_APP_TEXT_COLOR,
},
secondary: {
main: '#999',
}
},
},
};
+1
View File
@@ -114,6 +114,7 @@
"label": "100%",
"value": 1
},
"streamerMode": false,
"ringtone": {
"label": "Pixel",
"value": "pixel"
+2
View File
@@ -115,6 +115,7 @@
"APPS_SETTINGS_OPTION_FRAME": "Frame",
"APPS_SETTINGS_OPTION_THEME": "Theme",
"APPS_SETTINGS_OPTION_ZOOM": "Zoom",
"APPS_SETTINGS_OPTION_STREAMER_MODE": "Streamer Mode",
"APPS_SETTINGS_OPTION_RINGTONE": "Ringtone",
"APPS_SETTINGS_OPTION_RINGTONEVOL": "Ringtone Volume",
"APPS_SETTINGS_OPTION_NOTIFICATION_FILTER": "Notification Filters",
@@ -128,6 +129,7 @@
"APPS_MARKETPLACE_REPORT_LISTING_FAILED": "This listing has already been reported",
"APPS_MARKETPLACE_REPORT_LISTING_SUCCESS": "Successfully reported listing",
"GENERIC_CLICK_TO_REVEAL": "Click to reveal",
"GENERIC_WAIT": "Please wait...",
"GENERIC_SAVE": "Save",
"GENERIC_UPDATE": "Update",
+6 -2
View File
@@ -42,6 +42,10 @@ import {
} from '../../../apps/sellout/sellout.theme';
import { NOTES_APP_ICON_COLOR, NOTES_APP_PRIMARY_COLOR } from '../../../apps/notes/notes.theme';
import { DIALER_APP_PRIMARY_COLOR, DIALER_APP_TEXT_COLOR } from '../../../apps/dialer/dialer.theme';
import {
TWITTER_APP_PRIMARY_COLOR,
TWITTER_APP_TEXT_COLOR,
} from '../../../apps/twitter/twitter.theme';
export interface IAppConfig {
id: string;
@@ -120,8 +124,8 @@ export const APPS: IAppConfig[] = [
nameLocale: 'APPS_TWITTER',
icon: <FontAwesomeIcon icon={faTwitter} fixedWidth />,
notificationIcon: <FontAwesomeIcon icon={faTwitter} fixedWidth size="xs" />,
backgroundColor: blue[600],
color: common.white,
backgroundColor: TWITTER_APP_PRIMARY_COLOR,
color: TWITTER_APP_TEXT_COLOR,
path: '/twitter',
Route: () => <AppRoute id="TWITTER" path="/twitter" component={TwitterApp} />,
},
+1 -1
View File
@@ -18,7 +18,7 @@ export const CallModal = () => {
<AppContent>
<Box pt={24}>
<h1 style={{ textAlign: 'center' }}>
{myNumber == call?.transmitter ? call?.receiver : call?.transmitter}
{myNumber === call?.transmitter ? call?.receiver : call?.transmitter}
</h1>
<CallTimer isAccepted={call?.accepted} />
</Box>
+1 -1
View File
@@ -26,6 +26,6 @@ export const getSoundSettings = (
};
} catch (e) {
console.error('getSoundSettings.ts error', e, 'Using default sounds');
return { sound: getPath[type](), volume: 1 };
return { sound: getPath[type](), volume: 0 };
}
};
+56
View File
@@ -0,0 +1,56 @@
import React, { useEffect, useState } from 'react';
import { Box, makeStyles, Theme } from '@material-ui/core';
import { useSettings } from '../../apps/settings/hooks/useSettings';
import { useTranslation } from 'react-i18next';
interface IProps {
children: JSX.Element;
}
const useStyles = makeStyles<Theme, { covered: boolean }>((theme) => ({
cover: {
cursor: 'pointer',
backgroundColor: theme.palette.background.default,
color: theme.palette.getContrastText(theme.palette.background.default),
visibility: ({ covered }) => (covered ? 'visible' : 'hidden'),
},
}));
export const PictureReveal = ({ children }: IProps) => {
const [settings] = useSettings();
const [covered, setCovered] = useState<boolean>(false);
const [ready, setReady] = useState<boolean>(false);
const { t } = useTranslation();
const classes = useStyles({ covered });
useEffect(() => {
if (settings.streamerMode === true) {
setCovered(true);
}
setReady(true);
}, [settings.streamerMode]);
const onClickCover = () => setCovered(false);
return (
<Box width="100%" position="relative">
<Box
onClick={onClickCover}
className={classes.cover}
width="100%"
height="100%"
position="absolute"
display="flex"
alignItems="center"
justifyContent="center"
top={0}
left={0}
>
{t('GENERIC_CLICK_TO_REVEAL')}
</Box>
<Box width="100%" height="100%" visibility={ready ? 'visible' : 'hidden'}>
{children}
</Box>
</Box>
);
};