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,120 +1,122 @@
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
sx={{
justifyContent: "flex-start",
}}
>
<AppLibrarySubTitle
sx={{
fontSize: "30px",
}}
>
Apps Dashboard
</AppLibrarySubTitle>
</AppsContainer>
<Spacer height="20px" />
<AppsContainer <AppsContainer
sx={{ sx={{
justifyContent: "flex-start", justifyContent: "flex-start",
}} }}
> >
<Box sx={{ <AppLibrarySubTitle
display: 'flex', sx={{
gap: '20px', fontSize: "30px",
alignItems: 'center', }}
backgroundColor: '#1f2023', >
padding: '7px', Apps Dashboard
borderRadius: '20px', </AppLibrarySubTitle>
width: '100%', </AppsContainer>
maxWidth: '500px'
}}> <Spacer height="20px" />
<Input
id="standard-adornment-name" <AppsContainer
value={qortalUrl} sx={{
onChange={(e) => { justifyContent: "flex-start",
setQortalUrl(e.target.value) }}
}} >
disableUnderline <Box
autoComplete='off' sx={{
autoCorrect='off' display: "flex",
placeholder="qortal://" gap: "20px",
alignItems: "center",
backgroundColor: "#1f2023",
padding: "7px",
borderRadius: "20px",
width: "100%",
maxWidth: "500px",
}}
>
<Input
id="standard-adornment-name"
value={qortalUrl}
onChange={(e) => {
setQortalUrl(e.target.value);
}}
disableUnderline
autoComplete="off"
autoCorrect="off"
placeholder="qortal://"
sx={{
width: "100%",
color: "white",
"& .MuiInput-input::placeholder": {
color: "rgba(84, 84, 84, 0.70) !important",
fontSize: "20px",
fontStyle: "normal",
fontWeight: 400,
lineHeight: "120%", // 24px
letterSpacing: "0.15px",
opacity: 1,
},
"&:focus": {
outline: "none",
},
// Add any additional styles for the input here
}}
onKeyDown={(e) => {
if (e.key === "Enter" && qortalUrl) {
openQortalUrl();
}
}}
/>
<ButtonBase onClick={() => openQortalUrl()}>
<ArrowOutwardIcon
sx={{ sx={{
width: '100%', color: qortalUrl ? "white" : "rgba(84, 84, 84, 0.70)",
color: 'white',
'& .MuiInput-input::placeholder': {
color: 'rgba(84, 84, 84, 0.70) !important',
fontSize: '20px',
fontStyle: 'normal',
fontWeight: 400,
lineHeight: '120%', // 24px
letterSpacing: '0.15px',
opacity: 1
},
'&:focus': {
outline: 'none',
},
// Add any additional styles for the input here
}}
onKeyDown={(e) => {
if (e.key === 'Enter' && qortalUrl) {
openQortalUrl();
}
}} }}
/> />
<ButtonBase onClick={()=> openQortalUrl()}> </ButtonBase>
<ArrowOutwardIcon sx={{ </Box>
color: qortalUrl ? 'white' : 'rgba(84, 84, 84, 0.70)' </AppsContainer>
}} />
</ButtonBase>
</Box>
</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>
); );