Remove unused import, add themeSelector

This commit is contained in:
Nicola Benaglia 2025-04-04 09:08:53 +02:00
parent d92d75040d
commit ff927e017b
4 changed files with 114 additions and 87 deletions

View File

@ -1667,7 +1667,9 @@ function App() {
/> />
</Tooltip> </Tooltip>
</ButtonBase> </ButtonBase>
<Spacer height="20px" /> <Spacer height="20px" />
<ButtonBase <ButtonBase
onClick={() => { onClick={() => {
setIsOpenDrawerLookup(true); setIsOpenDrawerLookup(true);
@ -1699,7 +1701,9 @@ function App() {
/> />
</Tooltip> </Tooltip>
</ButtonBase> </ButtonBase>
<Spacer height="20px" /> <Spacer height="20px" />
<ButtonBase <ButtonBase
onClick={() => { onClick={() => {
executeEvent('openWalletsApp', {}) executeEvent('openWalletsApp', {})
@ -1732,7 +1736,6 @@ function App() {
</Tooltip> </Tooltip>
</ButtonBase> </ButtonBase>
{desktopViewMode !== 'home' && ( {desktopViewMode !== 'home' && (
<> <>
<Spacer height="20px" /> <Spacer height="20px" />

View File

@ -1,50 +1,46 @@
import React, { useMemo, useState } from "react"; import React, { useState } from "react";
import { import {
AppCircle, AppCircle,
AppCircleContainer, AppCircleContainer,
AppCircleLabel, AppCircleLabel,
AppLibrarySubTitle, AppLibrarySubTitle,
AppsContainer, AppsContainer,
AppsParent,
} from "./Apps-styles"; } from "./Apps-styles";
import { Avatar, Box, ButtonBase, Input } from "@mui/material"; import { Box, ButtonBase, Input } from "@mui/material";
import { Add } from "@mui/icons-material"; import { Add } from "@mui/icons-material";
import { getBaseApiReact, isMobile } from "../../App"; import { isMobile } from "../../App";
import LogoSelected from "../../assets/svgs/LogoSelected.svg";
import { executeEvent } from "../../utils/events"; import { executeEvent } from "../../utils/events";
import { Spacer } from "../../common/Spacer"; import { Spacer } from "../../common/Spacer";
import { SortablePinnedApps } from "./SortablePinnedApps"; import { SortablePinnedApps } from "./SortablePinnedApps";
import { extractComponents } from "../Chat/MessageDisplay"; import { extractComponents } from "../Chat/MessageDisplay";
import ArrowOutwardIcon from '@mui/icons-material/ArrowOutward'; import ArrowOutwardIcon from "@mui/icons-material/ArrowOutward";
import { AppsPrivate } from "./AppsPrivate"; import { AppsPrivate } from "./AppsPrivate";
import ThemeSelector from "../Theme/ThemeSelector";
export const AppsHomeDesktop = ({ export const AppsHomeDesktop = ({
setMode, setMode,
myApp, myApp,
myWebsite, myWebsite,
availableQapps, availableQapps,
myName myName,
}) => { }) => {
const [qortalUrl, setQortalUrl] = useState('') const [qortalUrl, setQortalUrl] = useState("");
const openQortalUrl = ()=> { const openQortalUrl = () => {
try { try {
if(!qortalUrl) return if (!qortalUrl) return;
const res = extractComponents(qortalUrl); const res = extractComponents(qortalUrl);
if (res) { if (res) {
const { service, name, identifier, path } = res; const { service, name, identifier, path } = res;
executeEvent("addTab", { data: { service, name, identifier, path } }); executeEvent("addTab", { data: { service, name, identifier, path } });
executeEvent("open-apps-mode", { }); executeEvent("open-apps-mode", {});
setQortalUrl('qortal://') setQortalUrl("qortal://");
}
} catch (error) {
}
} }
} catch (error) {}
};
return ( return (
<> <>
<AppsContainer <AppsContainer
sx={{ sx={{
justifyContent: "flex-start", justifyContent: "flex-start",
}} }}
> >
@ -56,65 +52,71 @@ export const AppsHomeDesktop = ({
Apps Dashboard Apps Dashboard
</AppLibrarySubTitle> </AppLibrarySubTitle>
</AppsContainer> </AppsContainer>
<Spacer height="20px" /> <Spacer height="20px" />
<AppsContainer <AppsContainer
sx={{ sx={{
justifyContent: "flex-start", justifyContent: "flex-start",
}} }}
> >
<Box sx={{ <Box
display: 'flex', sx={{
gap: '20px', display: "flex",
alignItems: 'center', gap: "20px",
backgroundColor: '#1f2023', alignItems: "center",
padding: '7px', backgroundColor: "#1f2023",
borderRadius: '20px', padding: "7px",
width: '100%', borderRadius: "20px",
maxWidth: '500px' width: "100%",
}}> maxWidth: "500px",
}}
>
<Input <Input
id="standard-adornment-name" id="standard-adornment-name"
value={qortalUrl} value={qortalUrl}
onChange={(e) => { onChange={(e) => {
setQortalUrl(e.target.value) setQortalUrl(e.target.value);
}} }}
disableUnderline disableUnderline
autoComplete='off' autoComplete="off"
autoCorrect='off' autoCorrect="off"
placeholder="qortal://" placeholder="qortal://"
sx={{ sx={{
width: '100%', width: "100%",
color: 'white', color: "white",
'& .MuiInput-input::placeholder': { "& .MuiInput-input::placeholder": {
color: 'rgba(84, 84, 84, 0.70) !important', color: "rgba(84, 84, 84, 0.70) !important",
fontSize: '20px', fontSize: "20px",
fontStyle: 'normal', fontStyle: "normal",
fontWeight: 400, fontWeight: 400,
lineHeight: '120%', // 24px lineHeight: "120%", // 24px
letterSpacing: '0.15px', letterSpacing: "0.15px",
opacity: 1 opacity: 1,
}, },
'&:focus': { "&:focus": {
outline: 'none', outline: "none",
}, },
// Add any additional styles for the input here // Add any additional styles for the input here
}} }}
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key === 'Enter' && qortalUrl) { if (e.key === "Enter" && qortalUrl) {
openQortalUrl(); openQortalUrl();
} }
}} }}
/> />
<ButtonBase onClick={()=> openQortalUrl()}> <ButtonBase onClick={() => openQortalUrl()}>
<ArrowOutwardIcon sx={{ <ArrowOutwardIcon
color: qortalUrl ? 'white' : 'rgba(84, 84, 84, 0.70)' sx={{
}} /> color: qortalUrl ? "white" : "rgba(84, 84, 84, 0.70)",
}}
/>
</ButtonBase> </ButtonBase>
</Box> </Box>
</AppsContainer> </AppsContainer>
<Spacer height="45px" /> <Spacer height="45px" />
<AppsContainer <AppsContainer
sx={{ sx={{
gap: "50px", gap: "50px",
@ -137,7 +139,9 @@ export const AppsHomeDesktop = ({
<AppCircleLabel>Library</AppCircleLabel> <AppCircleLabel>Library</AppCircleLabel>
</AppCircleContainer> </AppCircleContainer>
</ButtonBase> </ButtonBase>
<AppsPrivate myName={myName} /> <AppsPrivate myName={myName} />
<SortablePinnedApps <SortablePinnedApps
isDesktop={true} isDesktop={true}
availableQapps={availableQapps} availableQapps={availableQapps}
@ -145,6 +149,8 @@ export const AppsHomeDesktop = ({
myApp={myApp} myApp={myApp}
/> />
</AppsContainer> </AppsContainer>
<ThemeSelector style={{ position: "fixed", bottom: "1%", left: "0%" }} />
</> </>
); );
}; };

View File

@ -1,6 +1,17 @@
import { createContext, useContext, useState, useMemo } from 'react'; import { createContext, useContext, useState, useMemo } from 'react';
import { ThemeProvider as MuiThemeProvider } from '@mui/material/styles'; import { createTheme, ThemeProvider as MuiThemeProvider } from '@mui/material/styles';
import { darkTheme, lightTheme } from '../../styles/theme';
const darkTheme = createTheme({
palette: {
mode: 'dark',
},
});
const lightTheme = createTheme({
palette: {
mode: 'light',
},
});
const ThemeContext = createContext({ themeMode: 'light', toggleTheme: () => {} }); const ThemeContext = createContext({ themeMode: 'light', toggleTheme: () => {} });

View File

@ -1,15 +1,22 @@
import { useThemeContext } from "./ThemeContext"; import { useThemeContext } from "./ThemeContext";
import { Switch } from "@mui/material"; import { Switch } from "@mui/material";
import { Brightness4, Brightness7 } from "@mui/icons-material"; import LightModeIcon from '@mui/icons-material/LightMode';
import NightlightIcon from '@mui/icons-material/Nightlight';
const ThemeSelector = ({ style }) => { const ThemeSelector = ({ style }) => {
const { themeMode, toggleTheme } = useThemeContext(); const { themeMode, toggleTheme } = useThemeContext();
return ( return (
<div <div
style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: "1px", ...style }} style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
gap: "1px",
...style,
}}
> >
{themeMode === "dark" ? <Brightness7 /> : <Brightness4 />} {themeMode === "dark" ? <LightModeIcon /> : <NightlightIcon />}
<Switch checked={themeMode === "dark"} onChange={toggleTheme} /> <Switch checked={themeMode === "dark"} onChange={toggleTheme} />
</div> </div>
); );