-
Notifications
You must be signed in to change notification settings - Fork 34
/
AppMessageProvider.tsx
46 lines (42 loc) · 1.23 KB
/
AppMessageProvider.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React from 'react';
import { ThemeProvider } from 'styled-components';
import {
ToastContext,
ToastProvider,
} from '@msantang78/react-native-styled-toast';
import { registerToast } from 'AppMessages';
import sp from '~/services/serviceProvider';
export default function AppMessageProvider({ children }) {
const themedStyles = sp.styles;
const themeValue = themedStyles.theme;
const theme = React.useMemo(() => {
const bg = themedStyles.getColor('PrimaryBorder');
return {
space: [0, 4, 8, 12, 16, 20, 24, 32, 40, 48],
colors: {
text: themedStyles.getColor('PrimaryText'),
background: bg,
border: bg,
muted: bg,
success: '#7DBE31',
error: '#FC0021',
info: '#00FFFF',
},
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [themeValue]);
return (
<ThemeProvider theme={theme}>
{/* @ts-ignore TODO: Add children type to the fork*/}
<ToastProvider position="TOP" offset={20} maxToasts={5}>
<ToastContext.Consumer>
{({ toast }) => {
registerToast(toast);
return <></>;
}}
</ToastContext.Consumer>
{children}
</ToastProvider>
</ThemeProvider>
);
}