mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-19 13:08:05 +02:00
Merge pull request #32 from R0m1k3/antigravity
feat: Implement initial Xtream IPTV features including API service, m…
This commit is contained in:
8 files changed
+726
-63
No files matched your search
@@ -98,6 +98,128 @@ class Series {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Season model for series
|
||||||
|
class Season {
|
||||||
|
final int seasonNumber;
|
||||||
|
final String name;
|
||||||
|
final int episodeCount;
|
||||||
|
final String? cover;
|
||||||
|
|
||||||
|
const Season({
|
||||||
|
required this.seasonNumber,
|
||||||
|
required this.name,
|
||||||
|
required this.episodeCount,
|
||||||
|
this.cover,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Season.fromJson(Map<String, dynamic> json) {
|
||||||
|
return Season(
|
||||||
|
seasonNumber: int.tryParse(json['season_number']?.toString() ?? '1') ?? 1,
|
||||||
|
name: json['name']?.toString() ?? 'Season ${json['season_number'] ?? 1}',
|
||||||
|
episodeCount: int.tryParse(json['episode_count']?.toString() ?? '0') ?? 0,
|
||||||
|
cover: json['cover']?.toString(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Episode model for series
|
||||||
|
class Episode {
|
||||||
|
final String id;
|
||||||
|
final int episodeNum;
|
||||||
|
final String title;
|
||||||
|
final String? containerExtension;
|
||||||
|
final String? info;
|
||||||
|
final String? cover;
|
||||||
|
final int? durationSecs;
|
||||||
|
|
||||||
|
const Episode({
|
||||||
|
required this.id,
|
||||||
|
required this.episodeNum,
|
||||||
|
required this.title,
|
||||||
|
this.containerExtension,
|
||||||
|
this.info,
|
||||||
|
this.cover,
|
||||||
|
this.durationSecs,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Episode.fromJson(Map<String, dynamic> json) {
|
||||||
|
return Episode(
|
||||||
|
id: json['id']?.toString() ?? '',
|
||||||
|
episodeNum: int.tryParse(json['episode_num']?.toString() ?? '1') ?? 1,
|
||||||
|
title: json['title']?.toString() ?? 'Episode ${json['episode_num'] ?? 1}',
|
||||||
|
containerExtension: json['container_extension']?.toString() ?? 'mkv',
|
||||||
|
info: json['info']?.toString(),
|
||||||
|
cover: json['custom_cover']?.toString() ?? json['cover']?.toString(),
|
||||||
|
durationSecs: int.tryParse(json['duration_secs']?.toString() ?? '0'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String getStreamUrl(String dns, String username, String password) {
|
||||||
|
return '$dns/series/$username/$password/$id.${containerExtension ?? 'mkv'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Series info with seasons and episodes
|
||||||
|
class SeriesInfo {
|
||||||
|
final String seriesId;
|
||||||
|
final String name;
|
||||||
|
final String? cover;
|
||||||
|
final String? plot;
|
||||||
|
final String? cast;
|
||||||
|
final String? director;
|
||||||
|
final String? genre;
|
||||||
|
final String? releaseDate;
|
||||||
|
final String? rating;
|
||||||
|
final List<Season> seasons;
|
||||||
|
final Map<int, List<Episode>> episodes;
|
||||||
|
|
||||||
|
const SeriesInfo({
|
||||||
|
required this.seriesId,
|
||||||
|
required this.name,
|
||||||
|
this.cover,
|
||||||
|
this.plot,
|
||||||
|
this.cast,
|
||||||
|
this.director,
|
||||||
|
this.genre,
|
||||||
|
this.releaseDate,
|
||||||
|
this.rating,
|
||||||
|
required this.seasons,
|
||||||
|
required this.episodes,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory SeriesInfo.fromJson(Map<String, dynamic> json) {
|
||||||
|
final seasonsData = json['seasons'] as List<dynamic>? ?? [];
|
||||||
|
final seasons = seasonsData.map((s) => Season.fromJson(s as Map<String, dynamic>)).toList();
|
||||||
|
|
||||||
|
final episodesData = json['episodes'] as Map<String, dynamic>? ?? {};
|
||||||
|
final episodes = <int, List<Episode>>{};
|
||||||
|
|
||||||
|
episodesData.forEach((seasonNum, episodesList) {
|
||||||
|
final seasonInt = int.tryParse(seasonNum) ?? 1;
|
||||||
|
final episodeList = (episodesList as List<dynamic>?)
|
||||||
|
?.map((e) => Episode.fromJson(e as Map<String, dynamic>))
|
||||||
|
.toList() ?? [];
|
||||||
|
episodes[seasonInt] = episodeList;
|
||||||
|
});
|
||||||
|
|
||||||
|
final info = json['info'] as Map<String, dynamic>? ?? {};
|
||||||
|
|
||||||
|
return SeriesInfo(
|
||||||
|
seriesId: json['series_id']?.toString() ?? info['series_id']?.toString() ?? '',
|
||||||
|
name: info['name']?.toString() ?? json['name']?.toString() ?? 'Unknown',
|
||||||
|
cover: info['cover']?.toString() ?? json['cover']?.toString(),
|
||||||
|
plot: info['plot']?.toString(),
|
||||||
|
cast: info['cast']?.toString(),
|
||||||
|
director: info['director']?.toString(),
|
||||||
|
genre: info['genre']?.toString(),
|
||||||
|
releaseDate: info['releaseDate']?.toString(),
|
||||||
|
rating: info['rating']?.toString(),
|
||||||
|
seasons: seasons,
|
||||||
|
episodes: episodes,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Category {
|
class Category {
|
||||||
final String categoryId;
|
final String categoryId;
|
||||||
final String categoryName;
|
final String categoryName;
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
|
||||||
|
/// Settings state for IPTV preferences
|
||||||
|
class IptvSettings {
|
||||||
|
/// Category filter keywords (comma-separated)
|
||||||
|
/// Example: "FR,FRANCE,HD" will show only categories containing one of these words
|
||||||
|
final String categoryFilter;
|
||||||
|
|
||||||
|
const IptvSettings({
|
||||||
|
this.categoryFilter = '',
|
||||||
|
});
|
||||||
|
|
||||||
|
IptvSettings copyWith({
|
||||||
|
String? categoryFilter,
|
||||||
|
}) {
|
||||||
|
return IptvSettings(
|
||||||
|
categoryFilter: categoryFilter ?? this.categoryFilter,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get list of filter keywords (trimmed and non-empty)
|
||||||
|
List<String> get filterKeywords {
|
||||||
|
if (categoryFilter.isEmpty) return [];
|
||||||
|
return categoryFilter
|
||||||
|
.split(',')
|
||||||
|
.map((s) => s.trim().toUpperCase())
|
||||||
|
.where((s) => s.isNotEmpty)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if a category name matches the filter
|
||||||
|
/// Returns true if no filter is set or if the category contains any keyword
|
||||||
|
bool matchesFilter(String categoryName) {
|
||||||
|
final keywords = filterKeywords;
|
||||||
|
if (keywords.isEmpty) return true;
|
||||||
|
|
||||||
|
final upperName = categoryName.toUpperCase();
|
||||||
|
return keywords.any((keyword) => upperName.contains(keyword));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// IPTV Settings notifier for managing user preferences
|
||||||
|
class IptvSettingsNotifier extends StateNotifier<IptvSettings> {
|
||||||
|
IptvSettingsNotifier() : super(const IptvSettings());
|
||||||
|
|
||||||
|
void setCategoryFilter(String filter) {
|
||||||
|
state = state.copyWith(categoryFilter: filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearCategoryFilter() {
|
||||||
|
state = state.copyWith(categoryFilter: '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Provider for IPTV settings
|
||||||
|
final iptvSettingsProvider =
|
||||||
|
StateNotifierProvider<IptvSettingsNotifier, IptvSettings>((ref) {
|
||||||
|
return IptvSettingsNotifier();
|
||||||
|
});
|
||||||
@@ -0,0 +1,332 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
import '../../../core/models/playlist_config.dart';
|
||||||
|
import '../models/xtream_models.dart';
|
||||||
|
import '../providers/xtream_provider.dart';
|
||||||
|
import 'player_screen.dart';
|
||||||
|
|
||||||
|
/// Series detail screen showing seasons and episodes
|
||||||
|
class SeriesDetailScreen extends ConsumerStatefulWidget {
|
||||||
|
final Series series;
|
||||||
|
final PlaylistConfig playlist;
|
||||||
|
|
||||||
|
const SeriesDetailScreen({
|
||||||
|
super.key,
|
||||||
|
required this.series,
|
||||||
|
required this.playlist,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<SeriesDetailScreen> createState() => _SeriesDetailScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SeriesDetailScreenState extends ConsumerState<SeriesDetailScreen> {
|
||||||
|
SeriesInfo? _seriesInfo;
|
||||||
|
bool _isLoading = true;
|
||||||
|
String? _error;
|
||||||
|
int _selectedSeason = 1;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadSeriesInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadSeriesInfo() async {
|
||||||
|
try {
|
||||||
|
setState(() {
|
||||||
|
_isLoading = true;
|
||||||
|
_error = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
final service = ref.read(xtreamServiceProvider(widget.playlist));
|
||||||
|
final info = await service.getSeriesInfo(widget.series.seriesId);
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_seriesInfo = info;
|
||||||
|
_isLoading = false;
|
||||||
|
// Select first available season
|
||||||
|
if (info.episodes.isNotEmpty) {
|
||||||
|
_selectedSeason = info.episodes.keys.first;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
setState(() {
|
||||||
|
_error = e.toString();
|
||||||
|
_isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text(widget.series.name),
|
||||||
|
backgroundColor: Colors.black87,
|
||||||
|
),
|
||||||
|
backgroundColor: Colors.grey.shade900,
|
||||||
|
body: _isLoading
|
||||||
|
? const Center(child: CircularProgressIndicator())
|
||||||
|
: _error != null
|
||||||
|
? Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.error_outline, size: 48, color: Colors.red),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text('Error: $_error', style: const TextStyle(color: Colors.white70)),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _loadSeriesInfo,
|
||||||
|
child: const Text('Retry'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: _buildContent(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildContent() {
|
||||||
|
if (_seriesInfo == null) return const SizedBox.shrink();
|
||||||
|
|
||||||
|
final currentEpisodes = _seriesInfo!.episodes[_selectedSeason] ?? [];
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Left panel: Series info and season selector
|
||||||
|
SizedBox(
|
||||||
|
width: 280,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
// Cover image
|
||||||
|
if (_seriesInfo!.cover != null)
|
||||||
|
ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: CachedNetworkImage(
|
||||||
|
imageUrl: _seriesInfo!.cover!,
|
||||||
|
width: 248,
|
||||||
|
height: 350,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
errorWidget: (_, __, ___) => Container(
|
||||||
|
width: 248,
|
||||||
|
height: 350,
|
||||||
|
color: Colors.grey.shade800,
|
||||||
|
child: const Icon(Icons.tv, size: 64, color: Colors.white54),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Title
|
||||||
|
Text(
|
||||||
|
_seriesInfo!.name,
|
||||||
|
style: GoogleFonts.roboto(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
|
// Rating
|
||||||
|
if (_seriesInfo!.rating != null)
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.star, size: 16, color: Colors.amber.shade700),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Text(
|
||||||
|
_seriesInfo!.rating!,
|
||||||
|
style: GoogleFonts.roboto(fontSize: 13, color: Colors.white70),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
|
||||||
|
// Plot
|
||||||
|
if (_seriesInfo!.plot != null && _seriesInfo!.plot!.isNotEmpty)
|
||||||
|
Text(
|
||||||
|
_seriesInfo!.plot!,
|
||||||
|
style: GoogleFonts.roboto(fontSize: 12, color: Colors.white60),
|
||||||
|
maxLines: 5,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Season selector
|
||||||
|
Text(
|
||||||
|
'Seasons',
|
||||||
|
style: GoogleFonts.roboto(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Wrap(
|
||||||
|
spacing: 8,
|
||||||
|
runSpacing: 8,
|
||||||
|
children: _seriesInfo!.episodes.keys.map((seasonNum) {
|
||||||
|
final isSelected = seasonNum == _selectedSeason;
|
||||||
|
return ChoiceChip(
|
||||||
|
label: Text('S$seasonNum'),
|
||||||
|
selected: isSelected,
|
||||||
|
onSelected: (selected) {
|
||||||
|
if (selected) {
|
||||||
|
setState(() => _selectedSeason = seasonNum);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selectedColor: Colors.blue.shade700,
|
||||||
|
backgroundColor: Colors.grey.shade800,
|
||||||
|
labelStyle: GoogleFonts.roboto(
|
||||||
|
color: isSelected ? Colors.white : Colors.white70,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Divider
|
||||||
|
Container(width: 1, color: Colors.grey.shade700),
|
||||||
|
|
||||||
|
// Right panel: Episodes list
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Text(
|
||||||
|
'Season $_selectedSeason - ${currentEpisodes.length} Episodes',
|
||||||
|
style: GoogleFonts.roboto(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: currentEpisodes.isEmpty
|
||||||
|
? Center(
|
||||||
|
child: Text(
|
||||||
|
'No episodes found',
|
||||||
|
style: GoogleFonts.roboto(color: Colors.white54),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: ListView.builder(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
itemCount: currentEpisodes.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final episode = currentEpisodes[index];
|
||||||
|
return _buildEpisodeTile(episode);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildEpisodeTile(Episode episode) {
|
||||||
|
return Card(
|
||||||
|
color: Colors.grey.shade800,
|
||||||
|
margin: const EdgeInsets.only(bottom: 8),
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => PlayerScreen(
|
||||||
|
streamId: episode.id,
|
||||||
|
title: '${widget.series.name} - ${episode.title}',
|
||||||
|
playlist: widget.playlist,
|
||||||
|
streamType: StreamType.series,
|
||||||
|
containerExtension: episode.containerExtension ?? 'mkv',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
// Episode number badge
|
||||||
|
Container(
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.blue.shade700,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: Center(
|
||||||
|
child: Text(
|
||||||
|
'${episode.episodeNum}',
|
||||||
|
style: GoogleFonts.roboto(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
|
||||||
|
// Episode info
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
episode.title,
|
||||||
|
style: GoogleFonts.roboto(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
if (episode.durationSecs != null && episode.durationSecs! > 0)
|
||||||
|
Text(
|
||||||
|
_formatDuration(episode.durationSecs!),
|
||||||
|
style: GoogleFonts.roboto(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Colors.white54,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
// Play icon
|
||||||
|
const Icon(Icons.play_circle_outline, color: Colors.white70, size: 28),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String _formatDuration(int seconds) {
|
||||||
|
final hours = seconds ~/ 3600;
|
||||||
|
final minutes = (seconds % 3600) ~/ 60;
|
||||||
|
if (hours > 0) {
|
||||||
|
return '${hours}h ${minutes}m';
|
||||||
|
}
|
||||||
|
return '${minutes}m';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -399,6 +399,28 @@ class XtreamService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get series info with seasons and episodes
|
||||||
|
Future<xm.SeriesInfo> getSeriesInfo(String seriesId) async {
|
||||||
|
if (_currentPlaylist == null) throw Exception('No playlist configured');
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await _dio.get(
|
||||||
|
_wrapWithProxy(_currentPlaylist!.apiBaseUrl),
|
||||||
|
queryParameters: {
|
||||||
|
'username': _currentPlaylist!.username,
|
||||||
|
'password': _currentPlaylist!.password,
|
||||||
|
'action': 'get_series_info',
|
||||||
|
'series_id': seriesId,
|
||||||
|
},
|
||||||
|
options: Options(extra: _cacheOptions.toExtra()),
|
||||||
|
);
|
||||||
|
|
||||||
|
return xm.SeriesInfo.fromJson(response.data as Map<String, dynamic>);
|
||||||
|
} catch (e) {
|
||||||
|
throw Exception('Failed to fetch series info: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Get short EPG for a specific stream
|
/// Get short EPG for a specific stream
|
||||||
///
|
///
|
||||||
/// Returns "Now" and "Next" program info
|
/// Returns "Now" and "Next" program info
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import '../providers/xtream_provider.dart';
|
import '../providers/xtream_provider.dart';
|
||||||
|
import '../providers/settings_provider.dart';
|
||||||
import '../screens/player_screen.dart';
|
import '../screens/player_screen.dart';
|
||||||
import '../../../core/models/iptv_models.dart';
|
import '../../../core/models/iptv_models.dart';
|
||||||
import '../../../core/models/playlist_config.dart';
|
import '../../../core/models/playlist_config.dart';
|
||||||
@@ -64,16 +65,45 @@ class _LiveTVTabState extends ConsumerState<LiveTVTab>
|
|||||||
|
|
||||||
/// Build the category grid view with box cards
|
/// Build the category grid view with box cards
|
||||||
Widget _buildCategoryGrid(Map<String, List<Channel>> groupedChannels) {
|
Widget _buildCategoryGrid(Map<String, List<Channel>> groupedChannels) {
|
||||||
final categories = groupedChannels.keys.toList()..sort();
|
// Get filter settings
|
||||||
|
final settings = ref.watch(iptvSettingsProvider);
|
||||||
|
|
||||||
|
// Filter categories based on keywords
|
||||||
|
var categories = groupedChannels.keys.toList();
|
||||||
|
if (settings.filterKeywords.isNotEmpty) {
|
||||||
|
categories = categories.where((cat) => settings.matchesFilter(cat)).toList();
|
||||||
|
}
|
||||||
|
categories.sort();
|
||||||
|
|
||||||
|
if (categories.isEmpty) {
|
||||||
|
return Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.filter_list_off, size: 48, color: Colors.grey),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
'No categories match the filter',
|
||||||
|
style: GoogleFonts.roboto(color: Colors.grey),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'Filter: ${settings.categoryFilter}',
|
||||||
|
style: GoogleFonts.roboto(fontSize: 12, color: Colors.grey.shade600),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(12.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: GridView.builder(
|
child: GridView.builder(
|
||||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 4,
|
crossAxisCount: 6,
|
||||||
crossAxisSpacing: 12,
|
crossAxisSpacing: 8,
|
||||||
mainAxisSpacing: 12,
|
mainAxisSpacing: 8,
|
||||||
childAspectRatio: 1.5,
|
childAspectRatio: 1.8,
|
||||||
),
|
),
|
||||||
itemCount: categories.length,
|
itemCount: categories.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
@@ -283,32 +313,25 @@ class _CategoryBox extends StatelessWidget {
|
|||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(10),
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
begin: Alignment.topLeft,
|
begin: Alignment.topLeft,
|
||||||
end: Alignment.bottomRight,
|
end: Alignment.bottomRight,
|
||||||
colors: [
|
colors: [
|
||||||
Theme.of(context).colorScheme.primary.withOpacity(0.2),
|
Theme.of(context).colorScheme.primary.withOpacity(0.15),
|
||||||
Theme.of(context).colorScheme.secondary.withOpacity(0.1),
|
Theme.of(context).colorScheme.secondary.withOpacity(0.08),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(10),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Theme.of(context).colorScheme.primary.withOpacity(0.3),
|
color: Theme.of(context).colorScheme.primary.withOpacity(0.25),
|
||||||
width: 1.5,
|
width: 1,
|
||||||
),
|
),
|
||||||
boxShadow: [
|
|
||||||
BoxShadow(
|
|
||||||
color: Colors.black.withOpacity(0.1),
|
|
||||||
blurRadius: 8,
|
|
||||||
offset: const Offset(0, 4),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(8),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -317,20 +340,20 @@ class _CategoryBox extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
Icons.live_tv,
|
Icons.live_tv,
|
||||||
size: 24,
|
size: 16,
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.primary.withOpacity(0.2),
|
color: Theme.of(context).colorScheme.primary.withOpacity(0.2),
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
'$channelCount',
|
'$channelCount',
|
||||||
style: GoogleFonts.roboto(
|
style: GoogleFonts.roboto(
|
||||||
fontSize: 12,
|
fontSize: 10,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
@@ -342,7 +365,7 @@ class _CategoryBox extends StatelessWidget {
|
|||||||
Text(
|
Text(
|
||||||
categoryName,
|
categoryName,
|
||||||
style: GoogleFonts.roboto(
|
style: GoogleFonts.roboto(
|
||||||
fontSize: 14,
|
fontSize: 11,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
),
|
),
|
||||||
maxLines: 2,
|
maxLines: 2,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import 'package:google_fonts/google_fonts.dart';
|
|||||||
import '../../../core/models/playlist_config.dart';
|
import '../../../core/models/playlist_config.dart';
|
||||||
import '../models/xtream_models.dart';
|
import '../models/xtream_models.dart';
|
||||||
import '../providers/xtream_provider.dart';
|
import '../providers/xtream_provider.dart';
|
||||||
import '../screens/video_player_screen.dart';
|
import '../screens/player_screen.dart';
|
||||||
|
|
||||||
class MoviesTab extends ConsumerStatefulWidget {
|
class MoviesTab extends ConsumerStatefulWidget {
|
||||||
final PlaylistConfig playlist;
|
final PlaylistConfig playlist;
|
||||||
@@ -86,10 +86,10 @@ class _MoviesTabState extends ConsumerState<MoviesTab> {
|
|||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 5,
|
crossAxisCount: 7,
|
||||||
crossAxisSpacing: 8,
|
crossAxisSpacing: 6,
|
||||||
mainAxisSpacing: 8,
|
mainAxisSpacing: 6,
|
||||||
childAspectRatio: 0.7,
|
childAspectRatio: 0.65,
|
||||||
),
|
),
|
||||||
itemCount: _movies.length + (_hasMore ? 1 : 0),
|
itemCount: _movies.length + (_hasMore ? 1 : 0),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
@@ -122,19 +122,16 @@ class _MovieCard extends StatelessWidget {
|
|||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
final streamUrl = movie.getStreamUrl(
|
// Use PlayerScreen for VOD (video on demand)
|
||||||
playlist.dns,
|
|
||||||
playlist.username,
|
|
||||||
playlist.password,
|
|
||||||
);
|
|
||||||
|
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => VideoPlayerScreen(
|
builder: (context) => PlayerScreen(
|
||||||
streamUrl: streamUrl,
|
streamId: movie.streamId,
|
||||||
title: movie.name,
|
title: movie.name,
|
||||||
posterUrl: movie.streamIcon,
|
playlist: playlist,
|
||||||
|
streamType: StreamType.vod,
|
||||||
|
containerExtension: movie.containerExtension ?? 'mp4',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import '../../../core/models/playlist_config.dart';
|
import '../../../core/models/playlist_config.dart';
|
||||||
import '../services/xtream_service.dart';
|
|
||||||
import '../models/xtream_models.dart';
|
import '../models/xtream_models.dart';
|
||||||
import '../providers/xtream_provider.dart';
|
import '../providers/xtream_provider.dart';
|
||||||
|
import '../screens/series_detail_screen.dart';
|
||||||
|
|
||||||
class SeriesTab extends ConsumerStatefulWidget {
|
class SeriesTab extends ConsumerStatefulWidget {
|
||||||
final PlaylistConfig playlist;
|
final PlaylistConfig playlist;
|
||||||
@@ -86,10 +86,10 @@ class _SeriesTabState extends ConsumerState<SeriesTab> {
|
|||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: 5,
|
crossAxisCount: 7,
|
||||||
crossAxisSpacing: 8,
|
crossAxisSpacing: 6,
|
||||||
mainAxisSpacing: 8,
|
mainAxisSpacing: 6,
|
||||||
childAspectRatio: 0.7,
|
childAspectRatio: 0.65,
|
||||||
),
|
),
|
||||||
itemCount: _series.length + (_hasMore ? 1 : 0),
|
itemCount: _series.length + (_hasMore ? 1 : 0),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
@@ -98,7 +98,7 @@ class _SeriesTabState extends ConsumerState<SeriesTab> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final serie = _series[index];
|
final serie = _series[index];
|
||||||
return _SeriesCard(series: serie);
|
return _SeriesCard(series: serie, playlist: widget.playlist);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -106,8 +106,9 @@ class _SeriesTabState extends ConsumerState<SeriesTab> {
|
|||||||
|
|
||||||
class _SeriesCard extends StatelessWidget {
|
class _SeriesCard extends StatelessWidget {
|
||||||
final Series series;
|
final Series series;
|
||||||
|
final PlaylistConfig playlist;
|
||||||
|
|
||||||
const _SeriesCard({required this.series});
|
const _SeriesCard({required this.series, required this.playlist});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -115,22 +116,14 @@ class _SeriesCard extends StatelessWidget {
|
|||||||
clipBehavior: Clip.antiAlias,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// Series require episode selection screen (not implemented)
|
// Navigate to series detail screen for episode selection
|
||||||
// For now, show info dialog
|
Navigator.push(
|
||||||
showDialog(
|
context,
|
||||||
context: context,
|
MaterialPageRoute(
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) => SeriesDetailScreen(
|
||||||
title: Text(series.name),
|
series: series,
|
||||||
content: const Text(
|
playlist: playlist,
|
||||||
'Series playback requires episode selection.\n\n'
|
|
||||||
'Use Xtream API endpoint get_series_info to fetch episodes.',
|
|
||||||
),
|
),
|
||||||
actions: [
|
|
||||||
TextButton(
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
child: const Text('OK'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,17 +3,44 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import '../../auth/providers/auth_provider.dart';
|
import '../../auth/providers/auth_provider.dart';
|
||||||
|
import '../providers/settings_provider.dart';
|
||||||
|
|
||||||
class SettingsTab extends ConsumerWidget {
|
class SettingsTab extends ConsumerStatefulWidget {
|
||||||
const SettingsTab({super.key});
|
const SettingsTab({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
ConsumerState<SettingsTab> createState() => _SettingsTabState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||||
|
late TextEditingController _filterController;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_filterController = TextEditingController();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_filterController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
final currentUser = ref.watch(authProvider).currentUser;
|
final currentUser = ref.watch(authProvider).currentUser;
|
||||||
|
final settings = ref.watch(iptvSettingsProvider);
|
||||||
|
|
||||||
|
// Sync controller with state
|
||||||
|
if (_filterController.text != settings.categoryFilter) {
|
||||||
|
_filterController.text = settings.categoryFilter;
|
||||||
|
}
|
||||||
|
|
||||||
return ListView(
|
return ListView(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
children: [
|
children: [
|
||||||
|
// User info card
|
||||||
Card(
|
Card(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: const Icon(Icons.person),
|
leading: const Icon(Icons.person),
|
||||||
@@ -34,6 +61,88 @@ class SettingsTab extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Category filter section
|
||||||
|
Card(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.filter_list, size: 20),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text(
|
||||||
|
'Live TV Category Filter',
|
||||||
|
style: GoogleFonts.roboto(
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
fontSize: 14,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'Enter keywords separated by commas. Only categories containing one of these words will be shown.',
|
||||||
|
style: GoogleFonts.roboto(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Colors.grey.shade600,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
TextField(
|
||||||
|
controller: _filterController,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Ex: FR,FRANCE,HD,SPORT',
|
||||||
|
hintStyle: GoogleFonts.roboto(fontSize: 13),
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 12,
|
||||||
|
vertical: 10,
|
||||||
|
),
|
||||||
|
suffixIcon: _filterController.text.isNotEmpty
|
||||||
|
? IconButton(
|
||||||
|
icon: const Icon(Icons.clear, size: 18),
|
||||||
|
onPressed: () {
|
||||||
|
_filterController.clear();
|
||||||
|
ref.read(iptvSettingsProvider.notifier)
|
||||||
|
.clearCategoryFilter();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
style: GoogleFonts.roboto(fontSize: 13),
|
||||||
|
onChanged: (value) {
|
||||||
|
ref.read(iptvSettingsProvider.notifier)
|
||||||
|
.setCategoryFilter(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (settings.filterKeywords.isNotEmpty) ...[
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Wrap(
|
||||||
|
spacing: 4,
|
||||||
|
runSpacing: 4,
|
||||||
|
children: settings.filterKeywords.map((keyword) {
|
||||||
|
return Chip(
|
||||||
|
label: Text(
|
||||||
|
keyword,
|
||||||
|
style: GoogleFonts.roboto(fontSize: 11),
|
||||||
|
),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||||
|
visualDensity: VisualDensity.compact,
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
|
// Admin panel
|
||||||
if (currentUser?.isAdmin ?? false) ...[
|
if (currentUser?.isAdmin ?? false) ...[
|
||||||
Card(
|
Card(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
@@ -45,6 +154,8 @@ class SettingsTab extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// Change playlist
|
||||||
Card(
|
Card(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: const Icon(Icons.playlist_play),
|
leading: const Icon(Icons.playlist_play),
|
||||||
@@ -54,6 +165,8 @@ class SettingsTab extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
|
|
||||||
|
// About
|
||||||
Card(
|
Card(
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
leading: const Icon(Icons.info_outline),
|
leading: const Icon(Icons.info_outline),
|
||||||
@@ -65,6 +178,8 @@ class SettingsTab extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
|
|
||||||
|
// Logout button
|
||||||
FilledButton.icon(
|
FilledButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
ref.read(authProvider.notifier).logout();
|
ref.read(authProvider.notifier).logout();
|
||||||
|
|||||||
Reference in new issue
Block a user