mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-17 04:09:03 +02:00
Full visual overhaul from Cyber-Cinematic Glass to "Warm Cinema": warm charcoal (#0B0908), cream (#F3E9DF), ember (#D9541F). Fraunces (editorial serif) for display, Karla for body/UI. Design - app_colors: new palette, all existing token names preserved, plus posterScrim/heroScrim gradients and lift()/emberFocus() shadows - app_theme: new type scale, tighter radii, 20+ component themes - mobile_theme aligned on the same tokens - glass_container: opaque layered surfaces replace glassmorphism; adds GlassCard (hover + remote-focus states) and CinemaBackdrop - players and boot splash restyled (film-leader motif, no web fonts) Performance - remove every BackdropFilter (33 call sites): backdrop blur forced a full framebuffer read per frame per card, the main scroll jank source - bundle Fraunces/Karla as assets: google_fonts no longer fetches from fonts.gstatic.com at startup - drop the blocking hls.js CDN script from index.html; no Dart code ever used it, only the player iframes need it - self-host hls.js/mpegts.js and load them on demand, so ~213 KB of mpegts is never downloaded for HLS streams - bound image decode size on 10 sites: a 40-poster grid drops from ~240 MB to a few tens of MB of GPU memory Players (new shared engine: web/xf-player-core.js) - event-driven start instead of a 200 ms buffer poll plus a 1.5 s wait - initialLiveManifestSize 3 -> 1, liveSyncDurationCount 10 -> 2, startFragPrefetch on, testBandwidth off - MPEG-TS initial stash 512 KB -> 64 KB - adaptive escalation fast -> balanced -> safe on repeated stalls (60 s rolling window), applied live for HLS so there is no visible cut Pre-existing build breakage fixed along the way - undefined AppColors.shimmer, AppTheme.durationXs and spacing8/12/16/32 - broken relative imports in channel_card and quality_selector_widget - missing GlassCard widget and hasBorder/showShadow parameters Also resolves a leftover unmerged .claude/settings.local.json by keeping the remote version. Still broken (pre-existing, dead code, not reachable from main.dart): recommendations_provider.dart and continue_watching_widget.dart import a models/playlist.dart that no longer exists. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
255 lines
8.0 KiB
Dart
255 lines
8.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../../../core/services/adaptive_bitrate_service.dart';
|
|
import '../../../core/theme/app_colors.dart';
|
|
|
|
/// Widget for displaying and selecting video quality during playback
|
|
class QualitySelectorWidget extends ConsumerStatefulWidget {
|
|
final QualitySelector qualitySelector;
|
|
final VoidCallback onClose;
|
|
|
|
const QualitySelectorWidget({
|
|
super.key,
|
|
required this.qualitySelector,
|
|
required this.onClose,
|
|
});
|
|
|
|
@override
|
|
ConsumerState<QualitySelectorWidget> createState() =>
|
|
_QualitySelectorWidgetState();
|
|
}
|
|
|
|
class _QualitySelectorWidgetState extends ConsumerState<QualitySelectorWidget> {
|
|
late List<QualityLevel> _availableQualities;
|
|
late QualityLevel _selectedQuality;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_availableQualities = QualityProfiles.getBalancedProfiles();
|
|
_selectedQuality = widget.qualitySelector.currentQuality;
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final currentQuality = widget.qualitySelector.currentQuality;
|
|
final bandwidthMbps = widget.qualitySelector.getEstimatedBandwidthMbps();
|
|
|
|
return Dialog(
|
|
backgroundColor: AppColors.surfaceContainer,
|
|
insetPadding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
// Header
|
|
Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: const BoxDecoration(
|
|
border: Border(
|
|
bottom: BorderSide(color: AppColors.onSurface24),
|
|
),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
const Text(
|
|
'Video Quality',
|
|
style: TextStyle(
|
|
color: AppColors.onSurface,
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
IconButton(
|
|
icon: const Icon(Icons.close, color: AppColors.onSurface),
|
|
onPressed: widget.onClose,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
// Network Info
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.onSurface06,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
const Text(
|
|
'Current Bandwidth:',
|
|
style: TextStyle(color: AppColors.onSurfaceVariant, fontSize: 14),
|
|
),
|
|
Text(
|
|
'${bandwidthMbps.toStringAsFixed(1)} Mbps',
|
|
style: const TextStyle(
|
|
color: AppColors.onSurface,
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
|
|
// Quality Options
|
|
ListView.builder(
|
|
shrinkWrap: true,
|
|
itemCount: _availableQualities.length,
|
|
itemBuilder: (context, index) {
|
|
final quality = _availableQualities[index];
|
|
final isSelected = quality == currentQuality;
|
|
|
|
return ListTile(
|
|
contentPadding:
|
|
const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
|
leading: isSelected
|
|
? const Icon(Icons.check_circle, color: AppColors.primary)
|
|
: const Icon(
|
|
Icons.radio_button_unchecked,
|
|
color: AppColors.onSurface24,
|
|
),
|
|
title: Text(
|
|
quality.label,
|
|
style: TextStyle(
|
|
color: isSelected ? AppColors.primary : AppColors.onSurface,
|
|
fontWeight:
|
|
isSelected ? FontWeight.bold : FontWeight.normal,
|
|
),
|
|
),
|
|
subtitle: Text(
|
|
'${quality.bitrateBps ~/ 1000000} Mbps',
|
|
style: const TextStyle(color: AppColors.onSurfaceVariant, fontSize: 12),
|
|
),
|
|
onTap: () {
|
|
widget.qualitySelector.setQuality(quality);
|
|
setState(() {
|
|
_selectedQuality = quality;
|
|
});
|
|
},
|
|
);
|
|
},
|
|
),
|
|
|
|
// Auto Quality Option
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
child: Container(
|
|
decoration: const BoxDecoration(
|
|
border: Border(
|
|
top: BorderSide(color: AppColors.onSurface24),
|
|
),
|
|
),
|
|
child: ListTile(
|
|
contentPadding:
|
|
const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
|
leading: const Icon(Icons.auto_awesome, color: Colors.amber),
|
|
title: const Text(
|
|
'Auto Quality',
|
|
style: TextStyle(
|
|
color: Colors.amber,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
subtitle: const Text(
|
|
'Adjusts based on network speed',
|
|
style: TextStyle(color: AppColors.onSurfaceVariant, fontSize: 12),
|
|
),
|
|
onTap: () {
|
|
// Auto mode would be handled by the player
|
|
widget.onClose();
|
|
},
|
|
),
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Floating quality indicator (minimal UI during playback)
|
|
class QualityIndicator extends ConsumerWidget {
|
|
final QualitySelector qualitySelector;
|
|
final VoidCallback onTap;
|
|
|
|
const QualityIndicator({
|
|
super.key,
|
|
required this.qualitySelector,
|
|
required this.onTap,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final quality = qualitySelector.currentQuality;
|
|
|
|
return GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.baseLevel0,
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Icon(Icons.high_quality, color: AppColors.onSurface, size: 16),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
quality.resolution.split('x')[1], // Show just the height
|
|
style: const TextStyle(
|
|
color: AppColors.onSurface,
|
|
fontSize: 12,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Bandwidth monitor widget (for debugging/info)
|
|
class BandwidthMonitor extends ConsumerWidget {
|
|
final QualitySelector qualitySelector;
|
|
|
|
const BandwidthMonitor({
|
|
super.key,
|
|
required this.qualitySelector,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(8),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.baseLevel0,
|
|
borderRadius: BorderRadius.circular(4),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Icon(Icons.speed, color: Colors.green, size: 14),
|
|
const SizedBox(width: 4),
|
|
Text(
|
|
'${qualitySelector.getEstimatedBandwidthMbps().toStringAsFixed(1)} Mbps',
|
|
style: const TextStyle(
|
|
color: AppColors.onSurface,
|
|
fontSize: 11,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|