Skip to content

Commit

Permalink
🎨 Run prettier, fix syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
shankari committed Mar 29, 2024
1 parent 29e434c commit 022ccec
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 35 deletions.
18 changes: 9 additions & 9 deletions www/js/bluetooth/BluetoothCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ const BluetoothCard = ({ device, isClassic, isScanningBLE }: Props) => {
// If we don't do this, the results start accumulating in the device object
// first call, we put a result into the device
// second call, the device already has a result, so we put another one in...
const deviceWithoutResult = {...device};
const deviceWithoutResult = { ...device };
deviceWithoutResult.result = undefined;
window['cordova'].plugins.locationManager.getDelegate().didDetermineStateForRegion({
region: deviceWithoutResult,
eventType: "didDetermineStateForRegion",
state: "CLRegionStateInside"
eventType: 'didDetermineStateForRegion',
state: 'CLRegionStateInside',
});
}

Expand All @@ -45,12 +45,12 @@ const BluetoothCard = ({ device, isClassic, isScanningBLE }: Props) => {
left={() => <List.Icon icon={device.in_range ? 'access-point' : 'access-point-off'} />}
/>
<Card.Content>
<Text style={{ borderColor: colors.primary }} variant="bodyMedium">{device.result}</Text>
<Button
mode="elevated"
onPress={fakeCallback}>
Fake callback
</Button>
<Text style={{ borderColor: colors.primary }} variant="bodyMedium">
{device.result}
</Text>
<Button mode="elevated" onPress={fakeCallback}>
Fake callback
</Button>
</Card.Content>
</Card>
);
Expand Down
51 changes: 26 additions & 25 deletions www/js/bluetooth/BluetoothScanPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
*/

const BluetoothScanPage = ({ ...props }: any) => {
const STATIC_ID = "edu.berkeley.eecs.emission";
const STATIC_ID = 'edu.berkeley.eecs.emission';

const { t } = useTranslation();
const [bluetoothClassicList, setBluetoothClassicList] = useState<BluetoothClassicDevice[]>([]);
Expand Down Expand Up @@ -90,7 +90,7 @@ const BluetoothScanPage = ({ ...props }: any) => {
...prevDevices,
[uuid]: {
...prevDevices[uuid],
result: result,
result: result,
in_range: status,
},
}));
Expand Down Expand Up @@ -178,14 +178,14 @@ const BluetoothScanPage = ({ ...props }: any) => {

// Add a beacon with the new UUID to the list of BLE devices to scan
function addNewUUID(newUUID: string, newMajor: number, newMinor: number) {
console.log("Before adding UUID "+newUUID+" entries = "+sampleBLEDevices);
const devicesWithAddition = {...sampleBLEDevices};
console.log('Before adding UUID ' + newUUID + ' entries = ' + sampleBLEDevices);
const devicesWithAddition = { ...sampleBLEDevices };
devicesWithAddition[newUUID] = {
identifier: STATIC_ID,
minor: newMajor,
major: newMinor,
in_range: false,
}
};
setSampleBLEDevices(devicesWithAddition);
setNewUUID(null);
setNewMajor(undefined);
Expand All @@ -211,7 +211,9 @@ const BluetoothScanPage = ({ ...props }: any) => {
<div>
{beaconsAsArray.map((beacon) => {
if (beacon) {
return <BluetoothCard device={beacon} isScanningBLE={isScanningBLE} key={beacon.uuid} />;
return (
<BluetoothCard device={beacon} isScanningBLE={isScanningBLE} key={beacon.uuid} />
);
}
})}
</div>
Expand Down Expand Up @@ -286,25 +288,24 @@ const BluetoothScanPage = ({ ...props }: any) => {
<ScrollView style={{ flex: 1 }} contentContainerStyle={{ flex: 1 }}>
<BlueScanContent />
</ScrollView>
<TextInput
label="New UUID (mandatory)"
value={newUUID || ''}
onChangeText={(t) => setNewUUID(t.toUpperCase())}
/>
<TextInput
label="Major (optional)"
value={newMajor || ''}
onChangeText={(t) => setNewMajor(t)}
/>
<TextInput
label="Minor (optional)"
value={newMinor || ''}
onChangeText={(t) => setNewMinor(t)}
/>
<Button disabled={!(newUUID)}
onPress={() => addNewUUID(newUUID, newMajor, newMinor)}>
Add New Beacon To Scan
</Button>
<TextInput
label="New UUID (mandatory)"
value={newUUID || ''}
onChangeText={(t) => setNewUUID(t.toUpperCase())}
/>
<TextInput
label="Major (optional)"
value={newMajor || ''}
onChangeText={(t) => setNewMajor(t)}
/>
<TextInput
label="Minor (optional)"
value={newMinor || ''}
onChangeText={(t) => setNewMinor(t)}
/>
<Button disabled={!newUUID} onPress={() => addNewUUID(newUUID, newMajor, newMinor)}>
Add New Beacon To Scan
</Button>
</SafeAreaView>
</Modal>
</>
Expand Down
8 changes: 7 additions & 1 deletion www/js/types/BluetoothDevices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ export type BLEBeaconDevice = {
type_name?: string; // e.g., "BeaconRegion"; used for callback
};
export type BLEDeviceList = {
[key: string]: { identifier: string; minor: number; major: number; result: string, in_range: boolean };
[key: string]: {
identifier: string;
minor: number;
major: number;
result: string;
in_range: boolean;
};
};

export type BLEPluginCallback = {
Expand Down

0 comments on commit 022ccec

Please sign in to comment.