From 49a78d8aec2da1d2e5ba63947b45104e64c38684 Mon Sep 17 00:00:00 2001 From: 221900304 <1480466053@qq.com> Date: Wed, 11 May 2022 01:58:04 +0800 Subject: [PATCH] 304_change code --- component/OnlineStudy/2-PlayerPKHome/index.js | 11 ++++++++--- component/OnlineStudy/2-PlayerPKState/index.js | 2 +- component/OnlineStudy/2-PlayerPKStudy/index.js | 11 ++++++++--- component/OnlineStudy/BannerStyle/index.js | 4 +--- component/OnlineStudy/MyBanner/index.js | 14 +++++++------- component/OnlineStudy/MyButton/index.js | 2 +- component/OnlineStudy/MyStatistics/index.js | 2 +- component/OnlineStudy/MyTest/index.js | 4 ++-- component/OnlineStudy/MyTitle/index.js | 2 +- component/OnlineStudy/OnlineStudyHome/index.js | 6 ++---- 10 files changed, 32 insertions(+), 26 deletions(-) diff --git a/component/OnlineStudy/2-PlayerPKHome/index.js b/component/OnlineStudy/2-PlayerPKHome/index.js index 2381da8..1736513 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 5d2a621..2616831 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 aad6cf1..dc45437 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 a3ce2af..14f09b6 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 a4768bc..d28b5e5 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 9394d8e..cafd8db 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 da40d7a..c6b67ee 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 ee8dbff..e50dc4b 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 acd9ef7..e0942c6 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 c1b59bc..410cfe3 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: { -- GitLab