From 819c14a59271b712261c418d3e4d28c94746e518 Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Sat, 26 Feb 2022 15:05:09 +1100 Subject: [PATCH] Modal and connection modal improvements --- src/components/Connection.tsx | 163 +++++++++++++------------- src/components/connection/BLE.tsx | 45 +++---- src/components/connection/Serial.tsx | 73 ++++++------ src/components/generic/Card.tsx | 1 + src/components/generic/Modal.tsx | 90 ++++++++------ src/components/menu/BottomNav.tsx | 2 +- src/components/modals/VersionInfo.tsx | 87 +++++++------- 7 files changed, 237 insertions(+), 224 deletions(-) diff --git a/src/components/Connection.tsx b/src/components/Connection.tsx index 6534e607..66a6294d 100644 --- a/src/components/Connection.tsx +++ b/src/components/Connection.tsx @@ -1,7 +1,7 @@ import type React from 'react'; import { useEffect } from 'react'; -import { AnimatePresence, m } from 'framer-motion'; +import { m } from 'framer-motion'; import { BLE } from '@components/connection/BLE'; import { HTTP } from '@components/connection/HTTP'; @@ -49,92 +49,87 @@ export const Connection = (): JSX.Element => { }, [meshtasticState.ready, dispatch]); return ( - - {appState.connectionModalOpen && ( - { - dispatch(closeConnectionModal()); - }} - > -
-
-
- { + dispatch(setConnType(parseInt(e.target.value))); + }} + disabled={ + meshtasticState.deviceStatus === + Types.DeviceStatusEnum.DEVICE_CONNECTED + } + /> + {appState.connType === connType.HTTP && ( + + )} + {appState.connType === connType.BLE && ( + + )} + {appState.connType === connType.SERIAL && ( + + )} +
+
+
+
+ {meshtasticState.logs.length === 0 && ( +
+ - {appState.connType === connType.HTTP && ( - - )} - {appState.connType === connType.BLE && ( - - )} - {appState.connType === connType.SERIAL && ( - - )}
-
-
-
- {meshtasticState.logs.length === 0 && ( -
- + )} + {meshtasticState.logs + .filter((log) => { + return ![ + Types.Emitter.handleFromRadio, + Types.Emitter.handleMeshPacket, + Types.Emitter.sendPacket, + ].includes(log.emitter); + }) + .map((log, index) => ( +
+
+ {log.message}
- )} - {meshtasticState.logs - .filter((log) => { - return ![ - Types.Emitter.handleFromRadio, - Types.Emitter.handleMeshPacket, - Types.Emitter.sendPacket, - ].includes(log.emitter); - }) - .map((log, index) => ( -
-
- {log.message} -
-
- ))} -
-
+
+ ))}
- - )} - +
+
+
); }; diff --git a/src/components/connection/BLE.tsx b/src/components/connection/BLE.tsx index 94f649ae..66c79c3c 100644 --- a/src/components/connection/BLE.tsx +++ b/src/components/connection/BLE.tsx @@ -36,26 +36,31 @@ export const BLE = ({ connecting }: BLEProps): JSX.Element => { }); return ( -
- {bleDevices.map((device, index) => ( -
=> { - await setConnection(connType.BLE); - }} - className="flex justify-between rounded-md bg-gray-700 p-2 dark:text-white" - key={index} - > -
{device.name}
- => { - await setConnection(connType.BLE); - }} - icon={} - disabled={connecting} - /> -
- ))} + +
+ {bleDevices.length > 0 ? ( + bleDevices.map((device, index) => ( +
+
{device.name}
+ => { + await setConnection(connType.BLE); + }} + icon={} + disabled={connecting} + /> +
+ )) + ) : ( +
+

No previously connected devices found

+
+ )} +