Spaces:
Running
Running
Update src/App.tsx
Browse files- src/App.tsx +52 -139
src/App.tsx
CHANGED
@@ -1,4 +1,16 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import React, { useEffect, useRef, useState } from "react";
|
3 |
import './App.scss';
|
4 |
import { LiveAPIProvider, useLiveAPIContext } from "./contexts/LiveAPIContext";
|
@@ -92,7 +104,6 @@ const initialAppConfig: LiveConfig = {
|
|
92 |
},
|
93 |
};
|
94 |
|
95 |
-
|
96 |
const SvgHumanIcon = () => (
|
97 |
<svg width="100%" height="100%" viewBox="0 0 88 89" fill="none" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet">
|
98 |
<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"/>
|
@@ -100,26 +111,11 @@ const SvgHumanIcon = () => (
|
|
100 |
</svg>
|
101 |
);
|
102 |
|
103 |
-
|
104 |
-
|
105 |
-
<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"/>
|
106 |
-
<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"/>
|
107 |
-
</svg>
|
108 |
-
);
|
109 |
|
110 |
|
111 |
-
const AppInternalLogic: React.FC<{
|
112 |
-
isMicActive: boolean;
|
113 |
-
isCamActive: boolean;
|
114 |
-
setIsMicActive: React.Dispatch<React.SetStateAction<boolean>>;
|
115 |
-
setIsCamActive: React.Dispatch<React.SetStateAction<boolean>>;
|
116 |
-
createLogoFunction: (isMini: boolean, isActive: boolean, type?: 'human' | 'ai', forFooter?: boolean) => React.ReactNode;
|
117 |
-
videoRef: React.RefObject<HTMLVideoElement>;
|
118 |
-
notificationPopoverRef: React.RefObject<HTMLDivElement>;
|
119 |
-
notificationButtonRef: React.RefObject<HTMLButtonElement>;
|
120 |
-
isNotificationOpen: boolean;
|
121 |
-
setIsNotificationOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
122 |
-
}> = ({
|
123 |
isMicActive,
|
124 |
isCamActive,
|
125 |
setIsMicActive,
|
@@ -131,6 +127,7 @@ const AppInternalLogic: React.FC<{
|
|
131 |
isNotificationOpen,
|
132 |
setIsNotificationOpen
|
133 |
}) => {
|
|
|
134 |
const { connected, disconnect } = useLiveAPIContext();
|
135 |
|
136 |
useEffect(() => {
|
@@ -142,73 +139,37 @@ const AppInternalLogic: React.FC<{
|
|
142 |
return (
|
143 |
<div className="w-full flex flex-col items-center justify-center min-h-screen text-foreground antialiased">
|
144 |
<div className="main-wrapper max-w-3xl w-full flex flex-col items-center justify-center h-full relative">
|
145 |
-
{/*
|
146 |
-
<div className="header-controls">
|
147 |
<div id="notification-trigger-container">
|
148 |
-
<button
|
149 |
-
|
150 |
-
id="notification-button"
|
151 |
-
aria-label="Notifications"
|
152 |
-
className="header-button"
|
153 |
-
onClick={(e) => {
|
154 |
-
e.stopPropagation();
|
155 |
-
setIsNotificationOpen(!isNotificationOpen);
|
156 |
-
}}
|
157 |
-
>
|
158 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>
|
159 |
</button>
|
160 |
</div>
|
161 |
<div className="back-button-container">
|
162 |
-
<button
|
163 |
-
id="back-button"
|
164 |
-
aria-label="Go back"
|
165 |
-
className="header-button"
|
166 |
-
onClick={() => alert('Back clicked (implement navigation)')}
|
167 |
-
>
|
168 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="m15 18-6-6 6-6"></path></svg>
|
169 |
</button>
|
170 |
</div>
|
171 |
</div>
|
172 |
|
173 |
-
<div ref={notificationPopoverRef} id="notification-popover-wrapper" className="notification-popover-wrapper">
|
174 |
-
<div
|
175 |
-
|
176 |
-
className={cn("popover-content", {
|
177 |
-
"open animate-popover-open-top-center": isNotificationOpen,
|
178 |
-
"animate-popover-close-top-center": !isNotificationOpen && document.getElementById('notification-popover')?.classList.contains('open'),
|
179 |
-
})}
|
180 |
-
>
|
181 |
-
<div className="notification-popover-text-content">
|
182 |
-
مدلهای هوش مصنوعی میتوانند اشتباه کنند، صحت اطلاعات مهم را بررسی کنید و از وارد کردن اطلاعات حساس بپرهیزید.
|
183 |
-
</div>
|
184 |
</div>
|
185 |
</div>
|
186 |
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
id="video-feed"
|
191 |
-
ref={videoRef}
|
192 |
-
autoPlay
|
193 |
-
playsInline
|
194 |
-
className={cn(
|
195 |
-
"absolute top-0 left-0 w-full h-full object-cover scale-x-[-1]",
|
196 |
-
{ "hidden": !isCamActive }
|
197 |
-
)}
|
198 |
-
/>
|
199 |
-
{/* نمایش لوگوی بزرگ فقط زمانی که میکروفون فعال است و دوربین غیرفعال */}
|
200 |
{isMicActive && !isCamActive && (
|
201 |
-
<div
|
202 |
-
id="large-logo-container"
|
203 |
-
className="large-logo-container-class" // استفاده از کلاس برای استایل دهی بهتر
|
204 |
-
>
|
205 |
-
{/* پارامتر forFooter اینجا false است چون برای لوگوی بزرگ است */}
|
206 |
{createLogoFunction(false, true, 'human', false)}
|
207 |
</div>
|
208 |
)}
|
209 |
</div>
|
210 |
|
211 |
-
<ControlTray
|
212 |
videoRef={videoRef}
|
213 |
supportsVideo={true}
|
214 |
onVideoStreamChange={(stream) => { /* ... */ }}
|
@@ -217,105 +178,61 @@ const AppInternalLogic: React.FC<{
|
|
217 |
isAppCamActive={isCamActive}
|
218 |
onAppCamToggle={setIsCamActive}
|
219 |
createLogoFunction={createLogoFunction}
|
220 |
-
ReferenceMicrophoneIcon={
|
221 |
/>
|
222 |
</div>
|
223 |
</div>
|
224 |
);
|
225 |
-
}
|
226 |
|
|
|
227 |
const logoColorConfig = {
|
228 |
-
blue: {
|
229 |
-
|
230 |
-
|
231 |
-
mid: "bg-blue-300 dark:bg-blue-600",
|
232 |
-
inner: "bg-blue-400 dark:bg-blue-500",
|
233 |
-
},
|
234 |
-
// ... (رنگهای دیگر اگر نیاز باشد) ...
|
235 |
-
gray: { // fallback
|
236 |
-
ping: "bg-gray-200 dark:bg-gray-700",
|
237 |
-
outer: "bg-gray-200 dark:bg-gray-700",
|
238 |
-
mid: "bg-gray-300 dark:bg-gray-600",
|
239 |
-
inner: "bg-gray-400 dark:bg-gray-500",
|
240 |
-
}
|
241 |
};
|
242 |
|
|
|
243 |
function App() {
|
244 |
// ... (state ها و useEffect های دیگر بدون تغییر) ...
|
245 |
const videoRef = useRef<HTMLVideoElement>(null);
|
246 |
const [showIOSModal, setShowIOSModal] = useState(false);
|
247 |
const [isAllowedOrigin, setIsAllowedOrigin] = useState<boolean | null>(null);
|
248 |
-
|
249 |
const [isMicActive, setIsMicActive] = useState(false);
|
250 |
const [isCamActive, setIsCamActive] = useState(false);
|
251 |
const [isNotificationOpen, setIsNotificationOpen] = useState(false);
|
252 |
-
|
253 |
const notificationPopoverRef = useRef<HTMLDivElement>(null);
|
254 |
const notificationButtonRef = useRef<HTMLButtonElement>(null);
|
255 |
|
256 |
-
useEffect(() => {
|
257 |
-
|
258 |
-
|
259 |
-
}
|
260 |
-
const timer = setTimeout(() => {
|
261 |
-
setIsAllowedOrigin(true);
|
262 |
-
}, 100);
|
263 |
-
return () => clearTimeout(timer);
|
264 |
-
}, []);
|
265 |
-
|
266 |
-
useEffect(() => {
|
267 |
-
const handleClickOutside = (event: MouseEvent) => {
|
268 |
-
if (
|
269 |
-
isNotificationOpen &&
|
270 |
-
notificationPopoverRef.current &&
|
271 |
-
!notificationPopoverRef.current.contains(event.target as Node) &&
|
272 |
-
notificationButtonRef.current &&
|
273 |
-
!notificationButtonRef.current.contains(event.target as Node)
|
274 |
-
) {
|
275 |
-
setIsNotificationOpen(false);
|
276 |
-
}
|
277 |
-
};
|
278 |
-
document.addEventListener("mousedown", handleClickOutside);
|
279 |
-
return () => {
|
280 |
-
document.removeEventListener("mousedown", handleClickOutside);
|
281 |
-
};
|
282 |
-
}, [isNotificationOpen]);
|
283 |
-
|
284 |
-
if (isAllowedOrigin === null) {
|
285 |
-
return <div style={{ padding: '20px', textAlign: 'center' }}>در حال بررسی دسترسی...</div>;
|
286 |
-
}
|
287 |
-
|
288 |
|
|
|
289 |
const createLogoFunction = (isMini: boolean, isActive: boolean, type: 'human' | 'ai' = 'human', forFooter: boolean = false) => {
|
290 |
if (!isActive) return null;
|
291 |
|
292 |
-
const colorKey = type === 'human' ? 'blue' : 'gray';
|
293 |
const currentColors = logoColorConfig[colorKey as keyof typeof logoColorConfig];
|
294 |
|
295 |
-
const size = isMini ? 80 : 200;
|
296 |
-
const iconDisplaySize = isMini ? 35 : 70;
|
297 |
-
|
298 |
-
const iconInset = (size - iconDisplaySize) / 2; // محاسبه برای وسط چین کردن
|
299 |
|
300 |
-
// مقادیر inset برای حلقهها از HTML مرجع شما
|
301 |
const baseInsets = isMini
|
302 |
-
? { ping: 10, outer: 0, mid: 5, inner: 12 }
|
303 |
-
: { ping: 40, outer: 0, mid: 20, inner: 50 }
|
304 |
|
305 |
const IconComponent = type === 'human' ? SvgHumanIcon : null;
|
306 |
|
307 |
return (
|
308 |
-
// کانتینر اصلی با اندازه مشخص شده
|
309 |
<div className={cn("logo-animation-wrapper", {"for-footer": forFooter})} style={{ width: `${size}px`, height: `${size}px` }}>
|
310 |
-
{/*
|
311 |
<div className={`absolute rounded-full opacity-50 animate-ping ${currentColors.ping}`} style={{ inset: `${baseInsets.ping}px` }}></div>
|
312 |
-
{/* حلقه بیرونی */}
|
313 |
<div className={`absolute rounded-full opacity-50 ${currentColors.outer}`} style={{ inset: `${baseInsets.outer}px` }}></div>
|
314 |
-
{/* حلقه میانی */}
|
315 |
<div className={`absolute rounded-full opacity-50 ${currentColors.mid}`} style={{ inset: `${baseInsets.mid}px` }}></div>
|
316 |
-
{/* حلقه داخلی */}
|
317 |
<div className={`absolute rounded-full opacity-50 ${currentColors.inner}`} style={{ inset: `${baseInsets.inner}px` }}></div>
|
318 |
-
{/* کانتینر آیکون */}
|
319 |
<div className="z-10 absolute flex items-center justify-center" style={{ inset: `${iconInset}px`, width: `${iconDisplaySize}px`, height: `${iconDisplaySize}px` }}>
|
320 |
{IconComponent && <IconComponent />}
|
321 |
</div>
|
@@ -326,16 +243,12 @@ function App() {
|
|
326 |
return (
|
327 |
<LiveAPIProvider initialConfig={initialAppConfig}>
|
328 |
<AppInternalLogic
|
329 |
-
isMicActive={isMicActive}
|
330 |
-
|
331 |
-
isCamActive={isCamActive}
|
332 |
-
setIsCamActive={setIsCamActive}
|
333 |
createLogoFunction={createLogoFunction}
|
334 |
videoRef={videoRef}
|
335 |
-
notificationPopoverRef={notificationPopoverRef}
|
336 |
-
|
337 |
-
isNotificationOpen={isNotificationOpen}
|
338 |
-
setIsNotificationOpen={setIsNotificationOpen}
|
339 |
/>
|
340 |
<IOSModal isOpen={showIOSModal} onClose={() => setShowIOSModal(false)} />
|
341 |
</LiveAPIProvider>
|
|
|
1 |
+
/**
|
2 |
+
Copyright 2024 Google LLC
|
3 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
you may not use this file except in compliance with the License.
|
5 |
+
You may obtain a copy of the License at
|
6 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
7 |
+
Unless required by applicable law or agreed to in writing, software
|
8 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
9 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10 |
+
See the License for the specific language governing permissions and
|
11 |
+
limitations under the License.
|
12 |
+
*/
|
13 |
+
|
14 |
import React, { useEffect, useRef, useState } from "react";
|
15 |
import './App.scss';
|
16 |
import { LiveAPIProvider, useLiveAPIContext } from "./contexts/LiveAPIContext";
|
|
|
104 |
},
|
105 |
};
|
106 |
|
|
|
107 |
const SvgHumanIcon = () => (
|
108 |
<svg width="100%" height="100%" viewBox="0 0 88 89" fill="none" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet">
|
109 |
<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"/>
|
|
|
111 |
</svg>
|
112 |
);
|
113 |
|
114 |
+
// SVG آیکون میکروفون اولیه (سادهتر)
|
115 |
+
const SvgOriginalMicrophoneIcon = () => <svg width="38" height="38" viewBox="0 0 69 68" fill="none" xmlns="http://www.w3.org/2000/svg" transform="scale(0.55)"><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"/><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"/></svg>;
|
|
|
|
|
|
|
|
|
116 |
|
117 |
|
118 |
+
const AppInternalLogic: React.FC<{ /* ... (props بدون تغییر) ... */ }> = ({ /* ... (props بدون تغییر) ... */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
isMicActive,
|
120 |
isCamActive,
|
121 |
setIsMicActive,
|
|
|
127 |
isNotificationOpen,
|
128 |
setIsNotificationOpen
|
129 |
}) => {
|
130 |
+
// ... (useEffect ها بدون تغییر) ...
|
131 |
const { connected, disconnect } = useLiveAPIContext();
|
132 |
|
133 |
useEffect(() => {
|
|
|
139 |
return (
|
140 |
<div className="w-full flex flex-col items-center justify-center min-h-screen text-foreground antialiased">
|
141 |
<div className="main-wrapper max-w-3xl w-full flex flex-col items-center justify-center h-full relative">
|
142 |
+
<div className="header-controls"> {/* دکمههای نوتیفیکیشن و بازگشت */}
|
|
|
143 |
<div id="notification-trigger-container">
|
144 |
+
<button ref={notificationButtonRef} id="notification-button" aria-label="Notifications" className="header-button"
|
145 |
+
onClick={(e) => { e.stopPropagation(); setIsNotificationOpen(!isNotificationOpen); }}>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>
|
147 |
</button>
|
148 |
</div>
|
149 |
<div className="back-button-container">
|
150 |
+
<button id="back-button" aria-label="Go back" className="header-button" onClick={() => alert('Back clicked')}>
|
|
|
|
|
|
|
|
|
|
|
151 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="m15 18-6-6 6-6"></path></svg>
|
152 |
</button>
|
153 |
</div>
|
154 |
</div>
|
155 |
|
156 |
+
<div ref={notificationPopoverRef} id="notification-popover-wrapper" className="notification-popover-wrapper"> {/* پاپاور نوتیفیکیشن */}
|
157 |
+
<div id="notification-popover" className={cn("popover-content", { "open animate-popover-open-top-center": isNotificationOpen, "animate-popover-close-top-center": !isNotificationOpen && document.getElementById('notification-popover')?.classList.contains('open'), })}>
|
158 |
+
<div className="notification-popover-text-content">مدلهای هوش مصنوعی میتوانند اشتباه کنند، صحت اطلاعات مهم را بررسی کنید و از وارد کردن اطلاعات حساس بپرهیزید.</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
</div>
|
160 |
</div>
|
161 |
|
162 |
+
<div className="media-area w-full flex flex-col items-center justify-center flex-grow relative"> {/* منطقه نمایش ویدیو و لوگوی بزرگ */}
|
163 |
+
<video id="video-feed" ref={videoRef} autoPlay playsInline className={cn("absolute top-0 left-0 w-full h-full object-cover scale-x-[-1]", { "hidden": !isCamActive })} />
|
164 |
+
{/* لوگوی بزرگ فقط زمانی که میکروفون فعال است و دوربین غیرفعال */}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
{isMicActive && !isCamActive && (
|
166 |
+
<div className="large-logo-container-class"> {/* استفاده از کلاس جدید */}
|
|
|
|
|
|
|
|
|
167 |
{createLogoFunction(false, true, 'human', false)}
|
168 |
</div>
|
169 |
)}
|
170 |
</div>
|
171 |
|
172 |
+
<ControlTray /* ... (props های ControlTray مثل قبل، اما با آیکون میکروفون اولیه) ... */
|
173 |
videoRef={videoRef}
|
174 |
supportsVideo={true}
|
175 |
onVideoStreamChange={(stream) => { /* ... */ }}
|
|
|
178 |
isAppCamActive={isCamActive}
|
179 |
onAppCamToggle={setIsCamActive}
|
180 |
createLogoFunction={createLogoFunction}
|
181 |
+
ReferenceMicrophoneIcon={SvgOriginalMicrophoneIcon} // بازگشت به آیکون اولیه
|
182 |
/>
|
183 |
</div>
|
184 |
</div>
|
185 |
);
|
186 |
+
};
|
187 |
|
188 |
+
// ... (logoColorConfig بدون تغییر) ...
|
189 |
const logoColorConfig = {
|
190 |
+
blue: { ping: "bg-blue-200 dark:bg-blue-700", outer: "bg-blue-200 dark:bg-blue-700", mid: "bg-blue-300 dark:bg-blue-600", inner: "bg-blue-400 dark:bg-blue-500", },
|
191 |
+
green: { ping: "bg-green-200 dark:bg-green-700", outer: "bg-green-200 dark:bg-green-700", mid: "bg-green-300 dark:bg-green-600", inner: "bg-green-400 dark:bg-green-500", },
|
192 |
+
gray: { ping: "bg-gray-200 dark:bg-gray-700", outer: "bg-gray-200 dark:bg-gray-700", mid: "bg-gray-300 dark:bg-gray-600", inner: "bg-gray-400 dark:bg-gray-500", }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
193 |
};
|
194 |
|
195 |
+
|
196 |
function App() {
|
197 |
// ... (state ها و useEffect های دیگر بدون تغییر) ...
|
198 |
const videoRef = useRef<HTMLVideoElement>(null);
|
199 |
const [showIOSModal, setShowIOSModal] = useState(false);
|
200 |
const [isAllowedOrigin, setIsAllowedOrigin] = useState<boolean | null>(null);
|
|
|
201 |
const [isMicActive, setIsMicActive] = useState(false);
|
202 |
const [isCamActive, setIsCamActive] = useState(false);
|
203 |
const [isNotificationOpen, setIsNotificationOpen] = useState(false);
|
|
|
204 |
const notificationPopoverRef = useRef<HTMLDivElement>(null);
|
205 |
const notificationButtonRef = useRef<HTMLButtonElement>(null);
|
206 |
|
207 |
+
useEffect(() => { /* ... */ if (isIOS()) { setShowIOSModal(true); } const timer = setTimeout(() => { setIsAllowedOrigin(true); }, 100); return () => clearTimeout(timer); }, []);
|
208 |
+
useEffect(() => { /* ... */ const handleClickOutside = (event: MouseEvent) => { if (isNotificationOpen && notificationPopoverRef.current && !notificationPopoverRef.current.contains(event.target as Node) && notificationButtonRef.current && !notificationButtonRef.current.contains(event.target as Node)) { setIsNotificationOpen(false); } }; document.addEventListener("mousedown", handleClickOutside); return () => { document.removeEventListener("mousedown", handleClickOutside); }; }, [isNotificationOpen]);
|
209 |
+
if (isAllowedOrigin === null) { return <div style={{ padding: '20px', textAlign: 'center' }}>در حال بررسی دسترسی...</div>; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
|
211 |
+
// *** تابع createLogoFunction با دقت برای انیمیشن کامل ***
|
212 |
const createLogoFunction = (isMini: boolean, isActive: boolean, type: 'human' | 'ai' = 'human', forFooter: boolean = false) => {
|
213 |
if (!isActive) return null;
|
214 |
|
215 |
+
const colorKey = type === 'human' ? 'blue' : 'gray';
|
216 |
const currentColors = logoColorConfig[colorKey as keyof typeof logoColorConfig];
|
217 |
|
218 |
+
const size = isMini ? 80 : 200;
|
219 |
+
const iconDisplaySize = isMini ? 35 : 70;
|
220 |
+
const iconInset = (size - iconDisplaySize) / 2;
|
|
|
221 |
|
222 |
+
// مقادیر دقیق inset برای حلقهها از HTML مرجع شما
|
223 |
const baseInsets = isMini
|
224 |
+
? { ping: 10, outer: 0, mid: 5, inner: 12 }
|
225 |
+
: { ping: 40, outer: 0, mid: 20, inner: 50 };
|
226 |
|
227 |
const IconComponent = type === 'human' ? SvgHumanIcon : null;
|
228 |
|
229 |
return (
|
|
|
230 |
<div className={cn("logo-animation-wrapper", {"for-footer": forFooter})} style={{ width: `${size}px`, height: `${size}px` }}>
|
231 |
+
{/* حلقههای انیمیشن با کلاسها و استایلهای صحیح */}
|
232 |
<div className={`absolute rounded-full opacity-50 animate-ping ${currentColors.ping}`} style={{ inset: `${baseInsets.ping}px` }}></div>
|
|
|
233 |
<div className={`absolute rounded-full opacity-50 ${currentColors.outer}`} style={{ inset: `${baseInsets.outer}px` }}></div>
|
|
|
234 |
<div className={`absolute rounded-full opacity-50 ${currentColors.mid}`} style={{ inset: `${baseInsets.mid}px` }}></div>
|
|
|
235 |
<div className={`absolute rounded-full opacity-50 ${currentColors.inner}`} style={{ inset: `${baseInsets.inner}px` }}></div>
|
|
|
236 |
<div className="z-10 absolute flex items-center justify-center" style={{ inset: `${iconInset}px`, width: `${iconDisplaySize}px`, height: `${iconDisplaySize}px` }}>
|
237 |
{IconComponent && <IconComponent />}
|
238 |
</div>
|
|
|
243 |
return (
|
244 |
<LiveAPIProvider initialConfig={initialAppConfig}>
|
245 |
<AppInternalLogic
|
246 |
+
isMicActive={isMicActive} setIsMicActive={setIsMicActive}
|
247 |
+
isCamActive={isCamActive} setIsCamActive={setIsCamActive}
|
|
|
|
|
248 |
createLogoFunction={createLogoFunction}
|
249 |
videoRef={videoRef}
|
250 |
+
notificationPopoverRef={notificationPopoverRef} notificationButtonRef={notificationButtonRef}
|
251 |
+
isNotificationOpen={isNotificationOpen} setIsNotificationOpen={setIsNotificationOpen}
|
|
|
|
|
252 |
/>
|
253 |
<IOSModal isOpen={showIOSModal} onClose={() => setShowIOSModal(false)} />
|
254 |
</LiveAPIProvider>
|