Create basic back button (HD-28)

This commit is contained in:
Marquis Kurt 2019-12-11 12:27:42 -05:00
parent 927c9c06a1
commit 93f135e93b
No known key found for this signature in database
GPG Key ID: 725636D259F5402D
3 changed files with 34 additions and 0 deletions

View File

@ -57,6 +57,10 @@ export const styles = (theme: Theme) =>
display: "none"
}
},
appBarBackButton: {
marginLeft: -12,
marginRight: 20
},
appBarTitle: {
display: "none",
[theme.breakpoints.up("md")]: {

View File

@ -44,6 +44,7 @@ import SupervisedUserCircleIcon from "@material-ui/icons/SupervisedUserCircle";
import ExitToAppIcon from "@material-ui/icons/ExitToApp";
import TrendingUpIcon from "@material-ui/icons/TrendingUp";
import BuildIcon from "@material-ui/icons/Build";
import ArrowBackIcon from "@material-ui/icons/ArrowBack";
import { styles } from "./AppLayout.styles";
import { MultiAccount, UAccount } from "../../types/Account";
@ -67,6 +68,7 @@ import {
getAccountRegistry,
removeAccountFromRegistry
} from "../../utilities/accounts";
import { isChildView } from "../../utilities/appbar";
interface IAppLayoutState {
acctMenuOpen: boolean;
@ -484,6 +486,17 @@ export class AppLayout extends Component<any, IAppLayoutState> {
{this.titlebar()}
<AppBar className={classes.appBar} position="static">
<Toolbar>
{isChildView(window.location.hash) ? (
<IconButton
className={classes.appBarBackButton}
color="inherit"
aria-label="Go back"
onClick={() => window.history.back()}
>
<ArrowBackIcon />
</IconButton>
) : null}
<IconButton
className={classes.appBarMenuButton}
color="inherit"

View File

@ -9,3 +9,20 @@ import { isDarwinApp } from "./desktop";
export function isAppbarExpanded(): boolean {
return isDarwinApp() || process.env.NODE_ENV === "development";
}
/**
* Determine whether the current page is a child view and can go back.
*/
export function isChildView(hash: string): boolean {
const childViews = ["#/conversation", "#/profile"];
let foundProtocol = false;
childViews.forEach((childViewProtocol: string) => {
if (hash.includes(childViewProtocol)) {
console.log(childViewProtocol);
foundProtocol = true;
}
});
return foundProtocol;
}