Skip to content

Commit

Permalink
feat(gameMode): add modescreen, add gameModeCarousel
Browse files Browse the repository at this point in the history
  • Loading branch information
caxewsh committed Oct 24, 2024
1 parent e6a21ce commit 381726b
Show file tree
Hide file tree
Showing 10 changed files with 434 additions and 9 deletions.
Binary file added assets/modeC.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/modeD.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/modeJ.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions components/modescreen/GameModeCarousel.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React from "react";
import { View, Text, TouchableOpacity, Image } from "react-native";
import Carousel from "react-native-snap-carousel";
import { useNavigation } from "@react-navigation/native";

const GameModeCarousel = () => {
const navigation = useNavigation();

const gameModes = [
{
title: "La classique",
image: require("../../assets/modeC.jpg"),
description: "Joue seul avec un ami",
available: true,
},
{
title: "Full Défi",
image: require("../../assets/modeD.jpg"),
description: "Joue avec des amis",
available: false,
},
{
title: "5-10-15",
image: require("../../assets/modeJ.jpg"),
description: "Joue avec des amis et des amis",
available: false,
},
];

const renderItem = ({ item }) => (
<View className="bg-white rounded-lg shadow-md overflow-hidden opacity-100 disabled:opacity-50">
<Image
source={item.image}
className="w-full h-40"
resizeMode="cover"
/>
<View className="p-4">
<Text className="text-cyan-900 text-center font-bold text-lg mb-2">
{item.title}
</Text>
<TouchableOpacity
onPress={() => item.available && navigation.navigate("Lobby")}
className={`py-2 px-4 rounded-full ${
item.available ? 'bg-cyan-700' : 'bg-gray-400'
}`}
disabled={!item.available}
>
<Text className="text-white text-center">
{item.available ? 'Choisir' : 'Indisponible'}
</Text>
</TouchableOpacity>
</View>
</View>
);

return (
<View className="h-72 justify-center items-center">
<Carousel
data={gameModes}
renderItem={renderItem}
sliderWidth={300}
itemWidth={250}
loop
autoplay
autoplayInterval={5000}
/>
</View>
);
};

export default GameModeCarousel;
6 changes: 6 additions & 0 deletions navigation/AppNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Lobbyscreen from "../screens/Lobbyscreen";
import Gamescreen from "../screens/Gamescreen";
import Endscreen from "../screens/Endscreen";
import SettingScreen from "../screens/SettingScreen";
import Modescreen from "../screens/Modescreen";

const Stack = createNativeStackNavigator();

