-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
70 lines (61 loc) · 2.59 KB
/
App.tsx
File metadata and controls
70 lines (61 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React, { useState, useEffect, useCallback } from 'react';
import { Header } from './components/Header';
import { ApiKeySelector } from './components/ApiKeySelector';
import { MovieGenerator } from './components/MovieGenerator';
import { ImageStudio } from './components/ImageStudio';
import { Chatbot } from './components/Chatbot';
import { LiveChat } from './components/LiveChat';
import { CreativeStudio } from './components/CreativeStudio';
type ActiveTab = 'studio' | 'movie' | 'image' | 'chat' | 'live';
const App: React.FC = () => {
const [isApiKeyReady, setIsApiKeyReady] = useState<boolean>(false);
const [activeTab, setActiveTab] = useState<ActiveTab>('studio');
const checkApiKey = useCallback(async () => {
if (window.aistudio && typeof window.aistudio.hasSelectedApiKey === 'function') {
const hasKey = await window.aistudio.hasSelectedApiKey();
setIsApiKeyReady(hasKey);
} else {
// For local development or environments without the aistudio host
setIsApiKeyReady(true);
}
}, []);
useEffect(() => {
checkApiKey();
}, [checkApiKey]);
const renderContent = () => {
if (!isApiKeyReady) {
return <ApiKeySelector onKeySelected={() => setIsApiKeyReady(true)} />;
}
switch (activeTab) {
case 'studio':
return <CreativeStudio onApiKeyError={() => setIsApiKeyReady(false)} />;
case 'movie':
return <MovieGenerator onApiKeyError={() => setIsApiKeyReady(false)} />;
case 'image':
return <ImageStudio />;
case 'chat':
return <Chatbot />;
case 'live':
return <LiveChat />;
default:
return <CreativeStudio onApiKeyError={() => setIsApiKeyReady(false)} />;
}
};
return (
<div className="min-h-screen bg-gradient-to-br from-slate-950 via-slate-900 to-slate-950 flex flex-col items-center p-4 sm:p-6 md:p-8">
{/* Background gradient effects */}
<div className="fixed inset-0 overflow-hidden pointer-events-none">
<div className="absolute -top-40 -right-40 w-80 h-80 bg-cyan-500/10 rounded-full blur-3xl"></div>
<div className="absolute -bottom-40 -left-40 w-80 h-80 bg-purple-500/10 rounded-full blur-3xl"></div>
<div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-96 h-96 bg-cyan-600/5 rounded-full blur-3xl"></div>
</div>
<div className="relative w-full max-w-6xl mx-auto">
<Header activeTab={activeTab} setActiveTab={setActiveTab} />
<main className="mt-8 animate-fade-in">
{renderContent()}
</main>
</div>
</div>
);
};
export default App;