Spaces:
Running
Running
Update src/App.tsx
Browse files- src/App.tsx +22 -48
src/App.tsx
CHANGED
@@ -1,38 +1,13 @@
|
|
1 |
-
|
2 |
-
Copyright 2024 Google LLC
|
3 |
-
... (لایسنس و توضیحات دیگر مثل قبل) ...
|
4 |
-
*/
|
5 |
|
6 |
-
|
7 |
-
import './App.scss';
|
8 |
-
import { LiveAPIProvider, useLiveAPIContext } from "./contexts/LiveAPIContext";
|
9 |
-
import ControlTray from "./components/control-tray/ControlTray";
|
10 |
-
import { IOSModal } from "./components/ios-modal/IOSModal";
|
11 |
-
import { isIOS } from "./lib/platform";
|
12 |
-
import cn from "classnames";
|
13 |
-
import { LiveConfig } from "./multimodal-live-types";
|
14 |
-
|
15 |
-
const myCustomInstruction = `
|
16 |
-
... (دستورالعمل سفارشی شما بدون تغییر) ...
|
17 |
-
`.trim();
|
18 |
-
|
19 |
-
const initialAppConfig: LiveConfig = {
|
20 |
-
model: "models/gemini-2.0-flash-exp",
|
21 |
-
systemInstruction: {
|
22 |
-
parts: [{ text: myCustomInstruction }],
|
23 |
-
},
|
24 |
-
};
|
25 |
-
|
26 |
-
// آیکون انسان از HTML شما (برای لوگوی بزرگ و کوچک)
|
27 |
const SvgHumanIcon = () => (
|
28 |
<svg width="70" height="70" viewBox="0 0 88 89" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M75.1481 81.6361H12.9259C9.66667 81.6361 7 78.9721 7 75.7161V58.5112C7 57.5862 7 57.1052 7.44444 56.2172C8.85185 52.9612 13 50.2232 19.4815 47.8922C24.1111 56.6982 33.3704 62.6921 44 62.6921C54.6296 62.6921 63.9259 56.6982 68.5185 47.8922C75 50.1862 79.1852 52.9982 80.5556 56.2172C81 56.6612 81 57.6232 81 58.5112V75.7161C81 78.9721 78.3333 81.6361 75.0741 81.6361H75.1481Z" stroke="currentColor" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/><path d="M44.0371 50.1862C33.8519 50.1862 25.5186 41.8612 25.5186 31.6863V26.1363C25.5186 15.9613 33.8519 7.63635 44.0371 7.63635C54.2223 7.63635 62.5556 15.9613 62.5556 26.1363V31.6863C62.5556 41.8612 54.2223 50.1862 44.0371 50.1862Z" stroke="currentColor" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/></svg>
|
29 |
);
|
30 |
|
31 |
-
//
|
32 |
-
// این آیکون برای حالت فعال میکروفون (PauseIcon فعلی) استفاده خواهد شد
|
33 |
-
// و آیکون دیگر (MicrophoneIcon فعلی) برای حالت غیرفعال
|
34 |
const SvgReferenceMicrophoneIcon = () => (
|
35 |
-
<svg width="38" height="38" viewBox="0 0 69 68" fill="none" xmlns="http://www.w3.org/2000/svg" transform="scale(0.55)">
|
36 |
<path opacity="0.4" d="M49.9479 27.1824C49.0803 27.1824 48.3907 27.872 48.3907 28.7396V32.2544C48.3907 40.1293 41.984 46.5361 34.109 46.5361C26.234 46.5361 19.8273 40.1293 19.8273 32.2544V28.7173C19.8273 27.8497 19.1377 27.1601 18.2701 27.1601C17.4025 27.1601 16.7129 27.8497 16.7129 28.7173V32.2321C16.7129 41.2861 23.6758 48.7384 32.5518 49.5393V54.2776C32.5518 55.1452 33.2414 55.8348 34.109 55.8348C34.9766 55.8348 35.6662 55.1452 35.6662 54.2776V49.5393C44.52 48.7607 51.5051 41.2861 51.5051 32.2321V28.7173C51.4829 27.872 50.7933 27.1824 49.9479 27.1824Z" fill="#BE123C"/>
|
37 |
<path d="M34.1099 11.3434C28.682 11.3434 24.2773 15.7481 24.2773 21.176V32.5658C24.2773 37.9938 28.682 42.3984 34.1099 42.3984C39.5379 42.3984 43.9425 37.9938 43.9425 32.5658V21.176C43.9425 15.7481 39.5379 11.3434 34.1099 11.3434ZM37.0241 26.8042C36.8684 27.3826 36.3567 27.7608 35.7784 27.7608C35.6671 27.7608 35.5559 27.7385 35.4447 27.7163C34.5771 27.4716 33.665 27.4716 32.7974 27.7163C32.0856 27.9165 31.396 27.4938 31.218 26.8042C31.0178 26.1146 31.4404 25.4027 32.1301 25.2247C33.4426 24.8688 34.8218 24.8688 36.1343 25.2247C36.8017 25.4027 37.2021 26.1146 37.0241 26.8042ZM38.2031 22.4885C38.0029 23.0224 37.5135 23.3339 36.9796 23.3339C36.8239 23.3339 36.6904 23.3116 36.5347 23.2671C34.9775 22.6887 33.2423 22.6887 31.6852 23.2671C31.0178 23.5118 30.2614 23.1559 30.0167 22.4885C29.772 21.8212 30.128 21.0648 30.7953 20.8423C32.9309 20.0637 35.289 20.0637 37.4245 20.8423C38.0919 21.087 38.4478 21.8212 38.2031 22.4885Z" fill="#BE123C"/>
|
38 |
</svg>
|
@@ -44,7 +19,7 @@ const AppInternalLogic: React.FC<{
|
|
44 |
isCamActive: boolean;
|
45 |
setIsMicActive: React.Dispatch<React.SetStateAction<boolean>>;
|
46 |
setIsCamActive: React.Dispatch<React.SetStateAction<boolean>>;
|
47 |
-
createLogoFunction: (isMini: boolean, isActive: boolean, type?: 'human' | 'ai', forFooter?: boolean) => React.ReactNode;
|
48 |
videoRef: React.RefObject<HTMLVideoElement>;
|
49 |
notificationPopoverRef: React.RefObject<HTMLDivElement>;
|
50 |
notificationButtonRef: React.RefObject<HTMLButtonElement>;
|
@@ -72,7 +47,8 @@ const AppInternalLogic: React.FC<{
|
|
72 |
|
73 |
return (
|
74 |
<div className="w-full flex flex-col items-center justify-center min-h-screen text-foreground antialiased">
|
75 |
-
<div className="main-wrapper max-w-3xl w-full flex flex-col items-center justify-center h-full relative">
|
|
|
76 |
<div className="header-controls">
|
77 |
<div id="notification-trigger-container">
|
78 |
<button
|
@@ -114,8 +90,7 @@ const AppInternalLogic: React.FC<{
|
|
114 |
</div>
|
115 |
</div>
|
116 |
|
117 |
-
|
118 |
-
<div className="media-area w-full flex flex-col items-center justify-center flex-grow relative"> {/* Added class media-area */}
|
119 |
<video
|
120 |
id="video-feed"
|
121 |
ref={videoRef}
|
@@ -129,7 +104,7 @@ const AppInternalLogic: React.FC<{
|
|
129 |
{/* Large Logo - Only when Mic is active AND Cam is NOT active */}
|
130 |
{isMicActive && !isCamActive && (
|
131 |
<div
|
132 |
-
id="large-logo-container"
|
133 |
className="absolute top-0 left-0 w-full h-full flex items-center justify-center"
|
134 |
>
|
135 |
{createLogoFunction(false, true, 'human', false)}
|
@@ -146,14 +121,14 @@ const AppInternalLogic: React.FC<{
|
|
146 |
isAppCamActive={isCamActive}
|
147 |
onAppCamToggle={setIsCamActive}
|
148 |
createLogoFunction={createLogoFunction}
|
149 |
-
// Pass
|
150 |
-
ReferenceMicrophoneIcon={SvgReferenceMicrophoneIcon}
|
151 |
/>
|
152 |
</div>
|
153 |
</div>
|
154 |
);
|
155 |
}
|
156 |
|
|
|
157 |
const logoColorConfig = {
|
158 |
blue: { // For human
|
159 |
ping: "bg-blue-200 dark:bg-blue-700",
|
@@ -222,20 +197,17 @@ function App() {
|
|
222 |
const createLogoFunction = (isMini: boolean, isActive: boolean, type: 'human' | 'ai' = 'human', forFooter: boolean = false) => {
|
223 |
if (!isActive) return null;
|
224 |
|
225 |
-
// Use blue for human, green for AI, gray as fallback
|
226 |
const colorKey = type === 'human' ? 'blue' : (type === 'ai' ? 'green' : 'gray');
|
227 |
const currentColors = logoColorConfig[colorKey as keyof typeof logoColorConfig] || logoColorConfig.gray;
|
228 |
|
229 |
-
const size = isMini ? 80 : 200;
|
230 |
-
const iconSize = isMini ? 35 : 70; // This
|
231 |
|
232 |
-
// Adjust inset for icon based on whether it's for footer or large display
|
233 |
-
// This is crucial for centering the icon within the pulsing circles.
|
234 |
let iconInset;
|
235 |
-
if (isMini) {
|
236 |
-
iconInset = 22;
|
237 |
-
} else {
|
238 |
-
iconInset = 65;
|
239 |
}
|
240 |
|
241 |
const insetBase = {
|
@@ -246,6 +218,9 @@ function App() {
|
|
246 |
icon: iconInset
|
247 |
};
|
248 |
|
|
|
|
|
|
|
249 |
|
250 |
return (
|
251 |
<div className={cn("logo-animation-wrapper", {"for-footer": forFooter})} style={{ width: `${size}px`, height: `${size}px` }}>
|
@@ -253,9 +228,8 @@ function App() {
|
|
253 |
<div className={`absolute rounded-full opacity-50 ${currentColors.outer}`} style={{ inset: `${insetBase.outer}px` }}></div>
|
254 |
<div className={`absolute rounded-full opacity-50 ${currentColors.mid}`} style={{ inset: `${insetBase.mid}px` }}></div>
|
255 |
<div className={`absolute rounded-full opacity-50 ${currentColors.inner}`} style={{ inset: `${insetBase.inner}px` }}></div>
|
256 |
-
<div className="z-10 absolute flex items-center justify-center" style={{ inset: `${insetBase.icon}px` }}>
|
257 |
-
{
|
258 |
-
{/* Add AI icon here if needed: type === 'ai' && <SvgAiIcon /> */}
|
259 |
</div>
|
260 |
</div>
|
261 |
);
|
|
|
1 |
+
// ... (import ها و myCustomInstruction و initialAppConfig مثل قبل) ...
|
|
|
|
|
|
|
2 |
|
3 |
+
// آیکون انسان (بدون تغییر)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
const SvgHumanIcon = () => (
|
5 |
<svg width="70" height="70" viewBox="0 0 88 89" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M75.1481 81.6361H12.9259C9.66667 81.6361 7 78.9721 7 75.7161V58.5112C7 57.5862 7 57.1052 7.44444 56.2172C8.85185 52.9612 13 50.2232 19.4815 47.8922C24.1111 56.6982 33.3704 62.6921 44 62.6921C54.6296 62.6921 63.9259 56.6982 68.5185 47.8922C75 50.1862 79.1852 52.9982 80.5556 56.2172C81 56.6612 81 57.6232 81 58.5112V75.7161C81 78.9721 78.3333 81.6361 75.0741 81.6361H75.1481Z" stroke="currentColor" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/><path d="M44.0371 50.1862C33.8519 50.1862 25.5186 41.8612 25.5186 31.6863V26.1363C25.5186 15.9613 33.8519 7.63635 44.0371 7.63635C54.2223 7.63635 62.5556 15.9613 62.5556 26.1363V31.6863C62.5556 41.8612 54.2223 50.1862 44.0371 50.1862Z" stroke="currentColor" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/></svg>
|
6 |
);
|
7 |
|
8 |
+
// SVG آیکون میکروفون از HTML مرجع شما (با سه خط افقی)
|
|
|
|
|
9 |
const SvgReferenceMicrophoneIcon = () => (
|
10 |
+
<svg width="38" height="38" viewBox="0 0 69 68" fill="none" xmlns="http://www.w3.org/2000/svg" transform="scale(0.55)"> {/* حفظ scale اصلی */}
|
11 |
<path opacity="0.4" d="M49.9479 27.1824C49.0803 27.1824 48.3907 27.872 48.3907 28.7396V32.2544C48.3907 40.1293 41.984 46.5361 34.109 46.5361C26.234 46.5361 19.8273 40.1293 19.8273 32.2544V28.7173C19.8273 27.8497 19.1377 27.1601 18.2701 27.1601C17.4025 27.1601 16.7129 27.8497 16.7129 28.7173V32.2321C16.7129 41.2861 23.6758 48.7384 32.5518 49.5393V54.2776C32.5518 55.1452 33.2414 55.8348 34.109 55.8348C34.9766 55.8348 35.6662 55.1452 35.6662 54.2776V49.5393C44.52 48.7607 51.5051 41.2861 51.5051 32.2321V28.7173C51.4829 27.872 50.7933 27.1824 49.9479 27.1824Z" fill="#BE123C"/>
|
12 |
<path d="M34.1099 11.3434C28.682 11.3434 24.2773 15.7481 24.2773 21.176V32.5658C24.2773 37.9938 28.682 42.3984 34.1099 42.3984C39.5379 42.3984 43.9425 37.9938 43.9425 32.5658V21.176C43.9425 15.7481 39.5379 11.3434 34.1099 11.3434ZM37.0241 26.8042C36.8684 27.3826 36.3567 27.7608 35.7784 27.7608C35.6671 27.7608 35.5559 27.7385 35.4447 27.7163C34.5771 27.4716 33.665 27.4716 32.7974 27.7163C32.0856 27.9165 31.396 27.4938 31.218 26.8042C31.0178 26.1146 31.4404 25.4027 32.1301 25.2247C33.4426 24.8688 34.8218 24.8688 36.1343 25.2247C36.8017 25.4027 37.2021 26.1146 37.0241 26.8042ZM38.2031 22.4885C38.0029 23.0224 37.5135 23.3339 36.9796 23.3339C36.8239 23.3339 36.6904 23.3116 36.5347 23.2671C34.9775 22.6887 33.2423 22.6887 31.6852 23.2671C31.0178 23.5118 30.2614 23.1559 30.0167 22.4885C29.772 21.8212 30.128 21.0648 30.7953 20.8423C32.9309 20.0637 35.289 20.0637 37.4245 20.8423C38.0919 21.087 38.4478 21.8212 38.2031 22.4885Z" fill="#BE123C"/>
|
13 |
</svg>
|
|
|
19 |
isCamActive: boolean;
|
20 |
setIsMicActive: React.Dispatch<React.SetStateAction<boolean>>;
|
21 |
setIsCamActive: React.Dispatch<React.SetStateAction<boolean>>;
|
22 |
+
createLogoFunction: (isMini: boolean, isActive: boolean, type?: 'human' | 'ai', forFooter?: boolean) => React.ReactNode;
|
23 |
videoRef: React.RefObject<HTMLVideoElement>;
|
24 |
notificationPopoverRef: React.RefObject<HTMLDivElement>;
|
25 |
notificationButtonRef: React.RefObject<HTMLButtonElement>;
|
|
|
47 |
|
48 |
return (
|
49 |
<div className="w-full flex flex-col items-center justify-center min-h-screen text-foreground antialiased">
|
50 |
+
<div className="main-wrapper max-w-3xl w-full flex flex-col items-center justify-center h-full relative">
|
51 |
+
{/* ... (Header and Notification Popover without change) ... */}
|
52 |
<div className="header-controls">
|
53 |
<div id="notification-trigger-container">
|
54 |
<button
|
|
|
90 |
</div>
|
91 |
</div>
|
92 |
|
93 |
+
<div className="media-area w-full flex flex-col items-center justify-center flex-grow relative">
|
|
|
94 |
<video
|
95 |
id="video-feed"
|
96 |
ref={videoRef}
|
|
|
104 |
{/* Large Logo - Only when Mic is active AND Cam is NOT active */}
|
105 |
{isMicActive && !isCamActive && (
|
106 |
<div
|
107 |
+
id="large-logo-container" // This ID is from your HTML for the large centered logo
|
108 |
className="absolute top-0 left-0 w-full h-full flex items-center justify-center"
|
109 |
>
|
110 |
{createLogoFunction(false, true, 'human', false)}
|
|
|
121 |
isAppCamActive={isCamActive}
|
122 |
onAppCamToggle={setIsCamActive}
|
123 |
createLogoFunction={createLogoFunction}
|
124 |
+
ReferenceMicrophoneIcon={SvgReferenceMicrophoneIcon} // Pass the correct mic icon
|
|
|
125 |
/>
|
126 |
</div>
|
127 |
</div>
|
128 |
);
|
129 |
}
|
130 |
|
131 |
+
// ... (logoColorConfig و تابع App اصلی بدون تغییر) ...
|
132 |
const logoColorConfig = {
|
133 |
blue: { // For human
|
134 |
ping: "bg-blue-200 dark:bg-blue-700",
|
|
|
197 |
const createLogoFunction = (isMini: boolean, isActive: boolean, type: 'human' | 'ai' = 'human', forFooter: boolean = false) => {
|
198 |
if (!isActive) return null;
|
199 |
|
|
|
200 |
const colorKey = type === 'human' ? 'blue' : (type === 'ai' ? 'green' : 'gray');
|
201 |
const currentColors = logoColorConfig[colorKey as keyof typeof logoColorConfig] || logoColorConfig.gray;
|
202 |
|
203 |
+
const size = isMini ? 80 : 200;
|
204 |
+
// const iconSize = isMini ? 35 : 70; // This was for SvgHumanIcon's container, actual SVG might have own size
|
205 |
|
|
|
|
|
206 |
let iconInset;
|
207 |
+
if (isMini) {
|
208 |
+
iconInset = 22;
|
209 |
+
} else {
|
210 |
+
iconInset = 65;
|
211 |
}
|
212 |
|
213 |
const insetBase = {
|
|
|
218 |
icon: iconInset
|
219 |
};
|
220 |
|
221 |
+
// Ensure the SVG icon scales correctly within its designated space
|
222 |
+
// We can wrap SvgHumanIcon in a div that controls its size if SvgHumanIcon itself doesn't take width/height props well
|
223 |
+
const IconComponent = type === 'human' ? SvgHumanIcon : null; // Add SvgAiIcon here if you have one
|
224 |
|
225 |
return (
|
226 |
<div className={cn("logo-animation-wrapper", {"for-footer": forFooter})} style={{ width: `${size}px`, height: `${size}px` }}>
|
|
|
228 |
<div className={`absolute rounded-full opacity-50 ${currentColors.outer}`} style={{ inset: `${insetBase.outer}px` }}></div>
|
229 |
<div className={`absolute rounded-full opacity-50 ${currentColors.mid}`} style={{ inset: `${insetBase.mid}px` }}></div>
|
230 |
<div className={`absolute rounded-full opacity-50 ${currentColors.inner}`} style={{ inset: `${insetBase.inner}px` }}></div>
|
231 |
+
<div className="z-10 absolute flex items-center justify-center" style={{ inset: `${insetBase.icon}px`, width: `${isMini ? 35 : 70}px`, height: `${isMini ? 35 : 70}px` }}>
|
232 |
+
{IconComponent && <IconComponent />}
|
|
|
233 |
</div>
|
234 |
</div>
|
235 |
);
|