-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Change project folder structure
- Loading branch information
Showing
84 changed files
with
4,038 additions
and
628 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,4 +89,4 @@ test_video.mp4 | |
/tooling/cli.rs | ||
|
||
# UI Build directory | ||
/dist/* | ||
*/dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = [ | ||
"src-tauri", | ||
"manager-app", | ||
"soundcore-lib", | ||
"test_data" | ||
] | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "manager-ui", | ||
"version": "0.1.0", | ||
"type": "module", | ||
"scripts": { | ||
"lint": "eslint ./manager-ui", | ||
"lint:fix": "eslint --fix ./manager-ui", | ||
"format": "prettier --write './**/*.{js,jsx,ts,tsx,css,md,json}' --config ./.prettierrc", | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"preview": "vite preview", | ||
"tauri": "tauri", | ||
"generate-types": "yarn typeshare:tauri && yarn typeshare:soundcore-lib", | ||
"typeshare:soundcore-lib": "typeshare ./soundcore-lib --lang=typescript --output-file=./src/types/soundcore-lib.d.ts", | ||
"typeshare:tauri": "typeshare ./src-tauri --lang=typescript --output-file=./src/types/tauri-backend.d.ts" | ||
}, | ||
"dependencies": { | ||
"@emotion/react": "^11.10.4", | ||
"@emotion/styled": "^11.10.4", | ||
"@fontsource/roboto": "^4.5.8", | ||
"@mui/icons-material": "^5.11.16", | ||
"@mui/material": "^5.12.0", | ||
"@tanstack/react-query": "^4.20.4", | ||
"@tanstack/react-query-devtools": "^4.20.4", | ||
"@tauri-apps/api": "^1.5.0", | ||
"chart.js": "~3.9.1", | ||
"chartjs-plugin-dragdata": "^2.2.4", | ||
"react": "^18.2.0", | ||
"react-chartjs-2": "^4.3.1", | ||
"react-dom": "^18.2.0", | ||
"tauri-plugin-log-api": "https://github.com/tauri-apps/tauri-plugin-log#v1", | ||
"zustand": "^4.5.2" | ||
}, | ||
"devDependencies": { | ||
"@tauri-apps/cli": "^1.5.1", | ||
"@types/node": "^18.7.10", | ||
"@types/react": "^18.2.6", | ||
"@types/react-dom": "^18.0.6", | ||
"@typescript-eslint/eslint-plugin": "^7.1.0", | ||
"@typescript-eslint/parser": "^7.1.0", | ||
"@vitejs/plugin-react": "^4.0.0", | ||
"eslint": "^8.57.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"eslint-plugin-react": "^7.33.2", | ||
"prettier": "^3.2.5", | ||
"typescript": "^5.0.4", | ||
"vite": "^5.1.5" | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import './App.css'; | ||
import { useSoundcoreStore } from './stores/useSoundcoreStore'; | ||
import { BluetoothSearchScreen } from './screens/bluetoothSearch'; | ||
import { useAsyncBridgeEvent } from './hooks/useAsyncBridge'; | ||
import { useShallow } from 'zustand/react/shallow'; | ||
|
||
export const App: React.FC = () => { | ||
const [handleAsyncBridgeEvent, connectedDevices] = useSoundcoreStore( | ||
useShallow((state) => [state.handleAsyncBridgeEvent, state.connectedDevices]) | ||
); | ||
|
||
// Add the event listener to the bridge, which listener is | ||
// provided by the store. | ||
useAsyncBridgeEvent((event) => { | ||
handleAsyncBridgeEvent(event); | ||
}); | ||
|
||
return ( | ||
<React.Fragment> | ||
{connectedDevices.length !== 0 ? <h1>Some connected devices!</h1> : <BluetoothSearchScreen />} | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default App; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import React from 'react'; | ||
import { useSoundcoreStore } from '../stores/useSoundcoreStore'; | ||
import Stack from '@mui/material/Stack/Stack'; | ||
import { | ||
Container, | ||
Fab, | ||
LinearProgress, | ||
List, | ||
ListItem, | ||
ListItemButton, | ||
ListItemIcon, | ||
ListItemText, | ||
Typography | ||
} from '@mui/material'; | ||
import { useShallow } from 'zustand/react/shallow'; | ||
import ArrowForwardIcon from '@mui/icons-material/ArrowForward'; | ||
import { DiscoveredDevice } from '../types/soundcore-lib'; | ||
import BluetoothIcon from '@mui/icons-material/Bluetooth'; | ||
|
||
export const BluetoothSearchScreen: React.FC = () => { | ||
const { isLoading, startScan, latestScanResults } = useSoundcoreStore( | ||
useShallow((state) => ({ | ||
isLoading: state.isLoading, | ||
startScan: state.startScan, | ||
latestScanResults: state.latestScan | ||
})) | ||
); | ||
|
||
const [selectedDevice, setSelectedDevice] = React.useState<DiscoveredDevice>(); | ||
|
||
const connectFabClick = () => { | ||
console.log(selectedDevice); | ||
}; | ||
|
||
// useEffect(() => { | ||
// startScan(); | ||
// }, []); | ||
|
||
return ( | ||
<div> | ||
<Stack | ||
sx={{ | ||
mb: 2, | ||
mt: 2, | ||
width: '100vw', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center' | ||
}}> | ||
<Container | ||
sx={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
flexDirection: 'column', | ||
gap: '0.5rem' | ||
}}> | ||
<Typography color="text.secondary">Select a connected device...</Typography> | ||
{isLoading && <LinearProgress sx={{ width: '100vw', height: '0.15rem' }} />} | ||
{!isLoading && <div style={{ width: '100vw', height: '0.15rem' }}></div>} | ||
</Container> | ||
{latestScanResults && ( | ||
<BluetoothDeviceList devices={latestScanResults} setSelectedDevice={setSelectedDevice} /> | ||
)} | ||
<Fab | ||
onClick={() => connectFabClick()} | ||
variant="extended" | ||
size="medium" | ||
color="primary" | ||
aria-label="add" | ||
sx={{ position: 'absolute', bottom: 16, right: 16 }}> | ||
Connect | ||
<ArrowForwardIcon sx={{ ml: 1 }} /> | ||
</Fab> | ||
<Fab | ||
onClick={() => startScan()} | ||
variant="extended" | ||
size="medium" | ||
color="primary" | ||
aria-label="add" | ||
sx={{ position: 'absolute', bottom: 16, left: 16 }}> | ||
Refresh List | ||
</Fab> | ||
</Stack> | ||
</div> | ||
); | ||
}; | ||
|
||
const BluetoothDeviceList: React.FC<{ | ||
devices: DiscoveredDevice[]; | ||
setSelectedDevice: (device: DiscoveredDevice) => void; | ||
}> = ({ devices, setSelectedDevice }) => { | ||
const [selectedIndex, setSelectedIndex] = React.useState<number>(); | ||
|
||
const onItemClicked = (idx: number) => { | ||
setSelectedDevice(devices[idx]); | ||
setSelectedIndex(idx); | ||
}; | ||
|
||
return ( | ||
<List sx={{ width: '100vw' }}> | ||
{devices.map((device, idx) => ( | ||
<BluetoothDeviceListItem | ||
key={idx} | ||
idx={idx} | ||
device={device} | ||
onClick={onItemClicked} | ||
selected={selectedIndex === idx} | ||
/> | ||
))} | ||
</List> | ||
); | ||
}; | ||
|
||
const BluetoothDeviceListItem: React.FC<{ | ||
idx: number; | ||
device: DiscoveredDevice; | ||
onClick: (idx: number) => void; | ||
selected?: boolean; | ||
}> = ({ idx, device, onClick, selected }) => { | ||
return ( | ||
<ListItem disablePadding> | ||
<ListItemButton selected={selected} onClick={() => onClick(idx)}> | ||
<ListItemIcon> | ||
<BluetoothIcon /> | ||
</ListItemIcon> | ||
<ListItemText primary={device.descriptor.name} /> | ||
</ListItemButton> | ||
</ListItem> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { StateCreator } from 'zustand'; | ||
import { BluetoothAdrr, DiscoveredDevice } from '../types/soundcore-lib'; | ||
import { useAsyncBridgeRequest } from '../hooks/useAsyncBridge'; | ||
|
||
export const createBluetoothSlice: StateCreator<BluetoothSlice> = (set, _get) => ({ | ||
latestScan: null, | ||
isLoading: false, | ||
hasFailed: false, | ||
connectedDevices: [], | ||
setLatestScan: (scanRes: DiscoveredDevice[]) => set({ latestScan: scanRes, isLoading: false }), | ||
startScan: () => { | ||
useAsyncBridgeRequest({ command: 'scan' }) | ||
.then(() => { | ||
set({ isLoading: true }); | ||
}) | ||
.catch((error) => { | ||
console.error(`Could not start scan. ${error}`); | ||
set({ hasFailed: true }); | ||
}); | ||
} | ||
}); | ||
|
||
export interface BluetoothSlice { | ||
latestScan: DiscoveredDevice[] | null; | ||
isLoading: boolean; | ||
hasFailed: boolean; | ||
connectedDevices: Array<BluetoothAdrr>; | ||
setLatestScan: (scanRes: DiscoveredDevice[]) => void; | ||
startScan: () => void; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.