mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
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:
1 parent
d841ee0958
commit
75a4eb176e
27 files changed
+175
-92
No files matched your search
@@ -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>
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user