Skip to content

Commit 173f77d

Browse files
committed
test: demo app update
1 parent 32e15ae commit 173f77d

File tree

5 files changed

+69
-65
lines changed

5 files changed

+69
-65
lines changed

demo/app/main-view-model.ts

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,51 @@
1-
import { isIOS, Observable, Page } from '@nativescript/core';
2-
import { SpeakOptions, TNSTextToSpeech } from 'nativescript-texttospeech';
1+
import { Observable, Page, isIOS } from '@nativescript/core';
2+
import { SpeakOptions, TNSTextToSpeech } from '@nativescript-community/texttospeech';
33

44
export class HelloWorldModel extends Observable {
5-
public speakText: string;
6-
private _SpeechSynthesizer: TNSTextToSpeech;
7-
8-
constructor(mainPage: Page) {
9-
super();
10-
this.speakText =
11-
'Hello and welcome to Native Script. Hope you enjoy the power.';
12-
this._SpeechSynthesizer = new TNSTextToSpeech() as TNSTextToSpeech;
13-
this._SpeechSynthesizer.speak({ text: '' });
14-
}
15-
16-
public speakThis() {
17-
if (!this._SpeechSynthesizer) {
18-
this._SpeechSynthesizer = new TNSTextToSpeech() as TNSTextToSpeech;
5+
public speakText: string;
6+
private _SpeechSynthesizer: TNSTextToSpeech;
7+
8+
constructor(mainPage: Page) {
9+
super();
10+
this.speakText = 'Hello and welcome to Native Script. Hope you enjoy the power.';
11+
this._SpeechSynthesizer = new TNSTextToSpeech();
12+
this._SpeechSynthesizer.init().catch((err) => {
13+
alert(err);
14+
});
1915
}
2016

21-
const opts: SpeakOptions = {
22-
text: this.get('speakText'),
23-
speakRate: isIOS ? 0.45 : null,
24-
finishedCallback: () => {
25-
alert('Finished Speaking :)');
26-
},
27-
};
28-
29-
this._SpeechSynthesizer.speak(opts);
30-
}
17+
public async speakThis() {
18+
if (!this._SpeechSynthesizer) {
19+
this._SpeechSynthesizer = new TNSTextToSpeech();
20+
}
21+
22+
const opts: SpeakOptions = {
23+
text: this.get('speakText'),
24+
speakRate: isIOS ? 0.45 : null,
25+
finishedCallback: () => {
26+
alert('Finished Speaking :)');
27+
},
28+
};
29+
try {
30+
await this._SpeechSynthesizer.speak(opts);
31+
} catch (err) {
32+
alert(err);
33+
}
34+
}
3135

32-
public byebyeSynthesizer() {
33-
this._SpeechSynthesizer.pause();
34-
this._SpeechSynthesizer.destroy();
35-
console.log('destroyed');
36-
}
36+
public byebyeSynthesizer() {
37+
this._SpeechSynthesizer.pause();
38+
this._SpeechSynthesizer.destroy();
39+
console.log('destroyed');
40+
}
3741

38-
public pauseSynthesizer() {
39-
this._SpeechSynthesizer.pause();
40-
console.log('paused speech');
41-
}
42+
public pauseSynthesizer() {
43+
this._SpeechSynthesizer.pause();
44+
console.log('paused speech');
45+
}
4246

43-
public resumeSynthesizer() {
44-
this._SpeechSynthesizer.resume();
45-
console.log('resumed speech');
46-
}
47+
public resumeSynthesizer() {
48+
this._SpeechSynthesizer.resume();
49+
console.log('resumed speech');
50+
}
4751
}

demo/app/tests/tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
describe('lottiview class', function() {
22
it('can be instantiated', function() {
33
var testTNSTextToSpeech;
4-
var TNSTextToSpeech = require('nativescript-texttospeech').TNSTextToSpeech;
4+
var TNSTextToSpeech = require('@nativescript-community/texttospeech').TNSTextToSpeech;
55
if (TNSTextToSpeech) {
66
testTNSTextToSpeech = new TNSTextToSpeech();
77
console.log('TNSTextToSpeech instance: ' + testTNSTextToSpeech);

demo/nativescript.config.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { NativeScriptConfig } from '@nativescript/core';
22

33
export default {
4-
id: 'org.nativescript.demo',
5-
appResourcesPath: 'app/App_Resources',
6-
android: {
7-
v8Flags: '--expose_gc',
8-
markingMode: 'none',
9-
},
10-
appPath: 'app',
4+
id: 'org.nativescript.demo',
5+
appResourcesPath: 'app/App_Resources',
6+
android: {
7+
v8Flags: '--expose_gc',
8+
markingMode: 'none',
9+
},
10+
appPath: 'app',
1111
} as NativeScriptConfig;

demo/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"readme": "NativeScript Application",
55
"repository": "<fill-your-repository-here>",
66
"dependencies": {
7-
"nativescript-texttospeech": "file:../src",
7+
"@nativescript-community/texttospeech": "file:../plugin",
88
"nativescript-theme-core": "~1.0.4",
99
"nativescript-unit-test-runner": "0.7.0",
10-
"@nativescript/core": "^7.0.0"
10+
"@nativescript/core": "^7.0.13"
1111
},
1212
"devDependencies": {
1313
"@nativescript/android": "7.0.0",

demo/tsconfig.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
2-
"compilerOptions": {
3-
"module": "esnext",
4-
"target": "es2017",
5-
"moduleResolution": "node",
6-
"experimentalDecorators": true,
7-
"emitDecoratorMetadata": true,
8-
"noEmitHelpers": true,
9-
"noEmitOnError": true,
10-
"skipLibCheck": true,
11-
"lib": ["es2017", "dom", "es6"],
12-
"baseUrl": ".",
13-
"paths": {
14-
"~/*": ["app/*"]
15-
}
16-
},
17-
"exclude": ["node_modules", "platforms"]
2+
"compilerOptions": {
3+
"module": "esnext",
4+
"target": "es2017",
5+
"moduleResolution": "node",
6+
"experimentalDecorators": true,
7+
"emitDecoratorMetadata": true,
8+
"noEmitHelpers": true,
9+
"noEmitOnError": true,
10+
"skipLibCheck": true,
11+
"lib": ["es2017", "dom", "es6"],
12+
"baseUrl": ".",
13+
"paths": {
14+
"~/*": ["app/*"]
15+
}
16+
},
17+
"exclude": ["node_modules", "platforms"]
1818
}

0 commit comments

Comments
 (0)