Ezmary commited on
Commit
d17837b
·
verified ·
1 Parent(s): a77f50e

Update src/App.tsx

Browse files
Files changed (1) hide show
  1. src/App.tsx +12 -17
src/App.tsx CHANGED
@@ -19,8 +19,8 @@ import { IOSModal } from "./components/ios-modal/IOSModal";
19
  import { isIOS } from "./lib/platform";
20
  import cn from "classnames";
21
  import { LiveConfig } from "./multimodal-live-types";
22
- import { Altair } from "./components/altair/Altair"; // اگر می‌خواهید نمایش چت را داشته باشید
23
- import SidePanel from "./components/side-panel/SidePanel"; // اگر می‌خواهید پنل کناری را داشته باشید
24
 
25
 
26
  // --- دستورالعمل شخصی‌سازی شما (با بخش تعامل تصویری) ---
@@ -103,13 +103,12 @@ const myCustomInstruction = `
103
  // --- ---
104
 
105
  const initialAppConfig: LiveConfig = {
106
- model: "models/gemini-2.0-flash-exp", // یا هر مدلی که استفاده می‌کنید
107
  systemInstruction: {
108
  parts: [{ text: myCustomInstruction }],
109
  },
110
  };
111
 
112
- // SVG Icons (می‌توانید این‌ها را به فایل‌های جداگانه منتقل کنید و ایمپورت کنید اگر تمایل دارید)
113
  const SvgHumanIcon = () => (
114
  <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="#FCFCFC" 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="#FCFCFC" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/></svg>
115
  );
@@ -117,13 +116,11 @@ const SvgHumanIcon = () => (
117
 
118
  function App() {
119
  const videoRef = useRef<HTMLVideoElement>(null);
120
- // videoStream دیگر مستقیماً توسط App مدیریت نمی‌شود، بلکه توسط ControlTray از طریق onVideoStreamChange
121
- // const [videoStream, setVideoStream] = useState<MediaStream | null>(null);
122
  const [showIOSModal, setShowIOSModal] = useState(false);
123
  const [isAllowedOrigin, setIsAllowedOrigin] = useState<boolean | null>(null);
124
 
125
  const [isMicActive, setIsMicActive] = useState(false);
126
- const [isCamActive, setIsCamActive] = useState(false);
127
  const [isNotificationOpen, setIsNotificationOpen] = useState(false);
128
 
129
  const notificationPopoverRef = useRef<HTMLDivElement>(null);
@@ -190,8 +187,8 @@ function App() {
190
 
191
  return (
192
  <LiveAPIProvider initialConfig={initialAppConfig}>
193
- <div className="w-full flex flex-col items-center justify-center min-h-screen bg-background text-foreground antialiased"> {/* min-h-screen for full height */}
194
- <div className="max-w-3xl w-full flex flex-col items-center justify-center h-full relative"> {/* h-full */}
195
  {/* Header */}
196
  <div className="header-controls">
197
  <button
@@ -200,7 +197,7 @@ function App() {
200
  aria-label="Notifications"
201
  className="header-button"
202
  onClick={(e) => {
203
- e.stopPropagation(); // برای جلوگیری از بسته شدن بلافاصله توسط کلیک بیرون
204
  setIsNotificationOpen(!isNotificationOpen);
205
  }}
206
  >
@@ -227,22 +224,20 @@ function App() {
227
  </div>
228
 
229
  {/* Main Media Area and Chat Area */}
230
- <div className="flex flex-col md:flex-row w-full h-[calc(100vh-100px)] mt-[60px] mb-[40px]"> {/* Adjust height and margins as needed */}
231
- {/* SidePanel - اگر می‌خواهید پنل کناری چت را داشته باشید */}
232
  <div className="w-full md:w-1/3 p-2 overflow-y-auto">
233
  <SidePanel />
234
  <Altair />
235
  </div>
236
 
237
- {/* Video Area */}
238
- <div className="w-full md:w-2/3 flex flex-col items-center justify-center bg-background relative"> {/* Removed h-[90dvh] to fit within flex layout */}
239
  <video
240
  id="video-feed"
241
  ref={videoRef}
242
  autoPlay
243
  playsInline
244
  className={cn("absolute top-0 left-0 w-full h-full object-cover scale-x-[-1]", {
245
- "hidden": !isCamActive,
246
  })}
247
  />
248
  <div id="large-logo-container" className={cn("items-center justify-center w-full h-full absolute top-0 left-0", {
@@ -260,8 +255,8 @@ function App() {
260
  onVideoStreamChange={(stream) => { /* App.tsx no longer needs direct videoStream state */ }}
261
  isAppMicActive={isMicActive}
262
  onAppMicToggle={setIsMicActive}
263
- isAppCamActive={isAppCamActive}
264
- onAppCamToggle={setIsCamActive}
265
  createLogoFunction={createLogoHTML}
266
  />
267
 
 
19
  import { isIOS } from "./lib/platform";
20
  import cn from "classnames";
21
  import { LiveConfig } from "./multimodal-live-types";
22
+ import { Altair } from "./components/altair/Altair";
23
+ import SidePanel from "./components/side-panel/SidePanel";
24
 
25
 
26
  // --- دستورالعمل شخصی‌سازی شما (با بخش تعامل تصویری) ---
 
103
  // --- ---
104
 
105
  const initialAppConfig: LiveConfig = {
106
+ model: "models/gemini-2.0-flash-exp",
107
  systemInstruction: {
108
  parts: [{ text: myCustomInstruction }],
109
  },
110
  };
111
 
 
112
  const SvgHumanIcon = () => (
113
  <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="#FCFCFC" 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="#FCFCFC" strokeWidth="6.42146" strokeLinecap="round" strokeLinejoin="round"/></svg>
114
  );
 
116
 
117
  function App() {
118
  const videoRef = useRef<HTMLVideoElement>(null);
 
 
119
  const [showIOSModal, setShowIOSModal] = useState(false);
120
  const [isAllowedOrigin, setIsAllowedOrigin] = useState<boolean | null>(null);
121
 
122
  const [isMicActive, setIsMicActive] = useState(false);
123
+ const [isCamActive, setIsCamActive] = useState(false); // State برای کنترل دوربین از App
124
  const [isNotificationOpen, setIsNotificationOpen] = useState(false);
125
 
126
  const notificationPopoverRef = useRef<HTMLDivElement>(null);
 
187
 
188
  return (
189
  <LiveAPIProvider initialConfig={initialAppConfig}>
190
+ <div className="w-full flex flex-col items-center justify-center min-h-screen bg-background text-foreground antialiased">
191
+ <div className="max-w-3xl w-full flex flex-col items-center justify-center h-full relative">
192
  {/* Header */}
193
  <div className="header-controls">
194
  <button
 
197
  aria-label="Notifications"
198
  className="header-button"
199
  onClick={(e) => {
200
+ e.stopPropagation();
201
  setIsNotificationOpen(!isNotificationOpen);
202
  }}
203
  >
 
224
  </div>
225
 
226
  {/* Main Media Area and Chat Area */}
227
+ <div className="flex flex-col md:flex-row w-full h-[calc(100vh-100px)] mt-[60px] mb-[40px]">
 
228
  <div className="w-full md:w-1/3 p-2 overflow-y-auto">
229
  <SidePanel />
230
  <Altair />
231
  </div>
232
 
233
+ <div className="w-full md:w-2/3 flex flex-col items-center justify-center bg-background relative">
 
234
  <video
235
  id="video-feed"
236
  ref={videoRef}
237
  autoPlay
238
  playsInline
239
  className={cn("absolute top-0 left-0 w-full h-full object-cover scale-x-[-1]", {
240
+ "hidden": !isCamActive, // کنترل نمایش ویدیو با isCamActive از App.tsx
241
  })}
242
  />
243
  <div id="large-logo-container" className={cn("items-center justify-center w-full h-full absolute top-0 left-0", {
 
255
  onVideoStreamChange={(stream) => { /* App.tsx no longer needs direct videoStream state */ }}
256
  isAppMicActive={isMicActive}
257
  onAppMicToggle={setIsMicActive}
258
+ isAppCamActive={isCamActive} // <--- اصلاح شده: از isCamActive استفاده می‌شود
259
+ onAppCamToggle={setIsCamActive} // <--- کنترل isCamActive توسط App.tsx
260
  createLogoFunction={createLogoHTML}
261
  />
262