mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-18 20:59:59 +02:00
feat: Implement Xtream API data models and live TV tab for IPTV functionality, including application icons.
This commit is contained in:
1 parent
ec6108b747
commit
33239ca11e
10 files changed
+641
-57
No files matched your search
@@ -237,7 +237,7 @@ class _LiveTVTabState extends ConsumerState<LiveTVTab>
|
||||
|
||||
// Proxy HTTP images through our server to avoid Mixed Content blocking
|
||||
if (hasIcon && channel.streamIcon.startsWith('http://')) {
|
||||
iconUrl = '/api/xtream/${Uri.encodeComponent(channel.streamIcon)}';
|
||||
iconUrl = '/api/xtream/${channel.streamIcon}';
|
||||
}
|
||||
|
||||
final Widget placeholder = Container(
|
||||
|
||||
@@ -4,7 +4,9 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import '../../auth/providers/auth_provider.dart';
|
||||
import '../providers/settings_provider.dart';
|
||||
import 'streaming_settings_tab.dart';
|
||||
|
||||
/// Main Settings tab with sub-tabs for Filters and Streaming
|
||||
class SettingsTab extends ConsumerStatefulWidget {
|
||||
const SettingsTab({super.key});
|
||||
|
||||
@@ -12,7 +14,8 @@ class SettingsTab extends ConsumerStatefulWidget {
|
||||
ConsumerState<SettingsTab> createState() => _SettingsTabState();
|
||||
}
|
||||
|
||||
class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
class _SettingsTabState extends ConsumerState<SettingsTab> with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
late TextEditingController _liveTvController;
|
||||
late TextEditingController _moviesController;
|
||||
late TextEditingController _seriesController;
|
||||
@@ -21,6 +24,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: 2, vsync: this);
|
||||
_liveTvController = TextEditingController();
|
||||
_moviesController = TextEditingController();
|
||||
_seriesController = TextEditingController();
|
||||
@@ -28,6 +32,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
_liveTvController.dispose();
|
||||
_moviesController.dispose();
|
||||
_seriesController.dispose();
|
||||
@@ -57,6 +62,38 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
if (!_initialized) _syncControllers(settings);
|
||||
});
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
// TabBar
|
||||
Container(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: TabBar(
|
||||
controller: _tabController,
|
||||
tabs: const [
|
||||
Tab(icon: Icon(Icons.filter_list), text: 'Filtres'),
|
||||
Tab(icon: Icon(Icons.stream), text: 'Streaming'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// TabBarView
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
// Filters Tab
|
||||
_buildFiltersTab(context, currentUser, settings),
|
||||
|
||||
// Streaming Tab
|
||||
const StreamingSettingsTab(),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFiltersTab(BuildContext context, dynamic currentUser, IptvSettings settings) {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
@@ -65,7 +102,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.person),
|
||||
title: Text(
|
||||
'Logged in as',
|
||||
'Connecté en tant que',
|
||||
style: GoogleFonts.roboto(fontSize: 12, color: Colors.grey),
|
||||
),
|
||||
subtitle: Text(
|
||||
@@ -84,7 +121,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
|
||||
// Category filters section
|
||||
Text(
|
||||
'Category Filters',
|
||||
'Filtres de Catégories',
|
||||
style: GoogleFonts.roboto(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
@@ -92,7 +129,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'Only categories containing one of these keywords will be shown. Separate with commas.',
|
||||
'Seules les catégories contenant un de ces mots-clés seront affichées. Séparez par des virgules.',
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 12,
|
||||
color: Colors.grey.shade600,
|
||||
@@ -102,7 +139,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
|
||||
// Live TV Filter
|
||||
_buildFilterCard(
|
||||
title: 'Live TV Filter',
|
||||
title: 'Filtre TV Live',
|
||||
icon: Icons.live_tv,
|
||||
controller: _liveTvController,
|
||||
keywords: settings.liveTvKeywords,
|
||||
@@ -118,7 +155,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
|
||||
// Movies Filter
|
||||
_buildFilterCard(
|
||||
title: 'Movies Filter',
|
||||
title: 'Filtre Films',
|
||||
icon: Icons.movie,
|
||||
controller: _moviesController,
|
||||
keywords: settings.moviesKeywords,
|
||||
@@ -134,7 +171,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
|
||||
// Series Filter
|
||||
_buildFilterCard(
|
||||
title: 'Series Filter',
|
||||
title: 'Filtre Séries',
|
||||
icon: Icons.tv,
|
||||
controller: _seriesController,
|
||||
keywords: settings.seriesKeywords,
|
||||
@@ -153,7 +190,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.admin_panel_settings),
|
||||
title: Text('Admin Panel', style: GoogleFonts.roboto()),
|
||||
title: Text('Panneau Admin', style: GoogleFonts.roboto()),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => context.go('/admin'),
|
||||
),
|
||||
@@ -165,7 +202,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.playlist_play),
|
||||
title: Text('Change Playlist', style: GoogleFonts.roboto()),
|
||||
title: Text('Changer de Playlist', style: GoogleFonts.roboto()),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => context.go('/playlists'),
|
||||
),
|
||||
@@ -176,7 +213,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: const Icon(Icons.info_outline),
|
||||
title: Text('About', style: GoogleFonts.roboto()),
|
||||
title: Text('À propos', style: GoogleFonts.roboto()),
|
||||
subtitle: Text(
|
||||
'XtremFlow IPTV v1.0.0',
|
||||
style: GoogleFonts.roboto(fontSize: 12),
|
||||
@@ -192,7 +229,7 @@ class _SettingsTabState extends ConsumerState<SettingsTab> {
|
||||
context.go('/login');
|
||||
},
|
||||
icon: const Icon(Icons.logout),
|
||||
label: const Text('Logout'),
|
||||
label: const Text('Déconnexion'),
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: Colors.red.shade700,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import '../providers/settings_provider.dart';
|
||||
|
||||
/// Streaming settings tab for Live TV configuration
|
||||
class StreamingSettingsTab extends ConsumerWidget {
|
||||
const StreamingSettingsTab({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final settings = ref.watch(iptvSettingsProvider);
|
||||
final notifier = ref.read(iptvSettingsProvider.notifier);
|
||||
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
// Header
|
||||
Text(
|
||||
'Paramètres Streaming Live TV',
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Ces paramètres s\'appliquent uniquement aux flux TV en direct.',
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 12,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// Quality Section
|
||||
_buildSectionCard(
|
||||
context: context,
|
||||
title: 'Qualité Vidéo',
|
||||
icon: Icons.high_quality,
|
||||
children: [
|
||||
_buildDropdownTile<StreamQuality>(
|
||||
title: 'Qualité du flux',
|
||||
subtitle: 'Bitrate: ${settings.bitrateKbps} kbps',
|
||||
value: settings.streamQuality,
|
||||
items: StreamQuality.values,
|
||||
onChanged: (v) => notifier.setStreamQuality(v!),
|
||||
labelBuilder: (v) => switch (v) {
|
||||
StreamQuality.low => 'Faible (1.5 Mbps)',
|
||||
StreamQuality.medium => 'Moyen (3 Mbps)',
|
||||
StreamQuality.high => 'Élevé (5 Mbps)',
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Buffer Section
|
||||
_buildSectionCard(
|
||||
context: context,
|
||||
title: 'Buffer & Latence',
|
||||
icon: Icons.speed,
|
||||
children: [
|
||||
_buildDropdownTile<BufferSize>(
|
||||
title: 'Taille du buffer',
|
||||
subtitle: 'Segments HLS: ${settings.hlsSegmentDuration}s',
|
||||
value: settings.bufferSize,
|
||||
items: BufferSize.values,
|
||||
onChanged: (v) => notifier.setBufferSize(v!),
|
||||
labelBuilder: (v) => switch (v) {
|
||||
BufferSize.low => 'Faible (latence min)',
|
||||
BufferSize.medium => 'Moyen (équilibré)',
|
||||
BufferSize.high => 'Élevé (stabilité max)',
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Connection Section
|
||||
_buildSectionCard(
|
||||
context: context,
|
||||
title: 'Connexion',
|
||||
icon: Icons.wifi,
|
||||
children: [
|
||||
_buildDropdownTile<ConnectionTimeout>(
|
||||
title: 'Timeout de connexion',
|
||||
subtitle: '${settings.timeoutSeconds} secondes',
|
||||
value: settings.connectionTimeout,
|
||||
items: ConnectionTimeout.values,
|
||||
onChanged: (v) => notifier.setConnectionTimeout(v!),
|
||||
labelBuilder: (v) => switch (v) {
|
||||
ConnectionTimeout.short => 'Court (15s)',
|
||||
ConnectionTimeout.medium => 'Moyen (30s)',
|
||||
ConnectionTimeout.long => 'Long (60s)',
|
||||
},
|
||||
),
|
||||
const Divider(height: 1),
|
||||
SwitchListTile(
|
||||
title: Text(
|
||||
'Reconnexion automatique',
|
||||
style: GoogleFonts.roboto(fontSize: 14),
|
||||
),
|
||||
subtitle: Text(
|
||||
'Se reconnecter en cas de coupure',
|
||||
style: GoogleFonts.roboto(fontSize: 12, color: Colors.grey),
|
||||
),
|
||||
value: settings.autoReconnect,
|
||||
onChanged: (v) => notifier.setAutoReconnect(v),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Transcoding Section
|
||||
_buildSectionCard(
|
||||
context: context,
|
||||
title: 'Transcodage',
|
||||
icon: Icons.transform,
|
||||
children: [
|
||||
_buildDropdownTile<TranscodingMode>(
|
||||
title: 'Mode de transcodage',
|
||||
subtitle: 'Comment le flux est traité',
|
||||
value: settings.transcodingMode,
|
||||
items: TranscodingMode.values,
|
||||
onChanged: (v) => notifier.setTranscodingMode(v!),
|
||||
labelBuilder: (v) => switch (v) {
|
||||
TranscodingMode.auto => 'Auto (recommandé)',
|
||||
TranscodingMode.forced => 'Forcé (toujours transcoder)',
|
||||
TranscodingMode.disabled => 'Désactivé (direct)',
|
||||
},
|
||||
),
|
||||
const Divider(height: 1),
|
||||
SwitchListTile(
|
||||
title: Text(
|
||||
'Préférer lecture directe',
|
||||
style: GoogleFonts.roboto(fontSize: 14),
|
||||
),
|
||||
subtitle: Text(
|
||||
'Utiliser le flux original si compatible',
|
||||
style: GoogleFonts.roboto(fontSize: 12, color: Colors.grey),
|
||||
),
|
||||
value: settings.preferDirectPlay,
|
||||
onChanged: (v) => notifier.setPreferDirectPlay(v),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// Cache Section
|
||||
_buildSectionCard(
|
||||
context: context,
|
||||
title: 'Cache EPG',
|
||||
icon: Icons.schedule,
|
||||
children: [
|
||||
_buildDropdownTile<EpgCacheDuration>(
|
||||
title: 'Durée du cache EPG',
|
||||
subtitle: '${settings.epgCacheMinutes} minutes',
|
||||
value: settings.epgCacheDuration,
|
||||
items: EpgCacheDuration.values,
|
||||
onChanged: (v) => notifier.setEpgCacheDuration(v!),
|
||||
labelBuilder: (v) => switch (v) {
|
||||
EpgCacheDuration.short => 'Court (5 min)',
|
||||
EpgCacheDuration.medium => 'Moyen (15 min)',
|
||||
EpgCacheDuration.long => 'Long (1 heure)',
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
|
||||
// Info card
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.blue.withOpacity(0.3)),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.info_outline, color: Colors.blue),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'Les changements prennent effet immédiatement pour les nouveaux flux.',
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 12,
|
||||
color: Colors.blue.shade700,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionCard({
|
||||
required BuildContext context,
|
||||
required String title,
|
||||
required IconData icon,
|
||||
required List<Widget> children,
|
||||
}) {
|
||||
return Card(
|
||||
elevation: 2,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, size: 20, color: Theme.of(context).colorScheme.primary),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
title,
|
||||
style: GoogleFonts.roboto(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
...children,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDropdownTile<T>({
|
||||
required String title,
|
||||
required String subtitle,
|
||||
required T value,
|
||||
required List<T> items,
|
||||
required ValueChanged<T?> onChanged,
|
||||
required String Function(T) labelBuilder,
|
||||
}) {
|
||||
return ListTile(
|
||||
title: Text(title, style: GoogleFonts.roboto(fontSize: 14)),
|
||||
subtitle: Text(subtitle, style: GoogleFonts.roboto(fontSize: 12, color: Colors.grey)),
|
||||
trailing: DropdownButton<T>(
|
||||
value: value,
|
||||
underline: const SizedBox(),
|
||||
items: items.map((item) {
|
||||
return DropdownMenuItem<T>(
|
||||
value: item,
|
||||
child: Text(
|
||||
labelBuilder(item),
|
||||
style: GoogleFonts.roboto(fontSize: 13),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: onChanged,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user