Diseño mejorado
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import 'dart:typed_data';
|
||||
import 'dart:html' as html;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:chewie/chewie.dart';
|
||||
import 'package:nethive_neo/models/media/media_models.dart';
|
||||
import 'package:nethive_neo/providers/videos_provider.dart';
|
||||
import 'package:nethive_neo/theme/theme.dart';
|
||||
@@ -31,14 +33,22 @@ class _PremiumUploadDialogState extends State<PremiumUploadDialog> {
|
||||
Uint8List? selectedPoster;
|
||||
String? posterFileName;
|
||||
VideoPlayerController? _videoController;
|
||||
ChewieController? _chewieController;
|
||||
bool isUploading = false;
|
||||
bool _isVideoLoading = false;
|
||||
String? _videoBlobUrl;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
titleController.dispose();
|
||||
descriptionController.dispose();
|
||||
tagsController.dispose();
|
||||
_chewieController?.dispose();
|
||||
_videoController?.dispose();
|
||||
// Limpiar blob URL
|
||||
if (_videoBlobUrl != null) {
|
||||
html.Url.revokeObjectUrl(_videoBlobUrl!);
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -51,9 +61,63 @@ class _PremiumUploadDialogState extends State<PremiumUploadDialog> {
|
||||
titleController.text = widget.provider.tituloController.text;
|
||||
});
|
||||
|
||||
// Crear video player para preview (solo web)
|
||||
// Para preview en web, necesitaríamos crear un Blob URL, pero esto es complejo
|
||||
// Por ahora mostraremos solo el nombre y poster
|
||||
// Crear video player para preview en web
|
||||
await _initializeVideoPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _initializeVideoPlayer() async {
|
||||
if (selectedVideo == null) return;
|
||||
|
||||
setState(() => _isVideoLoading = true);
|
||||
|
||||
try {
|
||||
// Limpiar blob URL anterior si existe
|
||||
if (_videoBlobUrl != null) {
|
||||
html.Url.revokeObjectUrl(_videoBlobUrl!);
|
||||
}
|
||||
|
||||
// Crear Blob desde bytes
|
||||
final blob = html.Blob([selectedVideo!]);
|
||||
_videoBlobUrl = html.Url.createObjectUrlFromBlob(blob);
|
||||
|
||||
// Inicializar video player
|
||||
_videoController = VideoPlayerController.network(_videoBlobUrl!);
|
||||
await _videoController!.initialize();
|
||||
|
||||
_chewieController = ChewieController(
|
||||
videoPlayerController: _videoController!,
|
||||
autoPlay: false,
|
||||
looping: false,
|
||||
showControls: true,
|
||||
aspectRatio: _videoController!.value.aspectRatio,
|
||||
materialProgressColors: ChewieProgressColors(
|
||||
playedColor: const Color(0xFF4EC9F5),
|
||||
handleColor: const Color(0xFFFFB733),
|
||||
backgroundColor: Colors.grey.shade800,
|
||||
bufferedColor: Colors.grey.shade600,
|
||||
),
|
||||
placeholder: Container(
|
||||
color: Colors.black,
|
||||
child: const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Color(0xFF4EC9F5),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
setState(() => _isVideoLoading = false);
|
||||
} catch (e) {
|
||||
setState(() => _isVideoLoading = false);
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Error al cargar preview: $e'),
|
||||
backgroundColor: const Color(0xFFFF2D2D),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -482,6 +546,80 @@ class _PremiumUploadDialogState extends State<PremiumUploadDialog> {
|
||||
}
|
||||
|
||||
Widget _buildVideoPreview() {
|
||||
if (_isVideoLoading) {
|
||||
return Container(
|
||||
color: Colors.black,
|
||||
child: const Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CircularProgressIndicator(
|
||||
color: Color(0xFF4EC9F5),
|
||||
),
|
||||
Gap(12),
|
||||
Text(
|
||||
'Cargando preview...',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontFamily: 'Poppins',
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (_chewieController != null && _videoController != null) {
|
||||
return Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(14),
|
||||
child: Container(
|
||||
color: Colors.black,
|
||||
child: Chewie(
|
||||
controller: _chewieController!,
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 12,
|
||||
right: 12,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.green,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.check_circle, size: 16, color: Colors.white),
|
||||
Gap(4),
|
||||
Text(
|
||||
'Listo para subir',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
fontFamily: 'Poppins',
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
|
||||
Reference in New Issue
Block a user