Skip to content

Commit

Permalink
upgrade to MUI v5 and use yarn
Browse files Browse the repository at this point in the history
  • Loading branch information
lideming committed Apr 12, 2022
1 parent 99a6769 commit bc63b06
Show file tree
Hide file tree
Showing 23 changed files with 2,508 additions and 2,340 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
## Install & Run

```shell
npm i
npm run dev
yarn
yarn dev
```

Run with electron (electron is requried):

```shell
yarn electron
```

## Configuration
Expand Down
1,144 changes: 0 additions & 1,144 deletions package-lock.json

This file was deleted.

27 changes: 16 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,26 @@
"serve": "vite preview"
},
"dependencies": {
"@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.11.2",
"@emotion/react": "^11.9.0",
"@emotion/styled": "^11.8.1",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@mui/icons-material": "^5.6.1",
"@mui/material": "^5.6.1",
"@mui/styles": "^5.6.1",
"@yuuza/webfx": "^1.6.1",
"darkreader": "^4.9.31",
"esbuild": "^0.8.57",
"darkreader": "^4.9.46",
"esbuild": "^0.14.36",
"qrcode.react": "^3.0.1",
"react": "^17.0.0",
"react-dom": "^17.0.0"
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"devDependencies": {
"@types/node": "^14.14.41",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@vitejs/plugin-react-refresh": "^1.1.0",
"typescript": "^4.1.2",
"vite": "^2.0.1"
"@types/react": "^18.0.2",
"@types/react-dom": "^18.0.0",
"@vitejs/plugin-react-refresh": "^1.3.6",
"typescript": "^4.6.3",
"vite": "^2.9.1"
}
}
170 changes: 85 additions & 85 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,85 +1,85 @@
import React, { Ref, useEffect, useState } from 'react';
import './App.css';
import { Client } from './Client';
import { className, useWebfxCallback, useWebfxRef } from './utils';
import { BottomNavigation, BottomNavigationAction } from "@material-ui/core";
import Snackbar from '@material-ui/core/Snackbar';
import * as webfx from "@yuuza/webfx";
import { fakeScreen } from './config';
import { activities, ActivityName, defaultActivitiy } from './activities';
import { appTheme } from './appTheme';
import { navContext } from './contexts';

appTheme.init();

function App() {
// The Ref of (router) navigation state is created here.
const [navStateRef] = useState(() => Object.assign(new webfx.Ref<ActivityName>(), { value: defaultActivitiy }));

// Use `useWebfxRef()` to get the value of Ref in React function component.
const navState = useWebfxRef(navStateRef);

// The singleton Client is initialized here.
useEffect(() => {
Client.current.connect();
Client.current.onOpen.add(() => {
if (!Client.current.remoteServer)
Client.current.sendJson({
cmd: 'videoEnabled',
value: true,
})
})
return () => Client.current.close();
}, []);

// Initializing app theme
useEffect(() => {
var keydown = (e: KeyboardEvent) => {
if (e.ctrlKey && e.key == 'd') {
e.preventDefault();
appTheme.toggle();
}
};
window.addEventListener('keydown', keydown);
return () => window.removeEventListener('keydown', keydown);
}, []);

// const connection = useWebfxRef(Client.current.connectionState);

return (
<navContext.Provider value={navStateRef}>
<div className={className("App", { fakeScreen })}>
{/* {connection == 'disconnected' ? <div>(Disconnected)</div> : null} */}
<div className="activity-outer">
{
activities.map(x =>
<x.activity key={x.key} hidden={navState != x.key} navState={navStateRef} />
)
}
</div>
<NavBar valRef={navStateRef} />
{/* <Snackbar elevation={6} variant="filled" /> */}
</div>
</navContext.Provider>
);
}

/** The global fixed navigation bar */
function NavBar(props: { valRef: webfx.Ref<ActivityName>; }) {
const val = useWebfxRef(props.valRef);
return (
<BottomNavigation value={val} showLabels={true} onChange={(e, newval) => {
props.valRef.value = newval;
}} className="my-navbar">
{
activities
.filter(x => x.inBar)
.map(x =>
<BottomNavigationAction key={x.key} label={x.friendlyName} value={x.key} icon={<x.icon />} />
)
}
</BottomNavigation>
);
}

export default App;
import React, { Ref, useEffect, useState } from 'react';
import './App.css';
import { Client } from './Client';
import { className, useWebfxCallback, useWebfxRef } from './utils';
import { BottomNavigation, BottomNavigationAction } from "@mui/material";
import Snackbar from '@mui/material/Snackbar';
import * as webfx from "@yuuza/webfx";
import { fakeScreen } from './config';
import { activities, ActivityName, defaultActivitiy } from './activities';
import { appTheme } from './appTheme';
import { navContext } from './contexts';

appTheme.init();

function App() {
// The Ref of (router) navigation state is created here.
const [navStateRef] = useState(() => Object.assign(new webfx.Ref<ActivityName>(), { value: defaultActivitiy }));

// Use `useWebfxRef()` to get the value of Ref in React function component.
const navState = useWebfxRef(navStateRef);

// The singleton Client is initialized here.
useEffect(() => {
Client.current.connect();
Client.current.onOpen.add(() => {
if (!Client.current.remoteServer)
Client.current.sendJson({
cmd: 'videoEnabled',
value: true,
})
})
return () => Client.current.close();
}, []);

// Initializing app theme
useEffect(() => {
var keydown = (e: KeyboardEvent) => {
if (e.ctrlKey && e.key == 'd') {
e.preventDefault();
appTheme.toggle();
}
};
window.addEventListener('keydown', keydown);
return () => window.removeEventListener('keydown', keydown);
}, []);

// const connection = useWebfxRef(Client.current.connectionState);

return (
<navContext.Provider value={navStateRef}>
<div className={className("App", { fakeScreen })}>
{/* {connection == 'disconnected' ? <div>(Disconnected)</div> : null} */}
<div className="activity-outer">
{
activities.map(x =>
<x.activity key={x.key} hidden={navState != x.key} navState={navStateRef} />
)
}
</div>
<NavBar valRef={navStateRef} />
{/* <Snackbar elevation={6} variant="filled" /> */}
</div>
</navContext.Provider>
);
}

/** The global fixed navigation bar */
function NavBar(props: { valRef: webfx.Ref<ActivityName>; }) {
const val = useWebfxRef(props.valRef);
return (
<BottomNavigation value={val} showLabels={true} onChange={(e, newval) => {
props.valRef.value = newval;
}} className="my-navbar">
{
activities
.filter(x => x.inBar)
.map(x =>
<BottomNavigationAction key={x.key} label={x.friendlyName} value={x.key} icon={<x.icon />} />
)
}
</BottomNavigation>
);
}

export default App;
Loading

0 comments on commit bc63b06

Please sign in to comment.