Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: minor UI improvements #24

Merged
merged 3 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ PODS:
- React-utils (= 0.74.3)
- RNFS (2.20.0):
- React-Core
- RNScreens (3.34.0):
- RNScreens (3.32.0):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1476,10 +1476,10 @@ SPEC CHECKSUMS:
React-utils: 6f7ac39d9a0de447d4334bb25d144a28c0c5d8c9
ReactCommon: 4a09c7d8a06e93c1e2e988a3b9f3db3d2449f2fc
RNFS: 4ac0f0ea233904cb798630b3c077808c06931688
RNScreens: db442e7b8c7bc8befec2ce057927305ff8598cc8
RNScreens: fd2722bcc59f36a629205af8cc7b48e4bc0d09f5
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: eed50599a85bd9f6882a9938d118aed6a397db9c
Yoga: bd92064a0d558be92786820514d74fc4dddd1233

PODFILE CHECKSUM: c096dde368bb25db14174c2f8e4a6b2095e483e8

COCOAPODS: 1.15.2
COCOAPODS: 1.14.3
7 changes: 5 additions & 2 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ const CryptoScreen = () => {
return (
<View style={styles.cryptoContainer}>
<View style={styles.cryptoView}>
<Text>{result}</Text>
<Text style={styles.cryptoText}>{result}</Text>
</View>
<ScrollView style={styles.scrollView}>
<Button
text="generateKeyPair"
onPressFunction={() => {
AbrevvaCrypto.generateKeyPair().then((ret: any) => {
setResult(`Privat Key:\n${ret.privateKey}\n\nPublic Key\n:${ret.publicKey}`);
setResult(`Privat Key:\n${ret.privateKey}\n\nPublic Key:\n${ret.publicKey}`);
});
}}
/>
Expand Down Expand Up @@ -129,6 +129,9 @@ export const styles = StyleSheet.create({
marginTop: 20,
height: 150,
},
cryptoText: {
color: 'black',
},
cryptoContainer: {
alignItems: 'center',
},
Expand Down
31 changes: 18 additions & 13 deletions example/src/BleScreenComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,28 @@ const advManufacturerDataParser = new Parser()

export const BleScreen = () => {
const [statusCode, setStatusCode] = useState('none');
const [startScanNoftification, setStartScanNoftification] = useState(
'pull down to start scanning',
);

return (
<>
<ScanResults setStatus={setStatusCode} />
<Text style={bleStyles.scanNotification}>{startScanNoftification}</Text>
<ScanResults
props={{ setStatus: setStatusCode, setScanNoftification: setStartScanNoftification }}
/>
<SafeAreaView style={bleStyles.status}>
<Text>Last received Statuscode '{statusCode}'</Text>
</SafeAreaView>
</>
);
};

const ScanResults = ({ setStatus }) => {
const ScanResults = ({ props }) => {
const [deviceList, setdeviceList] = useState<ScanResult[]>([]);
const [refreshing, setRefreshing] = useState(false);
const setStatus = props.setStatus;
const setScanNoftification = props.setScanNoftification;

const scanRequestCallback = (data: ScanResult) => {
if (data.manufacturerData !== undefined && '2153' in data.manufacturerData) {
Expand All @@ -114,11 +122,13 @@ const ScanResults = ({ setStatus }) => {

const onRefresh = () => {
setStatus('none');
setScanNoftification('scanning ...');
setRefreshing(true);
setdeviceList([]);

const timeout: NodeJS.Timeout = setTimeout(() => {
setRefreshing(false);
setScanNoftification('');
}, SCAN_TIMEOUT);
AbrevvaBle.stopLEScan()
.then(() => {
Expand All @@ -139,17 +149,7 @@ const ScanResults = ({ setStatus }) => {
};

useEffect(() => {
AbrevvaBle.initialize(true).then(() => {
void AbrevvaBle.requestLEScan(
scanRequestCallback,
(address: string) => {
console.log(`connected to Device =${address}`);
},
(address: string) => {
console.log(`disconnected from Device =${address}`);
},
);
});
AbrevvaBle.initialize(true);
}, []);

return (
Expand Down Expand Up @@ -308,6 +308,11 @@ async function mobileIdentificationMediumService(data: ScanResult, setStatus: an
}

const bleStyles = StyleSheet.create({
scanNotification: {
margin: 'auto',
color: 'black',
marginVertical: 10,
},
BleScanResult: {
justifyContent: 'center',
alignItems: 'center',
Expand Down
Loading