MobileWarning improved

This commit is contained in:
srgooglo 2020-03-19 14:32:27 +01:00
parent 24291d2f32
commit dc35f86753
5 changed files with 76 additions and 66 deletions

View File

@ -3,7 +3,7 @@
"UUID": "annyudx7eo", "UUID": "annyudx7eo",
"title": "Comty™", "title": "Comty™",
"DevBuild": true, "DevBuild": true,
"version": "0.2.18", "version": "0.2.19",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"author": "RageStudio", "author": "RageStudio",

View File

@ -0,0 +1,38 @@
import React from 'react'
import styles from './index.less'
import store from 'store'
import * as antd from 'antd'
export default class MobileWarning extends React.PureComponent{
state = {
resbypass: store.get('resbypass') || false,
}
ResByPassHandler = () => {
this.setState({resbypass: true})
}
render(){
const { resbypass } = this.state
if (resbypass == false) {
return(
<div className={styles.mobilewarning}>
<antd.Result status="warning" title="Low resolution warning"
extra={
<div style={{ color: "white" }}>
<h3 style={{ color: "white" }}>This version of the application is not fully compatible with the resolution of this screen, a higher resolution is recommended for an optimal experience</h3>
<span>Please choose an option to continue</span>
<br /><br /><antd.Button type="dashed" onClick={() => this.ResByPassHandler()}>Continue</antd.Button>
</div>
}/>
</div>
)
}
return null
}
}

View File

@ -0,0 +1,18 @@
.mobilewarning{
background-color: rgba(0, 0, 0, 0.975);
color: white;
width: 100%;
position: absolute;
top: 0;
bottom: 0;
z-index: 100000;
display: flex;
justify-content: center;
text-align: center;
:global {
.ant-result-title {
color: white;
}
}
}

View File

@ -1,6 +1,7 @@
// @alias from 'components' // @alias from 'components'
// Helpers & Misc // Helpers & Misc
import MobileWarning from './MobileWarning'
import CustomIcons from './CustomIcons' import CustomIcons from './CustomIcons'
import Loader from './Loader/Loader.js' import Loader from './Loader/Loader.js'
import ScrollBar from './ScrollBar' import ScrollBar from './ScrollBar'
@ -27,7 +28,8 @@ import PostCreator from './PostCreator'
// Mix & Export all // Mix & Export all
export export
{ {
UserBadges, UserBadges,
MobileWarning,
PageTransition, PageTransition,
SearchCard, SearchCard,
HeaderSearch, HeaderSearch,

View File

@ -1,13 +1,11 @@
/* global window */ /* global window */
/* global document */ /* global document */
import React, { PureComponent, Fragment } from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import withRouter from 'umi/withRouter' import withRouter from 'umi/withRouter'
import { connect } from 'dva' import { connect } from 'dva'
import { MyLayout, PageTransition, HeaderSearch } from 'components' import { MyLayout, PageTransition, HeaderSearch, MobileWarning } from 'components'
import { Layout, Result, Button } from 'antd'
import { enquireScreen, unenquireScreen } from 'enquire-js' import { enquireScreen, unenquireScreen } from 'enquire-js'
import { langFromPath } from 'utils'
import store from 'store'; import store from 'store';
import classnames from 'classnames' import classnames from 'classnames'
@ -17,7 +15,7 @@ import * as Icons from '@ant-design/icons'
import styles from './PrimaryLayout.less' import styles from './PrimaryLayout.less'
const { Content } = Layout const { Content } = antd.Layout
const { Sider, Control, Secondary } = MyLayout const { Sider, Control, Secondary } = MyLayout
@withRouter @withRouter
@ -29,8 +27,6 @@ class PrimaryLayout extends React.Component {
this.state = { this.state = {
collapsed: ycore.DevOptions.default_collapse_sider, collapsed: ycore.DevOptions.default_collapse_sider,
isMobile: false, isMobile: false,
resbypass: store.get('resbypass') || false,
RemByPass: false,
userData: '' userData: ''
} }
} }
@ -57,16 +53,7 @@ class PrimaryLayout extends React.Component {
store.set('collapsed', !fromStore) store.set('collapsed', !fromStore)
} }
ResByPassHandler = () => {
const {RemByPass} = this.state;
if (RemByPass == true){
this.setState({resbypass: true})
store.set('resbypass', true)
return
}
this.setState({resbypass: true})
}
isDarkMode = () => { isDarkMode = () => {
const {app} = this.props const {app} = this.props
const { theme } = app const { theme } = app
@ -78,25 +65,10 @@ class PrimaryLayout extends React.Component {
render() { render() {
const { app, location, dispatch, children } = this.props const { app, location, dispatch, children } = this.props
const { theme, routeList } = app const { userData, collapsed, isMobile } = this.state
const { userData, isMobile, resbypass } = this.state
const collapsed = (this.state.collapsed? true : false)
const { onCollapseChange } = this const { onCollapseChange } = this
// Localized route name. const { theme } = app
const lang = langFromPath(location.pathname)
const newRouteList =
lang !== 'en'
? routeList.map(item => {
const { name, ...other } = item
return {
...other,
name: (item[lang] || {}).name || name,
}
})
: routeList
const SiderProps = { const SiderProps = {
theme, theme,
@ -111,43 +83,23 @@ class PrimaryLayout extends React.Component {
}) })
}, },
} }
const ContainerProps = {
theme,
userData,
collapsed,
}
const SecondaryProps = { const SecondaryProps = {
userData userData,
} isMobile,
theme,
const MobileWarning = () =>{
if (resbypass == false) {
if (isMobile == true) {
return(
<div className={styles.mobilewarning}>
<Result status="warning" title="Low resolution warning"
extra={ <div style={{ color: "white" }}><h3 style={{ color: "white" }}>This version of the application is not fully compatible with the resolution of this screen, a higher resolution is recommended for an optimal experience</h3><span>Please choose an option to continue</span><br /><br /><Button type="dashed" onClick={this.ResByPassHandler}>Continue</Button></div> }/>
</div>
)
}
}
return null
} }
return ( return (
<Fragment> <React.Fragment>
<MobileWarning /> {isMobile? <MobileWarning /> : null}
<div className={styles.BarControlWrapper}><Control /></div> <div className={styles.BarControlWrapper}><Control /></div>
<Layout className={classnames( styles.layout, {[styles.md_dark]: this.isDarkMode() })}> <antd.Layout className={classnames( styles.layout, {[styles.md_dark]: this.isDarkMode() })}>
<Sider {...SiderProps}/> <Sider {...SiderProps}/>
<div id="primaryLayout" className={styles.leftContainer}> <div id="primaryLayout" className={styles.leftContainer}>
<PageTransition preset="moveToRightScaleUp" id="scroller" transitionKey={location.pathname}> <PageTransition preset="moveToRightScaleUp" id="scroller" transitionKey={location.pathname}>
<Content className={classnames(styles.content, {[styles.collapsed]: !collapsed} )}>
<Content {...ContainerProps} className={classnames(styles.content, {[styles.collapsed]: !collapsed} )}>
<HeaderSearch /> <HeaderSearch />
{children} {children}
</Content> </Content>
@ -156,8 +108,8 @@ class PrimaryLayout extends React.Component {
<Secondary {...SecondaryProps} /> <Secondary {...SecondaryProps} />
</Layout> </antd.Layout>
</Fragment> </React.Fragment>
) )
} }