diff --git a/component/OnlineStudy/2-PlayerPKHome/index.js b/component/OnlineStudy/2-PlayerPKHome/index.js index 2381da89f7780f3e32e02036b675e8925c1f8df3..17365136124c95bcb3d045ff40795a1af09174cb 100644 --- a/component/OnlineStudy/2-PlayerPKHome/index.js +++ b/component/OnlineStudy/2-PlayerPKHome/index.js @@ -1,12 +1,17 @@ import React, {Component} from 'react'; -import { View, StyleSheet, Dimensions, Image, ToastAndroid, Platform, BackHandler } from "react-native"; +import { + View, + StyleSheet, + Image, + ToastAndroid, + Platform, + BackHandler, +} from 'react-native'; import Img1 from './img/img1.png'; import Img2 from './img/img2.png'; import MyButton from '../MyButton'; import {websocket} from '../MyUtilities'; -const {width, height} = Dimensions.get('window'); - class TwoPlayerPKHome extends Component { constructor() { super(); diff --git a/component/OnlineStudy/2-PlayerPKState/index.js b/component/OnlineStudy/2-PlayerPKState/index.js index 5d2a621d03922711fbc3b00547dd9fd1cc341df0..261683129c3d405524688556ef0443d10aa7ade4 100644 --- a/component/OnlineStudy/2-PlayerPKState/index.js +++ b/component/OnlineStudy/2-PlayerPKState/index.js @@ -11,7 +11,7 @@ import PropTypes from 'prop-types'; import Clock from './img/clock1.png'; import Searching from './img/searching1.png'; -const {width, height} = Dimensions.get('window'); +const {height} = Dimensions.get('window'); class TwoPlayerPKState extends Component { constructor() { diff --git a/component/OnlineStudy/2-PlayerPKStudy/index.js b/component/OnlineStudy/2-PlayerPKStudy/index.js index aad6cf1ed969a4c7c61b11ce8256b344c12d34c3..dc454373748ca5ea76560b87e70cae65a5a3f904 100644 --- a/component/OnlineStudy/2-PlayerPKStudy/index.js +++ b/component/OnlineStudy/2-PlayerPKStudy/index.js @@ -22,7 +22,7 @@ import { sno, } from '../MyUtilities'; -const {width, height} = Dimensions.get('window'); +const {height} = Dimensions.get('window'); /** * 标语风格切换共使用了组件: * 1. GlobalSetting(引入global变量global.bannerStyle,来控制标语风格) @@ -57,6 +57,7 @@ class TwoPlayerPKStudy extends Component { duration: -1, timeInTheMatch: -1, }, + isGoBack: false, victories: 0, isStarted: false, timeInTheGame: 0, @@ -97,8 +98,11 @@ class TwoPlayerPKStudy extends Component { } backEvent = () => { - this.finish(); - return true; + if (!this.state.isGoBack) { + this.finish(); + return true; + } + return false; }; resolveMessage = msg => { @@ -185,6 +189,7 @@ class TwoPlayerPKStudy extends Component { // console.log('点击确定'); websocket.disconnect(); clearInterval(this.timer); + this.setState({isGoBack: true}); this.props.navigation.goBack(); }, }, diff --git a/component/OnlineStudy/BannerStyle/index.js b/component/OnlineStudy/BannerStyle/index.js index a3ce2af220ee1e2fd2517c03c63fc99ced6058ad..14f09b6accdd6139bab93efc7826783f5d6b604b 100644 --- a/component/OnlineStudy/BannerStyle/index.js +++ b/component/OnlineStudy/BannerStyle/index.js @@ -1,10 +1,8 @@ import React, {Component} from 'react'; -import {View, StyleSheet, Dimensions} from 'react-native'; +import {View, StyleSheet} from 'react-native'; import MyButton from '../MyButton'; import {bannerStyle} from '../GlobalSetting'; -const {width, height} = Dimensions.get('window'); - class BannerStyle extends Component { constructor() { super(); diff --git a/component/OnlineStudy/MyBanner/index.js b/component/OnlineStudy/MyBanner/index.js index a4768bcec6a6ebdb5ad0d04174382d248c0e07f9..d28b5e522710ad698b0e5bb026e896d258fff9c1 100644 --- a/component/OnlineStudy/MyBanner/index.js +++ b/component/OnlineStudy/MyBanner/index.js @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'; import MyButton from '../MyButton'; import {bannerStyle} from '../GlobalSetting'; -const {width, height} = Dimensions.get('window'); +const {height} = Dimensions.get('window'); class MyBanner extends Component { constructor() { @@ -87,16 +87,16 @@ class MyBanner extends Component { disabled, }; const container = {...styles.container, ...containerStyle}; - const bannerStyle = this.chooseBannerStyle(); + const bannerContent = this.chooseBannerStyle(); const banner = { containerStyle: styles.containerStyle, - textEnabled: bannerStyle.textEnabled, - textDisabled: bannerStyle.textDisabled, + textEnabled: bannerContent.textEnabled, + textDisabled: bannerContent.textDisabled, textStyle: styles.textStyle, - buttonEnabled: bannerStyle.buttonEnabled, - buttonDisabled: bannerStyle.buttonDisabled, + buttonEnabled: bannerContent.buttonEnabled, + buttonDisabled: bannerContent.buttonDisabled, buttonStyle: styles.buttonStyle, - title: bannerStyle.title, + title: bannerContent.title, }; return ( diff --git a/component/OnlineStudy/MyButton/index.js b/component/OnlineStudy/MyButton/index.js index 9394d8e13393e1bca6cc11fc7ecdc29b30bd033a..cafd8db89ce054db3dbcd8e8e7ca25f6d08a9420 100644 --- a/component/OnlineStudy/MyButton/index.js +++ b/component/OnlineStudy/MyButton/index.js @@ -8,7 +8,7 @@ import { } from 'react-native'; import PropTypes from 'prop-types'; -const {width, height} = Dimensions.get('window'); +const {height} = Dimensions.get('window'); class MyButton extends Component { constructor() { diff --git a/component/OnlineStudy/MyStatistics/index.js b/component/OnlineStudy/MyStatistics/index.js index da40d7ac64d8c54fa51f9531613f532d446bd2af..c6b67ee5a129da80040e9863b4db6ea36e6f22b3 100644 --- a/component/OnlineStudy/MyStatistics/index.js +++ b/component/OnlineStudy/MyStatistics/index.js @@ -2,7 +2,7 @@ import React, {Component} from 'react'; import {View, Text, StyleSheet, Dimensions, Pressable} from 'react-native'; import PropTypes from 'prop-types'; -const {width, height} = Dimensions.get('window'); +const {height} = Dimensions.get('window'); class MyStatistics extends Component { constructor() { diff --git a/component/OnlineStudy/MyTest/index.js b/component/OnlineStudy/MyTest/index.js index ee8dbff2727c040ccf0eb57f2c1681a5b76fb88f..e50dc4b83dad384ee454de751bcadeb20dddc709 100644 --- a/component/OnlineStudy/MyTest/index.js +++ b/component/OnlineStudy/MyTest/index.js @@ -11,8 +11,8 @@ export function login() { sno: sno.get(), password: password.get(), }; - const resolveData = data => { - console.log(data); + const resolveData = r => { + console.log(r); }; // console.log('[Login] sno: ' + data.sno + ' password: ' + data.password); post(URL_LOGIN, data).then(resolveData).catch(); diff --git a/component/OnlineStudy/MyTitle/index.js b/component/OnlineStudy/MyTitle/index.js index acd9ef72f8d3564e9ef34ebb6b01b17582cc4df0..e0942c68154e9d5679e1f3525a5b8c280b848e80 100644 --- a/component/OnlineStudy/MyTitle/index.js +++ b/component/OnlineStudy/MyTitle/index.js @@ -2,7 +2,7 @@ import React, {Component} from 'react'; import {Text, StyleSheet, Dimensions, View} from 'react-native'; import PropTypes from 'prop-types'; -const {width, height} = Dimensions.get('window'); +const {height} = Dimensions.get('window'); class MyTitle extends Component { constructor() { diff --git a/component/OnlineStudy/OnlineStudyHome/index.js b/component/OnlineStudy/OnlineStudyHome/index.js index c1b59bc860b8f64bc40dafdebda0e1e5ac628aa4..410cfe37bf9aec884837c4696680fe9db0d8c304 100644 --- a/component/OnlineStudy/OnlineStudyHome/index.js +++ b/component/OnlineStudy/OnlineStudyHome/index.js @@ -1,9 +1,7 @@ import React, {Component} from 'react'; -import {View, StyleSheet, Dimensions, Image, Pressable} from 'react-native'; +import {View, StyleSheet, Image, Pressable} from 'react-native'; import {login, logout} from '../MyTest'; -const {width, height} = Dimensions.get('window'); - class OnlineStudyHome extends Component { constructor() { super(); @@ -62,7 +60,7 @@ const styles = StyleSheet.create({ textAlign: 'center', }, button: { - flex: 0.5, + flex: 1, borderRadius: 50, }, image: {