11import MaterialIcons from '@react-native-vector-icons/material-icons' ;
22import React , { useState } from 'react' ;
3- import { Button , Text , View } from 'react-native' ;
3+ import { Button , StyleSheet , Text , View } from 'react-native' ;
44import nfcManager from 'react-native-nfc-manager' ;
55
6- type NfcEnabledProps = {
7- nfcEnabled : string ,
6+ type NfcEnabledProps = {
7+ nfcEnabled : string ;
88} ;
99
10- function NfcEnabledScreen ( { nfcEnabled} : NfcEnabledProps ) {
11- const [ restart , setRestart ] = useState ( false ) ;
10+ function NfcEnabledScreen ( { nfcEnabled } : NfcEnabledProps ) {
11+ const [ restart , setRestart ] = useState ( false ) ;
1212
13- const enableNfc = async ( ) => {
14- await nfcManager . goToNfcSetting ( ) ;
15- setRestart ( true ) ;
16- return ;
17- }
13+ const enableNfc = async ( ) => {
14+ await nfcManager . goToNfcSetting ( ) ;
15+ setRestart ( true ) ;
16+ return ;
17+ } ;
1818
19- return (
20- < >
21- {
22- nfcEnabled === "unsupported" ?
23- < View style = { { flex : 1 , alignItems : 'center' , justifyContent : 'center' , margin : 10 } } >
24- < MaterialIcons name = { "error-outline" } size = { 100 } color = "#b00020" style = { { padding : 10 } } />
25- < Text style = { { fontSize : 30 } } > NFC is unsupported</ Text >
26- < Text style = { { fontSize : 20 , textAlign : "center" , marginBottom : 20 } } >
27- NFC capability is unsupported on this device.
28- </ Text >
29- </ View >
30- :
31- ! restart ?
32- < View style = { { flex : 1 , alignItems : 'center' , justifyContent : 'center' , margin : 10 } } >
33- < MaterialIcons name = { "error-outline" } size = { 100 } color = "#b00020" style = { { padding : 10 } } />
34- < Text style = { { fontSize : 30 } } > NFC is disabled</ Text >
35- < Text style = { { fontSize : 20 , textAlign : "center" , marginBottom : 20 } } >
36- Please enable NFC and restart the app to continue
37- </ Text >
38- < Button onPress = { enableNfc } color = "#EEB211" title = "Enable NFC" />
39- </ View >
40- :
41- < View style = { { flex : 1 , alignItems : 'center' , justifyContent : 'center' , margin : 10 } } >
42- < MaterialIcons name = { "error-outline" } size = { 100 } color = "#B78300" style = { { padding : 10 } } />
43- < Text style = { { fontSize : 30 } } > Restart to continue</ Text >
44- < Text style = { { fontSize : 20 , textAlign : "center" , marginBottom : 20 } } >
45- If you've enabled NFC, just restart the app and you'll be on your way!
46- </ Text >
47- </ View >
48- }
49- </ >
50- ) ;
19+ return (
20+ < >
21+ { nfcEnabled === 'unsupported' ? (
22+ < View style = { styles . view } >
23+ < MaterialIcons
24+ name = { 'error-outline' }
25+ size = { 100 }
26+ color = "#b00020"
27+ style = { styles . errorIcon }
28+ />
29+ < Text style = { styles . headerText } > NFC is unsupported</ Text >
30+ < Text style = { styles . bodyText } > NFC capability is unsupported on this device.</ Text >
31+ </ View >
32+ ) : ! restart ? (
33+ < View style = { styles . view } >
34+ < MaterialIcons
35+ name = { 'error-outline' }
36+ size = { 100 }
37+ color = "#b00020"
38+ style = { styles . errorIcon }
39+ />
40+ < Text style = { styles . headerText } > NFC is disabled</ Text >
41+ < Text style = { styles . bodyText } > Please enable NFC and restart the app to continue</ Text >
42+ < Button onPress = { enableNfc } color = "#EEB211" title = "Enable NFC" />
43+ </ View >
44+ ) : (
45+ < View style = { styles . view } >
46+ < MaterialIcons
47+ name = { 'error-outline' }
48+ size = { 100 }
49+ color = "#B78300"
50+ style = { styles . errorIcon }
51+ />
52+ < Text style = { styles . headerText } > Restart to continue</ Text >
53+ < Text style = { styles . bodyText } >
54+ { `If you've enabled NFC, just restart the app and you'll be on your way!` }
55+ </ Text >
56+ </ View >
57+ ) }
58+ </ >
59+ ) ;
5160}
5261
53- export default NfcEnabledScreen ;
62+ const styles = StyleSheet . create ( {
63+ bodyText : {
64+ fontSize : 20 ,
65+ marginBottom : 20 ,
66+ textAlign : 'center' ,
67+ } ,
68+ errorIcon : {
69+ padding : 10 ,
70+ } ,
71+ headerText : {
72+ fontSize : 30 ,
73+ } ,
74+ view : {
75+ alignItems : 'center' ,
76+ flex : 1 ,
77+ justifyContent : 'center' ,
78+ margin : 10 ,
79+ } ,
80+ } ) ;
81+
82+ export default NfcEnabledScreen ;
0 commit comments