mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-19 21:18:06 +02:00
fix(epg,ui): utiliser get_simple_data_table pour l'EPG et recaler la sidebar sur le thème
EPG — les trois chemins (backend /api/epg, XtreamService.getShortEpg et getShortEPG) n'utilisaient que get_epg et get_short_epg. Beaucoup de panneaux Xtream ne connaissent pas get_epg : ils répondent 200 avec le bloc d'authentification, sans epg_listings, ce qui produisait un guide vide indiscernable d'une chaîne sans programme. get_short_epg y renvoie epg_listings vide en permanence. - backend : get_simple_data_table en premier, get_short_epg en repli - client : bascule automatique et mémorisée vers le tableau complet dès qu'un panneau est muet sur l'action légère, pour ne pas doubler les requêtes sur chaque tuile de grille - dates dérivées des *_timestamp epoch et émises en ISO-8601 UTC : les champs texte sont dans le fuseau du panneau, sans indicateur de zone, et étaient relus comme de l'heure locale — le guide était décalé et les enregistrements planifiés depuis le guide l'étaient aussi - cache backend : la clé incluait seulement le channelId, deux playlists partageant un stream_id se servaient mutuellement leur guide UI — les deux halos d'ambiance du dashboard étaient restés de l'ancien thème : primary (#FFB68C) à 40 % posé sur le coin haut-gauche, donc pile derrière la sidebar, et info (#A3B8C4, bleu-gris) à 35 % dans une palette entièrement chaude. Ramenés à des braises ember à 8 % / 6 %. - fond via AppColors.backgroundGradient - onglet actif rempli en primaryContainer (surface) et non primary (teinte claire réservée au texte/icônes) - sidebar en niveau flottant : en niveau 1 son fond #181310 se confondait avec le haut du dégradé #1A1310 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
095eb2c1b0
commit
537312908a
4 files changed
+286
-114
No files matched your search
@@ -46,24 +46,18 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
body: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
// 1. Cinematic Deep Space Background - Premium Apple TV Style
|
||||
// 1. Fond « salle de projection » — dégradé chaud du design system.
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
AppColors.surfaceContainerLowest, // Very dark top
|
||||
AppColors.background, // Black bottom
|
||||
AppColors.baseLevel0, // Slightly darker for depth
|
||||
],
|
||||
),
|
||||
gradient: AppColors.backgroundGradient,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Ambient Glow Top-Left - Teal (Primary) - VISIBLE
|
||||
// Faisceau du projecteur, en haut à gauche.
|
||||
// Intensité volontairement basse (8 %) : au-delà, le halo délave la
|
||||
// sidebar et les cartes en pêche et sort le rendu de la palette.
|
||||
Positioned(
|
||||
top: -300,
|
||||
left: -300,
|
||||
@@ -74,8 +68,8 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
shape: BoxShape.circle,
|
||||
gradient: RadialGradient(
|
||||
colors: [
|
||||
AppColors.primary.withOpacity(0.4),
|
||||
AppColors.primary.withOpacity(0.1),
|
||||
AppColors.glowPrimary(0.08),
|
||||
AppColors.glowPrimary(0.03),
|
||||
Colors.transparent,
|
||||
],
|
||||
),
|
||||
@@ -83,7 +77,9 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
),
|
||||
),
|
||||
|
||||
// Ambient Glow Bottom-Right - Blue - VISIBLE
|
||||
// Braise résiduelle en bas à droite. L'ancien halo utilisait
|
||||
// `AppColors.info` (bleu-gris) : une teinte froide dans une palette
|
||||
// entièrement chaude, d'où le rendu grisâtre.
|
||||
Positioned(
|
||||
bottom: -250,
|
||||
right: -250,
|
||||
@@ -94,8 +90,8 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
shape: BoxShape.circle,
|
||||
gradient: RadialGradient(
|
||||
colors: [
|
||||
AppColors.info.withOpacity(0.35),
|
||||
AppColors.info.withOpacity(0.1),
|
||||
AppColors.glowPrimary(0.06),
|
||||
AppColors.glowPrimary(0.02),
|
||||
Colors.transparent,
|
||||
],
|
||||
),
|
||||
@@ -124,9 +120,12 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
top: 24,
|
||||
bottom: 24,
|
||||
width: 80,
|
||||
child: GlassContainer.glass(
|
||||
// Niveau « flottant » : le niveau 1 (#181310) se confondait avec
|
||||
// le haut du dégradé de fond (#1A1310) — la barre n'existait plus
|
||||
// que par sa bordure. Le niveau 2 apporte l'arête ember et
|
||||
// l'ombre profonde qui la détachent vraiment.
|
||||
child: GlassContainer.floating(
|
||||
borderRadius: 24,
|
||||
borderColor: AppColors.border,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
@@ -141,7 +140,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: AppColors.primary.withOpacity(0.4),
|
||||
color: AppColors.glowPrimary(0.35),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
@@ -149,7 +148,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.play_arrow_rounded,
|
||||
color: AppColors.textPrimary,
|
||||
color: AppColors.onPrimary,
|
||||
size: 28,
|
||||
),
|
||||
),
|
||||
@@ -172,21 +171,26 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
width: 48,
|
||||
height: 48,
|
||||
decoration: BoxDecoration(
|
||||
// Remplissage ember (`primaryContainer`) et non
|
||||
// `primary` : cette dernière est la teinte claire
|
||||
// réservée au texte/icône, pas aux surfaces.
|
||||
color: isSelected
|
||||
? AppColors.primary.withOpacity(0.2)
|
||||
? AppColors.primaryContainer
|
||||
.withValues(alpha: 0.20)
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
border: isSelected
|
||||
? Border.all(
|
||||
color: AppColors.primary.withOpacity(0.5),
|
||||
color: AppColors.primary
|
||||
.withValues(alpha: 0.55),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: Icon(
|
||||
_icons[index],
|
||||
color: isSelected
|
||||
? AppColors.textPrimary
|
||||
: AppColors.textSecondary,
|
||||
? AppColors.primary
|
||||
: AppColors.textTertiary,
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
@@ -203,10 +207,10 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
|
||||
onTap: () {},
|
||||
borderRadius: 50,
|
||||
scaleFactor: 1.1,
|
||||
child: CircleAvatar(
|
||||
child: const CircleAvatar(
|
||||
radius: 20,
|
||||
backgroundColor: AppColors.primary.withOpacity(0.1),
|
||||
child: const Icon(
|
||||
backgroundColor: AppColors.surfaceContainerHigh,
|
||||
child: Icon(
|
||||
Icons.person,
|
||||
color: AppColors.textSecondary,
|
||||
size: 20,
|
||||
|
||||
@@ -45,6 +45,18 @@ class XtreamService {
|
||||
/// quelques connexions parallèles, ce qui vide l'EPG de toute la grille.
|
||||
/// On sérialise donc par petits paquets.
|
||||
static final _Semaphore _epgGate = _Semaphore(3);
|
||||
|
||||
/// Action EPG retenue pour ce panneau.
|
||||
///
|
||||
/// `get_short_epg` est la requête légère (2-3 programmes) mais une partie
|
||||
/// des panneaux répond `{"epg_listings":[]}` en permanence ; seule
|
||||
/// `get_simple_data_table` y renvoie le guide. On teste la première, et
|
||||
/// dès qu'un panneau se révèle incapable de la servir on bascule
|
||||
/// définitivement, pour ne pas payer deux requêtes par tuile de grille.
|
||||
static const _epgActionShort = 'get_short_epg';
|
||||
static const _epgActionTable = 'get_simple_data_table';
|
||||
static String _epgAction = _epgActionShort;
|
||||
|
||||
late final Dio _dio;
|
||||
late final CacheOptions _cacheOptions;
|
||||
|
||||
@@ -662,6 +674,22 @@ class XtreamService {
|
||||
///
|
||||
/// Returns "Now" and "Next" program info
|
||||
Future<List<EpgEntry>> getShortEpg(String streamId) async {
|
||||
final listings = await _fetchEpgListings(streamId);
|
||||
return listings.map(EpgEntry.fromJson).toList();
|
||||
}
|
||||
|
||||
/// Get short EPG as ShortEPG object (for EPGWidget)
|
||||
Future<xm.ShortEPG> getShortEPG(String streamId) async {
|
||||
final listings = await _fetchEpgListings(streamId);
|
||||
if (listings.isEmpty) return const xm.ShortEPG();
|
||||
return xm.ShortEPG.fromJson({'epg_listings': listings});
|
||||
}
|
||||
|
||||
/// Récupère le guide d'une chaîne, normalisé et réduit à la fenêtre utile.
|
||||
///
|
||||
/// Bascule automatiquement de `get_short_epg` vers `get_simple_data_table`
|
||||
/// quand le panneau ne sert pas la première : voir [_epgAction].
|
||||
Future<List<Map<String, dynamic>>> _fetchEpgListings(String streamId) async {
|
||||
if (_currentPlaylist == null) throw Exception('No playlist configured');
|
||||
|
||||
if (isPlaybackLoading) {
|
||||
@@ -670,10 +698,33 @@ class XtreamService {
|
||||
}
|
||||
|
||||
await _epgGate.acquire();
|
||||
try {
|
||||
var listings = await _requestEpg(streamId, _epgAction);
|
||||
|
||||
// Panneau muet sur l'action légère : on retente avec le tableau complet
|
||||
// et on mémorise le choix pour toutes les chaînes suivantes.
|
||||
if (listings.isEmpty && _epgAction == _epgActionShort) {
|
||||
listings = await _requestEpg(streamId, _epgActionTable);
|
||||
if (listings.isNotEmpty) {
|
||||
debugPrint(
|
||||
'[XtreamService] EPG : $_epgActionShort vide sur ce panneau, '
|
||||
'bascule définitive vers $_epgActionTable',
|
||||
);
|
||||
_epgAction = _epgActionTable;
|
||||
}
|
||||
}
|
||||
|
||||
return _normalizeListings(listings);
|
||||
} finally {
|
||||
_epgGate.release();
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<dynamic>> _requestEpg(String streamId, String action) async {
|
||||
try {
|
||||
final response = await _apiGet(
|
||||
{
|
||||
'action': 'get_short_epg',
|
||||
'action': action,
|
||||
'stream_id': streamId,
|
||||
},
|
||||
options: Options(
|
||||
@@ -693,7 +744,7 @@ class XtreamService {
|
||||
if (data is String) {
|
||||
if (data.trim().isEmpty) {
|
||||
debugPrint('[XtreamService] EPG $streamId : réponse vide');
|
||||
return [];
|
||||
return const [];
|
||||
}
|
||||
try {
|
||||
data = json.decode(data);
|
||||
@@ -703,76 +754,90 @@ class XtreamService {
|
||||
'(${response.headers.value('content-type')}) — '
|
||||
'${data.length > 120 ? '${data.substring(0, 120)}…' : data}',
|
||||
);
|
||||
return [];
|
||||
return const [];
|
||||
}
|
||||
}
|
||||
|
||||
if (data == null) {
|
||||
debugPrint('[XtreamService] EPG $streamId : corps nul');
|
||||
return [];
|
||||
return const [];
|
||||
}
|
||||
|
||||
if (data is! Map || data['epg_listings'] == null) {
|
||||
if (data is! Map || data['epg_listings'] is! List) {
|
||||
// Cas typique de `get_epg` / `get_short_epg` non supportés : le
|
||||
// panneau répond 200 avec le payload d'authentification.
|
||||
debugPrint(
|
||||
'[XtreamService] EPG $streamId : pas de champ epg_listings '
|
||||
'(clés: ${data is Map ? data.keys.toList() : data.runtimeType})',
|
||||
'[XtreamService] EPG $streamId ($action) : pas de champ '
|
||||
'epg_listings (clés: '
|
||||
'${data is Map ? data.keys.toList() : data.runtimeType})',
|
||||
);
|
||||
return [];
|
||||
return const [];
|
||||
}
|
||||
|
||||
final List<dynamic> epgData = data['epg_listings'] as List<dynamic>;
|
||||
return epgData
|
||||
.map((entry) => EpgEntry.fromJson(entry as Map<String, dynamic>))
|
||||
.toList();
|
||||
return data['epg_listings'] as List<dynamic>;
|
||||
} on DioException catch (e) {
|
||||
// L'EPG reste optionnel — mais avaler l'erreur en silence rendait toute
|
||||
// panne indiscernable d'une grille réellement vide.
|
||||
debugPrint(
|
||||
'[XtreamService] EPG $streamId en échec : '
|
||||
'[XtreamService] EPG $streamId ($action) en échec : '
|
||||
'HTTP ${e.response?.statusCode} ${e.type} — ${e.message}',
|
||||
);
|
||||
return [];
|
||||
return const [];
|
||||
} catch (e) {
|
||||
debugPrint('[XtreamService] EPG $streamId en échec : $e');
|
||||
return [];
|
||||
} finally {
|
||||
_epgGate.release();
|
||||
debugPrint('[XtreamService] EPG $streamId ($action) en échec : $e');
|
||||
return const [];
|
||||
}
|
||||
}
|
||||
|
||||
/// Get short EPG as ShortEPG object (for EPGWidget)
|
||||
Future<xm.ShortEPG> getShortEPG(String streamId) async {
|
||||
if (_currentPlaylist == null) throw Exception('No playlist configured');
|
||||
/// Aligne les dates sur de l'ISO-8601 UTC et ne garde que la fenêtre utile.
|
||||
///
|
||||
/// Deux raisons :
|
||||
/// * `get_simple_data_table` renvoie plusieurs jours de programmes (~35 Ko
|
||||
/// par chaîne). Les appelants prennent « le premier élément » comme
|
||||
/// programme courant : sans coupe, ils afficheraient un programme
|
||||
/// d'avant-hier.
|
||||
/// * Les champs texte `start`/`end` sont dans le fuseau du panneau et sans
|
||||
/// indicateur de zone ; seuls les `*_timestamp` (epoch UTC) sont fiables.
|
||||
static List<Map<String, dynamic>> _normalizeListings(List<dynamic> raw) {
|
||||
final now = DateTime.now();
|
||||
final result = <Map<String, dynamic>>[];
|
||||
|
||||
if (isPlaybackLoading) {
|
||||
debugPrint('[XtreamService] Throttling short EPG metadata for $streamId');
|
||||
await Future.delayed(_throttleDelay);
|
||||
}
|
||||
for (final item in raw) {
|
||||
if (item is! Map) continue;
|
||||
final entry = Map<String, dynamic>.from(item);
|
||||
|
||||
try {
|
||||
final response = await _apiGet(
|
||||
{
|
||||
'action': 'get_short_epg',
|
||||
'stream_id': streamId,
|
||||
},
|
||||
options: Options(
|
||||
extra: CacheOptions(
|
||||
store: _cacheOptions.store,
|
||||
policy: CachePolicy.request,
|
||||
maxStale: const Duration(minutes: 5),
|
||||
).toExtra(),
|
||||
),
|
||||
final start = _epgDate(entry['start_timestamp'], entry['start']);
|
||||
final end = _epgDate(
|
||||
entry['stop_timestamp'] ?? entry['end_timestamp'],
|
||||
entry['stop'] ?? entry['end'],
|
||||
);
|
||||
if (start == null || end == null) continue;
|
||||
|
||||
if (response.data == null) {
|
||||
return const xm.ShortEPG();
|
||||
}
|
||||
// Programme déjà terminé : sans intérêt pour un « en cours / à suivre ».
|
||||
if (end.isBefore(now)) continue;
|
||||
|
||||
return xm.ShortEPG.fromJson(response.data as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
// EPG is optional, don't throw on failure
|
||||
return const xm.ShortEPG();
|
||||
entry['start'] = start.toIso8601String();
|
||||
entry['end'] = end.toIso8601String();
|
||||
entry['stop'] = entry['end'];
|
||||
result.add(entry);
|
||||
|
||||
if (result.length >= 8) break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Epoch UTC prioritaire, repli sur la chaîne « YYYY-MM-DD HH:MM:SS ».
|
||||
static DateTime? _epgDate(dynamic timestamp, dynamic text) {
|
||||
final seconds = timestamp is int ? timestamp : int.tryParse('$timestamp');
|
||||
if (seconds != null && seconds > 0) {
|
||||
return DateTime.fromMillisecondsSinceEpoch(seconds * 1000, isUtc: true);
|
||||
}
|
||||
final str = text?.toString() ?? '';
|
||||
if (str.isEmpty) return null;
|
||||
return DateTime.tryParse(
|
||||
str.contains(' ') && !str.contains('T') ? str.replaceFirst(' ', 'T') : str,
|
||||
);
|
||||
}
|
||||
|
||||
/// Dispose resources
|
||||
|
||||
Reference in new issue
Block a user