Ezmary commited on
Commit
7daa6bf
·
verified ·
1 Parent(s): cb5e6c3

Update src/App.tsx

Browse files
Files changed (1) hide show
  1. src/App.tsx +20 -17
src/App.tsx CHANGED
@@ -1,3 +1,5 @@
 
 
1
  /**
2
  Copyright 2024 Google LLC
3
  Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +21,7 @@ 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 LogoAnimation from "./components/logo-animation/LogoAnimation"; // ایمپورت کامپوننت لوگو
23
 
24
  const myCustomInstruction = `
25
  ت1. هویت دستیار:
@@ -105,8 +107,6 @@ const initialAppConfig: LiveConfig = {
105
  },
106
  };
107
 
108
- // SVG آیکون میکروفون از HTML مرجع شما (با سه خط افقی)
109
- // این آیکون به ControlTray پاس داده می‌شود
110
  const SvgReferenceMicrophoneIcon = () => (
111
  <svg className="reference-mic-svg" viewBox="0 0 69 68" fill="none" xmlns="http://www.w3.org/2000/svg">
112
  <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"/>
@@ -146,7 +146,20 @@ const AppInternalLogic: React.FC<{
146
  return (
147
  <div className="w-full flex flex-col items-center justify-center min-h-screen text-foreground antialiased">
148
  <div className="main-wrapper max-w-3xl w-full flex flex-col items-center justify-center h-full relative">
 
149
  <div className="header-controls">
 
 
 
 
 
 
 
 
 
 
 
 
150
  <div id="notification-trigger-container">
151
  <button
152
  ref={notificationButtonRef}
@@ -161,16 +174,6 @@ const AppInternalLogic: React.FC<{
161
  <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>
162
  </button>
163
  </div>
164
- <div className="back-button-container">
165
- <button
166
- id="back-button"
167
- aria-label="Go back"
168
- className="header-button"
169
- onClick={() => alert('Back clicked (implement navigation)')}
170
- >
171
- <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>
172
- </button>
173
- </div>
174
  </div>
175
 
176
  <div ref={notificationPopoverRef} id="notification-popover-wrapper" className="notification-popover-wrapper">
@@ -217,7 +220,6 @@ const AppInternalLogic: React.FC<{
217
  isAppCamActive={isCamActive}
218
  onAppCamToggle={setIsCamActive}
219
  ReferenceMicrophoneIcon={SvgReferenceMicrophoneIcon}
220
- // LogoAnimation کامپوننت مستقیما در ControlTray ایمپورت و استفاده می شود
221
  />
222
  </div>
223
  </div>
@@ -234,7 +236,7 @@ function App() {
234
  const [isNotificationOpen, setIsNotificationOpen] = useState(false);
235
 
236
  const notificationPopoverRef = useRef<HTMLDivElement>(null);
237
- const notificationButtonRef = useRef<HTMLButtonElement>(null);
238
 
239
  useEffect(() => {
240
  if (isIOS()) {
@@ -248,11 +250,12 @@ function App() {
248
 
249
  useEffect(() => {
250
  const handleClickOutside = (event: MouseEvent) => {
 
251
  if (
252
  isNotificationOpen &&
253
  notificationPopoverRef.current &&
254
  !notificationPopoverRef.current.contains(event.target as Node) &&
255
- notificationButtonRef.current &&
256
  !notificationButtonRef.current.contains(event.target as Node)
257
  ) {
258
  setIsNotificationOpen(false);
@@ -277,7 +280,7 @@ function App() {
277
  setIsCamActive={setIsCamActive}
278
  videoRef={videoRef}
279
  notificationPopoverRef={notificationPopoverRef}
280
- notificationButtonRef={notificationButtonRef}
281
  isNotificationOpen={isNotificationOpen}
282
  setIsNotificationOpen={setIsNotificationOpen}
283
  />
 
1
+ // src/App.tsx
2
+
3
  /**
4
  Copyright 2024 Google LLC
5
  Licensed under the Apache License, Version 2.0 (the "License");
 
21
  import { isIOS } from "./lib/platform";
22
  import cn from "classnames";
23
  import { LiveConfig } from "./multimodal-live-types";
24
+ import LogoAnimation from "./components/logo-animation/LogoAnimation";
25
 
26
  const myCustomInstruction = `
27
  ت1. هویت دستیار:
 
107
  },
108
  };
109
 
 
 
110
  const SvgReferenceMicrophoneIcon = () => (
111
  <svg className="reference-mic-svg" viewBox="0 0 69 68" fill="none" xmlns="http://www.w3.org/2000/svg">
112
  <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"/>
 
146
  return (
147
  <div className="w-full flex flex-col items-center justify-center min-h-screen text-foreground antialiased">
148
  <div className="main-wrapper max-w-3xl w-full flex flex-col items-center justify-center h-full relative">
149
+ {/* *** MODIFIED: ترتیب دکمه‌های هدر عوض شد *** */}
150
  <div className="header-controls">
151
+ {/* دکمه بازگشت (حالا سمت چپ) */}
152
+ <div className="back-button-container">
153
+ <button
154
+ id="back-button"
155
+ aria-label="Go back"
156
+ className="header-button"
157
+ onClick={() => alert('Back clicked (implement navigation)')}
158
+ >
159
+ <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>
160
+ </button>
161
+ </div>
162
+ {/* دکمه نوتیفیکیشن (حالا سمت راست) */}
163
  <div id="notification-trigger-container">
164
  <button
165
  ref={notificationButtonRef}
 
174
  <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>
175
  </button>
176
  </div>
 
 
 
 
 
 
 
 
 
 
177
  </div>
178
 
179
  <div ref={notificationPopoverRef} id="notification-popover-wrapper" className="notification-popover-wrapper">
 
220
  isAppCamActive={isCamActive}
221
  onAppCamToggle={setIsCamActive}
222
  ReferenceMicrophoneIcon={SvgReferenceMicrophoneIcon}
 
223
  />
224
  </div>
225
  </div>
 
236
  const [isNotificationOpen, setIsNotificationOpen] = useState(false);
237
 
238
  const notificationPopoverRef = useRef<HTMLDivElement>(null);
239
+ const notificationButtonRef = useRef<HTMLButtonElement>(null); // این ref هنوز برای دکمه نوتیفیکیشن استفاده می‌شود
240
 
241
  useEffect(() => {
242
  if (isIOS()) {
 
250
 
251
  useEffect(() => {
252
  const handleClickOutside = (event: MouseEvent) => {
253
+ // منطق بستن پاپ‌اور نوتیفیکیشن با کلیک بیرون، همچنان باید روی notificationButtonRef کار کند
254
  if (
255
  isNotificationOpen &&
256
  notificationPopoverRef.current &&
257
  !notificationPopoverRef.current.contains(event.target as Node) &&
258
+ notificationButtonRef.current && // اطمینان از اینکه ref دکمه نوتیفیکیشن هنوز معتبر است
259
  !notificationButtonRef.current.contains(event.target as Node)
260
  ) {
261
  setIsNotificationOpen(false);
 
280
  setIsCamActive={setIsCamActive}
281
  videoRef={videoRef}
282
  notificationPopoverRef={notificationPopoverRef}
283
+ notificationButtonRef={notificationButtonRef} // پاس دادن ref دکمه نوتیفیکیشن
284
  isNotificationOpen={isNotificationOpen}
285
  setIsNotificationOpen={setIsNotificationOpen}
286
  />