From f847f291f394edb46753acd52cbe58fe977dfd3c Mon Sep 17 00:00:00 2001 From: Thomas Renaud Date: Tue, 6 Feb 2024 11:44:59 +0100 Subject: [PATCH 01/16] Add modal with buttons --- package.json | 1 + .../src/components/modals/GenericModal.tsx | 47 +++++++++++++++++++ packages/example/src/pages/ProgramDetail.tsx | 13 +++++ yarn.lock | 25 +++++++++- 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 packages/example/src/components/modals/GenericModal.tsx diff --git a/package.json b/package.json index 103e05c4..bc391b39 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "@react-navigation/bottom-tabs": "^6.5.11", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-native-modal": "^13.0.1", "react-native-web": "^0.19.6" }, "resolutions": { diff --git a/packages/example/src/components/modals/GenericModal.tsx b/packages/example/src/components/modals/GenericModal.tsx new file mode 100644 index 00000000..4b90e412 --- /dev/null +++ b/packages/example/src/components/modals/GenericModal.tsx @@ -0,0 +1,47 @@ +import styled from '@emotion/native'; +import React from 'react'; +import { View, ModalProps } from 'react-native'; +import { Typography } from '../../design-system/components/Typography'; +import { Spacer } from '../../design-system/components/Spacer'; + +type CustomModalProps = ModalProps & { + isVisible: boolean; + children: React.ReactNode; + title: string; +}; + +export const GenericModal: React.FC = ({ isVisible, children, title }) => { + if (!isVisible) return null; + + return ( + + + + {title} + + + {children} + + + ); +}; + +const StyledModal = styled(View)({ + position: 'absolute', + top: 0, + left: 0, + right: 0, + bottom: 0, + justifyContent: 'center', + alignItems: 'center', +}); + +const ModalContentContainer = styled(View)({ + minHeight: 200, + minWidth: 200, + backgroundColor: 'grey', + padding: 32, + margin: 16, + borderRadius: 16, + justifyContent: 'center', +}); diff --git a/packages/example/src/pages/ProgramDetail.tsx b/packages/example/src/pages/ProgramDetail.tsx index 95fe4105..8ef54ddb 100644 --- a/packages/example/src/pages/ProgramDetail.tsx +++ b/packages/example/src/pages/ProgramDetail.tsx @@ -8,12 +8,15 @@ import { Spacer } from '../design-system/components/Spacer'; import { Typography } from '../design-system/components/Typography'; import { ProgramListWithTitle } from '../modules/program/view/ProgramListWithTitle'; import { Button } from '../design-system/components/Button'; +import { useState } from 'react'; +import { GenericModal } from '../components/GenericModal'; export const ProgramDetail = ({ route, }: { route: RouteProp; }) => { + const [isModalVisible, setIsModalVisible] = useState(false); const { programInfo } = route.params; return ( @@ -38,6 +41,16 @@ export const ProgramDetail = ({ {/* eslint-disable-next-line no-console */}