Skip to content

Commit 031a6eb

Browse files
authored
feat: custom shadow in ToastConfig (jeanverster#85)
feat: allow custom shadow in ToastConfig chore: add shadow to readme
1 parent f2a37db commit 031a6eb

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,6 @@ Because of the theming capability of `react-native-styled-toast`, it has out of
207207
| **`messageProps`** | TextProps | no | Allows custom styling message | {} |
208208
| **`subMessageProps`** | TextProps | no | Allows custom styling subMessage | {} |
209209
| **`allowFontScaling`** | boolean | no | Allows font scaling | true |
210+
| **`shadow`** | ShadowProps | no | Allows custom shadow | {} |
210211
<br />
211212
<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>

src/Toast/index.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ export type ToastConfig = {
4646
hideCloseIcon?: boolean
4747
iconSize?: number
4848
allowFontScaling?: boolean
49+
shadow?: {
50+
shadowColor?: string
51+
shadowOffset?: {
52+
width: number
53+
height: number
54+
}
55+
shadowOpacity?: number
56+
shadowRadius?: number
57+
elevation?: number
58+
}
4959
}
5060

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

6070
const offset = statusBarHeight + 16
6171

62-
const shadow = {
72+
const shadowDefault = {
6373
shadowColor: '#000',
6474
shadowOffset: {
6575
width: 0,
@@ -125,7 +135,8 @@ export const Toast: React.FC<ToastConfig & ToastInternalConfig> = ({
125135
closeButtonStyles,
126136
hideCloseIcon,
127137
iconSize,
128-
allowFontScaling
138+
allowFontScaling,
139+
shadow = shadowDefault
129140
}) => {
130141
const isSuccess = intent === 'SUCCESS'
131142
const isInfo = intent === 'INFO'

0 commit comments

Comments
 (0)