import React from "react" import { Motion, spring } from "react-motion" import { EviteComponent } from "evite" import * as antd from "antd" import { createIconRender } from "components/Icons" import classnames from "classnames" import "./index.less" export default class BottomBar extends EviteComponent { state = { allowed: true, show: false, visible: false, creatorActionsVisible: false, render: null, isManager: false, } handleBusEvents = { "app.render_initialization": () => { this.toggle(false) }, "app.render_initialization_done": () => { if (this.isAllowed()) { this.toggle(true) } }, "app.crash": () => { this.toggle(false) }, "locationChange": () => { this.toggle(this.isAllowed()) } } componentDidMount = () => { this._loadBusEvents() window.app.BottomBarController = { toogleVisible: this.toggle, isVisible: () => this.state.visible, render: (fragment) => { this.setState({ render: fragment }) }, clear: () => { this.setState({ render: null }) }, } } componentWillUnmount = () => { this._unloadBusEvents() delete window.app.BottomBarController } isAllowed() { return app.pageStatement?.bottomBarAllowed !== "undefined" && app.pageStatement?.bottomBarAllowed !== false } toggle = (to) => { if (!window.isMobile) { to = false } else { to = to ?? !this.state.visible } if (!to) { this.setState({ show: to }, () => { setTimeout(() => { this.setState({ visible: to }) }, 500) }) } else { this.setState({ visible: to }, () => { this.setState({ show: to }) }) } } onClickItemId = (id) => { window.app.setLocation(`/${id}`) } render() { if (this.state.render) { return
{this.state.render}
} if (!this.state.visible) { return null } return {({ y }) =>
window.app.goMain()} >
{createIconRender("Home")}
window.app.openCreateNew()} >
{createIconRender("PlusCircle")}
window.app.openSettings()} >
{createIconRender("Settings")}
{this.props.user ?
window.app.goToAccount()} >
:
this.onClickItemId("login")} className="item" >
{createIconRender("LogIn")}
}
}
} }