mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-04-11 00:30:19 +02:00
Refactoring
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
// Expo
|
||||
import { Slot } from 'expo-router';
|
||||
// Contexts
|
||||
import { TeamConnexionProvider } from "../src/context/teamConnexionContext";
|
||||
import { TeamProvider } from "../src/context/teamContext";
|
||||
import { AuthProvider } from "../src/contexts/authContext";
|
||||
import { TeamProvider } from "../src/contexts/teamContext";
|
||||
|
||||
const Layout = () => {
|
||||
return (
|
||||
<TeamConnexionProvider>
|
||||
<AuthProvider>
|
||||
<TeamProvider>
|
||||
<Slot/>
|
||||
</TeamProvider>
|
||||
</TeamConnexionProvider>
|
||||
</AuthProvider>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -8,19 +8,19 @@ import { CustomButton } from '../src/components/button';
|
||||
import { CustomImage } from '../src/components/image';
|
||||
import { CustomTextInput } from '../src/components/input';
|
||||
// Contexts
|
||||
import { useTeamConnexion } from "../src/context/teamConnexionContext";
|
||||
import { useAuth } from "../src/contexts/authContext";
|
||||
// Hooks
|
||||
import { usePickImage } from '../src/hook/usePickImage';
|
||||
import { usePickImage } from '../src/hooks/usePickImage';
|
||||
// Services
|
||||
import { uploadTeamImage } from '../src/services/imageService';
|
||||
import { getLocationAuthorization, stopLocationTracking } from '../src/services/backgroundLocationTask';
|
||||
import { uploadTeamImage } from '../src/services/api/image';
|
||||
import { getLocationAuthorization, stopLocationTracking } from '../src/services/tasks/backgroundLocation';
|
||||
// Constants
|
||||
import { COLORS } from '../src/constants';
|
||||
|
||||
const Index = () => {
|
||||
const router = useRouter();
|
||||
const { login, loggedIn } = useTeamConnexion();
|
||||
const {image, pickImage} = usePickImage();
|
||||
const { loggedIn, login } = useAuth();
|
||||
const { image, pickImage } = usePickImage();
|
||||
const [teamId, setTeamId] = useState("");
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
||||
|
||||
@@ -8,24 +8,23 @@ import { CustomMap } from '../src/components/map';
|
||||
import { Drawer } from '../src/components/drawer';
|
||||
import { TimerMMSS } from '../src/components/timer';
|
||||
// Contexts
|
||||
import { useTeamConnexion } from '../src/context/teamConnexionContext';
|
||||
import { useTeamContext } from '../src/context/teamContext';
|
||||
import { useAuth } from '../src/contexts/authContext';
|
||||
import { useTeam } from '../src/contexts/teamContext';
|
||||
// Hooks
|
||||
import { useGame } from '../src/hook/useGame';
|
||||
import { useTimeDifference } from '../src/hook/useTimeDifference';
|
||||
import { useTimeDifference } from '../src/hooks/useTimeDifference';
|
||||
// Services
|
||||
import { startLocationTracking } from '../src/services/backgroundLocationTask';
|
||||
import { emitSendPosition } from '../src/services/socket/emitters';
|
||||
import { startLocationTracking } from '../src/services/tasks/backgroundLocation';
|
||||
// Util
|
||||
import { secondsToMMSS } from '../src/util/functions';
|
||||
import { secondsToMMSS } from '../src/utils/functions';
|
||||
// Constants
|
||||
import { GAME_STATE, COLORS } from '../src/constants';
|
||||
|
||||
const Interface = () => {
|
||||
const router = useRouter();
|
||||
const {teamInfos, messages, nextZoneDate, isShrinking, gameState} = useTeamContext();
|
||||
const {teamInfos, messages, nextZoneDate, gameState} = useTeam();
|
||||
const {name, ready, captured, locationSendDeadline, outOfZone, outOfZoneDeadline, hasHandicap, enemyHasHandicap} = teamInfos;
|
||||
const {loggedIn, logout} = useTeamConnexion();
|
||||
const {sendCurrentPosition} = useGame();
|
||||
const { loggedIn, logout } = useAuth();
|
||||
const [timeLeftSendLocation] = useTimeDifference(locationSendDeadline, 1000);
|
||||
const [timeLeftNextZone] = useTimeDifference(nextZoneDate, 1000);
|
||||
const [timeLeftOutOfZone] = useTimeDifference(outOfZoneDeadline, 1000);
|
||||
@@ -87,7 +86,7 @@ const Interface = () => {
|
||||
</View>
|
||||
}
|
||||
{ gameState == GAME_STATE.PLAYING && !captured && <Fragment>
|
||||
<TimerMMSS style={{width: "50%"}} title={isShrinking ? "Réduction de la zone" : "Durée de la zone"} seconds={-timeLeftNextZone} />
|
||||
<TimerMMSS style={{width: "50%"}} title={"Réduction de la zone dans"} seconds={-timeLeftNextZone} />
|
||||
<TimerMMSS style={{width: "50%"}} title={"Position envoyée dans"} seconds={!hasHandicap ? -timeLeftSendLocation: 0} />
|
||||
</Fragment>}
|
||||
</View>
|
||||
@@ -98,7 +97,7 @@ const Interface = () => {
|
||||
<View style={styles.bottomContainer} onLayout={(event) => setBottomContainerHeight(event.nativeEvent.layout.height)}>
|
||||
<CustomMap/>
|
||||
{ gameState == GAME_STATE.PLAYING && !captured && !hasHandicap &&
|
||||
<TouchableOpacity style={styles.updatePosition} onPress={sendCurrentPosition}>
|
||||
<TouchableOpacity style={styles.updatePosition} onPress={emitSendPosition}>
|
||||
<Image source={require("../src/assets/images/update_position.png")} style={{width: 40, height: 40}} resizeMode="contain"></Image>
|
||||
</TouchableOpacity>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user