Last active
July 30, 2019 10:17
-
-
Save vadimkorr/25ae17c16de7c7949ae77415ea9a5ba4 to your computer and use it in GitHub Desktop.
Basic implementation
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
import React from "react"; | |
import PropTypes from "prop-types"; | |
import { StyleSheet, TouchableOpacity, Text } from "react-native"; | |
import { FontAwesome } from "@expo/vector-icons"; | |
const ICON_SQUARE_SIZE = 100; | |
// 'makeNotification' is a HOC | |
export const makeNotification = ( | |
// these values depend on notification type | |
iconName, | |
colorPrimary, | |
colorAccent | |
) => { | |
const NotificationBase = props => { | |
const { title, message, onClosePress } = props; | |
return ( | |
<TouchableOpacity | |
style={[styles.mainContainer, { backgroundColor: colorPrimary }]} | |
onPress={onClosePress} | |
> | |
<FontAwesome | |
style={styles.icon} | |
name={iconName} | |
size={ICON_SQUARE_SIZE} | |
color={colorAccent} | |
/> | |
<Text style={[styles.title, { color: colorAccent }]}>{title}</Text> | |
<Text style={[styles.message, { color: colorAccent }]}>{message}</Text> | |
</TouchableOpacity> | |
); | |
}; | |
NotificationBase.propTypes = { | |
title: PropTypes.string.isRequired, | |
message: PropTypes.string.isRequired, | |
onClosePress: PropTypes.func | |
}; | |
// 'NotificationBase' is returned from the HOC | |
return NotificationBase; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment