Compare commits

..

No commits in common. "560c3367593d87b9459c3d5e35773b004a63d9d3" and "b2ff90855f4c974d66eaa2a830842e8a9e722514" have entirely different histories.

9 changed files with 109 additions and 106 deletions

View file

@ -95,7 +95,6 @@
}, },
"home": { "home": {
"title": "Campus", "title": "Campus",
"feedTitle": "Amicale's News",
"feed": "Details", "feed": "Details",
"dashboard": { "dashboard": {
"seeMore": "Click to see more", "seeMore": "Click to see more",

View file

@ -95,7 +95,6 @@
}, },
"home": { "home": {
"title": "Campus", "title": "Campus",
"feedTitle": "News de l'Amicale",
"feed": "Détails", "feed": "Détails",
"dashboard": { "dashboard": {
"seeMore": "Clique pour plus d'infos", "seeMore": "Clique pour plus d'infos",

View file

@ -39,8 +39,8 @@ class SmallDashboardItem extends React.Component<Props> {
onPress={this.props.onPress} onPress={this.props.onPress}
borderless={true} borderless={true}
style={{ style={{
marginLeft: this.itemSize / 6, marginLeft: this.itemSize / 4,
marginRight: this.itemSize / 6, marginRight: this.itemSize / 4,
}} }}
> >
<View style={{ <View style={{
@ -50,12 +50,8 @@ class SmallDashboardItem extends React.Component<Props> {
<Image <Image
source={{uri: props.image}} source={{uri: props.image}}
style={{ style={{
width: "80%", width: "100%",
height: "80%", height: "100%",
marginLeft: "auto",
marginRight: "auto",
marginTop: "auto",
marginBottom: "auto",
}} }}
/> />
{ {

View file

@ -26,6 +26,7 @@ class CellComponent extends React.PureComponent<Props> {
borderWidth: 1, borderWidth: 1,
aspectRatio: 1, aspectRatio: 1,
}} }}
key={item.key}
/> />
); );
} }

View file

@ -31,7 +31,7 @@ class GridComponent extends React.Component<Props> {
} }
getCellRender = (item: Cell) => { getCellRender = (item: Cell) => {
return <CellComponent cell={item} key={item.key}/>; return <CellComponent cell={item}/>;
}; };
getGrid() { getGrid() {

View file

@ -205,15 +205,11 @@ export default class GameLogic {
} }
} }
stopGame() { endGame(isRestart: boolean) {
this.#gameRunning = false; this.#gameRunning = false;
this.#gamePaused = false; this.#gamePaused = false;
clearInterval(this.#gameTickInterval); clearInterval(this.#gameTickInterval);
clearInterval(this.#gameTimeInterval); clearInterval(this.#gameTimeInterval);
}
endGame(isRestart: boolean) {
this.stopGame();
this.endCallback(this.#gameTime, this.#scoreManager.getScore(), isRestart); this.endCallback(this.#gameTime, this.#scoreManager.getScore(), isRestart);
} }

View file

@ -67,10 +67,6 @@ class GameMainScreen extends React.Component<Props, State> {
this.startGame(); this.startGame();
} }
componentWillUnmount() {
this.logic.stopGame();
}
getRightButton = () => { getRightButton = () => {
return <MaterialHeaderButtons> return <MaterialHeaderButtons>
<Item title="pause" iconName="pause" onPress={this.togglePause}/> <Item title="pause" iconName="pause" onPress={this.togglePause}/>
@ -172,6 +168,32 @@ class GameMainScreen extends React.Component<Props, State> {
}); });
} }
showGameOverConfirm() {
let message = i18n.t("screens.game.gameOver.score") + this.state.gameScore + '\n';
message += i18n.t("screens.game.gameOver.level") + this.state.gameLevel + '\n';
message += i18n.t("screens.game.gameOver.time") + this.getFormattedTime(this.state.gameTime) + '\n';
const onDismiss = () => {
this.onDialogDismiss();
this.startGame();
};
this.setState({
dialogVisible: true,
dialogTitle: i18n.t("screens.game.gameOver.text"),
dialogMessage: message,
dialogButtons: [
{
title: i18n.t("screens.game.gameOver.exit"),
onPress: () => this.props.navigation.goBack()
},
{
title: i18n.t("screens.game.resume"),
onPress: onDismiss
}
],
onDialogDismiss: onDismiss,
});
}
startGame = () => { startGame = () => {
this.logic.startGame(this.onTick, this.onClock, this.onGameEnd); this.logic.startGame(this.onTick, this.onClock, this.onGameEnd);
this.setState({ this.setState({

View file

@ -110,7 +110,7 @@ class GameStartScreen extends React.Component<Props, State> {
animation={"fadeInDownBig"} animation={"fadeInDownBig"}
delay={animDelay} delay={animDelay}
duration={animDuration} duration={animDuration}
key={"piece" + index.toString()} key={index.toString()}
style={{ style={{
width: size + "%", width: size + "%",
position: "absolute", position: "absolute",
@ -118,14 +118,21 @@ class GameStartScreen extends React.Component<Props, State> {
left: left + "%", left: left + "%",
}} }}
> >
<GridComponent <View style={{
width={4} transform: [{rotateZ: rot + "deg"}],
height={4} }}>
grid={item} <GridComponent
style={{ width={4}
transform: [{rotateZ: rot + "deg"}], height={4}
}} grid={item}
/> style={{
marginRight: 5,
marginLeft: 5,
marginBottom: 5,
}}
/>
</View>
</Animatable.View> </Animatable.View>
); );
})} })}
@ -372,33 +379,43 @@ class GameStartScreen extends React.Component<Props, State> {
getMainContent() { getMainContent() {
return ( return (
<View style={{flex: 1}}> <LinearGradient
{ style={{flex: 1}}
this.gameStats != null colors={[
? this.getPostGameContent(this.gameStats) this.props.theme.colors.background + "00",
: this.getWelcomeText() this.props.theme.colors.background
} ]}
<Button start={{x: 0, y: 0.1}}
icon={"play"} end={{x: 0.1, y: 1}}
mode={"contained"} >
onPress={() => this.props.navigation.replace( <View style={{flex: 1}}>
"game-main", {
{ this.gameStats != null
highScore: this.scores.length > 0 ? this.getPostGameContent(this.gameStats)
? this.scores[0] : this.getWelcomeText()
: null }
} <Button
)} icon={"play"}
style={{ mode={"contained"}
marginLeft: "auto", onPress={() => this.props.navigation.replace(
marginRight: "auto", "game-main",
marginTop: 10, {
}} highScore: this.scores.length > 0
> ? this.scores[0]
{i18n.t("screens.game.play")} : null
</Button> }
{this.getTopScoresRender()} )}
</View> style={{
marginLeft: "auto",
marginRight: "auto",
marginTop: 10,
}}
>
{i18n.t("screens.game.play")}
</Button>
{this.getTopScoresRender()}
</View>
</LinearGradient>
) )
} }
@ -408,34 +425,24 @@ class GameStartScreen extends React.Component<Props, State> {
return ( return (
<View style={{flex: 1}}> <View style={{flex: 1}}>
{this.getPiecesBackground()} {this.getPiecesBackground()}
<LinearGradient <ScrollView>
style={{flex: 1}} {this.getMainContent()}
colors={[ <MascotPopup
this.props.theme.colors.background + "00", visible={this.state.mascotDialogVisible}
this.props.theme.colors.background title={i18n.t("screens.game.mascotDialog.title")}
]} message={i18n.t("screens.game.mascotDialog.message")}
start={{x: 0, y: 0}} icon={"gamepad-variant"}
end={{x: 0, y: 1}} buttons={{
> action: null,
<ScrollView> cancel: {
{this.getMainContent()} message: i18n.t("screens.game.mascotDialog.button"),
<MascotPopup icon: "check",
visible={this.state.mascotDialogVisible} onPress: this.hideMascotDialog,
title={i18n.t("screens.game.mascotDialog.title")} }
message={i18n.t("screens.game.mascotDialog.message")} }}
icon={"gamepad-variant"} emotion={MASCOT_STYLE.COOL}
buttons={{ />
action: null, </ScrollView>
cancel: {
message: i18n.t("screens.game.mascotDialog.button"),
icon: "check",
onPress: this.hideMascotDialog,
}
}}
emotion={MASCOT_STYLE.COOL}
/>
</ScrollView>
</LinearGradient>
</View> </View>
); );

View file

@ -5,9 +5,9 @@ import {FlatList} from 'react-native';
import i18n from "i18n-js"; import i18n from "i18n-js";
import DashboardItem from "../../components/Home/EventDashboardItem"; import DashboardItem from "../../components/Home/EventDashboardItem";
import WebSectionList from "../../components/Screens/WebSectionList"; import WebSectionList from "../../components/Screens/WebSectionList";
import {Headline, withTheme} from 'react-native-paper'; import {withTheme} from 'react-native-paper';
import FeedItem from "../../components/Home/FeedItem"; import FeedItem from "../../components/Home/FeedItem";
import SmallDashboardItem from "../../components/Home/SmallDashboardItem"; import SquareDashboardItem from "../../components/Home/SmallDashboardItem";
import PreviewEventDashboardItem from "../../components/Home/PreviewEventDashboardItem"; import PreviewEventDashboardItem from "../../components/Home/PreviewEventDashboardItem";
import {stringToDate} from "../../utils/Planning"; import {stringToDate} from "../../utils/Planning";
import ActionsDashBoardItem from "../../components/Home/ActionsDashboardItem"; import ActionsDashBoardItem from "../../components/Home/ActionsDashboardItem";
@ -228,7 +228,7 @@ class HomeScreen extends React.Component<Props, State> {
id: SECTIONS_ID[0] id: SECTIONS_ID[0]
}, },
{ {
title: i18n.t("screens.home.feedTitle"), title: '',
data: this.currentNewFeed, data: this.currentNewFeed,
id: SECTIONS_ID[1] id: SECTIONS_ID[1]
} }
@ -434,7 +434,7 @@ class HomeScreen extends React.Component<Props, State> {
*/ */
dashboardRowRenderItem = ({item}: { item: DashboardItem }) => { dashboardRowRenderItem = ({item}: { item: DashboardItem }) => {
return ( return (
<SmallDashboardItem <SquareDashboardItem
image={item.image} image={item.image}
onPress={item.onPress} onPress={item.onPress}
badgeCount={this.currentDashboard != null && item.badgeFunction != null badgeCount={this.currentDashboard != null && item.badgeFunction != null
@ -460,8 +460,7 @@ class HomeScreen extends React.Component<Props, State> {
contentContainerStyle={{ contentContainerStyle={{
marginLeft: 'auto', marginLeft: 'auto',
marginRight: 'auto', marginRight: 'auto',
marginTop: 10, marginTop: 5,
marginBottom: 10,
}} }}
/>); />);
} }
@ -511,21 +510,6 @@ class HomeScreen extends React.Component<Props, State> {
this.fabRef.current.onScroll(event); this.fabRef.current.onScroll(event);
}; };
renderSectionHeader = (data: { [key: string]: any }) => {
if (data.section.title !== "")
return (
<Headline style={{
textAlign: "center",
marginTop: 50,
marginBottom: 10,
}}>
{data.section.title}
</Headline>
)
else
return null;
}
/** /**
* Callback when pressing the login button on the banner. * Callback when pressing the login button on the banner.
* This hides the banner and takes the user to the login page. * This hides the banner and takes the user to the login page.
@ -555,7 +539,6 @@ class HomeScreen extends React.Component<Props, State> {
itemHeight={FEED_ITEM_HEIGHT} itemHeight={FEED_ITEM_HEIGHT}
onScroll={this.onScroll} onScroll={this.onScroll}
showError={false} showError={false}
renderSectionHeader={this.renderSectionHeader}
/> />
</View> </View>
<MascotPopup <MascotPopup