import React, { useState, useEffect, useMemo } from 'react'; import { Play, Pause, Radio, Tv, Newspaper, Settings, Home, Search, Mic, Volume2, Info, ChevronRight, Share2, Heart, BarChart3, Clock, Globe, Zap, Sparkles, Loader2, MessageSquare } from 'lucide-react'; const apiKey = ""; // Gemini API Key const App = () => { const [activeTab, setActiveTab] = useState('home'); const [isPlaying, setIsPlaying] = useState(false); const [currentStation, setCurrentStation] = useState({ title: "The Morning Beat", frequency: "98.5 FM", host: "Sarah Jenkins", type: "radio", image: "https://images.unsplash.com/photo-1598488035139-bdbb2231ce04?auto=format&fit=crop&w=300&q=80" }); const [isDarkMode, setIsDarkMode] = useState(true); const [aiLoading, setAiLoading] = useState(false); const [aiContent, setAiContent] = useState(null); // --- Gemini API Helper --- const callGemini = async (prompt, systemInstruction = "You are a helpful media assistant.") => { setAiLoading(true); setAiContent(null); let retries = 0; const delays = [1000, 2000, 4000, 8000, 16000]; while (retries < 5) { try { const response = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-preview-09-2025:generateContent?key=${apiKey}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ contents: [{ parts: [{ text: prompt }] }], systemInstruction: { parts: [{ text: systemInstruction }] } }) }); if (!response.ok) throw new Error('API Error'); const data = await response.json(); const text = data.candidates?.[0]?.content?.parts?.[0]?.text; setAiContent(text); setAiLoading(false); return text; } catch (err) { retries++; if (retries === 5) { setAiContent("Sorry, I couldn't connect to the AI service right now. Please try again later."); setAiLoading(false); } else { await new Promise(res => setTimeout(res, delays[retries - 1])); } } } }; // --- Nigerian Content Mock Data --- const tvChannels = [ { id: 1, title: "Arise News Live", category: "News/Nigeria", viewers: "12K", youtubeId: "vDEnbC0bW9I", // Arise News Live image: "https://images.unsplash.com/photo-1495020689067-958852a7765e?auto=format&fit=crop&w=600&q=80" }, { id: 2, title: "Channels TV Live", category: "News/Nigeria", viewers: "25K", youtubeId: "uL6T70D6_oY", // Channels TV Live image: "https://images.unsplash.com/photo-1585829365234-781f8c484603?auto=format&fit=crop&w=600&q=80" }, { id: 3, title: "Nollywood Cinema", category: "Movies/Nigeria", viewers: "8K", youtubeId: "K9I_R09KAnA", // Placeholder for Nollywood Live content image: "https://images.unsplash.com/photo-1536440136628-849c177e76a1?auto=format&fit=crop&w=600&q=80" }, { id: 4, title: "TVC News Live", category: "News/Nigeria", viewers: "15K", youtubeId: "gL785X_E34M", // TVC News Live image: "https://images.unsplash.com/photo-1504711434969-e33886168f5c?auto=format&fit=crop&w=600&q=80" } ]; const radioStations = [ { id: 1, title: "Cool FM Lagos", frequency: "96.9", host: "Do2dtun", image: "https://images.unsplash.com/photo-1511671782779-c97d3d27a1d4?auto=format&fit=crop&w=300&q=80" }, { id: 2, title: "Beat FM", frequency: "99.9", host: "Osi Suave", image: "https://images.unsplash.com/photo-1493225255756-d9584f8606e9?auto=format&fit=crop&w=300&q=80" }, { id: 3, title: "Wazobia FM", frequency: "95.1", host: "Yaw", image: "https://images.unsplash.com/photo-1459749411177-042180ce673c?auto=format&fit=crop&w=300&q=80" }, ]; // --- UI Components --- const Waveform = ({ playing }) => (
{[...Array(24)].map((_, i) => (
))}
); const Header = () => (

Media Hub

); const HomeView = () => (
{/* Featured Live Video Player (Arise News Default) */}
Live Nigeria

{tvChannels[0].title}

{tvChannels[0].category}

{/* Mini Radio Player */}
{aiLoading && (
)}
Cover
On Air

{currentStation.title}

{currentStation.frequency} FM • {currentStation.host}

{aiContent && !aiLoading && activeTab === 'home' && (

"{aiContent}"

)}
{/* Nigerian Radio Stations */}

Trending Radio

{radioStations.map(station => (
{ setCurrentStation(station); setIsPlaying(true); }} className="min-w-[140px] group cursor-pointer" >
{station.title}

{station.title}

{station.frequency} FM

))}
); const TvView = () => (

Nigerian TV

Live streams from Lagos & Abuja

{aiContent && activeTab === 'tv' && ( )}
{aiLoading && (

Analyzing current broadcast trends...

)} {aiContent && activeTab === 'tv' && !aiLoading && (

✨ AI Perspective

"{aiContent}"

)}
{tvChannels.map(channel => (

{channel.title}

Live {channel.viewers} watching
))}
); const SettingsView = () => (

Account & Settings

JD

John Doe

Premium Member • Nigeria

{[ { icon: , label: "Region", value: "Nigeria" }, { icon: , label: "Sleep Timer", value: "Off" }, { icon: , label: "Data Saver", value: "High Quality" }, { icon: , label: "About Hub", value: "" }, ].map((item, i) => ( ))}
); return (
{activeTab === 'home' && } {activeTab === 'tv' && } {activeTab === 'radio' && (

Radio Explorer

{radioStations.map((s, i) => (
{ setCurrentStation(s); setIsPlaying(true); }}>

{s.title}

{s.frequency} FM

))}
)} {activeTab === 'news' && (

Latest News

{aiContent && ( )}
{aiContent && !aiLoading && activeTab === 'news' && (
Deep Dive

{aiContent}

)} {[ { title: "CBN Updates Policy on Foreign Exchange Liquidity", category: "Economics", time: "2 hours ago" }, { title: "Lagos Startup Ecosystem Attracts Record Investment", category: "Technology", time: "5 hours ago" }, { title: "Super Eagles Prepare for Upcoming AFCON Qualifiers", category: "Sports", time: "8 hours ago" } ].map((news, i) => (
{news.category}

{news.title}

{news.time} • 4 min read

))}
)} {activeTab === 'settings' && }
{/* Floating Action */}
{/* Tab Bar */}
); }; const TabItem = ({ id, active, icon, label, onClick }) => { const isActive = active === id; return ( ); }; export default App;