livevoice-sdk-react-native 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +13 -0
- package/android/build.gradle +135 -0
- package/android/generated/java/io/livevoice/react/NativeLiveVoiceSdkSpec.java +182 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNLiveVoiceSpec-generated.cpp +229 -0
- package/android/generated/jni/RNLiveVoiceSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI-generated.cpp +238 -0
- package/android/generated/jni/react/renderer/components/RNLiveVoiceSpec/RNLiveVoiceSpecJSI.h +389 -0
- package/android/gradle.properties +7 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/io/livevoice/react/LiveVoiceModule.kt +293 -0
- package/android/src/main/java/io/livevoice/react/LiveVoiceSdkReactNativePackage.kt +45 -0
- package/android/src/main/java/io/livevoice/react/Mappings.kt +54 -0
- package/android/src/main/java/io/livevoice/react/NativeModels.kt +77 -0
- package/ios/LiveVoiceSdkReactNative.h +21 -0
- package/ios/LivevoiceSdkReactNative.mm +234 -0
- package/ios/generated/RNLiveVoiceSpec/RNLiveVoiceSpec-generated.mm +285 -0
- package/ios/generated/RNLiveVoiceSpec/RNLiveVoiceSpec.h +100 -0
- package/ios/generated/RNLiveVoiceSpecJSI-generated.cpp +238 -0
- package/ios/generated/RNLiveVoiceSpecJSI.h +389 -0
- package/lib/commonjs/components/AudioOutputSwitchView.js +140 -0
- package/lib/commonjs/components/AudioOutputSwitchView.js.map +1 -0
- package/lib/commonjs/components/BrandingView.js +78 -0
- package/lib/commonjs/components/BrandingView.js.map +1 -0
- package/lib/commonjs/components/ChannelView.js +117 -0
- package/lib/commonjs/components/ChannelView.js.map +1 -0
- package/lib/commonjs/components/ErrorView.js +88 -0
- package/lib/commonjs/components/ErrorView.js.map +1 -0
- package/lib/commonjs/components/LiveVoiceView.js +95 -0
- package/lib/commonjs/components/LiveVoiceView.js.map +1 -0
- package/lib/commonjs/components/PlayButtonView.js +161 -0
- package/lib/commonjs/components/PlayButtonView.js.map +1 -0
- package/lib/commonjs/components/ReconnectingView.js +109 -0
- package/lib/commonjs/components/ReconnectingView.js.map +1 -0
- package/lib/commonjs/components/WarningView.js +58 -0
- package/lib/commonjs/components/WarningView.js.map +1 -0
- package/lib/commonjs/components/index.js +94 -0
- package/lib/commonjs/components/index.js.map +1 -0
- package/lib/commonjs/icons/branding.png +0 -0
- package/lib/commonjs/icons/cpu.png +0 -0
- package/lib/commonjs/icons/headphones.png +0 -0
- package/lib/commonjs/icons/mic.png +0 -0
- package/lib/commonjs/icons/pause.png +0 -0
- package/lib/commonjs/icons/play.png +0 -0
- package/lib/commonjs/icons/speaker.png +0 -0
- package/lib/commonjs/index.js +310 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/specs/NativeLiveVoiceSdk.js +19 -0
- package/lib/commonjs/specs/NativeLiveVoiceSdk.js.map +1 -0
- package/lib/commonjs/util/Colors.js +30 -0
- package/lib/commonjs/util/Colors.js.map +1 -0
- package/lib/commonjs/util/ForegroundServiceConfig.js +33 -0
- package/lib/commonjs/util/ForegroundServiceConfig.js.map +1 -0
- package/lib/commonjs/util/PlayingState.js +24 -0
- package/lib/commonjs/util/PlayingState.js.map +1 -0
- package/lib/commonjs/util/Translations.js +47 -0
- package/lib/commonjs/util/Translations.js.map +1 -0
- package/lib/commonjs/util/UIState.js +6 -0
- package/lib/commonjs/util/UIState.js.map +1 -0
- package/lib/module/components/AudioOutputSwitchView.js +134 -0
- package/lib/module/components/AudioOutputSwitchView.js.map +1 -0
- package/lib/module/components/BrandingView.js +72 -0
- package/lib/module/components/BrandingView.js.map +1 -0
- package/lib/module/components/ChannelView.js +110 -0
- package/lib/module/components/ChannelView.js.map +1 -0
- package/lib/module/components/ErrorView.js +82 -0
- package/lib/module/components/ErrorView.js.map +1 -0
- package/lib/module/components/LiveVoiceView.js +90 -0
- package/lib/module/components/LiveVoiceView.js.map +1 -0
- package/lib/module/components/PlayButtonView.js +156 -0
- package/lib/module/components/PlayButtonView.js.map +1 -0
- package/lib/module/components/ReconnectingView.js +103 -0
- package/lib/module/components/ReconnectingView.js.map +1 -0
- package/lib/module/components/WarningView.js +52 -0
- package/lib/module/components/WarningView.js.map +1 -0
- package/lib/module/components/index.js +22 -0
- package/lib/module/components/index.js.map +1 -0
- package/lib/module/icons/branding.png +0 -0
- package/lib/module/icons/cpu.png +0 -0
- package/lib/module/icons/headphones.png +0 -0
- package/lib/module/icons/mic.png +0 -0
- package/lib/module/icons/pause.png +0 -0
- package/lib/module/icons/play.png +0 -0
- package/lib/module/icons/speaker.png +0 -0
- package/lib/module/index.js +215 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/specs/NativeLiveVoiceSdk.js +16 -0
- package/lib/module/specs/NativeLiveVoiceSdk.js.map +1 -0
- package/lib/module/util/Colors.js +26 -0
- package/lib/module/util/Colors.js.map +1 -0
- package/lib/module/util/ForegroundServiceConfig.js +28 -0
- package/lib/module/util/ForegroundServiceConfig.js.map +1 -0
- package/lib/module/util/PlayingState.js +21 -0
- package/lib/module/util/PlayingState.js.map +1 -0
- package/lib/module/util/Translations.js +41 -0
- package/lib/module/util/Translations.js.map +1 -0
- package/lib/module/util/UIState.js +4 -0
- package/lib/module/util/UIState.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/components/AudioOutputSwitchView.d.ts +6 -0
- package/lib/typescript/commonjs/src/components/AudioOutputSwitchView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/BrandingView.d.ts +6 -0
- package/lib/typescript/commonjs/src/components/BrandingView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/ChannelView.d.ts +13 -0
- package/lib/typescript/commonjs/src/components/ChannelView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/ErrorView.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/ErrorView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/LiveVoiceView.d.ts +6 -0
- package/lib/typescript/commonjs/src/components/LiveVoiceView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/PlayButtonView.d.ts +146 -0
- package/lib/typescript/commonjs/src/components/PlayButtonView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/ReconnectingView.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/ReconnectingView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/WarningView.d.ts +8 -0
- package/lib/typescript/commonjs/src/components/WarningView.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/index.d.ts +9 -0
- package/lib/typescript/commonjs/src/components/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +129 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/NativeLiveVoiceSdk.d.ts +47 -0
- package/lib/typescript/commonjs/src/specs/NativeLiveVoiceSdk.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/util/Colors.d.ts +13 -0
- package/lib/typescript/commonjs/src/util/Colors.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/util/ForegroundServiceConfig.d.ts +12 -0
- package/lib/typescript/commonjs/src/util/ForegroundServiceConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/util/PlayingState.d.ts +7 -0
- package/lib/typescript/commonjs/src/util/PlayingState.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/util/Translations.d.ts +22 -0
- package/lib/typescript/commonjs/src/util/Translations.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/util/UIState.d.ts +45 -0
- package/lib/typescript/commonjs/src/util/UIState.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/components/AudioOutputSwitchView.d.ts +6 -0
- package/lib/typescript/module/src/components/AudioOutputSwitchView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/BrandingView.d.ts +6 -0
- package/lib/typescript/module/src/components/BrandingView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/ChannelView.d.ts +13 -0
- package/lib/typescript/module/src/components/ChannelView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/ErrorView.d.ts +9 -0
- package/lib/typescript/module/src/components/ErrorView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/LiveVoiceView.d.ts +6 -0
- package/lib/typescript/module/src/components/LiveVoiceView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/PlayButtonView.d.ts +146 -0
- package/lib/typescript/module/src/components/PlayButtonView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/ReconnectingView.d.ts +9 -0
- package/lib/typescript/module/src/components/ReconnectingView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/WarningView.d.ts +8 -0
- package/lib/typescript/module/src/components/WarningView.d.ts.map +1 -0
- package/lib/typescript/module/src/components/index.d.ts +9 -0
- package/lib/typescript/module/src/components/index.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +129 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/NativeLiveVoiceSdk.d.ts +47 -0
- package/lib/typescript/module/src/specs/NativeLiveVoiceSdk.d.ts.map +1 -0
- package/lib/typescript/module/src/util/Colors.d.ts +13 -0
- package/lib/typescript/module/src/util/Colors.d.ts.map +1 -0
- package/lib/typescript/module/src/util/ForegroundServiceConfig.d.ts +12 -0
- package/lib/typescript/module/src/util/ForegroundServiceConfig.d.ts.map +1 -0
- package/lib/typescript/module/src/util/PlayingState.d.ts +7 -0
- package/lib/typescript/module/src/util/PlayingState.d.ts.map +1 -0
- package/lib/typescript/module/src/util/Translations.d.ts +22 -0
- package/lib/typescript/module/src/util/Translations.d.ts.map +1 -0
- package/lib/typescript/module/src/util/UIState.d.ts +45 -0
- package/lib/typescript/module/src/util/UIState.d.ts.map +1 -0
- package/livevoice-sdk-react-native.podspec +58 -0
- package/package.json +207 -0
- package/react-native.config.js +12 -0
- package/src/components/AudioOutputSwitchView.tsx +145 -0
- package/src/components/BrandingView.tsx +66 -0
- package/src/components/ChannelView.tsx +99 -0
- package/src/components/ErrorView.tsx +89 -0
- package/src/components/LiveVoiceView.tsx +120 -0
- package/src/components/PlayButtonView.tsx +181 -0
- package/src/components/ReconnectingView.tsx +133 -0
- package/src/components/WarningView.tsx +60 -0
- package/src/components/index.tsx +19 -0
- package/src/icons/branding.png +0 -0
- package/src/icons/cpu.png +0 -0
- package/src/icons/headphones.png +0 -0
- package/src/icons/mic.png +0 -0
- package/src/icons/pause.png +0 -0
- package/src/icons/play.png +0 -0
- package/src/icons/speaker.png +0 -0
- package/src/index.tsx +221 -0
- package/src/specs/NativeLiveVoiceSdk.ts +75 -0
- package/src/util/Colors.ts +27 -0
- package/src/util/ForegroundServiceConfig.tsx +32 -0
- package/src/util/PlayingState.ts +18 -0
- package/src/util/Translations.ts +39 -0
- package/src/util/UIState.ts +65 -0
package/package.json
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "livevoice-sdk-react-native",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "The LiveVoice SDK for integrating simultaneous interpretation, AI voice translation, guided tours, silent events, and more into your app.",
|
|
5
|
+
"source": "./src/index.tsx",
|
|
6
|
+
"main": "./lib/commonjs/index.js",
|
|
7
|
+
"module": "./lib/module/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./lib/typescript/module/src/index.d.ts",
|
|
12
|
+
"default": "./lib/module/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./lib/typescript/commonjs/src/index.d.ts",
|
|
16
|
+
"default": "./lib/commonjs/index.js"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"src",
|
|
22
|
+
"lib",
|
|
23
|
+
"android",
|
|
24
|
+
"ios",
|
|
25
|
+
"cpp",
|
|
26
|
+
"*.podspec",
|
|
27
|
+
"react-native.config.js",
|
|
28
|
+
"!ios/build",
|
|
29
|
+
"!android/build",
|
|
30
|
+
"!android/gradle",
|
|
31
|
+
"!android/gradlew",
|
|
32
|
+
"!android/gradlew.bat",
|
|
33
|
+
"!android/local.properties",
|
|
34
|
+
"!**/__tests__",
|
|
35
|
+
"!**/__fixtures__",
|
|
36
|
+
"!**/__mocks__",
|
|
37
|
+
"!**/.*"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"example": "yarn workspace livevoice-sdk-react-native-example",
|
|
41
|
+
"test": "jest",
|
|
42
|
+
"typecheck": "tsc",
|
|
43
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
44
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
45
|
+
"prepare": "bob build",
|
|
46
|
+
"release": "release-it",
|
|
47
|
+
"build:examples": "yarn example sync:ios && yarn example build:all",
|
|
48
|
+
"launch:examples": "yarn example sync:ios && yarn example ios && yarn example android",
|
|
49
|
+
"clear-all": "sh clear-all.sh"
|
|
50
|
+
},
|
|
51
|
+
"keywords": [
|
|
52
|
+
"react-native",
|
|
53
|
+
"ios",
|
|
54
|
+
"android",
|
|
55
|
+
"simultaneous interpretation",
|
|
56
|
+
"AI voice translation",
|
|
57
|
+
"guided tours",
|
|
58
|
+
"silent events",
|
|
59
|
+
"realtime audio"
|
|
60
|
+
],
|
|
61
|
+
"author": "LiveVoice GmbH <sdk-support@livevoice.io> (https://livevoice.io)",
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"bugs": {
|
|
64
|
+
"email": "sdk-support@livevoice.io"
|
|
65
|
+
},
|
|
66
|
+
"homepage": "https://livevoice.io/",
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"registry": "https://registry.npmjs.org/"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@commitlint/config-conventional": "^17.0.2",
|
|
72
|
+
"@react-native-community/cli": "15.0.1",
|
|
73
|
+
"@react-native/eslint-config": "^0.73.1",
|
|
74
|
+
"@release-it/conventional-changelog": "^9.0.2",
|
|
75
|
+
"@types/jest": "^29.5.5",
|
|
76
|
+
"@types/react": "^19.0.0",
|
|
77
|
+
"commitlint": "^17.0.2",
|
|
78
|
+
"del-cli": "^5.1.0",
|
|
79
|
+
"eslint": "^8.51.0",
|
|
80
|
+
"eslint-config-prettier": "^9.0.0",
|
|
81
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
82
|
+
"jest": "^29.7.0",
|
|
83
|
+
"prettier": "^3.0.3",
|
|
84
|
+
"react": "19.0.0",
|
|
85
|
+
"react-native": "0.78.1",
|
|
86
|
+
"react-native-builder-bob": "^0.37.0",
|
|
87
|
+
"release-it": "^17.10.0",
|
|
88
|
+
"turbo": "^1.10.7",
|
|
89
|
+
"typedoc": "^0.28.2",
|
|
90
|
+
"typescript": "^5.2.2"
|
|
91
|
+
},
|
|
92
|
+
"resolutions": {
|
|
93
|
+
"@types/react": "^18.2.44"
|
|
94
|
+
},
|
|
95
|
+
"peerDependencies": {
|
|
96
|
+
"react": "*",
|
|
97
|
+
"react-native": "*"
|
|
98
|
+
},
|
|
99
|
+
"workspaces": [
|
|
100
|
+
"example"
|
|
101
|
+
],
|
|
102
|
+
"packageManager": "yarn@3.6.1",
|
|
103
|
+
"jest": {
|
|
104
|
+
"preset": "react-native",
|
|
105
|
+
"modulePathIgnorePatterns": [
|
|
106
|
+
"<rootDir>/example/node_modules",
|
|
107
|
+
"<rootDir>/lib/"
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
"commitlint": {
|
|
111
|
+
"extends": [
|
|
112
|
+
"@commitlint/config-conventional"
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
"release-it": {
|
|
116
|
+
"git": {
|
|
117
|
+
"commitMessage": "chore: release ${version}",
|
|
118
|
+
"tagName": "v${version}"
|
|
119
|
+
},
|
|
120
|
+
"npm": {
|
|
121
|
+
"publish": true
|
|
122
|
+
},
|
|
123
|
+
"github": {
|
|
124
|
+
"release": true
|
|
125
|
+
},
|
|
126
|
+
"plugins": {
|
|
127
|
+
"@release-it/conventional-changelog": {
|
|
128
|
+
"preset": "angular"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"eslintConfig": {
|
|
133
|
+
"root": true,
|
|
134
|
+
"extends": [
|
|
135
|
+
"@react-native",
|
|
136
|
+
"prettier"
|
|
137
|
+
],
|
|
138
|
+
"rules": {
|
|
139
|
+
"react/react-in-jsx-scope": "off",
|
|
140
|
+
"prettier/prettier": [
|
|
141
|
+
"error",
|
|
142
|
+
{
|
|
143
|
+
"quoteProps": "consistent",
|
|
144
|
+
"singleQuote": true,
|
|
145
|
+
"tabWidth": 2,
|
|
146
|
+
"trailingComma": "es5",
|
|
147
|
+
"useTabs": false
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
"eslintIgnore": [
|
|
153
|
+
"node_modules/",
|
|
154
|
+
"lib/"
|
|
155
|
+
],
|
|
156
|
+
"prettier": {
|
|
157
|
+
"quoteProps": "consistent",
|
|
158
|
+
"singleQuote": true,
|
|
159
|
+
"tabWidth": 2,
|
|
160
|
+
"trailingComma": "es5",
|
|
161
|
+
"useTabs": false
|
|
162
|
+
},
|
|
163
|
+
"react-native-builder-bob": {
|
|
164
|
+
"source": "src",
|
|
165
|
+
"output": "lib",
|
|
166
|
+
"targets": [
|
|
167
|
+
"codegen",
|
|
168
|
+
[
|
|
169
|
+
"commonjs",
|
|
170
|
+
{
|
|
171
|
+
"esm": true
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
[
|
|
175
|
+
"module",
|
|
176
|
+
{
|
|
177
|
+
"esm": true
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
[
|
|
181
|
+
"typescript",
|
|
182
|
+
{
|
|
183
|
+
"project": "tsconfig.build.json",
|
|
184
|
+
"esm": true
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
]
|
|
188
|
+
},
|
|
189
|
+
"codegenConfig": {
|
|
190
|
+
"name": "RNLiveVoiceSpec",
|
|
191
|
+
"type": "modules",
|
|
192
|
+
"jsSrcsDir": "src/specs",
|
|
193
|
+
"outputDir": {
|
|
194
|
+
"ios": "ios/generated",
|
|
195
|
+
"android": "android/generated"
|
|
196
|
+
},
|
|
197
|
+
"android": {
|
|
198
|
+
"javaPackageName": "io.livevoice.react"
|
|
199
|
+
},
|
|
200
|
+
"includesGeneratedCode": true
|
|
201
|
+
},
|
|
202
|
+
"create-react-native-library": {
|
|
203
|
+
"type": "turbo-module",
|
|
204
|
+
"languages": "kotlin-objc",
|
|
205
|
+
"version": "0.48.2"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This source file is part of the LiveVoice SDK project
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) LiveVoice GmbH
|
|
5
|
+
* Licensed under the MIT license
|
|
6
|
+
*
|
|
7
|
+
* See LICENSE for license information
|
|
8
|
+
*
|
|
9
|
+
* SPDX-License-Identifier: MIT
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { getCurrentAudioState, onAudioOutputChanged, setLiveVoiceUseSpeaker } from 'livevoice-sdk-react-native';
|
|
13
|
+
import React, { useState, useRef, useEffect, } from 'react';
|
|
14
|
+
import {
|
|
15
|
+
View,
|
|
16
|
+
TouchableOpacity,
|
|
17
|
+
StyleSheet,
|
|
18
|
+
Animated,
|
|
19
|
+
Easing,
|
|
20
|
+
Image,
|
|
21
|
+
useColorScheme
|
|
22
|
+
} from 'react-native';
|
|
23
|
+
|
|
24
|
+
export interface AudioOutputSwitchProps {
|
|
25
|
+
isDarkMode?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const AudioOutputSwitchView: React.FC<AudioOutputSwitchProps> = (props) => {
|
|
29
|
+
const [isSpeaker, setIsSpeaker] = useState<Boolean>((() => (getCurrentAudioState())))
|
|
30
|
+
useEffect(
|
|
31
|
+
() => {
|
|
32
|
+
onAudioOutputChanged((value: boolean) => {
|
|
33
|
+
console.log('State changed: ' + value);
|
|
34
|
+
setIsSpeaker(value);
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
[]
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const isDarkMode = props.isDarkMode != undefined ? props.isDarkMode : useColorScheme() === 'dark';
|
|
41
|
+
const animation = useRef(new Animated.Value(isSpeaker ? 1 : 0)).current;
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
Animated.timing(animation, {
|
|
45
|
+
toValue: isSpeaker ? 1 : 0, //start with correct position depending on isSpeaker state
|
|
46
|
+
duration: 100,
|
|
47
|
+
easing: Easing.out(Easing.circle),
|
|
48
|
+
useNativeDriver: false,
|
|
49
|
+
}).start();
|
|
50
|
+
}, [isSpeaker]);
|
|
51
|
+
|
|
52
|
+
const togglePosition = animation.interpolate({
|
|
53
|
+
inputRange: [0, 1],
|
|
54
|
+
outputRange: [2, 60], // Adjust these values based on your design
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const iconColor = isDarkMode ? '#fff' : '#191919';
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<TouchableOpacity
|
|
61
|
+
activeOpacity={1}
|
|
62
|
+
onPress={() => {
|
|
63
|
+
console.log('Clicked: with current' + isSpeaker);
|
|
64
|
+
setLiveVoiceUseSpeaker(!isSpeaker);
|
|
65
|
+
}}
|
|
66
|
+
style={[
|
|
67
|
+
styles.container,
|
|
68
|
+
isDarkMode ? styles.darkMode : styles.lightMode,
|
|
69
|
+
]}
|
|
70
|
+
>
|
|
71
|
+
<View style={styles.iconContainer}>
|
|
72
|
+
<Image
|
|
73
|
+
source={require('../icons/headphones.png')}
|
|
74
|
+
style={{ tintColor: iconColor, width: 20, height: 20, resizeMode: 'contain' }}
|
|
75
|
+
/>
|
|
76
|
+
<Image
|
|
77
|
+
source={require('../icons/speaker.png')}
|
|
78
|
+
style={{ tintColor: iconColor, width: 20, height: 20, resizeMode: 'contain' }}
|
|
79
|
+
/>
|
|
80
|
+
</View>
|
|
81
|
+
|
|
82
|
+
<Animated.View
|
|
83
|
+
style={[
|
|
84
|
+
styles.toggle,
|
|
85
|
+
isDarkMode
|
|
86
|
+
? styles.toggleBackgroundDark
|
|
87
|
+
: styles.toggleBackgroundLight,
|
|
88
|
+
{ transform: [{ translateX: togglePosition }] },
|
|
89
|
+
]}
|
|
90
|
+
>
|
|
91
|
+
{isSpeaker ?
|
|
92
|
+
<Image
|
|
93
|
+
source={require('../icons/speaker.png')}
|
|
94
|
+
style={{ tintColor: iconColor, width: 20, height: 20, resizeMode: 'contain' }}
|
|
95
|
+
/> :
|
|
96
|
+
<Image
|
|
97
|
+
source={require('../icons/headphones.png')}
|
|
98
|
+
style={{ tintColor: iconColor, width: 20, height: 20, resizeMode: 'contain' }}
|
|
99
|
+
/>
|
|
100
|
+
}
|
|
101
|
+
</Animated.View>
|
|
102
|
+
</TouchableOpacity>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const styles = StyleSheet.create({
|
|
107
|
+
container: {
|
|
108
|
+
width: 120,
|
|
109
|
+
height: 40,
|
|
110
|
+
borderRadius: 20,
|
|
111
|
+
flexDirection: 'row',
|
|
112
|
+
alignItems: 'center',
|
|
113
|
+
justifyContent: 'space-between',
|
|
114
|
+
paddingHorizontal: 16,
|
|
115
|
+
position: 'relative',
|
|
116
|
+
},
|
|
117
|
+
darkMode: {
|
|
118
|
+
backgroundColor: '#393F45',
|
|
119
|
+
},
|
|
120
|
+
lightMode: {
|
|
121
|
+
backgroundColor: '#E7E7E7',
|
|
122
|
+
},
|
|
123
|
+
iconContainer: {
|
|
124
|
+
flexDirection: 'row',
|
|
125
|
+
alignItems: 'center',
|
|
126
|
+
justifyContent: 'space-between',
|
|
127
|
+
width: '100%',
|
|
128
|
+
paddingHorizontal: 7,
|
|
129
|
+
},
|
|
130
|
+
toggle: {
|
|
131
|
+
width: 58,
|
|
132
|
+
height: 36,
|
|
133
|
+
borderRadius: 18,
|
|
134
|
+
position: 'absolute',
|
|
135
|
+
flex: 1,
|
|
136
|
+
alignItems: 'center',
|
|
137
|
+
justifyContent: 'center',
|
|
138
|
+
},
|
|
139
|
+
toggleBackgroundDark: {
|
|
140
|
+
backgroundColor: '#212529',
|
|
141
|
+
},
|
|
142
|
+
toggleBackgroundLight: {
|
|
143
|
+
backgroundColor: '#fff',
|
|
144
|
+
},
|
|
145
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This source file is part of the LiveVoice SDK project
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) LiveVoice GmbH
|
|
5
|
+
* Licensed under the MIT license
|
|
6
|
+
*
|
|
7
|
+
* See LICENSE for license information
|
|
8
|
+
*
|
|
9
|
+
* SPDX-License-Identifier: MIT
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { View, Text, useColorScheme, StyleSheet, Image } from 'react-native';
|
|
14
|
+
|
|
15
|
+
import { COLORS } from '../util/Colors';
|
|
16
|
+
|
|
17
|
+
export interface BrandingProps {
|
|
18
|
+
isDarkMode?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const BrandingView: React.FC<BrandingProps> = (props) => {
|
|
22
|
+
const isDarkMode = props.isDarkMode ?? useColorScheme() === 'dark';
|
|
23
|
+
const bgColor = isDarkMode ? COLORS.cardBgDark : COLORS.cardBg;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<View style={{ width: '100%', alignItems: 'center' , backgroundColor: bgColor, borderRadius:8}}>
|
|
27
|
+
<View style={styles.container}>
|
|
28
|
+
<Text style={[styles.text, isDarkMode ? styles.darkText : styles.lightText]}>
|
|
29
|
+
Live Audio Streaming by
|
|
30
|
+
</Text>
|
|
31
|
+
<Image
|
|
32
|
+
source={require('../icons/branding.png')}
|
|
33
|
+
style={[styles.image, {height:30,tintColor: isDarkMode? COLORS.white : COLORS.black}] }
|
|
34
|
+
resizeMode='contain'
|
|
35
|
+
/>
|
|
36
|
+
</View>
|
|
37
|
+
</View>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const styles = StyleSheet.create({
|
|
42
|
+
container: {
|
|
43
|
+
padding: 12,
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
justifyContent: 'center',
|
|
46
|
+
borderRadius: 8,
|
|
47
|
+
width: 250,
|
|
48
|
+
},
|
|
49
|
+
text: {
|
|
50
|
+
textAlign: 'center',
|
|
51
|
+
fontSize: 16,
|
|
52
|
+
fontWeight: '500',
|
|
53
|
+
marginBottom: 4,
|
|
54
|
+
},
|
|
55
|
+
darkText: {
|
|
56
|
+
color: '#fff',
|
|
57
|
+
},
|
|
58
|
+
lightText: {
|
|
59
|
+
color: '#191919',
|
|
60
|
+
},
|
|
61
|
+
image: {
|
|
62
|
+
width: '100%', // Fill the container's width
|
|
63
|
+
height: undefined, // Height is determined by the aspectRatio
|
|
64
|
+
aspectRatio: 4, // Replace 4 with the correct ratio (width / height) of your image
|
|
65
|
+
},
|
|
66
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This source file is part of the LiveVoice SDK project
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) LiveVoice GmbH
|
|
5
|
+
* Licensed under the MIT license
|
|
6
|
+
*
|
|
7
|
+
* See LICENSE for license information
|
|
8
|
+
*
|
|
9
|
+
* SPDX-License-Identifier: MIT
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import React, { useState } from 'react';
|
|
13
|
+
import { View, Text, StyleSheet, TouchableOpacity, useColorScheme, Image } from 'react-native';
|
|
14
|
+
import { COLORS } from '../util/Colors';
|
|
15
|
+
import { Translations } from '../util/Translations';
|
|
16
|
+
import { type PlayingState } from '../util/PlayingState';
|
|
17
|
+
import PlayButtonView from './PlayButtonView';
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export interface ChannelProps {
|
|
21
|
+
channelName: string;
|
|
22
|
+
playingState: PlayingState;
|
|
23
|
+
muted: boolean;
|
|
24
|
+
isOnline: boolean;
|
|
25
|
+
aiSpeaker: boolean;
|
|
26
|
+
isDarkMode?: boolean;
|
|
27
|
+
onPress: () => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const ChannelView: React.FC<ChannelProps> = ({
|
|
31
|
+
channelName,
|
|
32
|
+
playingState,
|
|
33
|
+
muted,
|
|
34
|
+
isOnline,
|
|
35
|
+
aiSpeaker,
|
|
36
|
+
isDarkMode = useColorScheme() === 'dark',
|
|
37
|
+
onPress
|
|
38
|
+
}) => {
|
|
39
|
+
|
|
40
|
+
const [collapsed, setCollapsed] = useState(true);
|
|
41
|
+
|
|
42
|
+
const backgroundColor = isDarkMode ? COLORS.cardBgDark : COLORS.cardBg
|
|
43
|
+
const secondaryColor = isDarkMode ? COLORS['gray-300'] : COLORS.gray
|
|
44
|
+
const iconColor = isDarkMode ? COLORS.white : COLORS.black
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<View style={[styles.container, { backgroundColor }]}>
|
|
48
|
+
<PlayButtonView playingState={playingState} onPress={onPress} isDarkMode={isDarkMode} isChannelOnline={isOnline} />
|
|
49
|
+
|
|
50
|
+
{/* Channel Name */}
|
|
51
|
+
<View style={{ flex: 1, marginLeft: 10 }}>
|
|
52
|
+
<TouchableOpacity onPress={() => setCollapsed(!collapsed)} activeOpacity={1}>
|
|
53
|
+
<Text numberOfLines={collapsed ? 1 : undefined} ellipsizeMode='tail' style={[styles.text, { color: isDarkMode ? COLORS.white : COLORS.black }]}>
|
|
54
|
+
{channelName}
|
|
55
|
+
</Text>
|
|
56
|
+
</TouchableOpacity>
|
|
57
|
+
|
|
58
|
+
{
|
|
59
|
+
/* Ai-Speaker status message */
|
|
60
|
+
aiSpeaker && (
|
|
61
|
+
<View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>
|
|
62
|
+
<Image
|
|
63
|
+
source={require('../icons/cpu.png')}
|
|
64
|
+
style={{ width: 16, height: 16, tintColor: secondaryColor, resizeMode: 'contain' }} />
|
|
65
|
+
|
|
66
|
+
<Text style={[styles.aiText, { color: secondaryColor }]}>{Translations.isAiChannelStatusMessage()}</Text>
|
|
67
|
+
</View>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
</View>
|
|
71
|
+
{
|
|
72
|
+
muted &&
|
|
73
|
+
<Image
|
|
74
|
+
source={require('../icons/mic.png')}
|
|
75
|
+
style={{ tintColor: iconColor, width: 20, height: 20, resizeMode: 'contain' }} />
|
|
76
|
+
}
|
|
77
|
+
</View>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const styles = StyleSheet.create({
|
|
82
|
+
container: {
|
|
83
|
+
flexDirection: 'row',
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
padding: 10,
|
|
86
|
+
backgroundColor: '#fff',
|
|
87
|
+
borderRadius: 8,
|
|
88
|
+
marginBottom: 10,
|
|
89
|
+
},
|
|
90
|
+
text: {
|
|
91
|
+
fontSize: 16,
|
|
92
|
+
fontWeight: '500',
|
|
93
|
+
},
|
|
94
|
+
aiText: {
|
|
95
|
+
fontSize: 12,
|
|
96
|
+
fontWeight: '400',
|
|
97
|
+
marginLeft: 4,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This source file is part of the LiveVoice SDK project
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) LiveVoice GmbH
|
|
5
|
+
* Licensed under the MIT license
|
|
6
|
+
*
|
|
7
|
+
* See LICENSE for license information
|
|
8
|
+
*
|
|
9
|
+
* SPDX-License-Identifier: MIT
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { View, Text, useColorScheme, StyleSheet, TouchableOpacity } from 'react-native';
|
|
14
|
+
import { COLORS } from '../util/Colors';
|
|
15
|
+
import { Translations } from '../util/Translations';
|
|
16
|
+
import { type ErrorState } from '../util/UIState';
|
|
17
|
+
|
|
18
|
+
export interface ErrorProps {
|
|
19
|
+
isDarkMode?: boolean;
|
|
20
|
+
state: ErrorState
|
|
21
|
+
onPress: () => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const ErrorView: React.FC<ErrorProps> = (props) => {
|
|
25
|
+
const isDarkMode = props.isDarkMode ?? useColorScheme() === 'dark';
|
|
26
|
+
const state = props.state;
|
|
27
|
+
|
|
28
|
+
const canBeRetried = (state.type === 'error' && state.canBeRetried)
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<View
|
|
32
|
+
style={[
|
|
33
|
+
styles.container,
|
|
34
|
+
isDarkMode ? { backgroundColor: COLORS.cardBgDark } : { backgroundColor: COLORS.cardBg }
|
|
35
|
+
]}>
|
|
36
|
+
|
|
37
|
+
<Text
|
|
38
|
+
style={[styles.text, state.type === 'error' ? styles.dangerText : (isDarkMode ? styles.darkText : styles.lightText)]}>
|
|
39
|
+
{state.message}
|
|
40
|
+
</Text>
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
{canBeRetried && (
|
|
44
|
+
<TouchableOpacity onPress={props.onPress} activeOpacity={0.9} style={[styles.button, isDarkMode ? { backgroundColor: '#fff' } : { backgroundColor: '#191919' }]}>
|
|
45
|
+
{/* text should be centered */}
|
|
46
|
+
<Text style={[styles.buttonText, isDarkMode ? styles.lightText : styles.darkText]}>
|
|
47
|
+
{Translations.errorRetryNowButton()}
|
|
48
|
+
</Text>
|
|
49
|
+
</TouchableOpacity>
|
|
50
|
+
)}
|
|
51
|
+
</View>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const styles = StyleSheet.create({
|
|
56
|
+
container: {
|
|
57
|
+
paddingVertical: 30,
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
justifyContent: 'center',
|
|
60
|
+
borderRadius: 8,
|
|
61
|
+
width: '100%',
|
|
62
|
+
marginBottom: 10,
|
|
63
|
+
},
|
|
64
|
+
text: {
|
|
65
|
+
fontSize: 14,
|
|
66
|
+
fontWeight: '500',
|
|
67
|
+
textAlign: 'center',
|
|
68
|
+
},
|
|
69
|
+
dangerText: {
|
|
70
|
+
color: '#F1521B',
|
|
71
|
+
},
|
|
72
|
+
darkText: {
|
|
73
|
+
color: '#fff',
|
|
74
|
+
},
|
|
75
|
+
lightText: {
|
|
76
|
+
color: '#191919',
|
|
77
|
+
},
|
|
78
|
+
button: {
|
|
79
|
+
paddingHorizontal: 10,
|
|
80
|
+
paddingVertical: 8,
|
|
81
|
+
borderRadius: 8,
|
|
82
|
+
marginTop: 10,
|
|
83
|
+
},
|
|
84
|
+
buttonText: {
|
|
85
|
+
color: '#fff',
|
|
86
|
+
fontSize: 14,
|
|
87
|
+
fontWeight: '500',
|
|
88
|
+
},
|
|
89
|
+
});
|