import React, { useCallback } from 'react';
import cn from 'classnames';
import { Flex } from 'indigo-react';
import Footer from './Footer';
import useBreakpoints from 'lib/useBreakpoints';
import { MiniBackButton } from './MiniBackButton';
import { useHistory } from 'store/history';
import NavHeader from './NavHeader';
// View is a top-level component that all Views must render to inherit styling
function View({
className,
children,
inset = false,
full = false,
hideBack = false,
pop,
header,
centered = false,
...rest
}) {
const { reset } = useHistory();
const isMobile = useBreakpoints([true, false, false]);
const shouldInset = inset && !isMobile;
const insetPadding = cn({
pt7: shouldInset,
pt5: !shouldInset,
});
const goBack = useCallback(() => pop(), [pop]);
const goLogout = reset;
const showBackButton = !!pop;
const Header = useCallback(
({ logout }) => {
return showBackButton ? (
Logout
) : (
);
},
[goLogout, insetPadding, showBackButton]
);
return (
{showBackButton && !hideBack && (
)}
{header || }
{children}
);
}
// View.Full is sugar for to help with readability
View.Full = function FullView(props) {
return ;
};
export default View;