From 75a4eb176e8d5cc410cc74fb18f167198df3e707 Mon Sep 17 00:00:00 2001 From: J Francisco Rader Date: Thu, 11 Mar 2021 16:00:04 -0500 Subject: [PATCH] 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 --- phone/src/Phone.tsx | 2 +- .../apps/messages/components/MessagesApp.tsx | 13 +++++ .../components/modal/MessageBubble.tsx | 12 ++-- .../components/SelloutList/SelloutItem.tsx | 5 +- .../apps/settings/components/SettingItem.tsx | 18 ++++++ .../apps/settings/components/SettingsApp.tsx | 15 ++++- phone/src/apps/settings/hooks/useSettings.ts | 1 + .../apps/twitter/components/EmojiSelect.tsx | 7 ++- .../apps/twitter/components/TwitterApp.tsx | 2 +- .../components/buttons/ControlButtons.tsx | 7 ++- .../twitter/components/buttons/LikeButton.tsx | 6 +- .../components/buttons/RetweetButton.tsx | 12 ++-- .../components/buttons/SearchButton.tsx | 5 +- .../apps/twitter/components/images/Image.tsx | 18 ++---- .../components/images/ImageDisplay.tsx | 8 +-- .../twitter/components/profile/Profile.tsx | 2 +- .../apps/twitter/components/tweet/Retweet.tsx | 24 ++++---- .../apps/twitter/components/tweet/Tweet.tsx | 8 +-- .../twitter/hooks/useTwitterNotifications.ts | 1 - .../apps/twitter/hooks/useTwitterService.ts | 2 - phone/src/apps/twitter/twitter.theme.ts | 28 ++++------ phone/src/config/default.json | 1 + phone/src/locale/en.json | 2 + phone/src/os/apps/config/apps.tsx | 8 ++- phone/src/os/call/components/CallModal.tsx | 2 +- phone/src/os/sound/utils/getSoundSettings.ts | 2 +- phone/src/ui/components/PictureReveal.tsx | 56 +++++++++++++++++++ 27 files changed, 175 insertions(+), 92 deletions(-) create mode 100644 phone/src/ui/components/PictureReveal.tsx diff --git a/phone/src/Phone.tsx b/phone/src/Phone.tsx index 593d6fb..62db9b2 100644 --- a/phone/src/Phone.tsx +++ b/phone/src/Phone.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React from 'react'; import './Phone.css'; import './i18n'; import { Route } from 'react-router-dom'; diff --git a/phone/src/apps/messages/components/MessagesApp.tsx b/phone/src/apps/messages/components/MessagesApp.tsx index baad432..e8cd152 100644 --- a/phone/src/apps/messages/components/MessagesApp.tsx +++ b/phone/src/apps/messages/components/MessagesApp.tsx @@ -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(), + }, ], }, { diff --git a/phone/src/apps/messages/components/modal/MessageBubble.tsx b/phone/src/apps/messages/components/modal/MessageBubble.tsx index 98c9f47..9999c94 100644 --- a/phone/src/apps/messages/components/modal/MessageBubble.tsx +++ b/phone/src/apps/messages/components/modal/MessageBubble.tsx @@ -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 = ({ {isImage(message.message) ? ( - multimedia + + + ) : (
{message.message}
)} diff --git a/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx b/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx index e744660..0ae94c0 100644 --- a/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx +++ b/phone/src/apps/sellout/components/SelloutList/SelloutItem.tsx @@ -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) => { {listing.url ? ( - + + + ) : ( No image provided{' '} diff --git a/phone/src/apps/settings/components/SettingItem.tsx b/phone/src/apps/settings/components/SettingItem.tsx index ad5a14a..1800332 100644 --- a/phone/src/apps/settings/components/SettingItem.tsx +++ b/phone/src/apps/settings/components/SettingItem.tsx @@ -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) => ( + + {icon} + + + onClick(value)} /> + + +); + export const SettingItemIconAction = ({ icon, label, diff --git a/phone/src/apps/settings/components/SettingsApp.tsx b/phone/src/apps/settings/components/SettingsApp.tsx index 2cbd013..ade87c0 100644 --- a/phone/src/apps/settings/components/SettingsApp.tsx +++ b/phone/src/apps/settings/components/SettingsApp.tsx @@ -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)} /> + } + value={settings.streamerMode} + onClick={(curr) => handleSettingChange('streamerMode', !curr)} + /> }> { + const theme = useTheme(); + if (!visible) return null; - return ; + return ( + + ); }; export default memo(EmojiSelect); // The picker is an expensive render diff --git a/phone/src/apps/twitter/components/TwitterApp.tsx b/phone/src/apps/twitter/components/TwitterApp.tsx index 09151b1..d982637 100644 --- a/phone/src/apps/twitter/components/TwitterApp.tsx +++ b/phone/src/apps/twitter/components/TwitterApp.tsx @@ -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, diff --git a/phone/src/apps/twitter/components/buttons/ControlButtons.tsx b/phone/src/apps/twitter/components/buttons/ControlButtons.tsx index 2f44dec..3d79af2 100644 --- a/phone/src/apps/twitter/components/buttons/ControlButtons.tsx +++ b/phone/src/apps/twitter/components/buttons/ControlButtons.tsx @@ -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} {showCloseButton && ( - + )} ); diff --git a/phone/src/apps/twitter/components/buttons/LikeButton.tsx b/phone/src/apps/twitter/components/buttons/LikeButton.tsx index d304daf..47aebea 100644 --- a/phone/src/apps/twitter/components/buttons/LikeButton.tsx +++ b/phone/src/apps/twitter/components/buttons/LikeButton.tsx @@ -28,7 +28,11 @@ function LikeButton({ tweetId, isLiked }) { ); } - return ; + return ( + + ); } export default LikeButton; diff --git a/phone/src/apps/twitter/components/buttons/RetweetButton.tsx b/phone/src/apps/twitter/components/buttons/RetweetButton.tsx index 4d98fa7..596579a 100644 --- a/phone/src/apps/twitter/components/buttons/RetweetButton.tsx +++ b/phone/src/apps/twitter/components/buttons/RetweetButton.tsx @@ -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 (