import React, { useState, useEffect } from 'react';
import {
View,
Text,
StyleSheet,
ScrollView,
} from 'react-native';
import { Colors } from '../../constants/Colors';
import Header from '../../components/navigation/Header';
import LoadingSpinner from '../../components/common/LoadingSpinner';
import { logger } from '../../utils/logger';
import { analyticsService } from '../../services/analyticsService';
export default function AnalyticsOverviewScreen() {
const [stats, setStats] = useState({
followers: 0,
following: 0,
posts: 0,
reels: 0,
totalLikes: 0,
totalComments: 0,
profileViews: 0,
reach: 0,
});
const [loading, setLoading] = useState(true);
useEffect(() => {
loadAnalytics();
}, []);
const loadAnalytics = async () => {
try {
setLoading(true);
const response = await analyticsService.getOverview();
const analytics = response.analytics || response;
setStats({
followers: analytics.followers || 0,
following: analytics.following || 0,
posts: analytics.posts || 0,
reels: analytics.reels || 0,
totalLikes: analytics.totalLikes || 0,
totalComments: analytics.totalComments || 0,
profileViews: analytics.profileViews || 0,
reach: analytics.reach || 0,
});
} catch (error) {
logger.error('Load analytics error:', error);
} finally {
setLoading(false);
}
};
if (loading) {
return (
);
}
return (
Account Stats
{stats.followers.toLocaleString()}
Followers
{stats.following.toLocaleString()}
Following
{stats.posts.toLocaleString()}
Posts
{stats.reels.toLocaleString()}
Reels
Engagement
{stats.totalLikes.toLocaleString()}
Total Likes
{stats.totalComments.toLocaleString()}
Total Comments
Reach
{stats.profileViews.toLocaleString()}
Profile Views
{stats.reach.toLocaleString()}
Reach
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Colors.background,
},
content: {
flex: 1,
padding: 16,
},
section: {
marginBottom: 32,
},
sectionTitle: {
fontSize: 18,
fontWeight: '600',
color: Colors.text,
marginBottom: 16,
},
statsGrid: {
flexDirection: 'row',
flexWrap: 'wrap',
gap: 12,
},
statCard: {
flex: 1,
minWidth: '45%',
backgroundColor: Colors.surface,
borderRadius: 12,
padding: 16,
alignItems: 'center',
},
statValue: {
fontSize: 24,
fontWeight: 'bold',
color: Colors.accent,
marginBottom: 8,
},
statLabel: {
fontSize: 14,
color: Colors.textSecondary,
textAlign: 'center',
},
});