-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18945b2
commit 28523c3
Showing
15 changed files
with
829 additions
and
19 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* eslint-disable react-native/no-inline-styles */ | ||
import React from 'react'; | ||
import { SafeAreaView } from 'react-native'; | ||
import { Box, Flex, FlashList, Text } from 'react-native-ficus-ui'; | ||
|
||
const FlashListComponent = () => { | ||
const DATA = [ | ||
{ | ||
id: 'bd7acbea-c1b1-46c2-aed5-3ad53abb28ba', | ||
title: 'First Item', | ||
}, | ||
{ | ||
id: '3ac68afc-c605-48d3-a4f8-fbd91aa97f63', | ||
title: 'Second Item', | ||
}, | ||
{ | ||
id: '58694a0f-3da1-471f-bd96-145571e29d72', | ||
title: 'Third Item', | ||
}, | ||
]; | ||
return ( | ||
<SafeAreaView style={{ flex: 1 }}> | ||
<Text mx="xl" fontSize="4xl"> | ||
FlashList component | ||
</Text> | ||
<Flex mt="xl"> | ||
<FlashList | ||
bg="gray.200" | ||
p="xl" | ||
data={DATA} | ||
renderItem={({ item }) => ( | ||
<Box p="lg"> | ||
<Text>{item.title}</Text> | ||
</Box> | ||
)} | ||
estimatedItemSize={200} | ||
/> | ||
</Flex> | ||
</SafeAreaView> | ||
); | ||
}; | ||
|
||
export default FlashListComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import * as React from 'react'; | ||
import { View } from 'react-native'; | ||
import { FlashList as ShopifyFlashList } from '@shopify/flash-list'; | ||
|
||
import { getStyle } from './flashlist.style'; | ||
import type { FlashListProps } from './flashlist.type'; | ||
import { useTheme } from '../../theme/theme.hook'; | ||
import { useDefaultProps } from '../../utilities/useDefaultProps'; | ||
|
||
const FlashList: React.FunctionComponent<FlashListProps> = (incomingProps) => { | ||
const props = useDefaultProps('FlashList', incomingProps, { flex: 1 }); | ||
|
||
const { | ||
bg, | ||
h, | ||
w, | ||
m, | ||
mt, | ||
mr, | ||
mb, | ||
ml, | ||
ms, | ||
p, | ||
pr, | ||
pt, | ||
pb, | ||
pl, | ||
minH, | ||
minW, | ||
maxW, | ||
maxH, | ||
position, | ||
style, | ||
flexDirection, | ||
direction, | ||
borderRadius, | ||
borderTopRadius, | ||
borderTopLeftRadius, | ||
borderTopRightRadius, | ||
borderBottomLeftRadius, | ||
borderBottomRightRadius, | ||
borderLeftRadius, | ||
borderRightRadius, | ||
borderBottomRadius, | ||
children, | ||
alignItems, | ||
align, | ||
justifyContent, | ||
justify, | ||
borderColor, | ||
borderBottomColor, | ||
borderLeftColor, | ||
borderTopColor, | ||
borderRightColor, | ||
borderWidth, | ||
borderLeftWidth, | ||
borderRightWidth, | ||
borderBottomWidth, | ||
borderTopWidth, | ||
borderEndWidth, | ||
flexWrap, | ||
wrap, | ||
flexGrow, | ||
grow, | ||
flexBasis, | ||
basis, | ||
flexShrink, | ||
shrink, | ||
shadow, | ||
shadowColor, | ||
opacity, | ||
overflow, | ||
top, | ||
left, | ||
right, | ||
bottom, | ||
zIndex, | ||
...rest | ||
} = props; | ||
const { theme } = useTheme(); | ||
const computedStyle = getStyle(theme, props); | ||
|
||
return ( | ||
<View style={computedStyle.list}> | ||
<ShopifyFlashList {...rest} /> | ||
</View> | ||
); | ||
}; | ||
|
||
// FlashList.defaultProps = {}; | ||
|
||
export { FlashList }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react-native'; | ||
|
||
import { Text } from '../text/text.component'; | ||
import { FlashList } from './flashlist.component'; | ||
import type { FlashListProps } from './flashlist.type'; | ||
import { ThemeProvider } from '../../theme/theme.provider'; | ||
|
||
jest.mock('react-native-toast-message', () => 'Toast'); | ||
|
||
describe('FlashList component', () => { | ||
const TestList: React.FC<FlashListProps> = (props) => ( | ||
<ThemeProvider> | ||
<FlashList {...props} /> | ||
</ThemeProvider> | ||
); | ||
|
||
it('should render component passed to children', () => { | ||
render( | ||
<TestList | ||
data={[{ id: 0, text: 'I love Ficus UI (forked from Magnus UI)' }]} | ||
renderItem={({ item }) => <Text>{item.text}</Text>} | ||
keyExtractor={(item) => item.id} | ||
estimatedItemSize={200} | ||
/> | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { StyleSheet } from 'react-native'; | ||
|
||
import { | ||
createShadowStyles, | ||
createPositionStyle, | ||
createSpacingStyles, | ||
createBorderWidthStyles, | ||
createBorderColorStyles, | ||
createBorderRadiusStyles, | ||
getThemeColor, | ||
} from '../../theme/theme.service'; | ||
import type { FlashListProps } from './flashlist.type'; | ||
import type { ThemeType } from '../../theme/type'; | ||
|
||
/** | ||
* computed style | ||
* | ||
* @param theme | ||
* @param props | ||
*/ | ||
export const getStyle = (theme: ThemeType, props: FlashListProps) => { | ||
const computedStyle: any = {}; | ||
|
||
computedStyle.list = { | ||
flexDirection: props.direction ? props.direction : props.flexDirection, | ||
flexWrap: props.wrap ? props.wrap : props.flexWrap, | ||
alignItems: props.align ? props.align : props.alignItems, | ||
justifyContent: props.justify ? props.justify : props.justifyContent, | ||
flexBasis: props.basis ? props.basis : props.flexBasis, | ||
flexGrow: props.grow ? props.grow : props.flexGrow, | ||
flexShrink: props.shrink ? props.shrink : props.flexShrink, | ||
height: props.h, | ||
width: props.w, | ||
minWidth: props.minW, | ||
minHeight: props.minH, | ||
alignSelf: props.alignSelf, | ||
maxWidth: props.maxW, | ||
maxHeight: props.maxH, | ||
opacity: props.opacity, | ||
overflow: props.overflow || 'hidden', | ||
zIndex: props.zIndex, | ||
borderStyle: props.borderStyle, | ||
backgroundColor: getThemeColor(theme.colors, props.bg), | ||
flex: props.flex, | ||
...createPositionStyle(props), | ||
...createShadowStyles(props, theme), | ||
...createBorderWidthStyles(props), | ||
...createSpacingStyles(props, theme.spacing), | ||
...createBorderColorStyles(props, theme.colors), | ||
...createBorderRadiusStyles(props, theme.borderRadius), | ||
}; | ||
|
||
// merging custom style props to computed style | ||
if (props.style) { | ||
computedStyle.list = { | ||
...computedStyle.list, | ||
// @ts-ignore | ||
...props.style, | ||
}; | ||
} | ||
|
||
return StyleSheet.create(computedStyle); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { FlashListProps as ShopifyFlashListProps } from '@shopify/flash-list'; | ||
|
||
import type { | ||
BorderPropsType, | ||
SpacingPropsType, | ||
BorderRadiusPropsType, | ||
ShadowPropsType, | ||
DimensionPropsType, | ||
BackgroundPropsType, | ||
FlexPropsType, | ||
PositionPropsType, | ||
ZIndexPropsType, | ||
OverflowPropsType, | ||
OpacityPropsType, | ||
VariantPropsType, | ||
} from '../../types'; | ||
|
||
export interface FlashListProps | ||
extends ShopifyFlashListProps<any>, | ||
BorderPropsType, | ||
SpacingPropsType, | ||
BorderRadiusPropsType, | ||
ShadowPropsType, | ||
DimensionPropsType, | ||
BackgroundPropsType, | ||
FlexPropsType, | ||
PositionPropsType, | ||
ZIndexPropsType, | ||
OverflowPropsType, | ||
OpacityPropsType, | ||
VariantPropsType {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters