-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2921 from ecency/nt/feed-filters
Nt/feed filters
- Loading branch information
Showing
13 changed files
with
211 additions
and
144 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import EStyleSheet from 'react-native-extended-stylesheet'; | ||
import getWindowDimensions from '../../../utils/getWindowDimensions'; | ||
|
||
const deviceWidth = getWindowDimensions().width; | ||
|
||
export default EStyleSheet.create({ | ||
container: { | ||
justifyContent: 'center', | ||
backgroundColor: '$primaryLightBackground', | ||
shadowOpacity: 0.3, | ||
shadowColor: '$shadowColor', | ||
elevation: 0.1, | ||
shadowOffset: { | ||
height: 1, | ||
}, | ||
zIndex: 99, | ||
}, | ||
|
||
indicatorStyle: { | ||
backgroundColor: 'transparent', | ||
}, | ||
tabStyle: { | ||
width: 'auto', | ||
minWidth: deviceWidth / 3 - 12, | ||
height: 38, | ||
paddingTop: 0, | ||
}, | ||
tabBarStyle: { | ||
flex: 1, | ||
backgroundColor: EStyleSheet.value('$primaryLightBackground'), // Background color for the TabBar | ||
}, | ||
|
||
dropdownWrapper: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-around', | ||
alignItems: 'center', | ||
marginRight: 8, | ||
flex: 1, | ||
}, | ||
filterBarWrapper: { | ||
flex: 1, | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
justifyContent: 'space-between', | ||
}, | ||
rightIconWrapper: { | ||
paddingRight: 12, | ||
paddingLeft: 4, | ||
width: 40, | ||
alignSelf: 'center', | ||
}, | ||
rightIcon: { | ||
color: '$darkIconColor', | ||
textAlign: 'center', | ||
}, | ||
rightIconPlaceholder: { | ||
marginRight: 8, | ||
}, | ||
}); |
File renamed without changes.
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,77 @@ | ||
import React, { useRef } from 'react'; | ||
import { useIntl } from 'react-intl'; | ||
import { TabBar, TabBarProps } from 'react-native-tab-view'; | ||
import EStyleSheet from 'react-native-extended-stylesheet'; | ||
import { useWindowDimensions, View } from 'react-native'; | ||
import { CustomiseFiltersModal, IconButton, Tag } from '../..'; | ||
import { CustomiseFiltersModalRef } from '../../customiseFiltersModal/customiseFiltersModal'; | ||
import styles from '../styles/feedTabBar.styles'; | ||
|
||
export interface TabItem { | ||
filterKey: string; | ||
label: string; | ||
} | ||
|
||
interface FeedTabBarProps extends TabBarProps<any> { | ||
pageType?: 'main' | 'community' | 'profile' | 'ownProfile'; | ||
routes: { | ||
key: string; | ||
title: string; | ||
}[]; | ||
onFilterSelect: (filterKey: string) => void; | ||
} | ||
|
||
export const FeedTabBar = ({ routes, onFilterSelect, pageType, ...props }: FeedTabBarProps) => { | ||
const intl = useIntl(); | ||
const layout = useWindowDimensions(); | ||
|
||
const customiseModalRef = useRef<CustomiseFiltersModalRef>(); | ||
|
||
const enableCustomTabs = pageType !== undefined; | ||
|
||
const _onCustomisePress = () => { | ||
if (customiseModalRef.current) { | ||
customiseModalRef.current.show(); | ||
} | ||
}; | ||
|
||
return ( | ||
<View | ||
style={{ | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
backgroundColor: EStyleSheet.value('$primaryLightBackground'), | ||
}} | ||
> | ||
<TabBar | ||
renderLabel={({ route, focused }) => ( | ||
<Tag | ||
key={route.key} | ||
value={intl.formatMessage({ id: route.title.toLowerCase() }).toUpperCase()} | ||
isFilter | ||
isPin={focused} | ||
/> | ||
)} | ||
style={styles.tabBarStyle} | ||
indicatorStyle={styles.indicatorStyle} | ||
tabStyle={{ ...styles.tabStyle, minWidth: layout.width / 3 - (enableCustomTabs ? 14 : 0) }} | ||
scrollEnabled={routes.length > 3} | ||
onTabPress={({ route }) => { | ||
onFilterSelect(route.key); | ||
}} | ||
{...props} | ||
/> | ||
{enableCustomTabs && ( | ||
<IconButton | ||
iconStyle={styles.rightIcon} | ||
style={styles.rightIconWrapper} | ||
iconType="MaterialIcon" | ||
size={28} | ||
name="add" | ||
onPress={_onCustomisePress} | ||
/> | ||
)} | ||
{enableCustomTabs && <CustomiseFiltersModal pageType={pageType} ref={customiseModalRef} />} | ||
</View> | ||
); | ||
}; |
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
Oops, something went wrong.