-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Added a Notification head bar to present current notifications number #1322
base: main
Are you sure you want to change the base?
Changes from 6 commits
074ba83
87707c9
2d66bee
f464452
98b2ff4
7af305d
09c9d49
b2310fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,44 @@ | ||
import { useTheme } from '../../contexts/theme' | ||
import { useTranslation } from 'react-i18next' | ||
import React from 'react' | ||
import { View } from 'react-native' | ||
import { View, Text, StyleSheet } from 'react-native' | ||
import { NotificationReturnType } from '../../hooks/notifications' | ||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons' | ||
|
||
interface HomeHeaderViewProps { | ||
export interface HomeHeaderViewProps { | ||
notifications: NotificationReturnType | ||
showNotifications: boolean | ||
children?: any | ||
} | ||
|
||
const HomeHeaderView: React.FC<HomeHeaderViewProps> = ({ children }) => { | ||
return <View>{children}</View> | ||
const HomeHeaderView: React.FC<HomeHeaderViewProps> = ({ notifications, showNotifications, children }: HomeHeaderViewProps) => { | ||
const { t } = useTranslation() | ||
const { ColorPallet, TextTheme } = useTheme() | ||
|
||
const styles = StyleSheet.create({ | ||
noNotificationContainer: { | ||
flex: 1, | ||
flexDirection: "row", | ||
alignContent: "space-between", | ||
paddingHorizontal: 20, | ||
paddingTop: 20, | ||
paddingBottom: 0, | ||
backgroundColor: ColorPallet.brand.secondaryBackground, | ||
} | ||
}) | ||
return notifications?.length > 0 ? ( | ||
<View style={styles.noNotificationContainer}> | ||
<Text style={[TextTheme.label, { fontSize: 20, marginBottom: 6, textAlign: 'left' }]}> | ||
{t('Home.Notifications')} ({notifications?.length}) | ||
</Text> | ||
<Text style={{ position: 'absolute', right: 20, top: 20}}> | ||
<Icon name={showNotifications ? 'chevron-up' : 'chevron-down'} size={30} /> | ||
</Text> | ||
{children} | ||
</View> | ||
) : ( | ||
<></> | ||
) | ||
} | ||
|
||
export default HomeHeaderView |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -37,12 +37,13 @@ const Home: React.FC<HomeProps> = () => { | |||||||||||||||||||||
const { ColorPallet } = useTheme() | ||||||||||||||||||||||
const [store, dispatch] = useStore() | ||||||||||||||||||||||
const { start } = useTour() | ||||||||||||||||||||||
const [showNotifications] = useState(true) | ||||||||||||||||||||||
const [showTourPopup, setShowTourPopup] = useState(false) | ||||||||||||||||||||||
const screenIsFocused = useIsFocused() | ||||||||||||||||||||||
|
||||||||||||||||||||||
const styles = StyleSheet.create({ | ||||||||||||||||||||||
flatlist: { | ||||||||||||||||||||||
marginBottom: 35, | ||||||||||||||||||||||
marginBottom: 20, | ||||||||||||||||||||||
}, | ||||||||||||||||||||||
}) | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
@@ -130,7 +131,15 @@ const Home: React.FC<HomeProps> = () => { | |||||||||||||||||||||
scrollEnabled={notifications?.length > 0 ? true : false} | ||||||||||||||||||||||
decelerationRate="fast" | ||||||||||||||||||||||
ListEmptyComponent={NoNewUpdates} | ||||||||||||||||||||||
ListHeaderComponent={() => <HomeHeaderView />} | ||||||||||||||||||||||
ListHeaderComponent={() => { | ||||||||||||||||||||||
const homeHeaderViewProps = { | ||||||||||||||||||||||
notifications: notifications, | ||||||||||||||||||||||
showNotifications: showNotifications, | ||||||||||||||||||||||
} | ||||||||||||||||||||||
return ( | ||||||||||||||||||||||
<HomeHeaderView {...homeHeaderViewProps} /> | ||||||||||||||||||||||
) | ||||||||||||||||||||||
}} | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
If the |
||||||||||||||||||||||
ListFooterComponent={() => <HomeFooterView />} | ||||||||||||||||||||||
data={notifications} | ||||||||||||||||||||||
keyExtractor={(_, i) => i.toString()} | ||||||||||||||||||||||
|
@@ -139,11 +148,11 @@ const Home: React.FC<HomeProps> = () => { | |||||||||||||||||||||
style={{ | ||||||||||||||||||||||
paddingHorizontal: 20, | ||||||||||||||||||||||
paddingTop: index === 0 ? 20 : 0, | ||||||||||||||||||||||
paddingBottom: index === notifications.length - 1 ? 20 : 10, | ||||||||||||||||||||||
paddingBottom: !showNotifications ? 0 : index === notifications.length - 1 ? 20 : 10, | ||||||||||||||||||||||
backgroundColor: ColorPallet.brand.secondaryBackground, | ||||||||||||||||||||||
}} | ||||||||||||||||||||||
> | ||||||||||||||||||||||
{DisplayListItemType(item)} | ||||||||||||||||||||||
{ showNotifications && DisplayListItemType(item) } | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the chevron icons and the |
||||||||||||||||||||||
</View> | ||||||||||||||||||||||
)} | ||||||||||||||||||||||
/> | ||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`HomeHeaderView Component Renders correctly 1`] = `<View />`; | ||
exports[`HomeHeaderView Component Renders correctly 1`] = `null`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This state variable isn't changed and is used in more than one component. Would it be better adding it as a config option? (
TOKENS.CONFIG
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise I don't really see the purpose, as it's not overideable and isn't ever changed. If that's fine then maybe we can just remove it entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the chevron and showNotifications state, will add them back in story implements them