diff --git a/README.md b/README.md index 3ecd261..ad6959d 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,8 @@ Now we need to install [react-native-svg](https://github.com/react-native-svg/re | width | Number | No | Customize width for container view | | height | Number | No | Customize height for container view, Minimum is 50px and Maximum is 90px | | borderTopLeftRight | Boolean | No | Border radius top left and top right of container view | +| borderColor | String | No | Border color | +| borderWidth | Number | No | Border width | | bgColor | String | No | Background color of container view | diff --git a/src/CurvedBottomBar/components/BottomBarView/index.tsx b/src/CurvedBottomBar/components/BottomBarView/index.tsx index 7a6a7f5..803d9ee 100644 --- a/src/CurvedBottomBar/components/BottomBarView/index.tsx +++ b/src/CurvedBottomBar/components/BottomBarView/index.tsx @@ -38,6 +38,8 @@ const BottomBarComponent: ( renderCircle, borderTopLeftRight = false, shadowStyle, + borderColor = 'gray', + borderWidth = 0, } = props; const [itemLeft, setItemLeft] = useState([]); @@ -263,6 +265,8 @@ const BottomBarComponent: ( } bgColor={bgColor} path={d} + borderColor={borderColor} + borderWidth={borderWidth} /> {_renderTabContainer(props)} @@ -278,6 +282,8 @@ const BottomBarComponent: ( shadowStyle, style, type, + borderColor, + borderWidth, ] ); diff --git a/src/CurvedBottomBar/components/BottomBarView/model.ts b/src/CurvedBottomBar/components/BottomBarView/model.ts index 1447090..9990cde 100644 --- a/src/CurvedBottomBar/components/BottomBarView/model.ts +++ b/src/CurvedBottomBar/components/BottomBarView/model.ts @@ -42,6 +42,8 @@ interface Props { borderTopLeftRight?: boolean; circleWidth?: Range<50, 61>; bgColor?: string; + borderColor?: string; + borderWidth?: number; initialRouteName: string; defaultScreenOptions?: unknown; renderCircle: ({ diff --git a/src/CurvedBottomBar/components/BottomBarViewExpo/model.ts b/src/CurvedBottomBar/components/BottomBarViewExpo/model.ts index 1447090..9990cde 100644 --- a/src/CurvedBottomBar/components/BottomBarViewExpo/model.ts +++ b/src/CurvedBottomBar/components/BottomBarViewExpo/model.ts @@ -42,6 +42,8 @@ interface Props { borderTopLeftRight?: boolean; circleWidth?: Range<50, 61>; bgColor?: string; + borderColor?: string; + borderWidth?: number; initialRouteName: string; defaultScreenOptions?: unknown; renderCircle: ({ diff --git a/src/CurvedBottomBar/components/CurvedView/curvedView.tsx b/src/CurvedBottomBar/components/CurvedView/curvedView.tsx index 8080975..60fb2c4 100644 --- a/src/CurvedBottomBar/components/CurvedView/curvedView.tsx +++ b/src/CurvedBottomBar/components/CurvedView/curvedView.tsx @@ -4,12 +4,18 @@ import { CurvedBottomBarView } from '../ShadowView'; import { CurvedView } from './model'; const CurvedContainer: CurvedView = (props) => { - const { style, width, height, bgColor, path } = props; + const { style, width, height, bgColor, path, borderColor, borderWidth } = + props; + + const border = + borderWidth && borderWidth > 0 + ? { stroke: borderColor, strokeWidth: borderWidth } + : {}; return ( - + ); diff --git a/src/CurvedBottomBar/components/CurvedView/curvedViewExpo.tsx b/src/CurvedBottomBar/components/CurvedView/curvedViewExpo.tsx index 8e8d786..3f04f79 100644 --- a/src/CurvedBottomBar/components/CurvedView/curvedViewExpo.tsx +++ b/src/CurvedBottomBar/components/CurvedView/curvedViewExpo.tsx @@ -4,12 +4,18 @@ import { Path, Svg } from 'react-native-svg'; import { CurvedView } from './model'; const CurvedContainer: CurvedView = (props) => { - const { style, width, height, bgColor, path } = props; + const { style, width, height, bgColor, path, borderColor, borderWidth } = + props; + + const border = + borderWidth && borderWidth > 0 + ? { stroke: borderColor, strokeWidth: borderWidth } + : {}; return ( - + ); diff --git a/src/CurvedBottomBar/components/CurvedView/model.ts b/src/CurvedBottomBar/components/CurvedView/model.ts index db03d5e..c5eae95 100644 --- a/src/CurvedBottomBar/components/CurvedView/model.ts +++ b/src/CurvedBottomBar/components/CurvedView/model.ts @@ -7,6 +7,8 @@ interface ICurvedView { height: number; bgColor: string; path: any; + borderColor?: string; + borderWidth?: number; } export type CurvedView = React.FC; diff --git a/src/CurvedBottomBar/utils/pathDown.ts b/src/CurvedBottomBar/utils/pathDown.ts index cefdb5b..e079714 100644 --- a/src/CurvedBottomBar/utils/pathDown.ts +++ b/src/CurvedBottomBar/utils/pathDown.ts @@ -2,31 +2,63 @@ import * as shape from 'd3-shape'; import { scale } from 'react-native-size-scaling'; //** Path Line */ -const line = (width: number, height: number) => { +const line = (width: number, height: number, centerWidth: number) => { const path = (shape as any) .line() .x((d: { x: any }) => d.x) .y((d: { y: any }) => d.y)([ - { x: width / 2, y: 0 }, + { x: width / 2 + scale(centerWidth), y: 0 }, { x: width, y: 0 }, { x: width, y: height }, { x: 0, y: height }, { x: 0, y: 0 }, - { x: width / 2, y: 0 }, + { x: width / 2 - scale(centerWidth), y: 0 }, + ]); + + return path; +}; + +//** Path Line Left*/ +const lineLeft = (width: number, height: number, centerWidth: number) => { + const path = (shape as any) + .line() + .x((d: { x: any }) => d.x) + .y((d: { y: any }) => d.y)([ + { x: scale(centerWidth * 1.9) + scale(10), y: 0 }, + { x: width, y: 0 }, + { x: width, y: height }, + { x: 0, y: height }, + { x: 0, y: 0 }, + ]); + + return path; +}; + +//** Path Line Right*/ +const lineRight = (width: number, height: number, centerWidth: number) => { + const path = (shape as any) + .line() + .x((d: { x: any }) => d.x) + .y((d: { y: any }) => d.y)([ + { x: width, y: 0 }, + { x: width, y: height }, + { x: 0, y: height }, + { x: 0, y: 0 }, + { x: width - scale(centerWidth * 1.9) - scale(10), y: 0 }, ]); return path; }; //** Path Line Border Left Right Down */ -const lineBorder = (width: number, height: number) => { +const lineBorder = (width: number, height: number, centerWidth: number) => { const border = (shape as any) .line() .x((d: { x: any }) => d.x) .y((d: { y: any }) => d.y) .curve(shape.curveBasis)([ // right - { x: width / 2, y: 0 }, + { x: width / 2 + scale(centerWidth), y: 0 }, { x: width - scale(20), y: 0 }, { x: width - scale(10), y: scale(2) }, { x: width - scale(2), y: scale(10) }, @@ -43,14 +75,18 @@ const lineBorder = (width: number, height: number) => { { x: 0 + scale(2), y: scale(10) }, { x: 0 + scale(10), y: scale(2) }, { x: 0 + scale(20), y: 0 }, - { x: width / 2, y: 0 }, + { x: width / 2 - scale(centerWidth), y: 0 }, ]); return border; }; //** Path Line Border Left Right Down */ -const lineBorderLeft = (width: number, height: number) => { +const lineBorderRight = ( + width: number, + height: number, + centerWidth: number +) => { const border = (shape as any) .line() .x((d: { x: any }) => d.x) @@ -70,21 +106,21 @@ const lineBorderLeft = (width: number, height: number) => { { x: 0 + scale(2), y: scale(10) }, { x: 0 + scale(10), y: scale(2) }, { x: 0 + scale(20), y: 0 }, - { x: width / 2, y: 0 }, + { x: width - scale(centerWidth * 1.9) - scale(10), y: 0 }, ]); return border; }; //** Path Line Border Left Right Down */ -const lineBorderRight = (width: number, height: number) => { +const lineBorderLeft = (width: number, height: number, centerWidth: number) => { const border = (shape as any) .line() .x((d: { x: any }) => d.x) .y((d: { y: any }) => d.y) .curve(shape.curveBasis)([ // right - { x: width / 2, y: 0 }, + { x: scale(centerWidth * 1.9) + scale(10), y: 0 }, { x: width - scale(20), y: 0 }, { x: width - scale(10), y: scale(2) }, { x: width - scale(2), y: scale(10) }, @@ -96,6 +132,7 @@ const lineBorderRight = (width: number, height: number) => { { x: 0, y: height }, // left { x: 0, y: height }, + { x: 0, y: height }, { x: 0, y: 0 }, ]); @@ -144,7 +181,7 @@ export const getPathDown = ( const circleWidth = scale(centerWidth) + scale(16); if (borderTopLeftRight && position === 'LEFT') { - return `${lineBorderRight(width, height)} ${lineCurved( + return `${lineBorderLeft(width, height, centerWidth)} ${lineCurved( circleWidth / 3, height, circleWidth @@ -152,7 +189,7 @@ export const getPathDown = ( } if (borderTopLeftRight && position === 'RIGHT') { - return `${lineBorderLeft(width, height)} ${lineCurved( + return `${lineBorderRight(width, height, centerWidth)} ${lineCurved( width - circleWidth * 1.33, height, circleWidth @@ -160,7 +197,7 @@ export const getPathDown = ( } if (borderTopLeftRight && position === 'CENTER') { - return `${lineBorder(width, height)} ${lineCurved( + return `${lineBorder(width, height, centerWidth)} ${lineCurved( width / 2 - circleWidth / 2, height, circleWidth @@ -168,7 +205,7 @@ export const getPathDown = ( } if (position === 'LEFT') { - return `${line(width, height)} ${lineCurved( + return `${lineLeft(width, height, centerWidth)} ${lineCurved( circleWidth / 3, height, circleWidth @@ -176,14 +213,14 @@ export const getPathDown = ( } if (position === 'RIGHT') { - return `${line(width, height)} ${lineCurved( + return `${lineRight(width, height, centerWidth)} ${lineCurved( width - circleWidth * 1.33, height, circleWidth )}`; } - return `${line(width, height)} ${lineCurved( + return `${line(width, height, centerWidth)} ${lineCurved( width / 2 - circleWidth / 2, height, circleWidth diff --git a/src/CurvedBottomBar/utils/pathUp.ts b/src/CurvedBottomBar/utils/pathUp.ts index 24cd5b0..c21cd47 100644 --- a/src/CurvedBottomBar/utils/pathUp.ts +++ b/src/CurvedBottomBar/utils/pathUp.ts @@ -2,31 +2,64 @@ import * as shape from 'd3-shape'; import { scale } from 'react-native-size-scaling'; //** Path Line */ -const line = (width: number, height: number) => { +const line = (width: number, height: number, centerWidth: number) => { const path = (shape as any) .line() .x((d: { x: any }) => d.x) .y((d: { y: any }) => d.y)([ - { x: width / 2, y: scale(30) }, + { x: width / 2 - scale(centerWidth) - scale(20), y: scale(30) }, + { x: 0, y: scale(30) }, + { x: 0, y: height }, + { x: width, y: height }, + { x: width, y: scale(30) }, + { x: width / 2 + scale(centerWidth) + scale(20), y: scale(30) }, + ]); + + return path; +}; + +//** Path Line Left*/ +const lineLeft = (width: number, height: number, centerWidth: number) => { + const path = (shape as any) + .line() + .x((d: { x: any }) => d.x) + .y((d: { y: any }) => d.y)([ + { x: 0, y: scale(30) }, + { x: 0, y: scale(30) }, + { x: 0, y: height }, + { x: width, y: height }, + { x: width, y: scale(30) }, + { x: scale(centerWidth * 1.9) + scale(20), y: scale(30) }, + ]); + + return path; +}; + +//** Path Line Right*/ +const lineRight = (width: number, height: number, centerWidth: number) => { + const path = (shape as any) + .line() + .x((d: { x: any }) => d.x) + .y((d: { y: any }) => d.y)([ + { x: width - scale(centerWidth * 1.9) - scale(20), y: scale(30) }, { x: 0, y: scale(30) }, { x: 0, y: height }, { x: width, y: height }, { x: width, y: scale(30) }, - { x: width / 2, y: scale(30) }, ]); return path; }; //** Path Line Border Left Right Up */ -const lineBorder = (width: number, height: number) => { +const lineBorder = (width: number, height: number, centerWidth: number) => { const border = (shape as any) .line() .x((d: { x: any }) => d.x) .y((d: { y: any }) => d.y) .curve(shape.curveBasis)([ // right - { x: width / 2, y: scale(30) }, + { x: width / 2 + scale(centerWidth) + scale(20), y: scale(30) }, { x: width - scale(20), y: scale(30) }, { x: width - scale(10), y: scale(32) }, { x: width - scale(2), y: scale(40) }, @@ -43,14 +76,18 @@ const lineBorder = (width: number, height: number) => { { x: 0 + scale(2), y: scale(40) }, { x: 0 + scale(10), y: scale(32) }, { x: 0 + scale(20), y: scale(30) }, - { x: width / 2, y: scale(30) }, + { x: width / 2 - scale(centerWidth) - scale(20), y: scale(30) }, ]); return border; }; //** Path Line Border Left Right Down */ -const lineBorderLeft = (width: number, height: number) => { +const lineBorderRight = ( + width: number, + height: number, + centerWidth: number +) => { const border = (shape as any) .line() .x((d: { x: any }) => d.x) @@ -70,21 +107,21 @@ const lineBorderLeft = (width: number, height: number) => { { x: 0 + scale(2), y: scale(40) }, { x: 0 + scale(10), y: scale(32) }, { x: 0 + scale(20), y: scale(30) }, - { x: width / 2, y: scale(30) }, + { x: width - scale(centerWidth * 1.9) - scale(20), y: scale(30) }, ]); return border; }; //** Path Line Border Left Right Down */ -const lineBorderRight = (width: number, height: number) => { +const lineBorderLeft = (width: number, height: number, centerWidth: number) => { const border = (shape as any) .line() .x((d: { x: any }) => d.x) .y((d: { y: any }) => d.y) .curve(shape.curveBasis)([ // right - { x: width / 2, y: scale(30) }, + { x: scale(centerWidth * 1.9) + scale(20), y: scale(30) }, { x: width - scale(20), y: scale(30) }, { x: width - scale(10), y: scale(32) }, { x: width - scale(2), y: scale(40) }, @@ -139,41 +176,41 @@ export const getPathUp = ( const circleWidth = scale(centerWidth); if (borderTopLeftRight && position === 'LEFT') { - return `${lineBorderRight(width, height)} ${lineCurved( + return `${lineBorderLeft(width, height, centerWidth)} ${lineCurved( circleWidth / 1.7, circleWidth )}`; } if (borderTopLeftRight && position === 'RIGHT') { - return `${lineBorderLeft(width, height)} ${lineCurved( + return `${lineBorderRight(width, height, centerWidth)} ${lineCurved( width - circleWidth * 1.6, circleWidth )}`; } if (borderTopLeftRight && position === 'CENTER') { - return `${lineBorder(width, height)} ${lineCurved( + return `${lineBorder(width, height, centerWidth)} ${lineCurved( width / 2 - circleWidth / 2, circleWidth )}`; } if (position === 'LEFT') { - return `${line(width, height)} ${lineCurved( + return `${lineLeft(width, height, centerWidth)} ${lineCurved( circleWidth / 1.7, circleWidth )}`; } if (position === 'RIGHT') { - return `${line(width, height)} ${lineCurved( + return `${lineRight(width, height, centerWidth)} ${lineCurved( width - circleWidth * 1.6, circleWidth )}`; } - return `${line(width, height)} ${lineCurved( + return `${line(width, height, centerWidth)} ${lineCurved( width / 2 - circleWidth / 2, circleWidth )}`;