From a82608b319d5e2d37fb2ac09450ae30b4c26530a Mon Sep 17 00:00:00 2001 From: Joseph Chimebuka Date: Sun, 2 Jun 2024 18:57:28 +0000 Subject: [PATCH] Create dialog component (#144) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * added dialogpage * added icons * added modal component * added dialog page * yarn formatted the code * fixed spelling error * removed the componenets to show the products working * added button props from button component and added current colr to colors * deleted the dialog page * removed linking to router * formatted page * yarn lint * made some fixes * yarn formatted code * Remove unused icons, fix props, fix button text --------- Co-authored-by: Uğur Eren --- JoyboyCommunity/src/assets/icons.tsx | 8 +- .../src/components/modal/index.tsx | 61 +++++++++++++++ .../src/components/modal/styled.ts | 75 +++++++++++++++++++ 3 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 JoyboyCommunity/src/components/modal/index.tsx create mode 100644 JoyboyCommunity/src/components/modal/styled.ts diff --git a/JoyboyCommunity/src/assets/icons.tsx b/JoyboyCommunity/src/assets/icons.tsx index 2f9fc14b..0e093c54 100644 --- a/JoyboyCommunity/src/assets/icons.tsx +++ b/JoyboyCommunity/src/assets/icons.tsx @@ -107,6 +107,12 @@ export const UserIcon: React.FC = (props) => ( ); +export const LineIcon: React.FC = (props) => ( + + + +); + export const CopyIcon: React.FC = (props) => { return ( @@ -183,7 +189,7 @@ export const SendIcon: React.FC = (props) => { d="M22 3.464a12 12 0 0 1 12 0l12.249 7.072a12 12 0 0 1 6 10.392v14.144a12 12 0 0 1-6 10.392L34 52.536a12 12 0 0 1-12 0L9.751 45.464a12 12 0 0 1-6-10.392V20.928a12 12 0 0 1 6-10.392L22 3.464Z" /> diff --git a/JoyboyCommunity/src/components/modal/index.tsx b/JoyboyCommunity/src/components/modal/index.tsx new file mode 100644 index 00000000..62e7b4b0 --- /dev/null +++ b/JoyboyCommunity/src/components/modal/index.tsx @@ -0,0 +1,61 @@ +import React from 'react'; +import {Portal} from 'react-native-portalize'; + +import {LineIcon} from '../../assets/icons'; +import {Button} from '../button'; +import { + Container, + Content, + getButtonColor, + getTextColor, + IconContainer, + ModalContainer, + Overlay, + Title, +} from './styled'; + +export type ModalProps = { + name: string; + icon: React.ReactNode; + description: string; + visible: boolean; + buttons: { + label: string; + type: 'primary' | 'secondary' | 'dangerous'; + onPress: () => void; + }[]; +}; + +const Modal: React.FC = ({name, icon, description, visible, buttons}) => { + if (!visible) return null; + + return ( + + + + + + {icon} + {name} + {description} + + + + {buttons.map((button, index) => ( + + ))} + + + + + ); +}; + +export default Modal; diff --git a/JoyboyCommunity/src/components/modal/styled.ts b/JoyboyCommunity/src/components/modal/styled.ts new file mode 100644 index 00000000..6f87d3c1 --- /dev/null +++ b/JoyboyCommunity/src/components/modal/styled.ts @@ -0,0 +1,75 @@ +import {Text, View} from 'react-native'; +import styled from 'styled-components/native'; + +export const Overlay = styled(View)` + flex: 1; + justify-content: center; + align-items: center; + background-color: rgba(0, 0, 0, 0.5); + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; +`; + +export const ModalContainer = styled(View)` + width: 85%; + display: flex; + flex-direction: column; + padding: 0 20px; + background-color: white; + border-radius: 10px; + align-items: center; +`; + +export const Container = styled(View)` + flex-direction: column; + display: flex; + align-items: center; + justify-content: center; + padding-top: 20px; + margin-bottom: 20px; +`; + +export const Title = styled(Text)` + font-size: 21px; + font-weight: 700; + line-height: 24px; + margin-bottom: 12px; + margin-top: 12px; +`; +export const IconContainer = styled(View)` + margin-bottom: 10px; + margin-top: 16px; +`; + +export const Content = styled(Text)` + font-size: 16px; + text-align: center; + color: #8f979e; +`; + +export const getButtonColor = (type: string) => { + switch (type) { + case 'dangerous': + return '#0C0C4F'; + case 'primary': + return '#EC796B'; + case 'secondary': + return '#0c0c4f1a'; + default: + return '#ccc'; + } +}; + +export const getTextColor = (type: string) => { + switch (type) { + case 'dangerous': + return '#ffff'; + case 'primary': + return '#fff'; + case 'secondary': + return '#14142C'; + } +};