Spaces:
Running
Running
Update src/App.tsx
Browse files- src/App.tsx +34 -49
src/App.tsx
CHANGED
@@ -104,7 +104,6 @@ const initialAppConfig: LiveConfig = {
|
|
104 |
},
|
105 |
};
|
106 |
|
107 |
-
// آیکون انسان (برای لوگوی بزرگ و کوچک) - با width و height 100% برای انعطاف پذیری
|
108 |
const SvgHumanIcon = () => (
|
109 |
<svg width="100%" height="100%" viewBox="0 0 88 89" fill="none" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet">
|
110 |
<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"/>
|
@@ -112,38 +111,16 @@ const SvgHumanIcon = () => (
|
|
112 |
</svg>
|
113 |
);
|
114 |
|
115 |
-
// SVG آیکون میکروفون از HTML مرجع شما (با سه خط افقی)
|
116 |
const SvgReferenceMicrophoneIcon = () => (
|
117 |
-
|
|
|
118 |
<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"/>
|
119 |
<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"/>
|
120 |
</svg>
|
121 |
);
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
isMicActive: boolean;
|
126 |
-
isCamActive: boolean;
|
127 |
-
setIsMicActive: React.Dispatch<React.SetStateAction<boolean>>;
|
128 |
-
setIsCamActive: React.Dispatch<React.SetStateAction<boolean>>;
|
129 |
-
createLogoFunction: (isMini: boolean, isActive: boolean, type?: 'human' | 'ai', forFooter?: boolean) => React.ReactNode;
|
130 |
-
videoRef: React.RefObject<HTMLVideoElement>;
|
131 |
-
notificationPopoverRef: React.RefObject<HTMLDivElement>;
|
132 |
-
notificationButtonRef: React.RefObject<HTMLButtonElement>;
|
133 |
-
isNotificationOpen: boolean;
|
134 |
-
setIsNotificationOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
135 |
-
}> = ({
|
136 |
-
isMicActive,
|
137 |
-
isCamActive,
|
138 |
-
setIsMicActive,
|
139 |
-
setIsCamActive,
|
140 |
-
createLogoFunction,
|
141 |
-
videoRef,
|
142 |
-
notificationPopoverRef,
|
143 |
-
notificationButtonRef,
|
144 |
-
isNotificationOpen,
|
145 |
-
setIsNotificationOpen
|
146 |
-
}) => {
|
147 |
const { connected, disconnect } = useLiveAPIContext();
|
148 |
|
149 |
useEffect(() => {
|
@@ -153,8 +130,9 @@ const AppInternalLogic: React.FC<{
|
|
153 |
}, [isMicActive, isCamActive, connected, disconnect]);
|
154 |
|
155 |
return (
|
156 |
-
<div className="w-full flex flex-col items-center justify-center
|
157 |
<div className="main-wrapper max-w-3xl w-full flex flex-col items-center justify-center h-full relative">
|
|
|
158 |
<div className="header-controls">
|
159 |
<div id="notification-trigger-container">
|
160 |
<button
|
@@ -195,7 +173,6 @@ const AppInternalLogic: React.FC<{
|
|
195 |
</div>
|
196 |
</div>
|
197 |
</div>
|
198 |
-
|
199 |
<div className="media-area w-full flex flex-col items-center justify-center flex-grow relative">
|
200 |
<video
|
201 |
id="video-feed"
|
@@ -207,11 +184,10 @@ const AppInternalLogic: React.FC<{
|
|
207 |
{ "hidden": !isCamActive }
|
208 |
)}
|
209 |
/>
|
210 |
-
{/* نمایش لوگوی بزرگ فقط زمانی که میکروفون فعال است و دوربین غیرفعال */}
|
211 |
{isMicActive && !isCamActive && (
|
212 |
<div
|
213 |
-
id="large-logo-container"
|
214 |
-
className="absolute top-0 left-0 w-full h-full flex items-center justify-center pointer-events-none"
|
215 |
>
|
216 |
{createLogoFunction(false, true, 'human', false)}
|
217 |
</div>
|
@@ -232,23 +208,36 @@ const AppInternalLogic: React.FC<{
|
|
232 |
</div>
|
233 |
</div>
|
234 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
}
|
236 |
|
237 |
-
|
238 |
-
const logoColorConfig = {
|
239 |
-
blue: {
|
240 |
ping: "bg-blue-200 dark:bg-blue-700",
|
241 |
outer: "bg-blue-200 dark:bg-blue-700",
|
242 |
mid: "bg-blue-300 dark:bg-blue-600",
|
243 |
inner: "bg-blue-400 dark:bg-blue-500",
|
244 |
},
|
245 |
-
green: {
|
246 |
ping: "bg-green-200 dark:bg-green-700",
|
247 |
outer: "bg-green-200 dark:bg-green-700",
|
248 |
mid: "bg-green-300 dark:bg-green-600",
|
249 |
inner: "bg-green-400 dark:bg-green-500",
|
250 |
},
|
251 |
-
gray: {
|
252 |
ping: "bg-gray-200 dark:bg-gray-700",
|
253 |
outer: "bg-gray-200 dark:bg-gray-700",
|
254 |
mid: "bg-gray-300 dark:bg-gray-600",
|
@@ -256,7 +245,7 @@ const logoColorConfig = {
|
|
256 |
}
|
257 |
};
|
258 |
|
259 |
-
function App() {
|
260 |
const videoRef = useRef<HTMLVideoElement>(null);
|
261 |
const [showIOSModal, setShowIOSModal] = useState(false);
|
262 |
const [isAllowedOrigin, setIsAllowedOrigin] = useState<boolean | null>(null);
|
@@ -306,30 +295,26 @@ function App() {
|
|
306 |
const colorKey = type === 'human' ? 'blue' : (type === 'ai' ? 'green' : 'gray');
|
307 |
const currentColors = logoColorConfig[colorKey as keyof typeof logoColorConfig] || logoColorConfig.gray;
|
308 |
|
309 |
-
const size = isMini ? 80 : 200;
|
310 |
-
const iconDisplaySize = isMini ? 35 : 70;
|
311 |
-
|
312 |
-
// محاسبه دقیق inset برای وسط قرار گرفتن آیکون
|
313 |
const iconInset = (size - iconDisplaySize) / 2;
|
314 |
|
315 |
const insetBase = {
|
316 |
-
ping: isMini ? 10 : 40,
|
317 |
-
outer: 0,
|
318 |
mid: isMini ? 5 : 20,
|
319 |
inner: isMini ? 12 : 50,
|
320 |
-
icon: iconInset
|
321 |
};
|
322 |
|
323 |
-
const IconComponent = type === 'human' ? SvgHumanIcon : null;
|
324 |
|
325 |
return (
|
326 |
<div className={cn("logo-animation-wrapper", {"for-footer": forFooter})} style={{ width: `${size}px`, height: `${size}px` }}>
|
327 |
-
{/* حلقههای انیمیشن */}
|
328 |
<div className={`absolute rounded-full opacity-50 animate-ping ${currentColors.ping}`} style={{ inset: `${insetBase.ping}px` }}></div>
|
329 |
-
<div className={`absolute rounded-full opacity-50 ${currentColors.outer}`} style={{ inset: `${insetBase.outer}px` }}></div>
|
330 |
<div className={`absolute rounded-full opacity-50 ${currentColors.mid}`} style={{ inset: `${insetBase.mid}px` }}></div>
|
331 |
<div className={`absolute rounded-full opacity-50 ${currentColors.inner}`} style={{ inset: `${insetBase.inner}px` }}></div>
|
332 |
-
{/* کانتینر آیکون */}
|
333 |
<div className="z-10 absolute flex items-center justify-center" style={{ inset: `${insetBase.icon}px`, width: `${iconDisplaySize}px`, height: `${iconDisplaySize}px` }}>
|
334 |
{IconComponent && <IconComponent />}
|
335 |
</div>
|
|
|
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 |
const SvgReferenceMicrophoneIcon = () => (
|
115 |
+
// transform="scale(0.55)" را موقتا حذف می کنیم تا با CSS کنترل شود یا اگر لازم بود برمیگردانیم
|
116 |
+
<svg width="69" height="68" viewBox="0 0 69 68" fill="none" xmlns="http://www.w3.org/2000/svg">
|
117 |
<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"/>
|
118 |
<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"/>
|
119 |
</svg>
|
120 |
);
|
121 |
|
122 |
+
const AppInternalLogic: React.FC<{ /* ...props... */ }> = ({ /* ...props... */ }) => {
|
123 |
+
// ... (بدون تغییر نسبت به نسخه کامل قبلی)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
const { connected, disconnect } = useLiveAPIContext();
|
125 |
|
126 |
useEffect(() => {
|
|
|
130 |
}, [isMicActive, isCamActive, connected, disconnect]);
|
131 |
|
132 |
return (
|
133 |
+
<div className="app-container w-full flex flex-col items-center justify-center text-foreground antialiased">
|
134 |
<div className="main-wrapper max-w-3xl w-full flex flex-col items-center justify-center h-full relative">
|
135 |
+
{/* Header and Notification Popover (بدون تغییر) */}
|
136 |
<div className="header-controls">
|
137 |
<div id="notification-trigger-container">
|
138 |
<button
|
|
|
173 |
</div>
|
174 |
</div>
|
175 |
</div>
|
|
|
176 |
<div className="media-area w-full flex flex-col items-center justify-center flex-grow relative">
|
177 |
<video
|
178 |
id="video-feed"
|
|
|
184 |
{ "hidden": !isCamActive }
|
185 |
)}
|
186 |
/>
|
|
|
187 |
{isMicActive && !isCamActive && (
|
188 |
<div
|
189 |
+
id="large-logo-container"
|
190 |
+
className="absolute top-0 left-0 w-full h-full flex items-center justify-center pointer-events-none"
|
191 |
>
|
192 |
{createLogoFunction(false, true, 'human', false)}
|
193 |
</div>
|
|
|
208 |
</div>
|
209 |
</div>
|
210 |
);
|
211 |
+
};
|
212 |
+
// ... (Props for AppInternalLogic)
|
213 |
+
interface AppInternalLogicProps {
|
214 |
+
isMicActive: boolean;
|
215 |
+
isCamActive: boolean;
|
216 |
+
setIsMicActive: React.Dispatch<React.SetStateAction<boolean>>;
|
217 |
+
setIsCamActive: React.Dispatch<React.SetStateAction<boolean>>;
|
218 |
+
createLogoFunction: (isMini: boolean, isActive: boolean, type?: 'human' | 'ai', forFooter?: boolean) => React.ReactNode;
|
219 |
+
videoRef: React.RefObject<HTMLVideoElement>;
|
220 |
+
notificationPopoverRef: React.RefObject<HTMLDivElement>;
|
221 |
+
notificationButtonRef: React.RefObject<HTMLButtonElement>;
|
222 |
+
isNotificationOpen: boolean;
|
223 |
+
setIsNotificationOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
224 |
}
|
225 |
|
226 |
+
|
227 |
+
const logoColorConfig = { /* ... (بدون تغییر) ... */
|
228 |
+
blue: {
|
229 |
ping: "bg-blue-200 dark:bg-blue-700",
|
230 |
outer: "bg-blue-200 dark:bg-blue-700",
|
231 |
mid: "bg-blue-300 dark:bg-blue-600",
|
232 |
inner: "bg-blue-400 dark:bg-blue-500",
|
233 |
},
|
234 |
+
green: {
|
235 |
ping: "bg-green-200 dark:bg-green-700",
|
236 |
outer: "bg-green-200 dark:bg-green-700",
|
237 |
mid: "bg-green-300 dark:bg-green-600",
|
238 |
inner: "bg-green-400 dark:bg-green-500",
|
239 |
},
|
240 |
+
gray: {
|
241 |
ping: "bg-gray-200 dark:bg-gray-700",
|
242 |
outer: "bg-gray-200 dark:bg-gray-700",
|
243 |
mid: "bg-gray-300 dark:bg-gray-600",
|
|
|
245 |
}
|
246 |
};
|
247 |
|
248 |
+
function App() { // ... (بدون تغییر نسبت به نسخه کامل قبلی)
|
249 |
const videoRef = useRef<HTMLVideoElement>(null);
|
250 |
const [showIOSModal, setShowIOSModal] = useState(false);
|
251 |
const [isAllowedOrigin, setIsAllowedOrigin] = useState<boolean | null>(null);
|
|
|
295 |
const colorKey = type === 'human' ? 'blue' : (type === 'ai' ? 'green' : 'gray');
|
296 |
const currentColors = logoColorConfig[colorKey as keyof typeof logoColorConfig] || logoColorConfig.gray;
|
297 |
|
298 |
+
const size = isMini ? 80 : 200;
|
299 |
+
const iconDisplaySize = isMini ? 35 : 70;
|
|
|
|
|
300 |
const iconInset = (size - iconDisplaySize) / 2;
|
301 |
|
302 |
const insetBase = {
|
303 |
+
ping: isMini ? 10 : 40,
|
304 |
+
outer: 0,
|
305 |
mid: isMini ? 5 : 20,
|
306 |
inner: isMini ? 12 : 50,
|
307 |
+
icon: iconInset
|
308 |
};
|
309 |
|
310 |
+
const IconComponent = type === 'human' ? SvgHumanIcon : null;
|
311 |
|
312 |
return (
|
313 |
<div className={cn("logo-animation-wrapper", {"for-footer": forFooter})} style={{ width: `${size}px`, height: `${size}px` }}>
|
|
|
314 |
<div className={`absolute rounded-full opacity-50 animate-ping ${currentColors.ping}`} style={{ inset: `${insetBase.ping}px` }}></div>
|
315 |
+
<div className={`absolute rounded-full opacity-50 ${currentColors.outer}`} style={{ inset: `${insetBase.outer}px` }}></div>
|
316 |
<div className={`absolute rounded-full opacity-50 ${currentColors.mid}`} style={{ inset: `${insetBase.mid}px` }}></div>
|
317 |
<div className={`absolute rounded-full opacity-50 ${currentColors.inner}`} style={{ inset: `${insetBase.inner}px` }}></div>
|
|
|
318 |
<div className="z-10 absolute flex items-center justify-center" style={{ inset: `${insetBase.icon}px`, width: `${iconDisplaySize}px`, height: `${iconDisplaySize}px` }}>
|
319 |
{IconComponent && <IconComponent />}
|
320 |
</div>
|