src/components/buttons/ToDiaryButton.js
import React from 'react';
import {StyleSheet, TouchableOpacity} from 'react-native';
import ImageWrapper from '../wrappers/ImageWrapper';
import {globalStyles} from '../../styles/styles';
import {UIColors} from '../../utils/ColorConstants';
/**
* Component representing the button to navigate to diary.
* @param {Object} props - Properties
* @param {Object} props.style - Styling of the component
* @param {function} props.onPress - Action to be executed when the button is pressed
* @returns {Object} Button to navigate to diary
*/
export default function ToDiaryButton(props) {
// Retrieve props:
const style = props.style;
const onPressAction = props.onPress;
const buttonStyle = style === undefined ? styles.defaultPosition : style;
return (
<TouchableOpacity
onPress={onPressAction}
style={[styles.container, globalStyles.shadow, buttonStyle]}>
<ImageWrapper
source={require('../../assets/icons/diaryIcon.png')}
wrapperStyle={styles.icon}
/>
</TouchableOpacity>
);
}
/** Local styles
* @type {Object}
*/
const styles = StyleSheet.create({
container: {
width: 220,
aspectRatio: 1,
borderRadius: 30,
backgroundColor: UIColors.BACKGROUND_BUTTON,
borderWidth: 5,
borderColor: 'white',
},
defaultPosition: {
position: 'absolute',
bottom: '20%',
right: '25%',
},
icon: {
padding: 15,
width: '100%',
height: '100%',
},
});