react-native-gifted-chat
Version:
The most complete chat UI for React Native
19 lines (16 loc) • 661 B
text/typescript
import { useColorScheme as useRNColorScheme } from 'react-native'
import { useChatContext } from '../GiftedChatContext'
/**
* Custom hook that returns the color scheme from GiftedChat context if provided,
* otherwise falls back to the system color scheme from React Native.
*
* @returns The current color scheme ('light', 'dark', null, or undefined)
*/
export function useColorScheme() {
const { getColorScheme } = useChatContext()
const contextColorScheme = getColorScheme()
const systemColorScheme = useRNColorScheme()
return contextColorScheme !== undefined && contextColorScheme !== null
? contextColorScheme
: systemColorScheme
}