xref: /MusicFree/src/components/dialogs/index.tsx (revision 54bb1cc8f468f2f6f7187d4f13af720e58e5c74a)
1import React from 'react';
2import {Portal} from 'react-native-paper';
3import components from './components';
4import useDialog from './useDialog';
5
6export default function () {
7    const {dialogName, hideDialog, payload} = useDialog();
8
9    return (
10        <Portal>
11            {components.map(([key, DialogComponent]) =>
12                dialogName === key ? (
13                    <DialogComponent
14                        key={key}
15                        visible={dialogName === key}
16                        hideDialog={hideDialog}
17                        {...(payload ?? {})}
18                    />
19                ) : (
20                    <></>
21                ),
22            )}
23        </Portal>
24    );
25}
26