generated from Arquisoft/radarin_0
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from Arquisoft/publicKeyToStore
Public key to store
- Loading branch information
Showing
5 changed files
with
85 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,70 @@ | ||
import React from 'react'; | ||
import { Image } from 'react-native'; | ||
import { View, Text, TextInput, Button, Linking} from 'react-native'; | ||
import { Card} from 'react-native-elements' | ||
import styles from './MyStyles' | ||
import React, { useState } from 'react'; | ||
import { BackHandler, Image } from 'react-native'; | ||
import { View, Text, TextInput, Button, Linking, StyleSheet } from 'react-native'; | ||
import { Card } from 'react-native-elements'; | ||
import styles from './MyStyles'; | ||
import { BarCodeScanner } from "expo-barcode-scanner"; | ||
import * as SecureStore from "expo-secure-store"; | ||
|
||
export default function LoginScreen({ navigation }) { | ||
const [hasCameraPermission, setHasCameraPermission] = useState(null); | ||
const [scanned, setScanned] = useState(false); | ||
const [showScanner, setShowScanner] = useState(false); | ||
|
||
|
||
async function save(key, value) { | ||
await SecureStore.setItemAsync(key, value); | ||
} | ||
|
||
export default function LoginScreen({navigation}) { | ||
React.useLayoutEffect(() => { | ||
navigation.setOptions({ | ||
headerLeft: (() => ( | ||
<View style={styles.iconWrapper}> | ||
<Image | ||
style={styles.icon} | ||
source={require('./assets/icon.png')} | ||
/> | ||
</View> | ||
) | ||
), | ||
}); | ||
<Image | ||
style={styles.icon} | ||
source={require('./assets/icon.png')} | ||
/> | ||
</View> | ||
)), | ||
}), | ||
(async () => { | ||
const { status } = await BarCodeScanner.requestPermissionsAsync(); | ||
setHasCameraPermission(status == 'granted'); | ||
})(); | ||
}, [navigation]); | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<Card containerStyle={styles.card}> | ||
<Card.Title style={styles.signinCardTitle}>Sign in</Card.Title> | ||
<Card.Divider/> | ||
<Text style={styles.normalText}>Introduce your provider URL:</Text> | ||
<TextInput placeholder='https://inrupt.net' style={styles.textInput}></TextInput> | ||
<Text style={styles.smallText}>Don't have one? You can get it here: <Text style={{color: '#3f51b5'}} onPress={() => {Linking.openURL('https://inrupt.com/')}}> Inrupt </Text> </Text> | ||
<View style={styles.cardButton}> | ||
<Button color="#3f51b5" title='Log in'onPress={() => {navigation.navigate('Radarin')}}>Login</Button> | ||
</View> | ||
</Card> | ||
|
||
</View> | ||
); | ||
const handleQrScanned = ({ type, data }) => { | ||
setScanned(true); | ||
alert(data); | ||
save("op234iyu5v6oy234iuv6", data); | ||
navigation.navigate('Radarin'); | ||
}; | ||
|
||
function changeShowScanner() { | ||
setShowScanner(true); | ||
} | ||
|
||
if (showScanner) { | ||
return ( | ||
<BarCodeScanner | ||
onBarCodeScanned={scanned ? undefined : handleQrScanned} | ||
style={StyleSheet.absoluteFillObject} | ||
/> | ||
); | ||
} else { | ||
return ( | ||
<View style={styles.container}> | ||
<Card containerStyle={styles.card}> | ||
<Card.Title style={styles.signinCardTitle}>Sign in</Card.Title> | ||
<Card.Divider /> | ||
<Text style={styles.normalText}>Click the button and scan the QR:</Text> | ||
<Text style={styles.smallText}>Don't have the QR? You can get it here: <Text style={{ color: '#3f51b5' }} onPress={() => { Linking.openURL('https://inrupt.com/') }}> Inrupt </Text> </Text> | ||
<View style={styles.cardButton}> | ||
<Button color="#3f51b5" title='Scan' onPress={changeShowScanner}>Scan</Button> | ||
</View> | ||
</Card> | ||
|
||
</View> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,5 +97,5 @@ export default StyleSheet.create({ | |
alignSelf: 'center', | ||
padding:10, | ||
paddingBottom:30, | ||
} | ||
}, | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters