diff --git a/JokesApp/.idea/.gitignore b/JokesApp/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/JokesApp/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/JokesApp/.idea/JokesApp.iml b/JokesApp/.idea/JokesApp.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/JokesApp/.idea/JokesApp.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/JokesApp/.idea/modules.xml b/JokesApp/.idea/modules.xml new file mode 100644 index 0000000..9861d5c --- /dev/null +++ b/JokesApp/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/JokesApp/.idea/vcs.xml b/JokesApp/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/JokesApp/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/JokesApp/extension.js b/JokesApp/extension.js new file mode 100644 index 0000000..e2e7cf0 --- /dev/null +++ b/JokesApp/extension.js @@ -0,0 +1,7 @@ +export function loadExtensions() { + if (!string.prototype.toNounours) { + string.prototype.toNounours = function () { + return new Nounours(this) + }; + } +} \ No newline at end of file diff --git a/JokesApp/model/CustomJoke.ts b/JokesApp/model/CustomJoke.ts new file mode 100644 index 0000000..004637c --- /dev/null +++ b/JokesApp/model/CustomJoke.ts @@ -0,0 +1,15 @@ +class CustomJoke extends Joke{ + get id(): string { + return this._id; + } + + constructor(type : string, setup : string,punchline : string,image : string ,id : string) { + super(type,setup,punchline,image); + this._id = id + } + + + private _id : string + + +} \ No newline at end of file diff --git a/JokesApp/model/CustomStub.ts b/JokesApp/model/CustomStub.ts new file mode 100644 index 0000000..78ea955 --- /dev/null +++ b/JokesApp/model/CustomStub.ts @@ -0,0 +1,4 @@ +class CustomStub{ + public Customjoke = '[{type:"type",setup:"setup",image:"image",punchline:"punchline",id:"id"}]' +} + diff --git a/JokesApp/model/Joke.ts b/JokesApp/model/Joke.ts new file mode 100644 index 0000000..fdc51a6 --- /dev/null +++ b/JokesApp/model/Joke.ts @@ -0,0 +1,38 @@ +abstract class Joke{ + + private _type : string + private _setup : string + private _punchline : string + private _image : string + + protected constructor(type : string, setup : string, punchline : string, image : string ) { + this._type = type + this._setup = setup + this._punchline = punchline + this._image = image + } + public type(): string { + return this._type; + } + + public get setup(): string { + return this._setup; + } + + public get punchline(): string { + return this._punchline; + } + + public get image(): string { + return this._image; + } + + public summary():string{ + return this.setup.padEnd(25,'.') + } + + public description():string{ + return this.type+ ' - ' +this.summary() + } +} + diff --git a/JokesApp/model/JokeFactory.ts b/JokesApp/model/JokeFactory.ts new file mode 100644 index 0000000..43c9f1f --- /dev/null +++ b/JokesApp/model/JokeFactory.ts @@ -0,0 +1,25 @@ +class JokeFactory { + + public static createCustomJokes(jsonArray: string) : CustomJoke[]{ + let array = [] + let json = JSON.parse(jsonArray) + json.forEach(function (joke) { + array.push(new CustomJoke(joke.type,joke.setup,joke.punchline,joke.image,joke.id)) + }) + + return array + } + + + public 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)) + }) + + return array + } + + +} \ No newline at end of file diff --git a/JokesApp/model/JokeStub.ts b/JokesApp/model/JokeStub.ts new file mode 100644 index 0000000..e69de29 diff --git a/JokesApp/model/SampleJoke.ts b/JokesApp/model/SampleJoke.ts new file mode 100644 index 0000000..e5f7ecb --- /dev/null +++ b/JokesApp/model/SampleJoke.ts @@ -0,0 +1,18 @@ +class SampleJoke extends Joke{ + + private _id : number + + constructor(type : string, setup : string,punchline : string,image : string ,id : number) { + super(type,setup,punchline,image); + this._id = id + } + + get id(): number { + return this._id; + } + + set id(value: number) { + this._id = value; + } + +} \ No newline at end of file diff --git a/JokesApp/model/SampleStub.ts b/JokesApp/model/SampleStub.ts new file mode 100644 index 0000000..0de5f60 --- /dev/null +++ b/JokesApp/model/SampleStub.ts @@ -0,0 +1,3 @@ +class SampleStub{ + public Customjoke = '[{type:"typeSample",setup:"setupSample",image:"imageSample",punchline:"punchlineSample",id:"idSample"}]' +} \ No newline at end of file diff --git a/JokesApp/package-lock.json b/JokesApp/package-lock.json index f7c560e..0aec02d 100644 --- a/JokesApp/package-lock.json +++ b/JokesApp/package-lock.json @@ -8,10 +8,12 @@ "name": "jokesapp", "version": "1.0.0", "dependencies": { + "@types/react": "~18.2.45", "expo": "~50.0.3", "expo-status-bar": "~1.11.1", "react": "18.2.0", - "react-native": "0.73.2" + "react-native": "0.73.2", + "typescript": "^5.3.0" }, "devDependencies": { "@babel/core": "^7.20.0" @@ -5991,6 +5993,26 @@ "undici-types": "~5.26.4" } }, + "node_modules/@types/prop-types": { + "version": "15.7.11", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz", + "integrity": "sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==" + }, + "node_modules/@types/react": { + "version": "18.2.48", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.48.tgz", + "integrity": "sha512-qboRCl6Ie70DQQG9hhNREz81jqC1cs9EVNcjQ1AU+jH6NFfSAhVVbrrY/+nSF+Bsk4AOwm9Qa61InvMCyV+H3w==", + "dependencies": { + "@types/prop-types": "*", + "@types/scheduler": "*", + "csstype": "^3.0.2" + } + }, + "node_modules/@types/scheduler": { + "version": "0.16.8", + "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.8.tgz", + "integrity": "sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==" + }, "node_modules/@types/stack-utils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", @@ -7106,6 +7128,11 @@ "node": ">=8" } }, + "node_modules/csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==" + }, "node_modules/dag-map": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/dag-map/-/dag-map-1.0.2.tgz", @@ -12394,6 +12421,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typescript": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/ua-parser-js": { "version": "1.0.37", "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.37.tgz", diff --git a/JokesApp/package.json b/JokesApp/package.json index 282d66f..aa056ea 100644 --- a/JokesApp/package.json +++ b/JokesApp/package.json @@ -12,7 +12,9 @@ "expo": "~50.0.3", "expo-status-bar": "~1.11.1", "react": "18.2.0", - "react-native": "0.73.2" + "react-native": "0.73.2", + "typescript": "^5.3.0", + "@types/react": "~18.2.45" }, "devDependencies": { "@babel/core": "^7.20.0" diff --git a/JokesApp/tsconfig.json b/JokesApp/tsconfig.json new file mode 100644 index 0000000..997e15e --- /dev/null +++ b/JokesApp/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "typeRoots": [ + "./node_modules/@types", + "./types" + ] + }, + "extends": "expo/tsconfig.base" +} \ No newline at end of file