import React, {useEffect, useState} from 'react'; import type {PropsWithChildren} from 'react'; import { Button, FlatList, SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, useColorScheme, View, } from 'react-native'; import Toast from 'react-native-toast-message'; import BleService, {Peripheral} from './ble-service'; const bleService = new BleService(); function App(): React.JSX.Element { bleService: BleService; const [isScanning, setIsScanning] = useState(false); const [peripherals, setPeripherals] = useState< Map >([]); useEffect(() => { bleService.setEvents({ bleManagerConnectPeripheral: e => console.log(e.peripheral), bleManagerStartSuccess: () => { Toast.show({ type: 'info', text1: 'BleManager started..', }); }, bleManagerDiscoverPeripheral: p => { console.log(p.advertising.localName); }, bleManagerStopScan: () => { setIsScanning(false); setPeripherals(bleService.getPeripherals()); console.log('scan: stop;'); Toast.show({ type: 'success', text1: 'Scan stop..', position: 'bottom', }); }, bleManagerStartScan: () => { setIsScanning(true); console.log('scan: start;'); Toast.show({ type: 'info', text1: 'Scan start..', position: 'bottom', }); }, bleManagerDidUpdateValueForCharacteristic: a => { console.log(a.value); }, }); return () => bleService.destroy(); }); return ( <> Hello, World!!!! {isScanning ? SKANUJE! : Juz nie}