From 8640fdb99bdf35eb74923269427caa555caa9a67 Mon Sep 17 00:00:00 2001 From: Berend Sliedrecht Date: Thu, 26 Sep 2024 15:57:21 +0200 Subject: [PATCH] feat: split up regular and credo flow Signed-off-by: Berend Sliedrecht --- example/src/App.tsx | 82 ++++++++---------------- example/src/RequestPermissions.tsx | 30 +++------ example/src/bigPresentationMsg.ts | 37 ----------- example/src/presentationMsg.ts | 17 ----- example/src/{ => regular}/Central.tsx | 2 +- example/src/{ => regular}/Peripheral.tsx | 2 +- example/src/regular/Screen.tsx | 81 +++++++++++++++++++++++ 7 files changed, 117 insertions(+), 134 deletions(-) delete mode 100644 example/src/bigPresentationMsg.ts delete mode 100644 example/src/presentationMsg.ts rename example/src/{ => regular}/Central.tsx (98%) rename example/src/{ => regular}/Peripheral.tsx (98%) create mode 100644 example/src/regular/Screen.tsx diff --git a/example/src/App.tsx b/example/src/App.tsx index a283560..b7e5e9b 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,64 +1,37 @@ -import { isBleEnabled } from '@animo-id/react-native-ble-didcomm' -import * as React from 'react' -import { Alert, Button, PermissionsAndroid, Platform, StyleSheet, Text, View } from 'react-native' -import { Central } from './Central' -import { Peripheral } from './Peripheral' -import { Spacer } from './Spacer' +import React, { type ReactElement, useState } from 'react' +import { Button, StyleSheet, View } from 'react-native' -const requestPermissions = async () => { - await PermissionsAndroid.requestMultiple([ - 'android.permission.ACCESS_FINE_LOCATION', - 'android.permission.BLUETOOTH_CONNECT', - 'android.permission.BLUETOOTH_SCAN', - 'android.permission.BLUETOOTH_ADVERTISE', - 'android.permission.ACCESS_COARSE_LOCATION', - ]) -} +import { Spacer } from './Spacer' +import { RegularScreen } from './regular/Screen' export const App = () => { - const [isCentral, setIsCentral] = React.useState(false) - const [isPeripheral, setIsPeripheral] = React.useState(false) + const [flow, setFlow] = useState<'regular' | 'credo'>(undefined) + + let component: ReactElement - const asCentral = () => setIsCentral(true) + if (!flow) { + component = ( + <> +