Replace notifications icon

zio/stable
Paul Frazee 2022-11-01 13:45:58 -05:00
parent c949269abc
commit ae18007d35
3 changed files with 42 additions and 9 deletions

View File

@ -1,6 +1,6 @@
import React from 'react' import React from 'react'
import {StyleProp, ViewStyle} from 'react-native' import {StyleProp, ViewStyle} from 'react-native'
import Svg, {Circle, Line, G, Path} from 'react-native-svg' import Svg, {Path} from 'react-native-svg'
export function GridIcon({style}: {style?: StyleProp<ViewStyle>}) { export function GridIcon({style}: {style?: StyleProp<ViewStyle>}) {
const DIM = 4 const DIM = 4
@ -47,6 +47,30 @@ export function HomeIcon({style}: {style?: StyleProp<ViewStyle>}) {
) )
} }
// https://github.com/Remix-Design/RemixIcon/blob/master/License
export function BellIcon({
style,
size,
}: {
style?: StyleProp<ViewStyle>
size?: string | number
}) {
return (
<Svg
fill="none"
viewBox="0 0 24 24"
width={size || 24}
height={size || 24}
style={style}>
<Path fill="none" d="M0 0h24v24H0z" />
<Path
fill="currentColor"
d="M20 17h2v2H2v-2h2v-7a8 8 0 1 1 16 0v7zm-2 0v-7a6 6 0 1 0-12 0v7h12zm-9 4h6v2H9v-2z"
/>
</Svg>
)
}
// Copyright (c) 2020 Refactoring UI Inc. // Copyright (c) 2020 Refactoring UI Inc.
// https://github.com/tailwindlabs/heroicons/blob/master/LICENSE // https://github.com/tailwindlabs/heroicons/blob/master/LICENSE
export function UserGroupIcon({style}: {style?: StyleProp<ViewStyle>}) { export function UserGroupIcon({style}: {style?: StyleProp<ViewStyle>}) {

View File

@ -16,7 +16,7 @@ import Animated, {
} from 'react-native-reanimated' } from 'react-native-reanimated'
import {IconProp} from '@fortawesome/fontawesome-svg-core' import {IconProp} from '@fortawesome/fontawesome-svg-core'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {HomeIcon, UserGroupIcon} from '../../lib/icons' import {HomeIcon, UserGroupIcon, BellIcon} from '../../lib/icons'
import {UserAvatar} from '../../com/util/UserAvatar' import {UserAvatar} from '../../com/util/UserAvatar'
import {useStores} from '../../../state' import {useStores} from '../../../state'
import {s, colors} from '../../lib/styles' import {s, colors} from '../../lib/styles'
@ -70,6 +70,8 @@ export const MainMenu = observer(
<HomeIcon style={styles.menuItemIcon} /> <HomeIcon style={styles.menuItemIcon} />
) : icon === 'user-group' ? ( ) : icon === 'user-group' ? (
<UserGroupIcon style={styles.menuItemIcon} /> <UserGroupIcon style={styles.menuItemIcon} />
) : icon === 'bell' ? (
<BellIcon style={styles.menuItemIcon} size="28" />
) : ( ) : (
<FontAwesomeIcon <FontAwesomeIcon
icon={icon} icon={icon}
@ -160,7 +162,7 @@ export const MainMenu = observer(
<View style={[styles.menuItems]}> <View style={[styles.menuItems]}>
<MenuItem icon="home" label="Home" url="/" /> <MenuItem icon="home" label="Home" url="/" />
<MenuItem <MenuItem
icon={['far', 'bell']} icon="bell"
label="Notifications" label="Notifications"
url="/notifications" url="/notifications"
count={store.me.notificationCount} count={store.me.notificationCount}

View File

@ -9,6 +9,7 @@ import {
Text, Text,
TouchableOpacity, TouchableOpacity,
View, View,
ViewStyle,
} from 'react-native' } from 'react-native'
import {ScreenContainer, Screen} from 'react-native-screens' import {ScreenContainer, Screen} from 'react-native-screens'
import LinearGradient from 'react-native-linear-gradient' import LinearGradient from 'react-native-linear-gradient'
@ -31,7 +32,7 @@ import {LocationNavigator} from './LocationNavigator'
import {MainMenu} from './MainMenu' import {MainMenu} from './MainMenu'
import {TabsSelector} from './TabsSelector' import {TabsSelector} from './TabsSelector'
import {s, colors} from '../../lib/styles' import {s, colors} from '../../lib/styles'
import {GridIcon, HomeIcon} from '../../lib/icons' import {GridIcon, HomeIcon, BellIcon} from '../../lib/icons'
const SWIPE_GESTURE_DIST_TRIGGER = 0.5 const SWIPE_GESTURE_DIST_TRIGGER = 0.5
const SWIPE_GESTURE_VEL_TRIGGER = 2500 const SWIPE_GESTURE_VEL_TRIGGER = 2500
@ -43,17 +44,23 @@ const Btn = ({
onPress, onPress,
onLongPress, onLongPress,
}: { }: {
icon: IconProp icon: IconProp | 'menu' | 'house' | 'bell'
inactive?: boolean inactive?: boolean
notificationCount?: number notificationCount?: number
onPress?: (event: GestureResponderEvent) => void onPress?: (event: GestureResponderEvent) => void
onLongPress?: (event: GestureResponderEvent) => void onLongPress?: (event: GestureResponderEvent) => void
}) => { }) => {
let size = 21
let addedStyles
let IconEl let IconEl
if (icon === 'menu') { if (icon === 'menu') {
IconEl = GridIcon IconEl = GridIcon
} else if (icon === 'house') { } else if (icon === 'house') {
IconEl = HomeIcon IconEl = HomeIcon
} else if (icon === 'bell') {
IconEl = BellIcon
size = 24
addedStyles = {position: 'relative', top: -1} as ViewStyle
} else { } else {
IconEl = FontAwesomeIcon IconEl = FontAwesomeIcon
} }
@ -67,8 +74,8 @@ const Btn = ({
</View> </View>
) : undefined} ) : undefined}
<IconEl <IconEl
size={21} size={size}
style={[styles.ctrlIcon, styles.inactive]} style={[styles.ctrlIcon, styles.inactive, addedStyles]}
icon={icon} icon={icon}
/> />
</View> </View>
@ -85,7 +92,7 @@ const Btn = ({
<Text style={styles.ctrlCountLabel}>{notificationCount}</Text> <Text style={styles.ctrlCountLabel}>{notificationCount}</Text>
</View> </View>
) : undefined} ) : undefined}
<IconEl size={21} style={styles.ctrlIcon} icon={icon} /> <IconEl size={size} style={[styles.ctrlIcon, addedStyles]} icon={icon} />
</TouchableOpacity> </TouchableOpacity>
) )
} }
@ -203,7 +210,7 @@ export const MobileShell: React.FC = observer(() => {
<Btn icon="search" inactive={true} onPress={() => {} /* TODO */} /> <Btn icon="search" inactive={true} onPress={() => {} /* TODO */} />
<Btn icon="menu" onPress={onPressMenu} /> <Btn icon="menu" onPress={onPressMenu} />
<Btn <Btn
icon={['far', 'bell']} icon="bell"
onPress={onPressNotifications} onPress={onPressNotifications}
notificationCount={store.me.notificationCount} notificationCount={store.me.notificationCount}
/> />