diff --git a/example/src/examples/ScrollPanelExample.tsx b/example/src/examples/ScrollPanelExample.tsx new file mode 100644 index 0000000..43e2d28 --- /dev/null +++ b/example/src/examples/ScrollPanelExample.tsx @@ -0,0 +1,44 @@ +import React from 'react'; +import { View, Text, StyleSheet } from 'react-native'; +import { ScrollPanel } from 'react95-native'; + +function getRandomColor() { + var letters = '0123456789ABCDEF'; + var color = '#'; + for (var i = 0; i < 6; i++) { + color += letters[Math.floor(Math.random() * 16)]; + } + return color; +} + +const ScrollPanelExample = () => { + + const colors = new Array(16).fill(null).map(getRandomColor); + + return ( + + + {colors.map((color, i) => ( + + ))} + + + {colors.map((color, i) => ( + + ))} + + + ); +}; + +const styles = StyleSheet.create({ + item: { + height: 60, + width: 60, + borderRadius: 20, + backgroundColor: 'teal', + marginHorizontal: 8, + }, +}); + +export default ScrollPanelExample; diff --git a/example/src/examples/index.tsx b/example/src/examples/index.tsx index 936d284..c027b7c 100644 --- a/example/src/examples/index.tsx +++ b/example/src/examples/index.tsx @@ -11,6 +11,7 @@ import MenuExample from './MenuExample'; import PanelExample from './PanelExample'; import ProgressExample from './ProgressExample'; import RadioExample from './RadioExample'; +import ScrollPanelExample from './ScrollPanelExample'; import SelectBoxExample from './SelectBoxExample'; import SelectExample from './SelectExample'; import TabsExample from './TabsExample'; @@ -58,6 +59,7 @@ export default [ title: 'Divider', }, { name: 'PanelExample', component: PanelExample, title: 'Panel' }, + { name: 'ScrollPanelExample', component: ScrollPanelExample, title: 'ScrollPanel' }, { name: 'WindowExample', component: WindowExample, title: 'Window' }, ], }, diff --git a/src/ScrollPanel/ScrollPanel.tsx b/src/ScrollPanel/ScrollPanel.tsx new file mode 100644 index 0000000..d80355c --- /dev/null +++ b/src/ScrollPanel/ScrollPanel.tsx @@ -0,0 +1,66 @@ +import React from 'react'; +import { View, StyleSheet, ScrollView } from 'react-native'; +import type { StyleProp, ViewStyle } from 'react-native'; +import { ThemeContext } from '../common/theming/Theme'; + +import { Border } from '../common/styleElements'; +import { Divider } from '..'; + +// TODO: where to pass custom styles? +// TODO: add noBottomBorder and noTopBorder prop +type Props = { + style?: StyleProp; + children?: React.ReactNode; + noBackground?: boolean; +}; + +const ScrollPanel = ({ style = {}, children, noBackground }: Props) => { + const theme = React.useContext(ThemeContext); + + return ( + + + + + + + + {children} + + + + + ); +}; + +const styles = StyleSheet.create({ + inner: { + padding: 16, + // TODO: decide if left padding should be 8 or 16 + paddingLeft: 16, + display: 'flex', + flexDirection: 'row', + alignItems: 'center', + }, + borderWrapper: { + padding: 4, + position: 'relative', + minWidth: '100%' + }, + content: { + marginLeft: 8, + display: 'flex', + flexDirection: 'row', + alignItems: 'center', + }, +}); + +export default ScrollPanel; diff --git a/src/ScrollPanel/index.ts b/src/ScrollPanel/index.ts new file mode 100644 index 0000000..8cc454d --- /dev/null +++ b/src/ScrollPanel/index.ts @@ -0,0 +1 @@ +export { default } from './ScrollPanel'; diff --git a/src/index.ts b/src/index.ts index 7eef8af..3bbab60 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,5 +17,6 @@ export { default as Tabs } from './Tabs'; export { default as ScrollView } from './ScrollView'; export { default as Hourglass } from './Hourglass'; export { default as List } from './List'; +export { default as ScrollPanel } from './ScrollPanel'; export * from './common/theming';