Skip to content

Commit

Permalink
feat: custom shadow in ToastConfig (#85)
Browse files Browse the repository at this point in the history
feat: allow custom shadow in ToastConfig

chore: add shadow to readme
  • Loading branch information
msantang78 authored Feb 2, 2022
1 parent f2a37db commit 031a6eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,6 @@ Because of the theming capability of `react-native-styled-toast`, it has out of
| **`messageProps`** | TextProps | no | Allows custom styling message | {} |
| **`subMessageProps`** | TextProps | no | Allows custom styling subMessage | {} |
| **`allowFontScaling`** | boolean | no | Allows font scaling | true |
| **`shadow`** | ShadowProps | no | Allows custom shadow | {} |
<br />
<div>Toast icon by <a href="https://www.flaticon.com/authors/ultimatearm" title="ultimatearm">ultimatearm</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a></div>
15 changes: 13 additions & 2 deletions src/Toast/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ export type ToastConfig = {
hideCloseIcon?: boolean
iconSize?: number
allowFontScaling?: boolean
shadow?: {
shadowColor?: string
shadowOffset?: {
width: number
height: number
}
shadowOpacity?: number
shadowRadius?: number
elevation?: number
}
}

const statusBarHeight = getStatusBarHeight()
Expand All @@ -59,7 +69,7 @@ export type ToastInternalConfig = {

const offset = statusBarHeight + 16

const shadow = {
const shadowDefault = {
shadowColor: '#000',
shadowOffset: {
width: 0,
Expand Down Expand Up @@ -125,7 +135,8 @@ export const Toast: React.FC<ToastConfig & ToastInternalConfig> = ({
closeButtonStyles,
hideCloseIcon,
iconSize,
allowFontScaling
allowFontScaling,
shadow = shadowDefault
}) => {
const isSuccess = intent === 'SUCCESS'
const isInfo = intent === 'INFO'
Expand Down

0 comments on commit 031a6eb

Please # to comment.