/** * Copyright (c) 2019 Paul Armstrong */ import * as Theme from '../theme'; import Button from './Button'; import Menu from './Menu'; import MoreIcon from '../icons/More'; import React from 'react'; import { StyleProp, StyleSheet, Text, View, ViewStyle } from 'react-native'; interface Props { navigationIcon?: React.ComponentType<{ style?: StyleProp }>; navigationLabel?: string; onPressNavigationIcon?: () => void; style?: StyleProp; title?: React.ReactNode; actionItems?: Array; overflowItems?: React.ReactElement; } export interface Handles { dismissOverflow: () => void; } export const AppBar = React.forwardRef( (props: Props, ref: React.Ref): React.ReactElement => { const { actionItems, navigationIcon, onPressNavigationIcon, overflowItems, style, title } = props; const overflowRef = React.useRef(null); const [showOverflow, setShowOverflow] = React.useState(false); React.useImperativeHandle(ref, () => ({ dismissOverflow: () => { setShowOverflow(false); }, })); const handleShowOverflow = React.useCallback(() => { setShowOverflow((showOverflow) => !showOverflow); }, []); React.useEffect(() => { if (!overflowItems) { setShowOverflow(false); } }, [overflowItems]); return ( {navigationIcon ? (