dashboard mejorado
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
import 'package:energy_media/providers/videos_provider.dart';
|
||||
import 'package:energy_media/theme/theme.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
|
||||
// Importar los widgets modulares
|
||||
import 'package:energy_media/pages/videos/widgets/premium_dashboard_widgets/premium_dashboard_widgets.dart';
|
||||
|
||||
class PremiumDashboardPage extends StatefulWidget {
|
||||
const PremiumDashboardPage({Key? key}) : super(key: key);
|
||||
|
||||
@@ -48,9 +50,9 @@ class _PremiumDashboardPageState extends State<PremiumDashboardPage>
|
||||
|
||||
Future<void> _loadStats() async {
|
||||
final provider = Provider.of<VideosProvider>(context, listen: false);
|
||||
final result = await provider.getDashboardStats();
|
||||
final result = await provider.getVideoMetrics();
|
||||
setState(() {
|
||||
stats = result;
|
||||
stats = result ?? {};
|
||||
isLoading = false;
|
||||
});
|
||||
}
|
||||
@@ -116,38 +118,51 @@ class _PremiumDashboardPageState extends State<PremiumDashboardPage>
|
||||
|
||||
final totalVideos = stats['total_videos'] ?? 0;
|
||||
final totalViews = stats['total_reproducciones'] ?? 0;
|
||||
final avgViews = totalVideos > 0 ? (totalViews / totalVideos).round() : 0;
|
||||
final avgViewsPerDay = stats['promedio_reproducciones_por_dia'] ?? 0.0;
|
||||
|
||||
// Datos de ejemplo para sparkline (podrías obtenerlos de la BD)
|
||||
final sparklineData1 = [45.0, 52.0, 48.0, 65.0, 59.0, 72.0, 78.0];
|
||||
final sparklineData2 = [120.0, 145.0, 132.0, 168.0, 175.0, 190.0, 210.0];
|
||||
final sparklineData3 = [25.0, 28.0, 24.0, 32.0, 30.0, 35.0, 38.0];
|
||||
|
||||
final cards = [
|
||||
_StatCard(
|
||||
title: 'Total Videos',
|
||||
value: totalVideos.toString(),
|
||||
icon: Icons.video_library,
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF4EC9F5), Color(0xFF2E8BC0)],
|
||||
PremiumStatCard(
|
||||
data: StatCardData(
|
||||
title: 'Total Videos',
|
||||
value: totalVideos,
|
||||
icon: Icons.video_library_rounded,
|
||||
gradientColors: const [Color(0xFF4EC9F5), Color(0xFF2E8BC0)],
|
||||
trend: '+12%',
|
||||
trendUp: true,
|
||||
),
|
||||
trend: '+12%',
|
||||
trendUp: true,
|
||||
showSparkline: true,
|
||||
sparklineData: sparklineData1,
|
||||
),
|
||||
_StatCard(
|
||||
title: 'Reproducciones',
|
||||
value: _formatNumber(totalViews),
|
||||
icon: Icons.play_circle_filled,
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFFFFB733), Color(0xFFFF8A00)],
|
||||
PremiumStatCard(
|
||||
data: StatCardData(
|
||||
title: 'Reproducciones',
|
||||
value: totalViews,
|
||||
icon: Icons.play_circle_filled_rounded,
|
||||
gradientColors: const [Color(0xFFFFB733), Color(0xFFFF8A00)],
|
||||
trend: '+23%',
|
||||
trendUp: true,
|
||||
),
|
||||
trend: '+23%',
|
||||
trendUp: true,
|
||||
showSparkline: true,
|
||||
sparklineData: sparklineData2,
|
||||
),
|
||||
_StatCard(
|
||||
title: 'Promedio Vistas',
|
||||
value: _formatNumber(avgViews),
|
||||
icon: Icons.trending_up,
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF00C9A7), Color(0xFF00B894)],
|
||||
PremiumStatCard(
|
||||
data: StatCardData(
|
||||
title: 'Promedio/Día',
|
||||
value: avgViewsPerDay is num
|
||||
? avgViewsPerDay.toInt()
|
||||
: (avgViewsPerDay as double).toInt(),
|
||||
icon: Icons.trending_up_rounded,
|
||||
gradientColors: const [Color(0xFF00C9A7), Color(0xFF00B894)],
|
||||
trend: '+8%',
|
||||
trendUp: true,
|
||||
),
|
||||
trend: '+8%',
|
||||
trendUp: true,
|
||||
showSparkline: true,
|
||||
sparklineData: sparklineData3,
|
||||
),
|
||||
];
|
||||
|
||||
@@ -168,356 +183,76 @@ class _PremiumDashboardPageState extends State<PremiumDashboardPage>
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
crossAxisSpacing: 20,
|
||||
mainAxisSpacing: 20,
|
||||
childAspectRatio: 2.2,
|
||||
childAspectRatio: 1.8,
|
||||
children: cards,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLoadingSkeleton(bool isMobile) {
|
||||
if (isMobile) {
|
||||
// En mobile usar Column en lugar de GridView para evitar distorsión
|
||||
return Column(
|
||||
children: List.generate(
|
||||
3,
|
||||
(index) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: Shimmer.fromColors(
|
||||
baseColor: AppTheme.of(context).tertiaryBackground,
|
||||
highlightColor: AppTheme.of(context).secondaryBackground,
|
||||
child: const StatCardSkeleton(isMobile: true),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Shimmer.fromColors(
|
||||
baseColor: AppTheme.of(context).tertiaryBackground,
|
||||
highlightColor: AppTheme.of(context).secondaryBackground,
|
||||
child: GridView.count(
|
||||
crossAxisCount: isMobile ? 1 : 3,
|
||||
crossAxisCount: 3,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
crossAxisSpacing: 20,
|
||||
mainAxisSpacing: 20,
|
||||
childAspectRatio: isMobile ? 3 : 1.5,
|
||||
childAspectRatio: 1.8,
|
||||
children: List.generate(
|
||||
3,
|
||||
(index) => Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
),
|
||||
(index) => const StatCardSkeleton(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildViewsChart() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(28),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.of(context).secondaryBackground,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: AppTheme.of(context).primaryColor.withOpacity(0.1),
|
||||
width: 1,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFFFB733).withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.bar_chart,
|
||||
color: Color(0xFFFFB733),
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
const Gap(12),
|
||||
Text(
|
||||
'Reproducciones Semanales',
|
||||
style: AppTheme.of(context).title3.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).primaryText,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Gap(32),
|
||||
SizedBox(
|
||||
height: 200,
|
||||
child: BarChart(
|
||||
BarChartData(
|
||||
alignment: BarChartAlignment.spaceAround,
|
||||
maxY: 100,
|
||||
barTouchData: BarTouchData(enabled: true),
|
||||
titlesData: FlTitlesData(
|
||||
show: true,
|
||||
bottomTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: true,
|
||||
getTitlesWidget: (value, meta) {
|
||||
const days = ['L', 'M', 'X', 'J', 'V', 'S', 'D'];
|
||||
return Text(
|
||||
days[value.toInt() % 7],
|
||||
style: TextStyle(
|
||||
color: AppTheme.of(context).tertiaryText,
|
||||
fontSize: 12,
|
||||
fontFamily: 'Poppins',
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
leftTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: true,
|
||||
reservedSize: 40,
|
||||
getTitlesWidget: (value, meta) {
|
||||
return Text(
|
||||
value.toInt().toString(),
|
||||
style: TextStyle(
|
||||
color: AppTheme.of(context).tertiaryText,
|
||||
fontSize: 12,
|
||||
fontFamily: 'Poppins',
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
topTitles: AxisTitles(
|
||||
sideTitles: SideTitles(showTitles: false),
|
||||
),
|
||||
rightTitles: AxisTitles(
|
||||
sideTitles: SideTitles(showTitles: false),
|
||||
),
|
||||
),
|
||||
borderData: FlBorderData(show: false),
|
||||
gridData: FlGridData(
|
||||
show: true,
|
||||
drawVerticalLine: false,
|
||||
getDrawingHorizontalLine: (value) {
|
||||
return FlLine(
|
||||
color: AppTheme.of(context).tertiaryText.withOpacity(0.1),
|
||||
strokeWidth: 1,
|
||||
);
|
||||
},
|
||||
),
|
||||
barGroups: [
|
||||
BarChartGroupData(x: 0, barRods: [
|
||||
BarChartRodData(
|
||||
toY: 65,
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF4EC9F5), Color(0xFFFFB733)],
|
||||
),
|
||||
width: 20,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(6),
|
||||
topRight: Radius.circular(6),
|
||||
),
|
||||
)
|
||||
]),
|
||||
BarChartGroupData(x: 1, barRods: [
|
||||
BarChartRodData(
|
||||
toY: 80,
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF4EC9F5), Color(0xFFFFB733)],
|
||||
),
|
||||
width: 20,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(6),
|
||||
topRight: Radius.circular(6),
|
||||
),
|
||||
)
|
||||
]),
|
||||
BarChartGroupData(x: 2, barRods: [
|
||||
BarChartRodData(
|
||||
toY: 45,
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF4EC9F5), Color(0xFFFFB733)],
|
||||
),
|
||||
width: 20,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(6),
|
||||
topRight: Radius.circular(6),
|
||||
),
|
||||
)
|
||||
]),
|
||||
BarChartGroupData(x: 3, barRods: [
|
||||
BarChartRodData(
|
||||
toY: 90,
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF4EC9F5), Color(0xFFFFB733)],
|
||||
),
|
||||
width: 20,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(6),
|
||||
topRight: Radius.circular(6),
|
||||
),
|
||||
)
|
||||
]),
|
||||
BarChartGroupData(x: 4, barRods: [
|
||||
BarChartRodData(
|
||||
toY: 75,
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF4EC9F5), Color(0xFFFFB733)],
|
||||
),
|
||||
width: 20,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(6),
|
||||
topRight: Radius.circular(6),
|
||||
),
|
||||
)
|
||||
]),
|
||||
BarChartGroupData(x: 5, barRods: [
|
||||
BarChartRodData(
|
||||
toY: 55,
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF4EC9F5), Color(0xFFFFB733)],
|
||||
),
|
||||
width: 20,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(6),
|
||||
topRight: Radius.circular(6),
|
||||
),
|
||||
)
|
||||
]),
|
||||
BarChartGroupData(x: 6, barRods: [
|
||||
BarChartRodData(
|
||||
toY: 40,
|
||||
gradient: const LinearGradient(
|
||||
colors: [Color(0xFF4EC9F5), Color(0xFFFFB733)],
|
||||
),
|
||||
width: 20,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(6),
|
||||
topRight: Radius.circular(6),
|
||||
),
|
||||
)
|
||||
]),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// Datos de ejemplo - idealmente vendrían de la BD
|
||||
final chartData = [
|
||||
const ChartDataPoint(label: 'Lun', value: 65),
|
||||
const ChartDataPoint(label: 'Mar', value: 80),
|
||||
const ChartDataPoint(label: 'Mié', value: 45),
|
||||
const ChartDataPoint(label: 'Jue', value: 90),
|
||||
const ChartDataPoint(label: 'Vie', value: 75),
|
||||
const ChartDataPoint(label: 'Sáb', value: 55),
|
||||
const ChartDataPoint(label: 'Dom', value: 40),
|
||||
];
|
||||
|
||||
return PremiumViewsChart(
|
||||
data: chartData,
|
||||
title: 'Reproducciones Semanales',
|
||||
icon: Icons.bar_chart_rounded,
|
||||
iconColor: const Color(0xFFFFB733),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTopVideos() {
|
||||
final provider = Provider.of<VideosProvider>(context);
|
||||
final topVideos = provider.mediaFiles.take(5).toList();
|
||||
final provider = Provider.of<VideosProvider>(context, listen: false);
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(28),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.of(context).secondaryBackground,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: AppTheme.of(context).primaryColor.withOpacity(0.1),
|
||||
width: 1,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF6B2F8A).withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.star,
|
||||
color: Color(0xFF6B2F8A),
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
const Gap(12),
|
||||
Text(
|
||||
'Top 5 Videos',
|
||||
style: AppTheme.of(context).title3.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).primaryText,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Gap(24),
|
||||
...topVideos.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final video = entry.value;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 32,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
const Color(0xFF4EC9F5),
|
||||
const Color(0xFFFFB733),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'${index + 1}',
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF0B0B0D),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Poppins',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Gap(12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
video.title ?? video.fileName,
|
||||
style: AppTheme.of(context).bodyText1.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).primaryText,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
'${video.reproducciones} vistas',
|
||||
style: AppTheme.of(context).bodyText2.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).tertiaryText,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
],
|
||||
),
|
||||
return Top5VideosWidget(
|
||||
loadTopVideos: provider.getTop5VideosByViews,
|
||||
onVideoTap: (video) {
|
||||
// Opcional: navegar al video o mostrar detalles
|
||||
debugPrint('Video tapped: ${video.title}');
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -529,14 +264,19 @@ class _PremiumDashboardPageState extends State<PremiumDashboardPage>
|
||||
padding: const EdgeInsets.all(28),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.of(context).secondaryBackground,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
borderRadius: BorderRadius.circular(24),
|
||||
border: Border.all(
|
||||
color: AppTheme.of(context).primaryColor.withOpacity(0.1),
|
||||
color: AppTheme.of(context).primaryColor.withOpacity(0.08),
|
||||
width: 1,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
color: const Color(0xFF00C9A7).withOpacity(0.08),
|
||||
blurRadius: 30,
|
||||
offset: const Offset(0, 10),
|
||||
),
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.03),
|
||||
blurRadius: 20,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
@@ -548,26 +288,54 @@ class _PremiumDashboardPageState extends State<PremiumDashboardPage>
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(10),
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF00C9A7).withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
const Color(0xFF00C9A7).withOpacity(0.2),
|
||||
const Color(0xFF00C9A7).withOpacity(0.1),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: const Color(0xFF00C9A7).withOpacity(0.2),
|
||||
blurRadius: 12,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.history,
|
||||
Icons.history_rounded,
|
||||
color: Color(0xFF00C9A7),
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
const Gap(12),
|
||||
Text(
|
||||
'Actividad Reciente',
|
||||
style: AppTheme.of(context).title3.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).primaryText,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
const Gap(16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Actividad Reciente',
|
||||
style: AppTheme.of(context).title3.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).primaryText,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
const Gap(2),
|
||||
Text(
|
||||
'Últimos videos subidos',
|
||||
style: AppTheme.of(context).bodyText2.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).tertiaryText,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -575,75 +343,125 @@ class _PremiumDashboardPageState extends State<PremiumDashboardPage>
|
||||
...recentVideos.map((video) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppTheme.of(context).tertiaryBackground,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: 48,
|
||||
height: 48,
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// Opcional: navegar al video
|
||||
},
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
const Color(0xFF4EC9F5),
|
||||
const Color(0xFFFFB733),
|
||||
],
|
||||
color: AppTheme.of(context)
|
||||
.tertiaryBackground
|
||||
.withOpacity(0.5),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: Border.all(
|
||||
color:
|
||||
AppTheme.of(context).primaryColor.withOpacity(0.05),
|
||||
width: 1,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.video_library,
|
||||
color: Color(0xFF0B0B0D),
|
||||
),
|
||||
),
|
||||
const Gap(16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
video.title ?? video.fileName,
|
||||
style: AppTheme.of(context).bodyText1.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).primaryText,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
// Thumbnail
|
||||
Container(
|
||||
width: 56,
|
||||
height: 42,
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
colors: [
|
||||
const Color(0xFF4EC9F5).withOpacity(0.8),
|
||||
const Color(0xFFFFB733).withOpacity(0.8),
|
||||
],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.video_library_rounded,
|
||||
color: Color(0xFF0B0B0D),
|
||||
size: 22,
|
||||
),
|
||||
),
|
||||
const Gap(4),
|
||||
Text(
|
||||
'Subido hace ${_getTimeAgo(video.createdAt)}',
|
||||
style: AppTheme.of(context).bodyText2.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).tertiaryText,
|
||||
fontSize: 12,
|
||||
const Gap(16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
video.title ?? video.fileName,
|
||||
style: AppTheme.of(context).bodyText1.override(
|
||||
fontFamily: 'Poppins',
|
||||
color: AppTheme.of(context).primaryText,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const Gap(4),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.schedule_rounded,
|
||||
size: 14,
|
||||
color: AppTheme.of(context).tertiaryText,
|
||||
),
|
||||
const Gap(4),
|
||||
Text(
|
||||
'Subido ${_getTimeAgo(video.createdAt)}',
|
||||
style: AppTheme.of(context)
|
||||
.bodyText2
|
||||
.override(
|
||||
fontFamily: 'Poppins',
|
||||
color:
|
||||
AppTheme.of(context).tertiaryText,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Badge de reproducciones
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF00C9A7).withOpacity(0.15),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: const Color(0xFF00C9A7).withOpacity(0.3),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.play_arrow_rounded,
|
||||
color: Color(0xFF00C9A7),
|
||||
size: 14,
|
||||
),
|
||||
const Gap(4),
|
||||
Text(
|
||||
'${video.reproducciones}',
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF00C9A7),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12,
|
||||
fontFamily: 'Poppins',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF00C9A7).withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: Text(
|
||||
'${video.reproducciones}',
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF00C9A7),
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12,
|
||||
fontFamily: 'Poppins',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
@@ -652,167 +470,21 @@ class _PremiumDashboardPageState extends State<PremiumDashboardPage>
|
||||
);
|
||||
}
|
||||
|
||||
String _formatNumber(int number) {
|
||||
if (number >= 1000000) {
|
||||
return '${(number / 1000000).toStringAsFixed(1)}M';
|
||||
} else if (number >= 1000) {
|
||||
return '${(number / 1000).toStringAsFixed(1)}K';
|
||||
}
|
||||
return number.toString();
|
||||
}
|
||||
|
||||
String _getTimeAgo(DateTime? timestamp) {
|
||||
if (timestamp == null) return 'hace un momento';
|
||||
|
||||
final difference = DateTime.now().difference(timestamp);
|
||||
|
||||
if (difference.inDays > 30) {
|
||||
return '${(difference.inDays / 30).floor()} meses';
|
||||
return 'hace ${(difference.inDays / 30).floor()} meses';
|
||||
} else if (difference.inDays > 0) {
|
||||
return '${difference.inDays} días';
|
||||
return 'hace ${difference.inDays} días';
|
||||
} else if (difference.inHours > 0) {
|
||||
return '${difference.inHours} horas';
|
||||
return 'hace ${difference.inHours} horas';
|
||||
} else if (difference.inMinutes > 0) {
|
||||
return '${difference.inMinutes} minutos';
|
||||
return 'hace ${difference.inMinutes} minutos';
|
||||
} else {
|
||||
return 'hace un momento';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _StatCard extends StatefulWidget {
|
||||
final String title;
|
||||
final String value;
|
||||
final IconData icon;
|
||||
final Gradient gradient;
|
||||
final String? trend;
|
||||
final bool trendUp;
|
||||
|
||||
const _StatCard({
|
||||
required this.title,
|
||||
required this.value,
|
||||
required this.icon,
|
||||
required this.gradient,
|
||||
this.trend,
|
||||
this.trendUp = true,
|
||||
});
|
||||
|
||||
@override
|
||||
State<_StatCard> createState() => _StatCardState();
|
||||
}
|
||||
|
||||
class _StatCardState extends State<_StatCard>
|
||||
with SingleTickerProviderStateMixin {
|
||||
bool _isHovered = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MouseRegion(
|
||||
onEnter: (_) => setState(() => _isHovered = true),
|
||||
onExit: (_) => setState(() => _isHovered = false),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
transform: Matrix4.identity()..scale(_isHovered ? 1.02 : 1.0),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
gradient: widget.gradient,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: widget.gradient.colors.first.withOpacity(0.25),
|
||||
blurRadius: _isHovered ? 16 : 10,
|
||||
offset: Offset(0, _isHovered ? 6 : 3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
// Icono y valor en la izquierda
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// Icono
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.25),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Icon(
|
||||
widget.icon,
|
||||
color: const Color(0xFF0B0B0D),
|
||||
size: 22,
|
||||
),
|
||||
),
|
||||
const Gap(12),
|
||||
// Valor
|
||||
Text(
|
||||
widget.value,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF0B0B0D),
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Poppins',
|
||||
height: 1.0,
|
||||
),
|
||||
),
|
||||
const Gap(4),
|
||||
// Título
|
||||
Text(
|
||||
widget.title,
|
||||
style: TextStyle(
|
||||
color: const Color(0xFF0B0B0D).withOpacity(0.75),
|
||||
fontSize: 12,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Trend badge a la derecha
|
||||
if (widget.trend != null)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 6,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: widget.trendUp
|
||||
? Colors.white.withOpacity(0.3)
|
||||
: Colors.black.withOpacity(0.2),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
widget.trendUp
|
||||
? Icons.trending_up
|
||||
: Icons.trending_down,
|
||||
size: 18,
|
||||
color: const Color(0xFF0B0B0D),
|
||||
),
|
||||
const Gap(2),
|
||||
Text(
|
||||
widget.trend!,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF0B0B0D),
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Poppins',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user