({ navigation }: Props)
| 28 | const MEDIUM_FAB_HEIGHT = 56; |
| 29 | |
| 30 | const AppbarExample = ({ navigation }: Props) => { |
| 31 | const [showLeftIcon, setShowLeftIcon] = React.useState(true); |
| 32 | const [showSubtitle, setShowSubtitle] = React.useState(true); |
| 33 | const [showSearchIcon, setShowSearchIcon] = React.useState(true); |
| 34 | const [showMoreIcon, setShowMoreIcon] = React.useState(true); |
| 35 | const [showCustomColor, setShowCustomColor] = React.useState(false); |
| 36 | const [showExactTheme, setShowExactTheme] = React.useState(false); |
| 37 | const [appbarMode, setAppbarMode] = React.useState<AppbarModes>('small'); |
| 38 | const [showCalendarIcon, setShowCalendarIcon] = React.useState(false); |
| 39 | const [showElevated, setShowElevated] = React.useState(false); |
| 40 | const [showSnackbar, setShowSnackbar] = React.useState(false); |
| 41 | |
| 42 | const theme = useExampleTheme(); |
| 43 | const { bottom, left, right } = useSafeAreaInsets(); |
| 44 | const height = theme.isV3 ? 80 : 56; |
| 45 | |
| 46 | const isCenterAlignedMode = appbarMode === 'center-aligned'; |
| 47 | |
| 48 | React.useLayoutEffect(() => { |
| 49 | navigation.setOptions({ |
| 50 | header: () => ( |
| 51 | <Appbar.Header |
| 52 | style={showCustomColor ? styles.customColor : null} |
| 53 | theme={{ |
| 54 | mode: showExactTheme ? 'exact' : 'adaptive', |
| 55 | }} |
| 56 | mode={appbarMode} |
| 57 | elevated={showElevated} |
| 58 | > |
| 59 | {showLeftIcon && ( |
| 60 | <Appbar.BackAction onPress={() => navigation.goBack()} /> |
| 61 | )} |
| 62 | <Appbar.Content |
| 63 | title="Title" |
| 64 | subtitle={showSubtitle ? 'Subtitle' : null} |
| 65 | onPress={() => setShowSnackbar(true)} |
| 66 | /> |
| 67 | {isCenterAlignedMode |
| 68 | ? false |
| 69 | : showCalendarIcon && ( |
| 70 | <Appbar.Action icon="calendar" onPress={() => {}} /> |
| 71 | )} |
| 72 | {showSearchIcon && ( |
| 73 | <Appbar.Action icon="magnify" onPress={() => {}} /> |
| 74 | )} |
| 75 | {showMoreIcon && ( |
| 76 | <Appbar.Action icon={MORE_ICON} onPress={() => {}} /> |
| 77 | )} |
| 78 | </Appbar.Header> |
| 79 | ), |
| 80 | }); |
| 81 | }, [ |
| 82 | navigation, |
| 83 | showLeftIcon, |
| 84 | showSubtitle, |
| 85 | showSearchIcon, |
| 86 | showMoreIcon, |
| 87 | showCustomColor, |
nothing calls this directly
no test coverage detected
searching dependent graphs…