Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7911af217f |
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../services/iptv_provider.dart';
|
||||
@@ -15,8 +14,6 @@ class HomeScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _HomeScreenState extends State<HomeScreen> {
|
||||
int _focusedIndex = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -25,22 +22,14 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
double get _screenWidth => MediaQuery.of(context).size.width;
|
||||
bool get _isLargeScreen => _screenWidth > 900;
|
||||
bool get _isMediumScreen => _screenWidth > 600 && _screenWidth <= 900;
|
||||
|
||||
int get _gridCrossAxisCount {
|
||||
if (_screenWidth > 900) return 6;
|
||||
if (_screenWidth > 600) return 4;
|
||||
return 3;
|
||||
}
|
||||
|
||||
double get _titleFontSize => _isLargeScreen ? 32 : (_isMediumScreen ? 28 : 24);
|
||||
double get _iconSize => _isLargeScreen ? 80 : 60;
|
||||
double get _headerPadding => _isLargeScreen ? 32 : 24;
|
||||
|
||||
void _showLiveCategories() {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const ContentListScreen(type: ContentType.live)),
|
||||
MaterialPageRoute(
|
||||
builder: (_) => const ContentListScreen(type: ContentType.live),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -51,19 +40,16 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
|
||||
Future<void> _downloadPlaylistAsJson() async {
|
||||
final provider = context.read<IPTVProvider>();
|
||||
|
||||
|
||||
try {
|
||||
final filePath = await provider.downloadAndSaveM3UAsJson();
|
||||
|
||||
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('Playlist guardada en: $filePath'),
|
||||
duration: const Duration(seconds: 5),
|
||||
action: SnackBarAction(
|
||||
label: 'OK',
|
||||
onPressed: () {},
|
||||
),
|
||||
action: SnackBarAction(label: 'OK', onPressed: () {}),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -86,9 +72,12 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
if (provider.vodStreams.isEmpty) {
|
||||
await provider.loadVodStreams();
|
||||
}
|
||||
if (!mounted) return;
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const ContentListScreen(type: ContentType.movies)),
|
||||
MaterialPageRoute(
|
||||
builder: (_) => const ContentListScreen(type: ContentType.movies),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -98,9 +87,12 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
if (provider.seriesList.isEmpty) {
|
||||
await provider.loadSeries();
|
||||
}
|
||||
if (!mounted) return;
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const ContentListScreen(type: ContentType.series)),
|
||||
MaterialPageRoute(
|
||||
builder: (_) => const ContentListScreen(type: ContentType.series),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -126,10 +118,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
gradient: RadialGradient(
|
||||
center: Alignment.center,
|
||||
radius: 1.5,
|
||||
colors: [
|
||||
Color(0xFF1a1a2e),
|
||||
Color(0xFF0f0f1a),
|
||||
],
|
||||
colors: [Color(0xFF1a1a2e), Color(0xFF0f0f1a)],
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
@@ -149,7 +138,10 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
final double titleSize = _isLargeScreen ? 28.0 : 24.0;
|
||||
final double iconSize = _isLargeScreen ? 40.0 : 32.0;
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: _headerPadding, vertical: _isLargeScreen ? 24 : 16),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: _headerPadding,
|
||||
vertical: _isLargeScreen ? 24 : 16,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -170,11 +162,27 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(timeStr, style: TextStyle(color: Colors.white70, fontSize: _isLargeScreen ? 20 : 16)),
|
||||
Text(
|
||||
timeStr,
|
||||
style: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: _isLargeScreen ? 20 : 16,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Text(dateStr, style: TextStyle(color: Colors.white54, fontSize: _isLargeScreen ? 16 : 14)),
|
||||
Text(
|
||||
dateStr,
|
||||
style: TextStyle(
|
||||
color: Colors.white54,
|
||||
fontSize: _isLargeScreen ? 16 : 14,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 24),
|
||||
Icon(Icons.person, color: Colors.white70, size: _isLargeScreen ? 32 : 24),
|
||||
Icon(
|
||||
Icons.person,
|
||||
color: Colors.white70,
|
||||
size: _isLargeScreen ? 32 : 24,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Consumer<IPTVProvider>(
|
||||
builder: (context, provider, _) {
|
||||
@@ -218,11 +226,18 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
decoration: hasFocus
|
||||
? BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(color: Colors.white, width: 2),
|
||||
border: Border.all(
|
||||
color: Colors.white,
|
||||
width: 2,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.refresh, color: hasFocus ? Colors.white : Colors.white70, size: _isLargeScreen ? 32 : 24),
|
||||
icon: Icon(
|
||||
Icons.refresh,
|
||||
color: hasFocus ? Colors.white : Colors.white70,
|
||||
size: _isLargeScreen ? 32 : 24,
|
||||
),
|
||||
onPressed: _refreshChannels,
|
||||
tooltip: 'Actualizar canales',
|
||||
),
|
||||
@@ -245,7 +260,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
)
|
||||
: null,
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.download, color: hasFocus ? Colors.white : Colors.white70, size: _isLargeScreen ? 32 : 24),
|
||||
icon: Icon(
|
||||
Icons.download,
|
||||
color: hasFocus ? Colors.white : Colors.white70,
|
||||
size: _isLargeScreen ? 32 : 24,
|
||||
),
|
||||
onPressed: () => _downloadPlaylistAsJson(),
|
||||
tooltip: 'Descargar playlist como JSON',
|
||||
),
|
||||
@@ -266,7 +285,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
)
|
||||
: null,
|
||||
child: IconButton(
|
||||
icon: Icon(Icons.settings, color: hasFocus ? Colors.white : Colors.white70, size: _isLargeScreen ? 32 : 24),
|
||||
icon: Icon(
|
||||
Icons.settings,
|
||||
color: hasFocus ? Colors.white : Colors.white70,
|
||||
size: _isLargeScreen ? 32 : 24,
|
||||
),
|
||||
onPressed: () {
|
||||
context.read<IPTVProvider>().logout();
|
||||
},
|
||||
@@ -348,7 +371,7 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
builder: (context, provider, _) {
|
||||
final expDate = provider.userInfo?.expDate;
|
||||
final username = provider.userInfo?.username ?? 'Usuario';
|
||||
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.all(footerPadding),
|
||||
child: Row(
|
||||
@@ -400,22 +423,12 @@ class _DashboardCardState extends State<_DashboardCard> {
|
||||
widget.onTap();
|
||||
}
|
||||
|
||||
void _handleKeyEvent(KeyEvent event) {
|
||||
if (event is KeyDownEvent) {
|
||||
if (event.logicalKey == LogicalKeyboardKey.enter ||
|
||||
event.logicalKey == LogicalKeyboardKey.select ||
|
||||
event.logicalKey == LogicalKeyboardKey.space) {
|
||||
_handleTap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final iconSize = widget.isLarge ? 80.0 : 60.0;
|
||||
final titleSize = widget.isLarge ? 32.0 : 24.0;
|
||||
final bgIconSize = widget.isLarge ? 200.0 : 150.0;
|
||||
|
||||
|
||||
return FocusableActionDetector(
|
||||
actions: <Type, Action<Intent>>{
|
||||
ActivateIntent: CallbackAction<ActivateIntent>(
|
||||
@@ -445,7 +458,9 @@ class _DashboardCardState extends State<_DashboardCard> {
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: _hasFocus ? Colors.white.withValues(alpha: 0.6) : Colors.black.withValues(alpha: 0.3),
|
||||
color: _hasFocus
|
||||
? Colors.white.withValues(alpha: 0.6)
|
||||
: Colors.black.withValues(alpha: 0.3),
|
||||
blurRadius: _hasFocus ? 35 : 15,
|
||||
spreadRadius: _hasFocus ? 6 : 0,
|
||||
offset: const Offset(0, 8),
|
||||
@@ -507,12 +522,14 @@ class _ContentListScreenState extends State<ContentListScreen> {
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
String _searchQuery = '';
|
||||
String? _selectedCountry;
|
||||
final FocusNode _gridFocusNode = FocusNode();
|
||||
|
||||
List<XtreamStream>? _lastSearchSource;
|
||||
String _lastSearchQuery = '';
|
||||
List<XtreamStream>? _lastSearchResults;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
print('DEBUG: ContentListScreen.initState() - type: ${widget.type}');
|
||||
_loadContent();
|
||||
}
|
||||
|
||||
@@ -526,15 +543,13 @@ class _ContentListScreenState extends State<ContentListScreen> {
|
||||
return 3;
|
||||
}
|
||||
|
||||
double get _titleFontSize => _isLargeScreen ? 32 : (_isMediumScreen ? 28 : 24);
|
||||
double get _cardTextSize => _isLargeScreen ? 16 : 12;
|
||||
double get _titleFontSize =>
|
||||
_isLargeScreen ? 32 : (_isMediumScreen ? 28 : 24);
|
||||
double get _headerPadding => _isLargeScreen ? 32 : 16;
|
||||
|
||||
void _loadContent() {
|
||||
print('DEBUG: _loadContent() called for type: ${widget.type}');
|
||||
final provider = context.read<IPTVProvider>();
|
||||
if (widget.type == ContentType.live) {
|
||||
print('DEBUG: Loading live streams with country filter: "${_selectedCountry ?? ''}"');
|
||||
provider.loadLiveStreams(_selectedCountry ?? '');
|
||||
} else if (widget.type == ContentType.movies) {
|
||||
provider.loadVodStreams();
|
||||
@@ -551,7 +566,6 @@ class _ContentListScreenState extends State<ContentListScreen> {
|
||||
@override
|
||||
void dispose() {
|
||||
_searchController.dispose();
|
||||
_gridFocusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -566,21 +580,8 @@ class _ContentListScreenState extends State<ContentListScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
List<XtreamCategory> get _categories {
|
||||
final provider = context.read<IPTVProvider>();
|
||||
switch (widget.type) {
|
||||
case ContentType.live:
|
||||
return provider.liveCategories;
|
||||
case ContentType.movies:
|
||||
return provider.vodCategories;
|
||||
case ContentType.series:
|
||||
return provider.seriesCategories;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('DEBUG: ContentListScreen.build() - type: ${widget.type}, isLive: ${widget.type == ContentType.live}');
|
||||
return Scaffold(
|
||||
backgroundColor: const Color(0xFF0f0f1a),
|
||||
body: SafeArea(
|
||||
@@ -605,7 +606,9 @@ class _ContentListScreenState extends State<ContentListScreen> {
|
||||
}
|
||||
|
||||
Widget _buildHeader() {
|
||||
final searchWidth = _isLargeScreen ? 350.0 : (_isMediumScreen ? 300.0 : 250.0);
|
||||
final searchWidth = _isLargeScreen
|
||||
? 350.0
|
||||
: (_isMediumScreen ? 300.0 : 250.0);
|
||||
final searchHeight = _isLargeScreen ? 56.0 : 44.0;
|
||||
final iconSize = _isLargeScreen ? 32.0 : 24.0;
|
||||
return Container(
|
||||
@@ -633,17 +636,34 @@ class _ContentListScreenState extends State<ContentListScreen> {
|
||||
height: searchHeight,
|
||||
child: TextField(
|
||||
controller: _searchController,
|
||||
style: TextStyle(color: Colors.white, fontSize: _isLargeScreen ? 18 : 14),
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: _isLargeScreen ? 18 : 14,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Buscar...',
|
||||
hintStyle: TextStyle(color: Colors.grey, fontSize: _isLargeScreen ? 18 : 14),
|
||||
prefixIcon: Icon(Icons.search, color: Colors.grey, size: _isLargeScreen ? 28 : 20),
|
||||
hintStyle: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: _isLargeScreen ? 18 : 14,
|
||||
),
|
||||
prefixIcon: Icon(
|
||||
Icons.search,
|
||||
color: Colors.grey,
|
||||
size: _isLargeScreen ? 28 : 20,
|
||||
),
|
||||
suffixIcon: _searchQuery.isNotEmpty
|
||||
? IconButton(
|
||||
icon: Icon(Icons.clear, color: Colors.grey, size: _isLargeScreen ? 28 : 20),
|
||||
icon: Icon(
|
||||
Icons.clear,
|
||||
color: Colors.grey,
|
||||
size: _isLargeScreen ? 28 : 20,
|
||||
),
|
||||
onPressed: () {
|
||||
_searchController.clear();
|
||||
setState(() => _searchQuery = '');
|
||||
setState(() {
|
||||
_searchQuery = '';
|
||||
_lastSearchResults = null;
|
||||
});
|
||||
},
|
||||
)
|
||||
: null,
|
||||
@@ -653,10 +673,15 @@ class _ContentListScreenState extends State<ContentListScreen> {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: _isLargeScreen ? 16 : 12),
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
horizontal: 16,
|
||||
vertical: _isLargeScreen ? 16 : 12,
|
||||
),
|
||||
),
|
||||
onChanged: (value) {
|
||||
setState(() => _searchQuery = value);
|
||||
setState(() {
|
||||
_searchQuery = value;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -665,20 +690,66 @@ class _ContentListScreenState extends State<ContentListScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
String _getCountryName(String categoryName) {
|
||||
if (categoryName.contains('|')) {
|
||||
return categoryName.split('|').first.trim();
|
||||
List<XtreamStream> _buildStreamsForType(IPTVProvider provider) {
|
||||
if (widget.type == ContentType.live) {
|
||||
return provider.filteredLiveStreams;
|
||||
}
|
||||
return categoryName.trim();
|
||||
if (widget.type == ContentType.movies) {
|
||||
return provider.vodStreams;
|
||||
}
|
||||
return provider.seriesList
|
||||
.map(
|
||||
(s) => XtreamStream(
|
||||
streamId: s.seriesId,
|
||||
name: s.name,
|
||||
streamIcon: s.cover,
|
||||
plot: s.plot,
|
||||
rating: s.rating,
|
||||
),
|
||||
)
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
List<XtreamStream> _applySearchFilter(List<XtreamStream> streams) {
|
||||
if (_searchQuery.isEmpty) {
|
||||
_lastSearchSource = streams;
|
||||
_lastSearchQuery = '';
|
||||
_lastSearchResults = streams;
|
||||
return streams;
|
||||
}
|
||||
|
||||
if (identical(streams, _lastSearchSource) &&
|
||||
_searchQuery == _lastSearchQuery &&
|
||||
_lastSearchResults != null) {
|
||||
return _lastSearchResults!;
|
||||
}
|
||||
|
||||
final query = _searchQuery.toLowerCase();
|
||||
final filtered = streams
|
||||
.where((stream) {
|
||||
final name = stream.name.toLowerCase();
|
||||
if (query == 'arg|') {
|
||||
return name.contains('arg|');
|
||||
}
|
||||
return name.contains(query);
|
||||
})
|
||||
.toList(growable: false);
|
||||
|
||||
_lastSearchSource = streams;
|
||||
_lastSearchQuery = _searchQuery;
|
||||
_lastSearchResults = filtered;
|
||||
return filtered;
|
||||
}
|
||||
|
||||
Widget _buildCountrySidebar() {
|
||||
return Consumer<IPTVProvider>(
|
||||
builder: (context, provider, _) {
|
||||
print('🔥 BUILDING SIDEBAR - countries: ${provider.countries.length}, loading: ${provider.isLoading}, organizing: ${provider.isOrganizingCountries}');
|
||||
final countries = provider.countries;
|
||||
return SimpleCountriesSidebar(
|
||||
countries: provider.countries,
|
||||
selectedCountry: provider.selectedCategory.isNotEmpty ? provider.selectedCategory : provider.selectedCountry,
|
||||
countries: countries,
|
||||
selectedCountry: provider.selectedCategory.isNotEmpty
|
||||
? provider.selectedCategory
|
||||
: provider.selectedCountry,
|
||||
onCountrySelected: (country) => provider.filterByCountry(country),
|
||||
isLoading: provider.isLoading,
|
||||
isOrganizing: provider.isOrganizingCountries,
|
||||
@@ -699,7 +770,10 @@ class _ContentListScreenState extends State<ContentListScreen> {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CircularProgressIndicator(color: Colors.red, strokeWidth: _isLargeScreen ? 4 : 2),
|
||||
CircularProgressIndicator(
|
||||
color: Colors.red,
|
||||
strokeWidth: _isLargeScreen ? 4 : 2,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (provider.totalChannels > 0)
|
||||
Text(
|
||||
@@ -724,7 +798,9 @@ class _ContentListScreenState extends State<ContentListScreen> {
|
||||
child: LinearProgressIndicator(
|
||||
value: provider.loadingProgress,
|
||||
backgroundColor: Colors.grey[800],
|
||||
valueColor: const AlwaysStoppedAnimation<Color>(Colors.red),
|
||||
valueColor: const AlwaysStoppedAnimation<Color>(
|
||||
Colors.red,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -732,46 +808,26 @@ class _ContentListScreenState extends State<ContentListScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
List<XtreamStream> streams = [];
|
||||
if (widget.type == ContentType.live) {
|
||||
streams = provider.filteredLiveStreams;
|
||||
} else if (widget.type == ContentType.movies) {
|
||||
streams = provider.vodStreams;
|
||||
} else {
|
||||
streams = provider.seriesList.map((s) => XtreamStream(
|
||||
streamId: s.seriesId,
|
||||
name: s.name,
|
||||
streamIcon: s.cover,
|
||||
plot: s.plot,
|
||||
rating: s.rating,
|
||||
)).toList();
|
||||
}
|
||||
|
||||
if (_searchQuery.isNotEmpty) {
|
||||
// Special case: "arg|" prefix search - exact pattern match for "arg|" in channel name
|
||||
if (_searchQuery.toLowerCase() == 'arg|') {
|
||||
streams = streams
|
||||
.where((s) => s.name.toLowerCase().contains('arg|'))
|
||||
.toList();
|
||||
} else {
|
||||
// Normal search - contains query anywhere in name
|
||||
streams = streams
|
||||
.where((s) => s.name.toLowerCase().contains(_searchQuery.toLowerCase()))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
final baseStreams = _buildStreamsForType(provider);
|
||||
final streams = _applySearchFilter(baseStreams);
|
||||
|
||||
if (streams.isEmpty) {
|
||||
return Center(
|
||||
child: Text(
|
||||
_searchQuery.isNotEmpty ? 'No se encontraron resultados' : 'Sin contenido',
|
||||
style: TextStyle(color: Colors.grey, fontSize: _isLargeScreen ? 20 : 16),
|
||||
_searchQuery.isNotEmpty
|
||||
? 'No se encontraron resultados'
|
||||
: 'Sin contenido',
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: _isLargeScreen ? 20 : 16,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return GridView.builder(
|
||||
padding: EdgeInsets.all(padding),
|
||||
cacheExtent: _isLargeScreen ? 1600 : 1100,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: _gridCrossAxisCount,
|
||||
childAspectRatio: 16 / 9,
|
||||
@@ -890,73 +946,82 @@ class _ChannelCardState extends State<_ChannelCard> {
|
||||
: null,
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
if (widget.stream.streamIcon != null && widget.stream.streamIcon!.isNotEmpty)
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Image.network(
|
||||
widget.stream.streamIcon!,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (_, __, ___) => _buildPlaceholder(placeholderIconSize),
|
||||
),
|
||||
)
|
||||
else
|
||||
_buildPlaceholder(placeholderIconSize),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.transparent,
|
||||
Colors.black.withValues(alpha: 0.8),
|
||||
],
|
||||
),
|
||||
),
|
||||
children: [
|
||||
if (widget.stream.streamIcon != null &&
|
||||
widget.stream.streamIcon!.isNotEmpty)
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
child: Image.network(
|
||||
widget.stream.streamIcon!,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
fit: BoxFit.cover,
|
||||
cacheWidth: widget.isLarge ? 512 : 384,
|
||||
cacheHeight: widget.isLarge ? 288 : 216,
|
||||
filterQuality: FilterQuality.low,
|
||||
gaplessPlayback: false,
|
||||
errorBuilder: (context, error, stackTrace) =>
|
||||
_buildPlaceholder(placeholderIconSize),
|
||||
),
|
||||
Positioned(
|
||||
bottom: padding,
|
||||
left: padding,
|
||||
right: padding,
|
||||
child: Text(
|
||||
widget.stream.name,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: textSize,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
)
|
||||
else
|
||||
_buildPlaceholder(placeholderIconSize),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.transparent,
|
||||
Colors.black.withValues(alpha: 0.8),
|
||||
],
|
||||
),
|
||||
if (widget.stream.rating != null)
|
||||
Positioned(
|
||||
top: padding,
|
||||
right: padding,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: ratingPaddingH, vertical: ratingPaddingV),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.amber,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
widget.stream.rating!,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: ratingFontSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: padding,
|
||||
left: padding,
|
||||
right: padding,
|
||||
child: Text(
|
||||
widget.stream.name,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: textSize,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
if (widget.stream.rating != null)
|
||||
Positioned(
|
||||
top: padding,
|
||||
right: padding,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: ratingPaddingH,
|
||||
vertical: ratingPaddingV,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.amber,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(
|
||||
widget.stream.rating!,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: ratingFontSize,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPlaceholder(double iconSize) {
|
||||
@@ -1009,7 +1074,11 @@ class _SeriesEpisodesScreenState extends State<SeriesEpisodesScreen> {
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: Colors.white, size: iconSize),
|
||||
icon: Icon(
|
||||
Icons.arrow_back,
|
||||
color: Colors.white,
|
||||
size: iconSize,
|
||||
),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
iconSize: 48,
|
||||
padding: EdgeInsets.all(_isLargeScreen ? 12 : 8),
|
||||
@@ -1035,7 +1104,10 @@ class _SeriesEpisodesScreenState extends State<SeriesEpisodesScreen> {
|
||||
builder: (context, provider, _) {
|
||||
if (provider.isLoading) {
|
||||
return Center(
|
||||
child: CircularProgressIndicator(color: Colors.red, strokeWidth: _isLargeScreen ? 4 : 2),
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.red,
|
||||
strokeWidth: _isLargeScreen ? 4 : 2,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1044,7 +1116,10 @@ class _SeriesEpisodesScreenState extends State<SeriesEpisodesScreen> {
|
||||
return Center(
|
||||
child: Text(
|
||||
'No hay episodios',
|
||||
style: TextStyle(color: Colors.grey, fontSize: _isLargeScreen ? 20 : 16),
|
||||
style: TextStyle(
|
||||
color: Colors.grey,
|
||||
fontSize: _isLargeScreen ? 20 : 16,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1056,9 +1131,13 @@ class _SeriesEpisodesScreenState extends State<SeriesEpisodesScreen> {
|
||||
final episode = episodes[index];
|
||||
return Card(
|
||||
color: Colors.grey[900],
|
||||
margin: EdgeInsets.only(bottom: _isLargeScreen ? 16 : 8),
|
||||
margin: EdgeInsets.only(
|
||||
bottom: _isLargeScreen ? 16 : 8,
|
||||
),
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.all(_isLargeScreen ? 16 : 12),
|
||||
contentPadding: EdgeInsets.all(
|
||||
_isLargeScreen ? 16 : 12,
|
||||
),
|
||||
leading: Icon(
|
||||
Icons.play_circle_fill,
|
||||
color: Colors.red,
|
||||
@@ -1066,7 +1145,10 @@ class _SeriesEpisodesScreenState extends State<SeriesEpisodesScreen> {
|
||||
),
|
||||
title: Text(
|
||||
'S${episode.seasonNumber}E${episode.episodeNumber} - ${episode.title}',
|
||||
style: TextStyle(color: Colors.white, fontSize: _isLargeScreen ? 20 : 16),
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: _isLargeScreen ? 20 : 16,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
@@ -1076,7 +1158,8 @@ class _SeriesEpisodesScreenState extends State<SeriesEpisodesScreen> {
|
||||
stream: XtreamStream(
|
||||
streamId: episode.episodeId,
|
||||
name: episode.title,
|
||||
containerExtension: episode.containerExtension,
|
||||
containerExtension:
|
||||
episode.containerExtension,
|
||||
url: episode.url,
|
||||
),
|
||||
isLive: false,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:chewie/chewie.dart';
|
||||
import '../models/xtream_models.dart';
|
||||
@@ -8,18 +7,14 @@ class PlayerScreen extends StatefulWidget {
|
||||
final XtreamStream stream;
|
||||
final bool isLive;
|
||||
|
||||
const PlayerScreen({
|
||||
super.key,
|
||||
required this.stream,
|
||||
this.isLive = true,
|
||||
});
|
||||
const PlayerScreen({super.key, required this.stream, this.isLive = true});
|
||||
|
||||
@override
|
||||
State<PlayerScreen> createState() => _PlayerScreenState();
|
||||
}
|
||||
|
||||
class _PlayerScreenState extends State<PlayerScreen> {
|
||||
late VideoPlayerController _videoController;
|
||||
VideoPlayerController? _videoController;
|
||||
ChewieController? _chewieController;
|
||||
bool _isLoading = true;
|
||||
String? _error;
|
||||
@@ -32,20 +27,32 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
||||
|
||||
Future<void> _initPlayer() async {
|
||||
try {
|
||||
_chewieController?.dispose();
|
||||
_chewieController = null;
|
||||
await _videoController?.dispose();
|
||||
_videoController = null;
|
||||
|
||||
final url = widget.stream.url;
|
||||
if (url == null || url.isEmpty) {
|
||||
throw Exception('No stream URL available');
|
||||
}
|
||||
|
||||
_videoController = VideoPlayerController.networkUrl(Uri.parse(url));
|
||||
|
||||
await _videoController.initialize();
|
||||
final videoController = VideoPlayerController.networkUrl(
|
||||
Uri.parse(url),
|
||||
videoPlayerOptions: VideoPlayerOptions(
|
||||
allowBackgroundPlayback: false,
|
||||
mixWithOthers: false,
|
||||
),
|
||||
);
|
||||
|
||||
await videoController.initialize();
|
||||
_videoController = videoController;
|
||||
|
||||
_chewieController = ChewieController(
|
||||
videoPlayerController: _videoController,
|
||||
videoPlayerController: videoController,
|
||||
autoPlay: true,
|
||||
looping: widget.isLive,
|
||||
aspectRatio: _videoController.value.aspectRatio,
|
||||
aspectRatio: videoController.value.aspectRatio,
|
||||
allowFullScreen: true,
|
||||
allowMuting: true,
|
||||
showControls: true,
|
||||
@@ -76,10 +83,6 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
|
||||
_videoController.addListener(() {
|
||||
setState(() {});
|
||||
});
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
_error = e.toString();
|
||||
@@ -90,7 +93,7 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_videoController.dispose();
|
||||
_videoController?.dispose();
|
||||
_chewieController?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
@@ -112,13 +115,13 @@ class _PlayerScreenState extends State<PlayerScreen> {
|
||||
child: _isLoading
|
||||
? const CircularProgressIndicator(color: Colors.red)
|
||||
: _error != null
|
||||
? _buildError()
|
||||
: _chewieController != null
|
||||
? Chewie(controller: _chewieController!)
|
||||
: const Text(
|
||||
'No video available',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
? _buildError()
|
||||
: _chewieController != null
|
||||
? Chewie(controller: _chewieController!)
|
||||
: const Text(
|
||||
'No video available',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,43 +30,44 @@ class IPTVProvider extends ChangeNotifier {
|
||||
List<XtreamEpisode> _seriesEpisodes = [];
|
||||
|
||||
String _selectedLiveCategory = '';
|
||||
String _selectedVodCategory = '';
|
||||
String _selectedCountry = '';
|
||||
String _selectedCategory = ''; // For special categories like "Fútbol Argentino"
|
||||
String _selectedCategory =
|
||||
''; // For special categories like "Fútbol Argentino"
|
||||
List<String> _countries = [];
|
||||
bool _isOrganizingCountries = false;
|
||||
XtreamSeries? _selectedSeries;
|
||||
|
||||
Map<String, String>? _categoryToCountryMapCache;
|
||||
List<XtreamStream>? _filteredLiveStreamsCache;
|
||||
String _filteredCountryCacheKey = '';
|
||||
String _filteredCategoryCacheKey = '';
|
||||
int _liveStreamsVersion = 0;
|
||||
int _filteredCacheVersion = -1;
|
||||
int _lastProgressUiUpdateMs = 0;
|
||||
|
||||
bool get isLoading => _isLoading;
|
||||
String? get error => _error;
|
||||
XtreamUserInfo? get userInfo => _userInfo;
|
||||
XtreamApiService get api => _api;
|
||||
int get loadedChannels => _loadedChannels;
|
||||
int get totalChannels => _totalChannels;
|
||||
double get loadingProgress => _totalChannels > 0 ? _loadedChannels / _totalChannels : 0.0;
|
||||
double get loadingProgress =>
|
||||
_totalChannels > 0 ? _loadedChannels / _totalChannels : 0.0;
|
||||
bool get isOrganizingCountries => _isOrganizingCountries;
|
||||
|
||||
|
||||
List<XtreamCategory> get liveCategories => _liveCategories;
|
||||
List<XtreamCategory> get vodCategories => _vodCategories;
|
||||
List<XtreamCategory> get seriesCategories => _seriesCategories;
|
||||
|
||||
|
||||
List<XtreamStream> get liveStreams => _liveStreams;
|
||||
List<XtreamStream> get vodStreams => _vodStreams;
|
||||
List<XtreamSeries> get seriesList => _seriesList;
|
||||
List<XtreamEpisode> get seriesEpisodes => _seriesEpisodes;
|
||||
|
||||
|
||||
String get selectedLiveCategory => _selectedLiveCategory;
|
||||
String get selectedCountry => _selectedCountry;
|
||||
String get selectedCategory => _selectedCategory;
|
||||
List<String> get countries {
|
||||
print('DEBUG: =========================================');
|
||||
print('DEBUG: countries getter called');
|
||||
print('DEBUG: _countries list length: ${_countries.length}');
|
||||
print('DEBUG: _countries list content: $_countries');
|
||||
print('DEBUG: _countries is empty: ${_countries.isEmpty}');
|
||||
print('DEBUG: =========================================');
|
||||
return _countries;
|
||||
}
|
||||
List<String> get countries => _countries;
|
||||
|
||||
/// Get display items for sidebar including special categories
|
||||
/// Returns a list of maps with 'name', 'type', and 'priority' for proper ordering
|
||||
@@ -76,27 +77,28 @@ class IPTVProvider extends ChangeNotifier {
|
||||
// Add all countries with their priority
|
||||
for (final country in _countries) {
|
||||
int priority = _getCountryPriority(country);
|
||||
items.add({
|
||||
'name': country,
|
||||
'type': 'country',
|
||||
'priority': priority,
|
||||
});
|
||||
items.add({'name': country, 'type': 'country', 'priority': priority});
|
||||
}
|
||||
|
||||
// Add special category: Fútbol Argentino (priority 2.5 - between Perú and other countries)
|
||||
// Only add if there are any Argentine football channels
|
||||
final hasArgentineFootball = _liveStreams.any((s) => _api.isArgentineFootballChannel(s.name));
|
||||
final hasArgentineFootball = _liveStreams.any(
|
||||
(s) => _api.isArgentineFootballChannel(s.name),
|
||||
);
|
||||
if (hasArgentineFootball) {
|
||||
items.add({
|
||||
'name': SpecialCategories.argentineFootball,
|
||||
'type': 'category',
|
||||
'priority': 2.5, // Between Perú (2) and other South American countries (3)
|
||||
'priority':
|
||||
2.5, // Between Perú (2) and other South American countries (3)
|
||||
});
|
||||
}
|
||||
|
||||
// Sort by priority, then alphabetically
|
||||
items.sort((a, b) {
|
||||
final priorityCompare = (a['priority'] as double).compareTo(b['priority'] as double);
|
||||
final priorityCompare = (a['priority'] as double).compareTo(
|
||||
b['priority'] as double,
|
||||
);
|
||||
if (priorityCompare != 0) return priorityCompare;
|
||||
return (a['name'] as String).compareTo(b['name'] as String);
|
||||
});
|
||||
@@ -126,8 +128,33 @@ class IPTVProvider extends ChangeNotifier {
|
||||
return 100; // Low priority for other countries
|
||||
}
|
||||
}
|
||||
|
||||
XtreamSeries? get selectedSeries => _selectedSeries;
|
||||
|
||||
void _invalidateLiveDerivedCaches() {
|
||||
_categoryToCountryMapCache = null;
|
||||
_filteredLiveStreamsCache = null;
|
||||
_filteredCacheVersion = -1;
|
||||
}
|
||||
|
||||
void _setLiveStreams(List<XtreamStream> streams, String categoryId) {
|
||||
_liveStreams = streams;
|
||||
_selectedLiveCategory = categoryId;
|
||||
_liveStreamsVersion++;
|
||||
_invalidateLiveDerivedCaches();
|
||||
}
|
||||
|
||||
void _notifyProgressUpdate() {
|
||||
final nowMs = DateTime.now().millisecondsSinceEpoch;
|
||||
final shouldUpdate =
|
||||
(nowMs - _lastProgressUiUpdateMs) >= 120 ||
|
||||
(_totalChannels > 0 && _loadedChannels >= _totalChannels);
|
||||
if (shouldUpdate) {
|
||||
_lastProgressUiUpdateMs = nowMs;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> login(String server, String username, String password) async {
|
||||
_isLoading = true;
|
||||
_error = null;
|
||||
@@ -136,9 +163,9 @@ class IPTVProvider extends ChangeNotifier {
|
||||
try {
|
||||
_api.setCredentials(server, username, password);
|
||||
_userInfo = await _api.getUserInfo();
|
||||
|
||||
|
||||
// No automatic data loading on startup - data loads on demand only
|
||||
|
||||
|
||||
await _saveCredentials(server, username, password);
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
@@ -148,140 +175,144 @@ class IPTVProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> _loadCategories() async {
|
||||
try {
|
||||
_liveCategories = await _api.getLiveCategories();
|
||||
_vodCategories = await _api.getVodCategories();
|
||||
_seriesCategories = await _api.getSeriesCategories();
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> loadLiveStreams([String categoryId = '']) async {
|
||||
print('DEBUG: =========================================================');
|
||||
print('DEBUG: loadLiveStreams() START - API First Strategy');
|
||||
print('DEBUG: =========================================================');
|
||||
_isLoading = true;
|
||||
_isOrganizingCountries = false;
|
||||
_loadedChannels = 0;
|
||||
_totalChannels = 0;
|
||||
_countries = [];
|
||||
_lastProgressUiUpdateMs = 0;
|
||||
_invalidateLiveDerivedCaches();
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
// STEP 1: Load from API first (much faster than M3U)
|
||||
print('DEBUG: Attempting to load from API first...');
|
||||
|
||||
|
||||
try {
|
||||
_liveStreams = await _api.getLiveStreams(categoryId);
|
||||
_selectedLiveCategory = categoryId;
|
||||
_setLiveStreams(await _api.getLiveStreams(categoryId), categoryId);
|
||||
_totalChannels = _liveStreams.length;
|
||||
_loadedChannels = _liveStreams.length;
|
||||
print('DEBUG: API SUCCESS - Loaded ${_liveStreams.length} streams in < 5 seconds');
|
||||
|
||||
|
||||
if (_liveStreams.isEmpty) {
|
||||
throw Exception('API returned 0 streams');
|
||||
}
|
||||
} catch (apiError) {
|
||||
print('DEBUG: API failed: $apiError');
|
||||
print('DEBUG: Falling back to M3U...');
|
||||
|
||||
// Fallback to M3U only if API fails
|
||||
_liveStreams = await _api.getM3UStreams(
|
||||
onProgress: (loaded, total) {
|
||||
_loadedChannels = loaded;
|
||||
_totalChannels = total;
|
||||
print('DEBUG: M3U progress: $loaded of $total');
|
||||
notifyListeners();
|
||||
},
|
||||
_setLiveStreams(
|
||||
await _api.getM3UStreams(
|
||||
onProgress: (loaded, total) {
|
||||
_loadedChannels = loaded;
|
||||
_totalChannels = total;
|
||||
_notifyProgressUpdate();
|
||||
},
|
||||
),
|
||||
categoryId,
|
||||
);
|
||||
_selectedLiveCategory = categoryId;
|
||||
print('DEBUG: M3U FALLBACK - Loaded ${_liveStreams.length} streams');
|
||||
|
||||
|
||||
if (_liveStreams.isEmpty) {
|
||||
throw Exception('No channels available from API or M3U');
|
||||
}
|
||||
}
|
||||
|
||||
// STEP 2: Mark loading complete - channels ready to display
|
||||
print('DEBUG: === CHANNELS READY - Starting background country extraction ===');
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
|
||||
|
||||
// STEP 3: Extract countries in background (using optimized method)
|
||||
_extractCountriesInBackground();
|
||||
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
print('DEBUG: ERROR loading streams: $e');
|
||||
}
|
||||
|
||||
print('DEBUG: =========================================================');
|
||||
print('DEBUG: loadLiveStreams() END - Loaded ${_liveStreams.length} channels');
|
||||
print('DEBUG: =========================================================');
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
/// Extract countries from streams in the background to avoid UI freezing
|
||||
void _extractCountriesInBackground() {
|
||||
if (_liveStreams.isEmpty) return;
|
||||
|
||||
|
||||
_isOrganizingCountries = true;
|
||||
notifyListeners();
|
||||
|
||||
print('DEBUG: Starting background country extraction from ${_liveStreams.length} streams...');
|
||||
|
||||
|
||||
// Use Future.microtask to schedule the extraction after the current frame
|
||||
Future.microtask(() {
|
||||
try {
|
||||
// Use optimized extraction (only sample 2000 channels for speed)
|
||||
_countries = _api.getCountriesOptimized(_liveStreams, maxChannelsToProcess: 2000);
|
||||
print('DEBUG: Countries extraction complete. Found ${_countries.length} countries');
|
||||
print('DEBUG: Countries list: $_countries');
|
||||
_countries = _api.getCountriesOptimized(
|
||||
_liveStreams,
|
||||
maxChannelsToProcess: 2000,
|
||||
);
|
||||
} catch (e) {
|
||||
print('DEBUG: Error extracting countries: $e');
|
||||
_countries = [];
|
||||
} finally {
|
||||
_isOrganizingCountries = false;
|
||||
print('DEBUG: === CHANNEL LOADING COMPLETE ===');
|
||||
notifyListeners();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Extract country names from live categories (format: "Country|XX")
|
||||
List<String> _extractCountriesFromCategories() {
|
||||
final countries = <String>{};
|
||||
for (final category in _liveCategories) {
|
||||
final countryName = category.name.split('|').first.trim();
|
||||
// Only add if it's a valid country (not a group title)
|
||||
if (countryName.isNotEmpty && !_isGroupTitle(countryName)) {
|
||||
countries.add(countryName);
|
||||
}
|
||||
}
|
||||
return countries.toList()..sort();
|
||||
}
|
||||
|
||||
/// Check if a string is a group title (not a country)
|
||||
bool _isGroupTitle(String name) {
|
||||
final normalized = name.toLowerCase().trim();
|
||||
final groupTitles = {
|
||||
'24/7', '24/7 ar', '24/7 in', '24/7-es', '24/7-de', '24/7-gr',
|
||||
'24/7-my', '24/7-pt', '24/7-ro', '24/7-tr', '24/7-latino',
|
||||
'vip', 'vip - pk', 'ppv', 'movies', 'cine', 'cine sd',
|
||||
'cine y serie', 'latino', 'general', 'music', 'religious',
|
||||
'bein', 'mbc', 'tod', 'osn', 'myhd', 'dstv', 'art',
|
||||
'icc-ca', 'icc-car', 'icc-dstv', 'icc-in', 'icc-nz',
|
||||
'icc-pk', 'icc-uk', 'xmas', 'sin', 'ezd', 'exyu', 'rot',
|
||||
'ar-kids', 'ar-sp', 'islam', 'bab', 'as', 'ei'
|
||||
'24/7',
|
||||
'24/7 ar',
|
||||
'24/7 in',
|
||||
'24/7-es',
|
||||
'24/7-de',
|
||||
'24/7-gr',
|
||||
'24/7-my',
|
||||
'24/7-pt',
|
||||
'24/7-ro',
|
||||
'24/7-tr',
|
||||
'24/7-latino',
|
||||
'vip',
|
||||
'vip - pk',
|
||||
'ppv',
|
||||
'movies',
|
||||
'cine',
|
||||
'cine sd',
|
||||
'cine y serie',
|
||||
'latino',
|
||||
'general',
|
||||
'music',
|
||||
'religious',
|
||||
'bein',
|
||||
'mbc',
|
||||
'tod',
|
||||
'osn',
|
||||
'myhd',
|
||||
'dstv',
|
||||
'art',
|
||||
'icc-ca',
|
||||
'icc-car',
|
||||
'icc-dstv',
|
||||
'icc-in',
|
||||
'icc-nz',
|
||||
'icc-pk',
|
||||
'icc-uk',
|
||||
'xmas',
|
||||
'sin',
|
||||
'ezd',
|
||||
'exyu',
|
||||
'rot',
|
||||
'ar-kids',
|
||||
'ar-sp',
|
||||
'islam',
|
||||
'bab',
|
||||
'as',
|
||||
'ei',
|
||||
};
|
||||
return groupTitles.contains(normalized);
|
||||
}
|
||||
|
||||
// Build a map from category ID to country name for API streams
|
||||
Map<String, String> _buildCategoryToCountryMap() {
|
||||
if (_categoryToCountryMapCache != null) {
|
||||
return _categoryToCountryMapCache!;
|
||||
}
|
||||
|
||||
final map = <String, String>{};
|
||||
for (final category in _liveCategories) {
|
||||
final countryName = category.name.split('|').first.trim();
|
||||
@@ -290,41 +321,68 @@ class IPTVProvider extends ChangeNotifier {
|
||||
map[category.id] = countryName;
|
||||
}
|
||||
}
|
||||
print('DEBUG: Built category map with ${map.length} entries');
|
||||
_categoryToCountryMapCache = map;
|
||||
return map;
|
||||
}
|
||||
|
||||
void filterByCountry(String country) {
|
||||
_selectedCountry = country.trim();
|
||||
final normalizedCountry = country.trim();
|
||||
if (_selectedCountry == normalizedCountry && _selectedCategory.isEmpty) {
|
||||
return;
|
||||
}
|
||||
_selectedCountry = normalizedCountry;
|
||||
_selectedCategory = ''; // Clear special category when country is selected
|
||||
print('DEBUG: Filter by country: "$_selectedCountry"');
|
||||
_filteredLiveStreamsCache = null;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void filterByCategory(String category) {
|
||||
_selectedCategory = category.trim();
|
||||
final normalizedCategory = category.trim();
|
||||
if (_selectedCategory == normalizedCategory && _selectedCountry.isEmpty) {
|
||||
return;
|
||||
}
|
||||
_selectedCategory = normalizedCategory;
|
||||
_selectedCountry = ''; // Clear country when special category is selected
|
||||
print('DEBUG: Filter by category: "$_selectedCategory"');
|
||||
_filteredLiveStreamsCache = null;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
List<XtreamStream> get filteredLiveStreams {
|
||||
// If a special category is selected, filter by that
|
||||
if (_selectedCategory.isNotEmpty) {
|
||||
print('DEBUG: Filtering by special category: "$_selectedCategory"');
|
||||
return _api.filterByCategory(_liveStreams, _selectedCategory);
|
||||
final selectedCountry = _selectedCountry.trim();
|
||||
final selectedCategory = _selectedCategory.trim();
|
||||
if (_filteredLiveStreamsCache != null &&
|
||||
_filteredCacheVersion == _liveStreamsVersion &&
|
||||
_filteredCountryCacheKey == selectedCountry &&
|
||||
_filteredCategoryCacheKey == selectedCategory) {
|
||||
return _filteredLiveStreamsCache!;
|
||||
}
|
||||
|
||||
// Show all if empty or "Todos"/"All" selected
|
||||
final normalizedCountry = _selectedCountry.trim();
|
||||
if (normalizedCountry.isEmpty ||
|
||||
normalizedCountry.toLowerCase() == 'todos' ||
|
||||
normalizedCountry.toLowerCase() == 'all') {
|
||||
return _liveStreams;
|
||||
late final List<XtreamStream> result;
|
||||
|
||||
// If a special category is selected, filter by that
|
||||
if (selectedCategory.isNotEmpty) {
|
||||
result = _api.filterByCategory(_liveStreams, selectedCategory);
|
||||
} else if (selectedCountry.isEmpty ||
|
||||
selectedCountry.toLowerCase() == 'todos' ||
|
||||
selectedCountry.toLowerCase() == 'all') {
|
||||
result = _liveStreams;
|
||||
} else {
|
||||
// Build category map for API streams that don't have country in name
|
||||
final categoryMap = _buildCategoryToCountryMap();
|
||||
result = _api.filterByCountry(
|
||||
_liveStreams,
|
||||
selectedCountry,
|
||||
categoryToCountryMap: categoryMap,
|
||||
);
|
||||
}
|
||||
// Build category map for API streams that don't have country in name
|
||||
final categoryMap = _buildCategoryToCountryMap();
|
||||
return _api.filterByCountry(_liveStreams, _selectedCountry, categoryToCountryMap: categoryMap);
|
||||
|
||||
_filteredCountryCacheKey = selectedCountry;
|
||||
_filteredCategoryCacheKey = selectedCategory;
|
||||
_filteredCacheVersion = _liveStreamsVersion;
|
||||
_filteredLiveStreamsCache = identical(result, _liveStreams)
|
||||
? _liveStreams
|
||||
: List.unmodifiable(result);
|
||||
return _filteredLiveStreamsCache!;
|
||||
}
|
||||
|
||||
Future<void> loadVodStreams([String categoryId = '']) async {
|
||||
@@ -333,7 +391,6 @@ class IPTVProvider extends ChangeNotifier {
|
||||
|
||||
try {
|
||||
_vodStreams = await _api.getVodStreams(categoryId);
|
||||
_selectedVodCategory = categoryId;
|
||||
} catch (e) {
|
||||
_error = e.toString();
|
||||
}
|
||||
@@ -378,40 +435,36 @@ class IPTVProvider extends ChangeNotifier {
|
||||
_loadedChannels = 0;
|
||||
_totalChannels = 0;
|
||||
_countries = [];
|
||||
_lastProgressUiUpdateMs = 0;
|
||||
_invalidateLiveDerivedCaches();
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
// Try API first, then M3U fallback
|
||||
try {
|
||||
print('DEBUG: Attempting to reload from API...');
|
||||
_liveStreams = await _api.getLiveStreams('');
|
||||
_setLiveStreams(await _api.getLiveStreams(''), '');
|
||||
_totalChannels = _liveStreams.length;
|
||||
_loadedChannels = _liveStreams.length;
|
||||
print('DEBUG: API reload - Loaded ${_liveStreams.length} streams');
|
||||
} catch (apiError) {
|
||||
print('DEBUG: API reload failed: $apiError');
|
||||
print('DEBUG: Falling back to M3U...');
|
||||
|
||||
_liveStreams = await _api.getM3UStreams(
|
||||
onProgress: (loaded, total) {
|
||||
_loadedChannels = loaded;
|
||||
_totalChannels = total;
|
||||
print('DEBUG: M3U progress: $loaded of $total');
|
||||
notifyListeners();
|
||||
},
|
||||
_setLiveStreams(
|
||||
await _api.getM3UStreams(
|
||||
onProgress: (loaded, total) {
|
||||
_loadedChannels = loaded;
|
||||
_totalChannels = total;
|
||||
_notifyProgressUpdate();
|
||||
},
|
||||
),
|
||||
'',
|
||||
);
|
||||
print('DEBUG: M3U reload - Loaded ${_liveStreams.length} streams');
|
||||
}
|
||||
|
||||
|
||||
// Mark loading as complete - channels are ready to display
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
|
||||
|
||||
// Extract countries in background (optimized)
|
||||
_extractCountriesInBackground();
|
||||
|
||||
} catch (e) {
|
||||
print('DEBUG: Error reloading channels: $e');
|
||||
_error = 'Error al cargar canales: $e';
|
||||
_isLoading = false;
|
||||
_isOrganizingCountries = false;
|
||||
@@ -427,20 +480,20 @@ class IPTVProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
print('DEBUG: Starting M3U download and JSON conversion...');
|
||||
|
||||
// If we already have streams loaded, save those instead of downloading again
|
||||
if (_liveStreams.isNotEmpty) {
|
||||
print('DEBUG: Using already loaded ${_liveStreams.length} streams');
|
||||
|
||||
// Create M3U result from loaded streams
|
||||
final channels = _liveStreams.map((stream) => M3UChannel(
|
||||
name: stream.name,
|
||||
url: stream.url ?? '',
|
||||
groupTitle: stream.plot ?? 'Unknown',
|
||||
tvgLogo: stream.streamIcon,
|
||||
)).toList();
|
||||
|
||||
final channels = _liveStreams
|
||||
.map(
|
||||
(stream) => M3UChannel(
|
||||
name: stream.name,
|
||||
url: stream.url ?? '',
|
||||
groupTitle: stream.plot ?? 'Unknown',
|
||||
tvgLogo: stream.streamIcon,
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
|
||||
final result = M3UDownloadResult(
|
||||
sourceUrl: '${_api.server}/get.php',
|
||||
downloadTime: DateTime.now(),
|
||||
@@ -448,40 +501,34 @@ class IPTVProvider extends ChangeNotifier {
|
||||
groupsCount: _groupChannelsByCountry(channels),
|
||||
channels: channels,
|
||||
);
|
||||
|
||||
|
||||
// Save as JSON file
|
||||
final filePath = await _api.saveM3UAsJson(result);
|
||||
print('DEBUG: Saved JSON to: $filePath');
|
||||
|
||||
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
|
||||
|
||||
return filePath;
|
||||
}
|
||||
|
||||
|
||||
// If no streams loaded, try to download
|
||||
print('DEBUG: No streams loaded, attempting download...');
|
||||
final result = await _api.downloadM3UAsJson();
|
||||
print('DEBUG: Downloaded ${result.totalChannels} channels from ${result.sourceUrl}');
|
||||
print('DEBUG: Groups found: ${result.groupsCount}');
|
||||
|
||||
|
||||
// Save as JSON file
|
||||
final filePath = await _api.saveM3UAsJson(result);
|
||||
print('DEBUG: Saved JSON to: $filePath');
|
||||
|
||||
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
|
||||
|
||||
return filePath;
|
||||
} catch (e) {
|
||||
print('DEBUG: Error downloading/saving M3U as JSON: $e');
|
||||
_error = 'Error al descargar playlist: $e';
|
||||
_isLoading = false;
|
||||
notifyListeners();
|
||||
throw Exception(_error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Map<String, int> _groupChannelsByCountry(List<M3UChannel> channels) {
|
||||
final groups = <String, int>{};
|
||||
for (final channel in channels) {
|
||||
@@ -494,8 +541,6 @@ class IPTVProvider extends ChangeNotifier {
|
||||
/// Saves all loaded live channels as a text file for analysis
|
||||
Future<String> saveChannelsAsText() async {
|
||||
try {
|
||||
print('DEBUG: Saving ${_liveStreams.length} channels as text file');
|
||||
|
||||
// Build text content
|
||||
final buffer = StringBuffer();
|
||||
buffer.writeln('=== XSTREAM TV - LISTA DE CANALES ===');
|
||||
@@ -517,7 +562,8 @@ class IPTVProvider extends ChangeNotifier {
|
||||
country = countryFromName;
|
||||
}
|
||||
// If not found, try category mapping (API format)
|
||||
else if (stream.categoryId != null && categoryMap.containsKey(stream.categoryId)) {
|
||||
else if (stream.categoryId != null &&
|
||||
categoryMap.containsKey(stream.categoryId)) {
|
||||
country = categoryMap[stream.categoryId];
|
||||
}
|
||||
|
||||
@@ -549,13 +595,12 @@ class IPTVProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
// Save to file
|
||||
final fileName = 'xstream_canales_${DateTime.now().millisecondsSinceEpoch}.txt';
|
||||
final fileName =
|
||||
'xstream_canales_${DateTime.now().millisecondsSinceEpoch}.txt';
|
||||
final filePath = await _api.saveTextFile(fileName, buffer.toString());
|
||||
|
||||
print('DEBUG: Saved channels list to: $filePath');
|
||||
return filePath;
|
||||
} catch (e) {
|
||||
print('DEBUG: Error saving channels as text: $e');
|
||||
throw Exception('Error al guardar lista: $e');
|
||||
}
|
||||
}
|
||||
@@ -565,7 +610,11 @@ class IPTVProvider extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> _saveCredentials(String server, String username, String password) async {
|
||||
Future<void> _saveCredentials(
|
||||
String server,
|
||||
String username,
|
||||
String password,
|
||||
) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString('server', server);
|
||||
await prefs.setString('username', username);
|
||||
@@ -599,8 +648,12 @@ class IPTVProvider extends ChangeNotifier {
|
||||
_vodStreams = [];
|
||||
_seriesList = [];
|
||||
_countries = [];
|
||||
_selectedLiveCategory = '';
|
||||
_selectedCountry = '';
|
||||
_selectedCategory = '';
|
||||
_isOrganizingCountries = false;
|
||||
_liveStreamsVersion = 0;
|
||||
_invalidateLiveDerivedCaches();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -18,10 +18,6 @@ class CountriesSidebar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('DEBUG: CountriesSidebar.build() called');
|
||||
print('DEBUG: CountriesSidebar received ${countries.length} countries: $countries');
|
||||
print('DEBUG: CountriesSidebar selectedCountry: "$selectedCountry"');
|
||||
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final isLargeScreen = screenWidth > 900;
|
||||
final sidebarWidth = isLargeScreen ? 280.0 : 220.0;
|
||||
@@ -103,46 +99,48 @@ class CountriesSidebar extends StatelessWidget {
|
||||
),
|
||||
)
|
||||
: countries.isEmpty
|
||||
? Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(horizontalPadding),
|
||||
child: Text(
|
||||
'No hay países disponibles',
|
||||
style: TextStyle(
|
||||
color: Colors.white.withValues(alpha: 0.5),
|
||||
fontSize: fontSize,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
? Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(horizontalPadding),
|
||||
child: Text(
|
||||
'No hay países disponibles',
|
||||
style: TextStyle(
|
||||
color: Colors.white.withValues(alpha: 0.5),
|
||||
fontSize: fontSize,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: EdgeInsets.symmetric(vertical: isLargeScreen ? 12 : 8),
|
||||
itemCount: countries.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return _CountryListItem(
|
||||
name: 'Todos',
|
||||
isSelected: selectedCountry.isEmpty,
|
||||
onTap: () => onCountrySelected(''),
|
||||
itemHeight: itemHeight,
|
||||
fontSize: fontSize,
|
||||
horizontalPadding: horizontalPadding,
|
||||
icon: Icons.apps,
|
||||
);
|
||||
}
|
||||
|
||||
final country = countries[index - 1];
|
||||
return _CountryListItem(
|
||||
name: country,
|
||||
isSelected: selectedCountry == country,
|
||||
onTap: () => onCountrySelected(country),
|
||||
itemHeight: itemHeight,
|
||||
fontSize: fontSize,
|
||||
horizontalPadding: horizontalPadding,
|
||||
);
|
||||
},
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: isLargeScreen ? 12 : 8,
|
||||
),
|
||||
itemCount: countries.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return _CountryListItem(
|
||||
name: 'Todos',
|
||||
isSelected: selectedCountry.isEmpty,
|
||||
onTap: () => onCountrySelected(''),
|
||||
itemHeight: itemHeight,
|
||||
fontSize: fontSize,
|
||||
horizontalPadding: horizontalPadding,
|
||||
icon: Icons.apps,
|
||||
);
|
||||
}
|
||||
|
||||
final country = countries[index - 1];
|
||||
return _CountryListItem(
|
||||
name: country,
|
||||
isSelected: selectedCountry == country,
|
||||
onTap: () => onCountrySelected(country),
|
||||
itemHeight: itemHeight,
|
||||
fontSize: fontSize,
|
||||
horizontalPadding: horizontalPadding,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -172,10 +170,7 @@ class _CountryListItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: horizontalPadding,
|
||||
vertical: 2,
|
||||
),
|
||||
padding: EdgeInsets.symmetric(horizontal: horizontalPadding, vertical: 2),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
@@ -211,7 +206,9 @@ class _CountryListItem extends StatelessWidget {
|
||||
if (icon != null) ...[
|
||||
Icon(
|
||||
icon,
|
||||
color: isSelected ? Colors.white : Colors.white.withValues(alpha: 0.6),
|
||||
color: isSelected
|
||||
? Colors.white
|
||||
: Colors.white.withValues(alpha: 0.6),
|
||||
size: fontSize + 2,
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
@@ -233,7 +230,9 @@ class _CountryListItem extends StatelessWidget {
|
||||
? Colors.white
|
||||
: Colors.white.withValues(alpha: 0.7),
|
||||
fontSize: fontSize,
|
||||
fontWeight: isSelected ? FontWeight.w600 : FontWeight.w400,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.w600
|
||||
: FontWeight.w400,
|
||||
letterSpacing: 0.3,
|
||||
),
|
||||
maxLines: 1,
|
||||
@@ -241,11 +240,7 @@ class _CountryListItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
if (isSelected)
|
||||
Icon(
|
||||
Icons.check,
|
||||
color: Colors.white,
|
||||
size: fontSize + 2,
|
||||
),
|
||||
Icon(Icons.check, color: Colors.white, size: fontSize + 2),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class SimpleCountriesSidebar extends StatelessWidget {
|
||||
final List<String> countries;
|
||||
@@ -25,21 +24,10 @@ class SimpleCountriesSidebar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('🔥 SIDEBAR BUILD ============================================');
|
||||
print('🔥 SIDEBAR BUILD - Countries count: ${countries.length}');
|
||||
print('🔥 SIDEBAR BUILD - Is Loading: $isLoading');
|
||||
print('🔥 SIDEBAR BUILD - Is Organizing: $isOrganizing');
|
||||
print('🔥 SIDEBAR BUILD - Countries list: $countries');
|
||||
print('🔥 SIDEBAR BUILD - Selected country: "$selectedCountry"');
|
||||
|
||||
if (countries.isNotEmpty) {
|
||||
print('🔥 SIDEBAR BUILD - First 10 countries:');
|
||||
for (int i = 0; i < countries.length && i < 10; i++) {
|
||||
print('🔥 SIDEBAR BUILD [${i + 1}] "${countries[i]}"');
|
||||
}
|
||||
for (int i = 0; i < countries.length && i < 10; i++) {}
|
||||
}
|
||||
print('🔥 SIDEBAR BUILD ============================================');
|
||||
|
||||
|
||||
return Container(
|
||||
width: 250,
|
||||
color: Colors.grey[900],
|
||||
@@ -64,7 +52,7 @@ class SimpleCountriesSidebar extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
// List
|
||||
Expanded(
|
||||
child: isOrganizing || (isLoading && countries.isEmpty)
|
||||
@@ -82,25 +70,25 @@ class SimpleCountriesSidebar extends StatelessWidget {
|
||||
),
|
||||
)
|
||||
: countries.isEmpty
|
||||
? const Center(
|
||||
child: Text(
|
||||
'No hay países',
|
||||
style: TextStyle(color: Colors.white54),
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: _getItemCount(),
|
||||
itemBuilder: (context, index) {
|
||||
return _buildItemAtIndex(context, index);
|
||||
},
|
||||
),
|
||||
? const Center(
|
||||
child: Text(
|
||||
'No hay países',
|
||||
style: TextStyle(color: Colors.white54),
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: _getItemCount(),
|
||||
itemBuilder: (context, index) {
|
||||
return _buildItemAtIndex(context, index);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Widget _buildCountryItem(String name, bool isSelected, VoidCallback onTap) {
|
||||
return FocusableActionDetector(
|
||||
actions: <Type, Action<Intent>>{
|
||||
@@ -125,10 +113,16 @@ class SimpleCountriesSidebar extends StatelessWidget {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? Colors.red : (hasFocus ? Colors.red.withValues(alpha: 0.5) : Colors.transparent),
|
||||
color: isSelected
|
||||
? Colors.red
|
||||
: (hasFocus
|
||||
? Colors.red.withValues(alpha: 0.5)
|
||||
: Colors.transparent),
|
||||
border: Border(
|
||||
left: BorderSide(
|
||||
color: isSelected ? Colors.white : (hasFocus ? Colors.white : Colors.transparent),
|
||||
color: isSelected
|
||||
? Colors.white
|
||||
: (hasFocus ? Colors.white : Colors.transparent),
|
||||
width: 4,
|
||||
),
|
||||
),
|
||||
@@ -167,7 +161,9 @@ class SimpleCountriesSidebar extends StatelessWidget {
|
||||
|
||||
// Find insertion point for "Fútbol Argentino" (after Perú)
|
||||
final peruIndex = countries.indexOf('Perú');
|
||||
final footballInsertIndex = peruIndex >= 0 ? peruIndex + 1 : countries.length;
|
||||
final footballInsertIndex = peruIndex >= 0
|
||||
? peruIndex + 1
|
||||
: countries.length;
|
||||
|
||||
if (showFootballCategory) {
|
||||
// Adjust for "Todos" at index 0 and "Fútbol Argentino" after Perú
|
||||
@@ -231,21 +227,23 @@ class SimpleCountriesSidebar extends StatelessWidget {
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? Colors.green[700] : (hasFocus ? Colors.green[700]?.withOpacity(0.8) : Colors.green[900]?.withOpacity(0.3)),
|
||||
color: isSelected
|
||||
? Colors.green[700]
|
||||
: (hasFocus
|
||||
? Colors.green[700]?.withValues(alpha: 0.8)
|
||||
: Colors.green[900]?.withValues(alpha: 0.3)),
|
||||
border: Border(
|
||||
left: BorderSide(
|
||||
color: isSelected ? Colors.white : (hasFocus ? Colors.white : Colors.green[400]!),
|
||||
color: isSelected
|
||||
? Colors.white
|
||||
: (hasFocus ? Colors.white : Colors.green[400]!),
|
||||
width: 4,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.sports_soccer,
|
||||
color: Colors.white,
|
||||
size: 20,
|
||||
),
|
||||
Icon(Icons.sports_soccer, color: Colors.white, size: 20),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
@@ -253,7 +251,9 @@ class SimpleCountriesSidebar extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.bold
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,30 +1,21 @@
|
||||
// This is a basic Flutter widget test.
|
||||
//
|
||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
||||
// utility in the flutter_test package. For example, you can send tap and scroll
|
||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
||||
// tree, read text, and verify that the values of widget properties are correct.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:xstream_tv/main.dart';
|
||||
import 'package:xstream_tv/screens/login_screen.dart';
|
||||
import 'package:xstream_tv/services/iptv_provider.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(const MyApp());
|
||||
testWidgets('renders login screen', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
ChangeNotifierProvider(
|
||||
create: (_) => IPTVProvider(),
|
||||
child: const MaterialApp(home: LoginScreen()),
|
||||
),
|
||||
);
|
||||
|
||||
// Verify that our counter starts at 0.
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
expect(find.text('1'), findsNothing);
|
||||
|
||||
// Tap the '+' icon and trigger a frame.
|
||||
await tester.tap(find.byIcon(Icons.add));
|
||||
await tester.pump();
|
||||
|
||||
// Verify that our counter has incremented.
|
||||
expect(find.text('0'), findsNothing);
|
||||
expect(find.text('1'), findsOneWidget);
|
||||
expect(find.text('XStream TV'), findsOneWidget);
|
||||
expect(find.text('IPTV Player for Android TV'), findsOneWidget);
|
||||
expect(find.text('Login'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user