Tony Fages 1 year ago
parent c9678e6e7a
commit 0f495be35f

@ -0,0 +1,15 @@
> Why do I have a folder named ".expo" in my project?
The ".expo" folder is created when an Expo project is started using "expo start" command.
> What do the files contain?
- "devices.json": contains information about devices that have recently opened this project. This is used to populate the "Development sessions" list in your development builds.
- "packager-info.json": contains port numbers and process PIDs that are used to serve the application to the mobile device/simulator.
- "settings.json": contains the server configuration that is used to serve the application manifest.
> Should I commit the ".expo" folder?
No, you should not share the ".expo" folder. It does not contain any information that is relevant for other developers working on the project, it is specific to your machine.
Upon project creation, the ".expo" folder is already added to your ".gitignore" file.

@ -0,0 +1,8 @@
{
"hostType": "lan",
"lanType": "ip",
"dev": true,
"minify": false,
"urlRandomness": null,
"https": false
}

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="FLOW" />
</component>
</project>

@ -1,20 +0,0 @@
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
export default function App() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});

@ -0,0 +1,33 @@
import {StatusBar} from 'expo-status-bar';
import {StyleSheet, Text, View} from 'react-native';
import {JokeStub} from "./model/JokeStub";
import {JokeFactory} from "./model/JokeFactory";
import {loadExtensions} from "./extensions";
loadExtensions();
export default function App() {
let customJokes = JokeFactory.createCustomJokes(JokeStub.customJokes);
let samplesJokes = JokeFactory.createSampleJokes(JokeStub.sampleJokes);
return (
<View style={styles.container}>
<Text>CustomJokes</Text>
<Text>{customJokes.displayJoke()}</Text>
<Text>SamplesJokes</Text>
<Text>{samplesJokes.displayJoke()}</Text>
<StatusBar style="auto"/>
</View>
);
}
// Styles pour le composant
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});

@ -1,7 +0,0 @@
export function loadExtensions() {
if (!string.prototype.toNounours) {
string.prototype.toNounours = function () {
return new Nounours(this)
};
}
}

@ -0,0 +1,9 @@
// Fonction pour étendre le prototype d'Array avec une nouvelle méthode print
export function loadExtensions() {
// Ajout de la méthode print au prototype d'Array
if (!Array.prototype.displayJoke) {
Array.prototype.displayJoke = function () {
return this.map((item) => item.description() + '\n')
};
}
}

@ -1,4 +1,8 @@
class CustomJoke extends Joke{
import { Joke } from "./Joke";
export class CustomJoke extends Joke{
private _id : string
get id(): string {
return this._id;
}
@ -9,7 +13,6 @@ class CustomJoke extends Joke{
}
private _id : string
}

@ -1,4 +0,0 @@
class CustomStub{
public Customjoke = '[{type:"type",setup:"setup",image:"image",punchline:"punchline",id:"id"}]'
}

@ -1,4 +1,4 @@
abstract class Joke{
export abstract class Joke{
private _type : string
private _setup : string
@ -28,11 +28,13 @@ abstract class Joke{
}
public summary():string{
return this.setup.padEnd(25,'.')
return this.setup.substring(0,25) + ' ...'
}
public description():string{
return this.type+ ' - ' +this.summary()
return this.type() + ' - ' +this.summary()
}
}

@ -1,4 +1,7 @@
class JokeFactory {
import { CustomJoke } from "./CustomJoke";
import { SampleJoke } from "./SampleJoke";
export class JokeFactory {
public static createCustomJokes(jsonArray: string) : CustomJoke[]{
let array = []
@ -7,18 +10,18 @@ class JokeFactory {
array.push(new CustomJoke(joke.type,joke.setup,joke.punchline,joke.image,joke.id))
})
return array
return array;
}
public static createSampleJokes(jsonArray: string) : SampleJoke[] {
let array = []
let json = JSON.parse(jsonArray)
static createSampleJokes(jsonArray: string): SampleJoke[] {
let array = [];
let json = JSON.parse(jsonArray);
json.forEach(function (joke) {
array.push(new SampleJoke(joke.type,joke.setup,joke.punchline,joke.image,joke.id))
array.push(new SampleJoke(joke.type, joke.setup, joke.punchline, joke.image, joke.id));
})
return array
return array;
}

@ -0,0 +1,10 @@
import {SampleJoke} from "./SampleJoke";
export class JokeStub {
// Données JSON pour les CustomJokes
public static customJokes = '[{"type":"custom", "setup":"Quel jour les poules ont-elles l anus dilaté au maximum ?", "punchline":"Le jour où elles passent du coq à l âne.", "image":"image1", "id":"id1"}, {"type":"custom", "setup":"Savez-vous comment on appelle le sexe de Michael Jackson ???", "punchline":"Vérité ! Car la vérité sort toujours de la bouche des enfants .", "image":"image2", "id":"id2"}]';
// Données JSON pour les SampleJokes
public static sampleJokes = '[{"type":"sample", "setup":"Que dit un escargot quand il croise une limace ?", "punchline":"Oh la belle décapotable ", "image":"image1", "id":"id1"}, {"type":"sample", "setup":"Qu est ce qui n est pas un steak ?", "punchline":"Une pastèque.", "image":"image2", "id":"id2"}]';
}

@ -1,6 +1,8 @@
class SampleJoke extends Joke{
import { Joke } from "./Joke";
private _id : number
export class SampleJoke extends Joke{
private _id : number
constructor(type : string, setup : string,punchline : string,image : string ,id : number) {
super(type,setup,punchline,image);
@ -11,8 +13,4 @@ class SampleJoke extends Joke{
return this._id;
}
set id(value: number) {
this._id = value;
}
}

@ -1,3 +0,0 @@
class SampleStub{
public Customjoke = '[{type:"typeSample",setup:"setupSample",image:"imageSample",punchline:"punchlineSample",id:"idSample"}]'
}

@ -0,0 +1,8 @@
export {}
// Extension de l'interface globale Array avec une nouvelle méthode print
declare global {
interface Array<T> {
displayJoke(): string[];
}
}
Loading…
Cancel
Save