@expo/vector-icons#FontAwesome JavaScript Examples
The following examples show how to use
@expo/vector-icons#FontAwesome.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ThirdPartyAuthComponent.js From CoughCheckApp with MIT License | 6 votes |
export default function ThirdPartyAuth(props) {
return (
<View style={styles.thirdPartyAuthWrapper}>
<View style={styles.thirdPartyAuthButton}>
<FontAwesome.Button
name="facebook"
backgroundColor="#126FEE"
// onPress={props.loginWithFacebook}
iconStyle={{ marginLeft: 6, marginRight: 18 }}
style={{ height: 40 }}
>
Login with Facebook
</FontAwesome.Button>
</View>
<View style={styles.thirdPartyAuthButton}>
<FontAwesome.Button
name="google"
backgroundColor="#126FEE"
iconStyle={{ marginLeft: 3, marginRight: 15 }}
style={{ height: 40 }}
// onPress={props.loginWithGoogle}
>
Login with Google
</FontAwesome.Button>
</View>
</View>
)
}
Example #2
Source File: ResourceCardNoteActions.js From discovery-mobile-ui with MIT License | 6 votes |
ResourceCardNoteActions = ({
hasNotes, showNotes, setShowNotes, resourceId,
}) => {
const navigation = useNavigation();
if (!hasNotes) {
return (
<TouchableOpacity style={styles.addNoteButton} onPress={() => navigation.navigate('Notes', { resourceId })}>
<Entypo name="squared-plus" size={24} color={Colors.darkgrey2} />
<BaseText variant="title" style={styles.buttonText}>Add Notes</BaseText>
</TouchableOpacity>
);
}
const showNotesText = showNotes ? 'Hide Notes' : 'Show Notes';
const showNotesIcon = showNotes ? 'sticky-note' : 'sticky-note-o';
return (
<View style={styles.actionsContainer}>
<TouchableOpacity style={styles.addNoteButton} onPress={() => navigation.navigate('Notes', { resourceId })}>
<Entypo name="squared-plus" size={24} color={Colors.darkgrey2} />
<BaseText variant="title" style={styles.buttonText}>Add Notes</BaseText>
</TouchableOpacity>
<View style={styles.verticalDivider} />
<TouchableOpacity style={styles.addNoteButton} onPress={() => setShowNotes(!showNotes)}>
<FontAwesome name={showNotesIcon} size={20} color={Colors.darkgrey2} />
<BaseText variant="title" style={styles.buttonText}>{showNotesText}</BaseText>
</TouchableOpacity>
</View>
);
}
Example #3
Source File: styles.js From atendimento-e-agilidade-medica-AAMed with MIT License | 5 votes |
ButtonIcon = styled(FontAwesome)`
position: absolute;
align-self: flex-end;
padding: 20px;
right: 10px;
font-size: 22px;
color: #e2e2e2;
`
Example #4
Source File: index.js From be-the-hero with MIT License | 5 votes |
export default function Details() {
const navigation = useNavigation()
const route = useRoute()
const incident = route.params.incident
const messageToSend = `Olá ${incident.name}, estou entrando em contato pois gostaria de ajudar no caso "${incident.title}" com o valor de R$ ${
Intl.NumberFormat('pt-BR', {
style: 'currency',
currency: 'BRL' }
).format(incident.value)
}`
function navigateBack() {
navigation.goBack()
}
function sendEmail() {
MailComposer.composeAsync({
subject: `Herói do caso: ${incident.title}`,
recipients: [ incident.email ],
body: messageToSend
})
}
function sendWhatsapp() {
Linking.openURL(`whatsapp://send?phone=${incident.whatsapp}&text=${messageToSend}`)
}
return (
<View style={ styles.detailsContainer }>
<View style={ styles.headerContainer }>
<Image source={ logoImage }/>
<TouchableOpacity style={ styles.headerButton } onPress={ navigateBack }>
<Feather name="arrow-left" size={ 28 } color="#E02041"/>
<Text style={ styles.headerButtonText }>Voltar</Text>
</TouchableOpacity>
</View>
<View style={ styles.incident }>
<Text style={ styles.incidentOng }>
{ incident.name } de { incident.city }/{ incident.uf }
</Text>
<Text style={ styles.incidentDescription }>
{ incident.description }
</Text>
<Text style={ styles.incidentValue }>
{
Intl.NumberFormat('pt-BR', {
style: 'currency',
currency: 'BRL' }
).format(incident.value)
}
</Text>
</View>
<View style={ styles.contact }>
<Text style={ styles.heroTitle }>Salve o dia!</Text>
<Text style={ styles.heroTitle }>Seja o herói desse caso</Text>
<Text style={ styles.heroDescription }> Entre em contato:</Text>
<View style={ styles.contactButtons }>
<TouchableOpacity onPress={ sendWhatsapp } style={ styles.buttonWhatsapp }>
<FontAwesome name="whatsapp" size={ 32 } color="#E9FAEF"/>
<Text style={[ styles.buttonText, styles.buttonTextWhatsapp ]}>Whatsapp</Text>
</TouchableOpacity>
<TouchableOpacity onPress={ sendEmail } style={ styles.buttonEmail }>
<FontAwesome name="envelope-o" size={ 30 } color="#FBE8EC"/>
<Text style={[ styles.buttonText, styles.buttonTextEmail ]}>E-mail</Text>
</TouchableOpacity>
</View>
</View>
</View>
)
}
Example #5
Source File: index.js From discovery-mobile-ui with MIT License | 5 votes |
DetailsPanel = ({
navigation, collection, savedRecordsGroupedByType, savedRecords,
}) => {
const { detailsPanelSortingState: sortingState } = collection;
const { RECORD_TYPE, RECORD_DATE, TIME_SAVED } = sortFields;
const hasSavedRecords = Object.entries(savedRecords).length > 0;
const hasMultipleSavedRecords = Object.entries(savedRecords).length > 1;
const savedItemsCount = useSelector(savedRecordsSelector).length;
const handlePressNoteIcon = () => {
navigation.navigate('Notes');
};
const displayAccordion = () => {
switch (sortingState.activeSortField) {
case RECORD_TYPE:
return (
<SubTypeAccordionsContainer
data={savedRecordsGroupedByType}
fromDetailsPanel
/>
);
case RECORD_DATE:
return (
<DateAccordionsContainer
fromDetailsPanel
/>
);
case TIME_SAVED:
return (
<TimeSavedAccordionsContainer
fromDetailsPanel
/>
);
default:
console.warn('No activeSortField in DetailsPanel'); // eslint-disable-line no-console
return null;
}
};
return (
<SafeAreaView style={styles.root}>
<Header style={styles.header}>
<Left>
<TouchableOpacity onPress={() => navigation.goBack()}>
<Entypo name="chevron-thin-left" size={20} color={Colors.headerIcon} />
</TouchableOpacity>
</Left>
<View style={styles.headerTitleContainer}>
{savedItemsCount > 0 && <HeaderCountIcon count={savedItemsCount} outline />}
<Title style={styles.headerText}>{collection?.label}</Title>
</View>
<Right>
<TouchableOpacity onPress={handlePressNoteIcon}>
<FontAwesome name="sticky-note-o" size={20} color={Colors.headerIcon} />
</TouchableOpacity>
</Right>
</Header>
{!hasSavedRecords && (
<View style={styles.zeroStateContainer}>
<Text style={styles.zeroStateText}>No Records in Collection.</Text>
</View>
)}
{hasSavedRecords && (
<>
<SortingHeader
sortingState={sortingState}
hasMultipleSavedRecords={hasMultipleSavedRecords}
/>
<ScrollView>
{displayAccordion()}
</ScrollView>
</>
)}
</SafeAreaView>
);
}
Example #6
Source File: birthday_swipable.js From Reminder-App with MIT License | 4 votes |
export default function renderItem({
item,
index,
itemRefs,
deleteItem,
showmodel,
}) {
const { colors } = useTheme();
function Age() {
let years = Math.floor(moment().diff(moment(item.Date), "years", true));
let days = Math.floor(moment().diff(moment(item.Date), "days", true));
let text = "";
if (years == 0 && days == 0) {
return null;
} else if (days == 0) {
text = `Happy Birthday, ${item.text} is ${years} old`;
} else if (years == 0) {
text = `Lived for ${days} days`;
} else {
text = "Lived for " + days + " Days, \n" + years + " Years old";
}
return (
<Text
style={[
styles.text,
{ color: colors.text, fontSize: 16, marginTop: 15 },
]}
>
{text}
</Text>
);
}
const renderUnderlayLeft = ({ item, percentOpen }) => (
<Animated.View
style={[
styles.row,
styles.underlayLeft,
{ opacity: percentOpen, backgroundColor: colors.elemprim },
]} // Fade in on open
>
<TouchableOpacity onPressOut={() => deleteItem(item)}>
<FontAwesome name="trash-o" size={35} color={colors.text} />
</TouchableOpacity>
</Animated.View>
);
const renderUnderlayRight = ({ item, percentOpen, open, close }) => (
<Animated.View
style={[
styles.row,
styles.underlayRight,
{
backgroundColor: colors.elemsec,
transform: [{ translateX: multiply(sub(1, percentOpen), -400) }], // Translate from left on open
},
]}
>
<TouchableOpacity onPressOut={close}>
<Text style={[styles.text, { color: colors.text }]}>CLOSE</Text>
</TouchableOpacity>
</Animated.View>
);
return (
<SwipeableItem
key={item.key}
item={item}
ref={(ref) => {
if (ref && !itemRefs.get(item.key)) {
itemRefs.set(item.key, ref);
}
}}
onChange={({ open }) => {
if (open) {
// Close all other open items
[...itemRefs.entries()].forEach(([key, ref]) => {
if (key !== item.key && ref) ref.close();
});
}
}}
overSwipe={30}
renderUnderlayLeft={renderUnderlayLeft}
renderUnderlayRight={renderUnderlayRight}
snapPointsLeft={[150]}
snapPointsRight={[175]}
>
<View style={[styles.row, { flex: 1, backgroundColor: colors.tab }]}>
<View
style={{
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
flex: 1,
}}
>
<View style={{ flex: 1, marginVertical: 10, marginHorizontal: 5 }}>
<TouchableOpacity onPress={() => showmodel(item)}>
<Text style={[styles.text, { color: colors.text, flex: 1 }]}>
{item.text == "Tap to change the name"
? item.text
: `${item.text}'s Birthday`}
</Text>
{Age()}
{/* <Text
style={[
styles.text,
{ color: colors.text, fontSize: 16, marginTop: 15 },
]}
>
{Age()}
</Text> */}
</TouchableOpacity>
</View>
<View style={styles.sep} />
<View style={{ flex: 0.3 }}>
<Text
style={[
styles.text,
{
color: colors.text,
fontSize: 14,
textAlign: "center",
lineHeight: 22,
},
]}
>
{`${
moment(item.Date).format("Do ") +
"," +
moment(item.Date).format("MMM")
}`}
</Text>
</View>
</View>
</View>
</SwipeableItem>
);
}
Example #7
Source File: Swipablelist.js From Reminder-App with MIT License | 4 votes |
export default function renderItem({
item,
index,
itemRefs,
deleteItem,
showmodel,
}) {
const { colors } = useTheme();
const renderUnderlayLeft = ({ item, percentOpen }) => (
<Animated.View
style={[
styles.row,
styles.underlayLeft,
{ opacity: percentOpen, backgroundColor: colors.elemprim },
]} // Fade in on open
>
<TouchableOpacity onPressOut={() => deleteItem(item)}>
<FontAwesome name="trash-o" size={35} color={colors.text} />
</TouchableOpacity>
</Animated.View>
);
const renderUnderlayRight = ({ item, percentOpen, open, close }) => (
<Animated.View
style={[
styles.row,
styles.underlayRight,
{
backgroundColor: colors.elemsec,
transform: [{ translateX: multiply(sub(1, percentOpen), -400) }], // Translate from left on open
},
]}
>
<TouchableOpacity onPressOut={close}>
<Text style={[styles.text, { color: colors.text }]}>CLOSE</Text>
</TouchableOpacity>
</Animated.View>
);
return (
<SwipeableItem
key={item.key}
item={item}
ref={(ref) => {
if (ref && !itemRefs.get(item.key)) {
itemRefs.set(item.key, ref);
}
}}
onChange={({ open }) => {
if (open) {
// Close all other open items
[...itemRefs.entries()].forEach(([key, ref]) => {
if (key !== item.key && ref) ref.close();
});
}
}}
overSwipe={30}
renderUnderlayLeft={renderUnderlayLeft}
renderUnderlayRight={renderUnderlayRight}
snapPointsLeft={[150]}
snapPointsRight={[175]}
>
<View style={[styles.row, { flex: 1, backgroundColor: colors.tab }]}>
<View
style={{
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
flex: 1,
}}
>
<View style={{ flex: 1, marginVertical: 10, marginHorizontal: 5 }}>
<TouchableOpacity onPress={() => showmodel(item)}>
<Text style={[styles.text, { color: colors.text, flex: 1 }]}>
{item.text}
</Text>
</TouchableOpacity>
</View>
<View style={styles.sep} />
<View style={{ flex: 0.3 }}>
<Text
style={[
styles.text,
{
color: colors.text,
fontSize: 14,
textAlign: "center",
lineHeight: 22,
},
]}
>
{`${moment(item.Date).format("hh:mm a")}\n${
moment(item.Date).format("Do ") +
"," +
moment(item.Date).format("MMM")
}`}
</Text>
</View>
</View>
</View>
</SwipeableItem>
);
}
Example #8
Source File: index.js From atendimento-e-agilidade-medica-AAMed with MIT License | 4 votes |
export default function Home() {
const navigation = useNavigation();
const [hospitals, setHospitals] = useState([]);
const [user, setUser] = useState(null || '');
const [currentRegion, setCurrentRegion] = useState(null);
const [regionChange, setRegionChange] = useState(null);
const [currentLocation, setCurrentLocation] = useState(null);
const [description, setDescription] = useState('');
const [connection, setConnection] = useState(null);
const [isActiveButton, setIsActiveButton] = useState(false);
const [modal, setModal] = useState(false);
const [approved, setApproved] = useState(false);
const [hospitalName, setHospitalName] = useState('');
const [hospitalDest, setHospitalDest] = useState({});
const [distance, setDistance] = useState('');
const [duration, setDuration] = useState('');
const [userOrigin, setUserOrigin] = useState({ latitude: 0, longitude: 0 });
const [destination, setDestination] = useState({ latitude: 0, longitude: 0 });
// let conn;
useEffect(() => {
const conn = io('http://10.0.0.53:3333', {
query: { user_id: user._id },
});
setConnection(conn);
conn.on('solicitation_response', data => {
setHospitalDest(data);
setHospitalName(data.hospital.name);
data.approved ? setApproved(true) : setApproved(false);
setDestination({
latitude: data.hospital.location.coordinates[1],
longitude: data.hospital.location.coordinates[0],
});
});
conn.on('arrived__manually_mobile', data => {
const { arrived_mobile } = data;
if (arrived_mobile) {
setDuration('');
setDistance('');
setDestination({ latitude: 0, longitude: 0 });
setModal(false);
setApproved(false);
}
});
conn.on('warning', data => {
const { not_here } = data;
if (not_here) {
setDuration('');
setDistance('');
setDestination({ latitude: 0, longitude: 0 });
setModal(false);
setApproved(false);
Alert.alert(
'Você não compareceu',
'Você tem mais 2 oportunidades antes de ser banido'
);
}
});
}, []);
useEffect(() => {
function getUserLogged() {
return new Promise((resolve, result) => {
setTimeout(() => {
resolve(AsyncStorage.getItem('store'));
}, 1000);
});
}
getUserLogged()
.then(data => {
const dataParse = JSON.parse(data);
setUser(dataParse.auth.user);
})
.catch(error => console.log(error));
watchPositionAsync(
{
accuracy: Accuracy.High,
timeInterval: 10000,
enableHighAccuracy: true,
},
data => {
console.log('10s se passaram');
setUserOrigin({
latitude: data.coords.latitude,
longitude: data.coords.longitude,
});
if (approved) {
console.log('aprovado');
fetch(
'https://maps.googleapis.com/maps/api/geocode/json?address=' +
data.coords.latitude +
',' +
data.coords.longitude +
'&key=' +
GOOGLE_MAPS_APIKEY
)
.then(response => response.json())
.then(responseJson => {
setCurrentLocation(responseJson.results[0].formatted_address);
});
if (
calculateDistance(data.coords, destination) == 0.01 ||
calculateDistance(data.coords, destination) == 0.02
) {
console.log('chegou');
connection.emit('arrived', {
hospital_id: hospitalDest.hospital._id,
user,
arrived: true,
});
setApproved(false);
setDestination({ latitude: 0, longitude: 0 });
setModal(!modal);
setDuration(null);
setDistance(null);
}
}
}
);
}, []);
// função que vai carregar a posição inicial do paciente no mapa
useEffect(() => {
async function loadInitialPosition() {
const { granted } = await requestPermissionsAsync();
if (!granted) {
return Alert.alert('Ops', 'Você precisa habilitar a permissão');
}
const { coords } = await getCurrentPositionAsync({
enableHighAccuracy: true,
});
const { latitude, longitude } = coords;
setCurrentRegion({
latitude,
longitude,
latitudeDelta: 0.014,
longitudeDelta: 0.014,
});
setUserOrigin({
latitude: latitude,
longitude: longitude,
});
fetch(
'https://maps.googleapis.com/maps/api/geocode/json?address=' +
latitude +
',' +
longitude +
'&key=' +
GOOGLE_MAPS_APIKEY
)
.then(response => response.json())
.then(responseJson => {
setCurrentLocation(responseJson.results[0].formatted_address);
});
}
loadInitialPosition();
//handlePositionUpdate();
}, [currentRegion]);
useEffect(() => {
async function loadHospitals() {
const { latitude, longitude } = currentRegion || 1;
if (latitude && longitude) {
try {
const response = await api.get('search', {
params: {
longitude,
latitude,
},
});
setHospitals(response.data.hospitais);
} catch (err) {
console.debug('[ERROR: loadHospitals] => ', err);
}
}
}
loadHospitals();
}, [currentRegion]);
async function handleSolicitation() {
const hospital_ids = [];
hospitals.map(hospital => {
hospital_ids.push(hospital._id);
});
if (description === '') return Alert.alert('AVISO', 'Preencha o campo.');
connection.emit('user_solicitation', {
hospital_ids,
user,
description,
currentLocation,
});
Alert.alert(
'Solicitação enviada',
'Sua solicitação de atendimento foi enviada aos hospitais próximos à sua localização.'
);
Keyboard.dismiss();
setDescription('');
setIsActiveButton(true);
setModal(true);
setTimeout(() => {
setIsActiveButton(false);
}, 1000);
}
function rad(x) {
return (x * Math.PI) / 180;
}
function calculateDistance(pointA, pointB) {
let R = 6378137;
let dLat = rad(pointB.latitude - pointA.latitude);
let dLong = rad(pointB.longitude - pointA.longitude);
let a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(rad(pointA.latitude)) *
Math.cos(rad(pointB.latitude)) *
Math.sin(dLong / 2) *
Math.sin(dLong / 2);
let c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
let d = (R * c) / 1000;
return d.toFixed(2);
}
async function handleRegionChanged(region) {
setRegionChange(region);
}
if (!currentRegion) {
return null;
}
return (
<View style={styles.container}>
<Header flag={true} navigation={navigation} />
<MapView
onRegionChangeComplete={handleRegionChanged}
initialRegion={currentRegion}
showsUserLocation
loadingEnabled={true}
style={styles.mapContainer}
>
{approved && !!destination.latitude && !!destination.longitude && (
<MapViewDirections
origin={userOrigin}
onReady={result => {
setDistance(result.distance);
setDuration(result.duration);
}}
onError={err => console.log(err)}
destination={destination}
apikey={GOOGLE_MAPS_APIKEY}
strokeWidth={4}
strokeColor={'#222'}
/>
)}
{hospitals.map(hospital => (
<Marker
key={hospital._id}
coordinate={{
latitude: hospital.location.coordinates[1],
longitude: hospital.location.coordinates[0],
}}
>
<MaterialCommunityIcons
name="hospital-marker"
size={40}
color="#0984e3"
/>
<Callout style={styles.calloutHospital}>
<Text style={styles.name}>{hospital.name}</Text>
<Text style={styles.desc}>
<Text style={styles.tittles}>RUA:</Text>{' '}
{hospital.address.street}
</Text>
<Text>
<Text style={styles.tittles}>BAIRRO:</Text>{' '}
{hospital.address.neighborhood}
</Text>
<Text>
<Text style={styles.tittles}>CEP:</Text> {hospital.address.cep}
</Text>
<Text>
<Text style={styles.tittles}>TELEFONE: </Text>
{hospital.phone}
</Text>
</Callout>
</Marker>
))}
</MapView>
{modal ? (
<Animatable.View
style={styles.modal}
animation="fadeInDown"
duration={1000}
useNativeDriver
>
{!approved ? (
<>
<FontAwesome name="circle" size={15} color="#ff9f1a" />
<Text>Solicitação aguardando aprovação do hospital.</Text>
</>
) : (
<>
<FontAwesome name="circle" size={15} color="#0ec445" />
<Text>
Sua solicitação foi aprovada em {hospitalName}.{'\n'}
Tempo estimado: {`${Math.round(duration)} min \n`}
Distância: {`${Number(distance).toFixed(2)} km`}
</Text>
</>
)}
</Animatable.View>
) : null}
{!approved && (
<View style={styles.searchForm}>
<TextInput
style={styles.searchInput}
placeholder="Descrição..."
placeholderTextColor="#999"
autoCapitalize="words"
autoCorrect={false}
multiline
value={description}
onChangeText={setDescription}
/>
<TouchableOpacity
onPress={handleSolicitation}
style={
isActiveButton
? [styles.loadButton, { backgroundColor: '#006bad55' }]
: styles.loadButton
}
disabled={isActiveButton}
>
<MaterialIcons name="send" size={25} color="#fff" />
</TouchableOpacity>
</View>
)}
<View style={styles.mapDrawerOverlay} />
</View>
);
}
Example #9
Source File: ViewProfile.js From salyd with GNU General Public License v3.0 | 4 votes |
ViewProfile = ({ navigation }) => {
const { user, token } = useContext(GlobalContext);
const { _id, name, email, phone, image } = user;
const logout = async () => {
const token = await AsyncStorage.removeItem("token")
const user = await AsyncStorage.removeItem("user")
if (!token) {
navigation.replace("Login");
}
}
console.log(image)
return (
<React.Fragment>
<Header navigation={navigation} isBack> View Profile </Header>
<View style={styles.root}>
<View style={{ alignItems: "center" }}>
<Image
style={{ width: 140, height: 140, borderRadius: 140 / 2, marginTop: 50 }}
source={{ uri: (image ? image : "https://sanjaymotels.com/wp-content/uploads/2019/01/testimony.png") }}
/>
</View>
<View style={{ alignItems: "center", margin: 15 }}>
<Text style={styles.name}> {name} </Text>
</View>
<TouchableOpacity onPress={() => {
navigation.navigate('EditProfile', {
name, email, phone
})
}}>
<View style={styles.cardContainer}>
<View style={styles.mycard}>
<View style={styles.cardContent}>
<FontAwesome name="user-circle" style={styles.icon} />
<Text style={styles.mytext}>Account Details</Text>
<Ionicons name="ios-arrow-forward" style={styles.arrow} />
</View>
</View>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={() => {
navigation.navigate('RecentOrders')
}}>
<View style={styles.mycard}>
<View style={styles.cardContent}>
<MaterialCommunityIcons name="food-variant" style={styles.icon} />
<Text style={styles.mytext}>Order History</Text>
<Ionicons name="ios-arrow-forward" style={styles.arrow} />
</View>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={() => {
navigation.navigate('Contact')
}}>
<View style={styles.mycard} onPress={() => {
navigation.navigate('Contact')
}}>
<View style={styles.cardContent}>
<Feather name="phone-call" style={styles.icon} />
<Text style={styles.mytext}>Contact Us</Text>
<Ionicons name="ios-arrow-forward" style={styles.arrow} />
</View>
</View>
</TouchableOpacity>
<View style={{
justifyContent: "center",
alignItems: "center"
}}>
<Button onPressFunction={() => logout()}>Logout</Button>
</View>
</View>
</React.Fragment>
)
}
Example #10
Source File: index.js From be-the-hero with MIT License | 4 votes |
export default function Detail() {
const navigation = useNavigation();
const route = useRoute();
const incident = route.params.incident;
const messege = `Olá ${
incident.name
}, estou entrando em contato pois gostaria de ajudar no caso "${
incident.title
}" com o valor de ${Intl.NumberFormat('pt-BR', {
style: 'currency',
currency: 'BRL',
}).format(incident.value)}`;
function navigateBack() {
navigation.goBack();
}
function sendMail() {
MailComposer.composeAsync({
subject: `Herói do caso: ${incident.title}`,
recipients: [incident.email],
body: messege,
});
}
function sendWhatsapp() {
Linking.openURL(
`whatsapp://send?phone=+55${incident.whatsapp}&text=${messege}`
);
}
return (
<View style={styles.container}>
<View style={styles.header}>
<Image source={logoImg} />
<TouchableOpacity onPress={navigateBack}>
<Feather name="arrow-left" size={20} color="#E02041" />
</TouchableOpacity>
</View>
<View style={styles.incident}>
<Text style={[styles.incidentProperty, { marginTop: 0 }]}>ONG:</Text>
<Text style={styles.incidentValue}>
{incident.name} de {incident.city}/{incident.uf}
</Text>
<Text style={styles.incidentProperty}>CASO:</Text>
<Text style={styles.incidentValue}>{incident.description}</Text>
<Text style={styles.incidentProperty}>VALOR:</Text>
<Text style={styles.incidentValue}>
{Intl.NumberFormat('pt-BR', {
style: 'currency',
currency: 'BRL',
}).format(incident.value)}
</Text>
</View>
<View style={styles.contactBox}>
<Text style={styles.heroTitle}>Salve o dia!</Text>
<Text style={styles.heroTitle}>Seja o herói desse caso.</Text>
<Text style={styles.heroDescription}>Entre em contato:</Text>
<View style={styles.actions}>
<TouchableOpacity style={styles.action} onPress={sendWhatsapp}>
<FontAwesome name="whatsapp" size={20} color="#fff" />
<Text style={styles.actionText}>Whatsapp</Text>
</TouchableOpacity>
<TouchableOpacity style={styles.action} onPress={sendMail}>
<Icon name="mail" size={20} color="#fff" />
<Text style={styles.actionText}>Email</Text>
</TouchableOpacity>
</View>
</View>
</View>
);
}