Add notification viewed sync and header badge dot
This commit is contained in:
26
App.js
26
App.js
@@ -273,6 +273,12 @@ const MainNavigation = ({ route }) => {
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
const appState = useSnapshot(GlobalState);
|
||||
const viewer = appState.me || {};
|
||||
const hasUnviewedNotifications = Array.isArray(viewer?.notifications)
|
||||
? viewer.notifications.some((n) => n && n.viewed !== true)
|
||||
: false;
|
||||
|
||||
return (
|
||||
<PaperProvider settings={{
|
||||
icon: props => <MaterialIcons {...props} />,
|
||||
@@ -295,7 +301,25 @@ export default function App() {
|
||||
props.navigation.navigate("SongPlayer");
|
||||
}} />
|
||||
<Appbar.Action icon="search" onPress={() => { props.navigation.navigate("Search") }} />
|
||||
<Appbar.Action icon="notifications" onPress={() => { props.navigation.navigate("Notifications") }} />
|
||||
<Appbar.Action
|
||||
icon={({ size, color }) => (
|
||||
<View style={{ width: size, height: size, justifyContent: "center", alignItems: "center" }}>
|
||||
<MaterialIcons name="notifications" size={size} color={color} />
|
||||
{hasUnviewedNotifications ? (
|
||||
<View style={{
|
||||
position: "absolute",
|
||||
top: 2,
|
||||
right: 0,
|
||||
width: 8,
|
||||
height: 8,
|
||||
borderRadius: 4,
|
||||
backgroundColor: "#d93025",
|
||||
}} />
|
||||
) : <></>}
|
||||
</View>
|
||||
)}
|
||||
onPress={() => { props.navigation.navigate("Notifications") }}
|
||||
/>
|
||||
</Appbar.Header>
|
||||
)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user