Expand Down Expand Up @@ -43,6 +44,11 @@ export default function AppNavigation() {
options={{ headerShown: false }}
component={SettingScreen}
/>
<Stack.Screen
name="Mode"
options={{ headerShown: false }}
component={Modescreen}
/>
</Stack.Navigator>
</NavigationContainer>
);
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"postinstall": "patch-package",
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
Expand All @@ -28,6 +29,8 @@
"mongodb": "^6.3.0",
"mongoose": "^8.2.0",
"nativewind": "^2.0.11",
"patch-package": "^8.0.0",
"postinstall-postinstall": "^2.1.0",
"react": "18.2.0",
"react-native": "0.74.5",
"react-native-dotenv": "^3.4.11",
Expand All @@ -37,6 +40,7 @@
"react-native-reanimated": "~3.10.1",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "3.31.1",
"react-native-snap-carousel": "^3.9.1",
"react-native-svg": "15.2.0",
"react-native-url-polyfill": "^2.0.0",
"react-native-uuid": "^2.0.2",
Expand Down
169 changes: 169 additions & 0 deletions patches/react-native-snap-carousel+3.9.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
diff --git a/node_modules/react-native-snap-carousel/src/carousel/Carousel.js b/node_modules/react-native-snap-carousel/src/carousel/Carousel.js
index dae71a3..4c1c8c1 100644
--- a/node_modules/react-native-snap-carousel/src/carousel/Carousel.js
+++ b/node_modules/react-native-snap-carousel/src/carousel/Carousel.js
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
import { Animated, Easing, FlatList, I18nManager, Platform, ScrollView, View, ViewPropTypes } from 'react-native';
import PropTypes from 'prop-types';
import shallowCompare from 'react-addons-shallow-compare';
+import { ViewStyle } from 'react-native'
import {
defaultScrollInterpolator,
stackScrollInterpolator,
@@ -43,8 +44,16 @@ export default class Carousel extends Component {
autoplayDelay: PropTypes.number,
autoplayInterval: PropTypes.number,
callbackOffsetMargin: PropTypes.number,
- containerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
- contentContainerCustomStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
+ containerCustomStyle: PropTypes.oneOfType([
+ PropTypes.object,
+ PropTypes.array,
+ PropTypes.number
+ ]),
+ contentContainerCustomStyle: PropTypes.oneOfType([
+ PropTypes.object,
+ PropTypes.array,
+ PropTypes.number
+ ]),
enableMomentum: PropTypes.bool,
enableSnap: PropTypes.bool,
firstItem: PropTypes.number,
@@ -61,7 +70,11 @@ export default class Carousel extends Component {
scrollEnabled: PropTypes.bool,
scrollInterpolator: PropTypes.func,
slideInterpolatedStyle: PropTypes.func,
- slideStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
+ slideStyle: PropTypes.oneOfType([
+ PropTypes.object,
+ PropTypes.array,
+ PropTypes.number
+ ]),
shouldOptimizeUpdates: PropTypes.bool,
swipeThreshold: PropTypes.number,
useScrollView: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
@@ -151,9 +164,6 @@ export default class Carousel extends Component {
this._ignoreNextMomentum = false;

// Warnings
- if (!ViewPropTypes) {
- console.warn('react-native-snap-carousel: It is recommended to use at least version 0.44 of React Native with the plugin');
- }
if (!props.vertical && (!props.sliderWidth || !props.itemWidth)) {
console.error('react-native-snap-carousel: You need to specify both `sliderWidth` and `itemWidth` for horizontal carousels');
}
diff --git a/node_modules/react-native-snap-carousel/src/pagination/Pagination.js b/node_modules/react-native-snap-carousel/src/pagination/Pagination.js
index 5c021cf..ee5fe96 100644
--- a/node_modules/react-native-snap-carousel/src/pagination/Pagination.js
+++ b/node_modules/react-native-snap-carousel/src/pagination/Pagination.js
@@ -3,6 +3,8 @@ import { I18nManager, Platform, View, ViewPropTypes } from 'react-native';
import PropTypes from 'prop-types';
import PaginationDot from './PaginationDot';
import styles from './Pagination.style';
+import { ViewStyle } from 'react-native'
+

const IS_IOS = Platform.OS === 'ios';
const IS_RTL = I18nManager.isRTL;
@@ -14,16 +16,32 @@ export default class Pagination extends PureComponent {
dotsLength: PropTypes.number.isRequired,
activeOpacity: PropTypes.number,
carouselRef: PropTypes.object,
- containerStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
+ containerStyle: PropTypes.oneOfType([
+ PropTypes.object,
+ PropTypes.array,
+ PropTypes.number
+ ]),
dotColor: PropTypes.string,
- dotContainerStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
+ dotContainerStyle: PropTypes.oneOfType([
+ PropTypes.object,
+ PropTypes.array,
+ PropTypes.number
+ ]),
dotElement: PropTypes.element,
- dotStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
+ dotStyle: PropTypes.oneOfType([
+ PropTypes.object,
+ PropTypes.array,
+ PropTypes.number
+ ]),
inactiveDotColor: PropTypes.string,
inactiveDotElement: PropTypes.element,
inactiveDotOpacity: PropTypes.number,
inactiveDotScale: PropTypes.number,
- inactiveDotStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
+ inactiveDotStyle: PropTypes.oneOfType([
+ PropTypes.object,
+ PropTypes.array,
+ PropTypes.number
+ ]),
renderDots: PropTypes.func,
tappableDots: PropTypes.bool,
vertical: PropTypes.bool,
diff --git a/node_modules/react-native-snap-carousel/src/pagination/PaginationDot.js b/node_modules/react-native-snap-carousel/src/pagination/PaginationDot.js
index e59d196..bedbf81 100644
--- a/node_modules/react-native-snap-carousel/src/pagination/PaginationDot.js
+++ b/node_modules/react-native-snap-carousel/src/pagination/PaginationDot.js
@@ -2,6 +2,7 @@ import React, { PureComponent } from 'react';
import { View, Animated, Easing, TouchableOpacity, ViewPropTypes } from 'react-native';
import PropTypes from 'prop-types';
import styles from './Pagination.style';
+import { ViewStyle } from 'react-native'

export default class PaginationDot extends PureComponent {

@@ -12,11 +13,23 @@ export default class PaginationDot extends PureComponent {
activeOpacity: PropTypes.number,
carouselRef: PropTypes.object,
color: PropTypes.string,
- containerStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
+ containerStyle: PropTypes.oneOfType([
+ PropTypes.object,
+ PropTypes.array,
+ PropTypes.number
+ ]),
inactiveColor: PropTypes.string,
- inactiveStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
+ inactiveStyle: PropTypes.oneOfType([
+ PropTypes.object,
+ PropTypes.array,
+ PropTypes.number
+ ]),
index: PropTypes.number,
- style: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
+ style: PropTypes.oneOfType([
+ PropTypes.object,
+ PropTypes.array,
+ PropTypes.number
+ ]),
tappable: PropTypes.bool
};

diff --git a/node_modules/react-native-snap-carousel/src/parallaximage/ParallaxImage.js b/node_modules/react-native-snap-carousel/src/parallaximage/ParallaxImage.js
index 8bc774a..c9c2578 100644
--- a/node_modules/react-native-snap-carousel/src/parallaximage/ParallaxImage.js
+++ b/node_modules/react-native-snap-carousel/src/parallaximage/ParallaxImage.js
@@ -4,6 +4,8 @@ import React, { Component } from 'react';
import { View, ViewPropTypes, Image, Animated, Easing, ActivityIndicator, findNodeHandle } from 'react-native';
import PropTypes from 'prop-types';
import styles from './ParallaxImage.style';
+import { ViewStyle } from 'react-native'
+

export default class ParallaxImage extends Component {

@@ -16,7 +18,11 @@ export default class ParallaxImage extends Component {
sliderHeight: PropTypes.number, // passed from <Carousel />
sliderWidth: PropTypes.number, // passed from <Carousel />
vertical: PropTypes.bool, // passed from <Carousel />
- containerStyle: ViewPropTypes ? ViewPropTypes.style : View.propTypes.style,
+ containerStyle: PropTypes.oneOfType([
+ PropTypes.object,
+ PropTypes.array,
+ PropTypes.number
+ ]),
dimensions: PropTypes.shape({
width: PropTypes.number,
height: PropTypes.number
6 changes: 5 additions & 1 deletion screens/Homescreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export default function HomeScreen() {
AsyncStorage.clear();
navigation.navigate("Lobby");
};

const goToMode = () => {
navigation.navigate("Mode");
};
/* eslint-disable react/no-unescaped-entities */
return (
<View className="flex-1">
Expand All @@ -31,7 +35,7 @@ export default function HomeScreen() {
<StatusBar style="light" />
<Header />
<GifViewer />
<StartButton onPress={goToLobby} />
<StartButton onPress={goToMode} />
<VersionNumber />
<SettingButton />
</SafeAreaView>
Expand Down
39 changes: 39 additions & 0 deletions screens/Modescreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from "react";
import { View, ImageBackground } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { StatusBar } from "expo-status-bar";
import { useNavigation } from "@react-navigation/native";
import { useImage } from "../provider/ImageContext";
import SettingHeader from "../components/settingscreen/SettingHeader";
import GameModeCarousel from "../components/modescreen/GameModeCarousel";


export default function Modescreen() {
const navigation = useNavigation();
const { backgroundImageSource } = useImage();

const goToHomescreen = () => {
navigation.goBack();
};

return (
<View className="flex-1">
<ImageBackground
blurRadius={70}
source={backgroundImageSource}
resizeMode="cover"
className="absolute h-full w-full"
/>
<SafeAreaView className="flex-1 ">
<StatusBar style="light" />
<SettingHeader title="MODE DE JEU" onPress={goToHomescreen} />
<View
style={{ backgroundColor: "rgba(255, 255, 255, 0.1)" }}
className="flex m-10 p-10 mx-4 rounded-lg items-center"
>
<GameModeCarousel />
</View>
</SafeAreaView>
</View>
);
}
Loading

0 comments on commit 381726b

Please sign in to comment.