mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 10:31:35 +00:00
Add switch for light QR codes on dark theme
This commit is contained in:
parent
811cb4181d
commit
298ce130f7
@ -12,7 +12,7 @@ const SettingsPage = (): JSX.Element => {
|
|||||||
elevation={12}
|
elevation={12}
|
||||||
sx={{
|
sx={{
|
||||||
padding: '0.6em',
|
padding: '0.6em',
|
||||||
width: '18em',
|
width: '21em',
|
||||||
maxHeight: `${maxHeight}em`,
|
maxHeight: `${maxHeight}em`,
|
||||||
overflow: 'auto',
|
overflow: 'auto',
|
||||||
overflowX: 'clip',
|
overflowX: 'clip',
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useTheme } from '@mui/material/styles';
|
import { useTheme } from '@mui/material/styles';
|
||||||
import QRCode from 'react-qr-code';
|
import QRCode from 'react-qr-code';
|
||||||
@ -13,6 +13,7 @@ import {
|
|||||||
Grid,
|
Grid,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import { NewTabIcon } from '../Icons';
|
import { NewTabIcon } from '../Icons';
|
||||||
|
import { AppContext, UseAppStoreType } from '../../contexts/AppContext';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -22,6 +23,7 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const EnableTelegramDialog = ({ open, onClose, tgBotName, tgToken }: Props): JSX.Element => {
|
const EnableTelegramDialog = ({ open, onClose, tgBotName, tgToken }: Props): JSX.Element => {
|
||||||
|
const { settings } = useContext<UseAppStoreType>(AppContext);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
@ -49,7 +51,7 @@ const EnableTelegramDialog = ({ open, onClose, tgBotName, tgToken }: Props): JSX
|
|||||||
sx={{
|
sx={{
|
||||||
width: 290,
|
width: 290,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
backgroundColor: theme.palette.background.paper,
|
backgroundColor: settings.lightQRs ? '#fff' : theme.palette.background.paper,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
padding: '0.5em',
|
padding: '0.5em',
|
||||||
@ -63,7 +65,7 @@ const EnableTelegramDialog = ({ open, onClose, tgBotName, tgToken }: Props): JSX
|
|||||||
>
|
>
|
||||||
<QRCode
|
<QRCode
|
||||||
bgColor={'rgba(255, 255, 255, 0)'}
|
bgColor={'rgba(255, 255, 255, 0)'}
|
||||||
fgColor={theme.palette.text.primary}
|
fgColor={settings.lightQRs ? '#000000' : theme.palette.text.primary}
|
||||||
value={'tg://resolve?domain=' + tgBotName + '&start=' + tgToken}
|
value={'tg://resolve?domain=' + tgBotName + '&start=' + tgToken}
|
||||||
size={275}
|
size={275}
|
||||||
onClick={handleOpenTG}
|
onClick={handleOpenTG}
|
||||||
|
@ -25,6 +25,7 @@ import {
|
|||||||
Link,
|
Link,
|
||||||
AccountBalance,
|
AccountBalance,
|
||||||
AttachMoney,
|
AttachMoney,
|
||||||
|
QrCode,
|
||||||
} from '@mui/icons-material';
|
} from '@mui/icons-material';
|
||||||
import { systemClient } from '../../services/System';
|
import { systemClient } from '../../services/System';
|
||||||
import SwapCalls from '@mui/icons-material/SwapCalls';
|
import SwapCalls from '@mui/icons-material/SwapCalls';
|
||||||
@ -112,6 +113,61 @@ const SettingsForm = ({ dense = false, showNetwork = false }: SettingsFormProps)
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
{settings.mode === 'dark' ? (
|
||||||
|
<>
|
||||||
|
<ListItemIcon>
|
||||||
|
<QrCode />
|
||||||
|
</ListItemIcon>
|
||||||
|
<FormControlLabel
|
||||||
|
sx={{ position: 'relative', right: '1.5em', width: '3em' }}
|
||||||
|
labelPlacement='end'
|
||||||
|
label={settings.lightQRs ? t('Light') : t('Dark')}
|
||||||
|
control={
|
||||||
|
<Switch
|
||||||
|
checked={!settings.lightQRs}
|
||||||
|
checkedIcon={
|
||||||
|
<Paper
|
||||||
|
elevation={3}
|
||||||
|
sx={{
|
||||||
|
width: '1.2em',
|
||||||
|
height: '1.2em',
|
||||||
|
borderRadius: '0.4em',
|
||||||
|
backgroundColor: 'white',
|
||||||
|
position: 'relative',
|
||||||
|
top: `${7 - 0.5 * theme.typography.fontSize}px`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DarkMode sx={{ width: '0.8em', height: '0.8em', color: '#666' }} />
|
||||||
|
</Paper>
|
||||||
|
}
|
||||||
|
icon={
|
||||||
|
<Paper
|
||||||
|
elevation={3}
|
||||||
|
sx={{
|
||||||
|
width: '1.2em',
|
||||||
|
height: '1.2em',
|
||||||
|
borderRadius: '0.4em',
|
||||||
|
backgroundColor: 'white',
|
||||||
|
padding: '0.07em',
|
||||||
|
position: 'relative',
|
||||||
|
top: `${7 - 0.5 * theme.typography.fontSize}px`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<LightMode sx={{ width: '0.67em', height: '0.67em', color: '#666' }} />
|
||||||
|
</Paper>
|
||||||
|
}
|
||||||
|
onChange={(e) => {
|
||||||
|
const lightQRs = !e.target.checked;
|
||||||
|
setSettings({ ...settings, lightQRs });
|
||||||
|
systemClient.setItem('settings_lightQRs', lightQRs);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|
||||||
<ListItem>
|
<ListItem>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Button, Box, Grid, Typography, TextField, Tooltip, useTheme } from '@mui/material';
|
import { Button, Box, Grid, Typography, TextField, Tooltip, useTheme } from '@mui/material';
|
||||||
import { ContentCopy } from '@mui/icons-material';
|
import { ContentCopy } from '@mui/icons-material';
|
||||||
@ -7,6 +7,7 @@ import { Order } from '../../../models';
|
|||||||
import { systemClient } from '../../../services/System';
|
import { systemClient } from '../../../services/System';
|
||||||
import currencies from '../../../../static/assets/currencies.json';
|
import currencies from '../../../../static/assets/currencies.json';
|
||||||
import WalletsButton from '../WalletsButton';
|
import WalletsButton from '../WalletsButton';
|
||||||
|
import { AppContext, UseAppStoreType } from '../../../contexts/AppContext';
|
||||||
|
|
||||||
interface LockInvoicePromptProps {
|
interface LockInvoicePromptProps {
|
||||||
order: Order;
|
order: Order;
|
||||||
@ -14,6 +15,7 @@ interface LockInvoicePromptProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const LockInvoicePrompt = ({ order, concept }: LockInvoicePromptProps): JSX.Element => {
|
export const LockInvoicePrompt = ({ order, concept }: LockInvoicePromptProps): JSX.Element => {
|
||||||
|
const { settings } = useContext<UseAppStoreType>(AppContext);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const currencyCode: string = currencies[`${order.currency}`];
|
const currencyCode: string = currencies[`${order.currency}`];
|
||||||
@ -81,7 +83,7 @@ export const LockInvoicePrompt = ({ order, concept }: LockInvoicePromptProps): J
|
|||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
backgroundColor: theme.palette.background.paper,
|
backgroundColor: settings.lightQRs ? '#fff' : theme.palette.background.paper,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
padding: '0.5em',
|
padding: '0.5em',
|
||||||
@ -95,7 +97,7 @@ export const LockInvoicePrompt = ({ order, concept }: LockInvoicePromptProps): J
|
|||||||
>
|
>
|
||||||
<QRCode
|
<QRCode
|
||||||
bgColor={'rgba(255, 255, 255, 0)'}
|
bgColor={'rgba(255, 255, 255, 0)'}
|
||||||
fgColor={theme.palette.text.primary}
|
fgColor={settings.lightQRs ? '#000000' : theme.palette.text.primary}
|
||||||
value={invoice ?? 'Undefined: BOLT11 invoice not received'}
|
value={invoice ?? 'Undefined: BOLT11 invoice not received'}
|
||||||
size={theme.typography.fontSize * 21.8}
|
size={theme.typography.fontSize * 21.8}
|
||||||
onClick={handleClickQR}
|
onClick={handleClickQR}
|
||||||
|
@ -113,7 +113,7 @@ export const useAppStore = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTheme(makeTheme(settings));
|
setTheme(makeTheme(settings));
|
||||||
}, [settings.fontSize, settings.mode]);
|
}, [settings.fontSize, settings.mode, settings.lightQRs]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
i18n.changeLanguage(settings.language);
|
i18n.changeLanguage(settings.language);
|
||||||
|
@ -30,6 +30,8 @@ class BaseSettings {
|
|||||||
? 'dark'
|
? 'dark'
|
||||||
: 'light';
|
: 'light';
|
||||||
|
|
||||||
|
this.lightQRs = systemClient.getItem('settings_lightQRs') === 'true';
|
||||||
|
|
||||||
const languageCookie = systemClient.getItem('settings_language');
|
const languageCookie = systemClient.getItem('settings_language');
|
||||||
this.language =
|
this.language =
|
||||||
languageCookie !== ''
|
languageCookie !== ''
|
||||||
@ -45,6 +47,7 @@ class BaseSettings {
|
|||||||
public frontend: 'basic' | 'pro' = 'basic';
|
public frontend: 'basic' | 'pro' = 'basic';
|
||||||
public mode: 'light' | 'dark' = 'light';
|
public mode: 'light' | 'dark' = 'light';
|
||||||
public fontSize: number = 14;
|
public fontSize: number = 14;
|
||||||
|
public lightQRs: boolean = false;
|
||||||
public language?: Language;
|
public language?: Language;
|
||||||
public freezeViewports: boolean = false;
|
public freezeViewports: boolean = false;
|
||||||
public network: 'mainnet' | 'testnet' = 'mainnet';
|
public network: 'mainnet' | 'testnet' = 'mainnet';
|
||||||
|
@ -44,11 +44,11 @@ const App = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EncryptedStorage.removeItem('sessionid');
|
EncryptedStorage.removeItem('sessionid');
|
||||||
// EncryptedStorage.removeItem('csrftoken');
|
|
||||||
loadCookie('robot_token');
|
loadCookie('robot_token');
|
||||||
loadCookie('settings_fontsize_basic');
|
loadCookie('settings_fontsize_basic');
|
||||||
loadCookie('settings_language');
|
loadCookie('settings_language');
|
||||||
loadCookie('settings_mode');
|
loadCookie('settings_mode');
|
||||||
|
loadCookie('settings_lightQRs');
|
||||||
loadCookie('settings_network');
|
loadCookie('settings_network');
|
||||||
loadCookie('garage').then(() => injectMessageResolve(responseId));
|
loadCookie('garage').then(() => injectMessageResolve(responseId));
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user