From 8aed6c522170c7494fde2d7867f51606d47a86e0 Mon Sep 17 00:00:00 2001 From: FreakyCoder Date: Wed, 20 Mar 2019 18:23:37 +0300 Subject: [PATCH] #New Feature: Shadow. New Props: shadowStyle and shadowColor --- README.md | 2 ++ lib/src/components/StateView.js | 26 +++++++++------- lib/src/components/styles/StateView.style.js | 31 ++++++++++++++++---- package.json | 2 +- 4 files changed, 44 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c98f482..22011c3 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,8 @@ npm i react-native-easy-state-view | buttonTextStyle | style | check the source code | use this to implement your own style for button's text style | | buttonTextColor | color | "white" | use this to change button's text color | | buttonText | string | "Let's Go!" | use this to set your button's text | +| shadowColor | color | "#000" | use this to change button's shadow color | +| shadowStyle | style | _shadowStyle | use this to set your own shadow style | # Change Log diff --git a/lib/src/components/StateView.js b/lib/src/components/StateView.js index 4dbf327..716e246 100644 --- a/lib/src/components/StateView.js +++ b/lib/src/components/StateView.js @@ -3,6 +3,7 @@ import { Image, View, Text } from "react-native"; import PropTypes from "prop-types"; import Ripple from "react-native-material-ripple"; import styles, { + _shadowStyle, buttonContainer, buttonTextContainer } from "./styles/StateView.style"; @@ -20,7 +21,9 @@ const StateView = props => { titleStyle, buttonText, rippleColor, + shadowStyle, buttonColor, + shadowColor, imageSource, enableButton, subtitleStyle, @@ -58,7 +61,10 @@ const StateView = props => { onPress={onPress} rippleColor={rippleColor || "white"} rippleDuration={rippleDuration || 750} - style={buttonContainerStyle || buttonContainer(buttonColor)} + style={[ + shadowStyle || _shadowStyle(shadowColor), + buttonContainerStyle || buttonContainer(buttonColor) + ]} rippleContainerBorderRadius={rippleContainerBorderRadius || 16} > {}, subtitle: "", isCenter: true, - imageStyle: styles.imageStyle, - titleStyle: styles.titleStyle, buttonText: " ", + onPress: () => {}, rippleColor: "white", - buttonColor: "#FFAF10", enableButton: false, - subtitleStyle: styles.subTitleStyle, rippleDuration: 750, buttonComponent: null, - imageResizeMode: "contain", + buttonColor: "#FFAF10", + style: styles.container, buttonTextColor: "white", + imageResizeMode: "contain", + imageStyle: styles.imageStyle, + titleStyle: styles.titleStyle, + rippleContainerBorderRadius: 16, + subtitleStyle: styles.subTitleStyle, buttonTextStyle: styles.buttonTextStyle, - buttonContainerStyle: styles.buttonContainerStyle, - rippleContainerBorderRadius: 16 + buttonContainerStyle: styles.buttonContainerStyle }; export default StateView; diff --git a/lib/src/components/styles/StateView.style.js b/lib/src/components/styles/StateView.style.js index 06f2a44..1b71323 100644 --- a/lib/src/components/styles/StateView.style.js +++ b/lib/src/components/styles/StateView.style.js @@ -1,24 +1,43 @@ - +import { Platform } from "react-native"; export function buttonContainer(buttonColor) { - return ({ + return { margin: 36, paddingTop: 12, borderRadius: 16, paddingBottom: 12, backgroundColor: buttonColor || "#FFAF10" - }) + }; } export function buttonTextContainer(buttonTextColor) { - return ({ + return { fontSize: 16, fontWeight: "700", textAlign: "center", color: buttonTextColor || "white" - }) + }; } +export const _shadowStyle = shadowColor => { + return { + ...Platform.select({ + ios: { + shadowRadius: 2, + shadowOpacity: 0.3, + shadowColor: shadowColor || "#000", + shadowOffset: { + width: 2, + height: 3 + } + }, + android: { + elevation: 5 + } + }) + }; +}; + export default { titleStyle: { padding: 16, @@ -40,5 +59,5 @@ export default { center: { alignSelf: "center", alignContent: "center" - }, + } }; diff --git a/package.json b/package.json index dc8e7df..4aa555e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-easy-state-view", - "version": "0.3.0", + "version": "0.3.1", "description": "Fully customizable State View for React Native.", "keywords": [ "react-native",