Merge branch 'main' into inherit_system_theme
This commit is contained in:
@@ -3,11 +3,15 @@ import {useNavigation} from '@react-navigation/native'
|
||||
|
||||
import {NavigationProp} from 'lib/routes/types'
|
||||
import {bskyTitle} from 'lib/strings/headings'
|
||||
import {useUnreadCountLabel} from './useUnreadCountLabel'
|
||||
import {useStores} from 'state/index'
|
||||
|
||||
/**
|
||||
* Requires consuming component to be wrapped in `observer`:
|
||||
* https://stackoverflow.com/a/71488009
|
||||
*/
|
||||
export function useSetTitle(title?: string) {
|
||||
const navigation = useNavigation<NavigationProp>()
|
||||
const unreadCountLabel = useUnreadCountLabel()
|
||||
const {unreadCountLabel} = useStores().me.notifications
|
||||
useEffect(() => {
|
||||
if (title) {
|
||||
navigation.setOptions({title: bskyTitle(title, unreadCountLabel)})
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import {useEffect, useReducer} from 'react'
|
||||
import {DeviceEventEmitter} from 'react-native'
|
||||
import {useStores} from 'state/index'
|
||||
|
||||
export function useUnreadCountLabel() {
|
||||
// HACK: We don't have anything like Redux selectors,
|
||||
// and we don't want to use <RootStoreContext.Consumer />
|
||||
// to react to the whole store
|
||||
const [, forceUpdate] = useReducer(x => x + 1, 0)
|
||||
useEffect(() => {
|
||||
const subscription = DeviceEventEmitter.addListener(
|
||||
'unread-notifications',
|
||||
forceUpdate,
|
||||
)
|
||||
return () => subscription?.remove()
|
||||
}, [forceUpdate])
|
||||
|
||||
return useStores().me.notifications.unreadCountLabel
|
||||
}
|
||||
@@ -320,6 +320,35 @@ export function MoonIcon({
|
||||
)
|
||||
}
|
||||
|
||||
// Copyright (c) 2020 Refactoring UI Inc.
|
||||
// https://github.com/tailwindlabs/heroicons/blob/master/LICENSE
|
||||
export function SunIcon({
|
||||
style,
|
||||
size,
|
||||
strokeWidth = 1.5,
|
||||
}: {
|
||||
style?: StyleProp<ViewStyle>
|
||||
size?: string | number
|
||||
strokeWidth?: number
|
||||
}) {
|
||||
return (
|
||||
<Svg
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
width={size || 32}
|
||||
height={size || 32}
|
||||
strokeWidth={strokeWidth}
|
||||
stroke="currentColor"
|
||||
style={style}>
|
||||
<Path
|
||||
d="M12 3V5.25M18.364 5.63604L16.773 7.22703M21 12H18.75M18.364 18.364L16.773 16.773M12 18.75V21M7.22703 16.773L5.63604 18.364M5.25 12H3M7.22703 7.22703L5.63604 5.63604M15.75 12C15.75 14.0711 14.0711 15.75 12 15.75C9.92893 15.75 8.25 14.0711 8.25 12C8.25 9.92893 9.92893 8.25 12 8.25C14.0711 8.25 15.75 9.92893 15.75 12Z"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</Svg>
|
||||
)
|
||||
}
|
||||
|
||||
// Copyright (c) 2020 Refactoring UI Inc.
|
||||
// https://github.com/tailwindlabs/heroicons/blob/master/LICENSE
|
||||
export function UserIcon({
|
||||
|
||||
Reference in New Issue
Block a user