a89c7894cf
Backend: - FastAPI avec PostgreSQL et Redis - Authentification JWT complète - API REST pour musique, playlists, recherche - Streaming audio via yt-dlp - SQLAlchemy 2.0 async Frontend: - Flutter avec thème néon cyberpunk - State management Riverpod - Layout adaptatif desktop/mobile - Lecteur audio avec mini-player Infrastructure: - Docker Compose (PostgreSQL + Redis) - Scripts d'installation automatisés - Scripts de build pour exécutables Fichiers ajoutés: - BUILD_CLIENT_*.bat/sh: Scripts de compilation - BUILD_CLIENT_README.md: Documentation compilation - CHECK_FLUTTER.sh: Vérificateur d'environnement - requirements.txt mis à jour pour Python 3.13 - Modèles SQLAlchemy corrigés (metadata -> extra_metadata) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
260 lines
8.6 KiB
Dart
260 lines
8.6 KiB
Dart
/// Cache Management Tile Widget
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../../../core/theme/colors.dart';
|
|
import '../../../core/theme/text_styles.dart';
|
|
import '../../providers/settings_provider.dart';
|
|
|
|
/// Cache management tile widget
|
|
class CacheManagementTile extends ConsumerWidget {
|
|
const CacheManagementTile({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final settingsState = ref.watch(settingsProvider);
|
|
final cacheSize = settingsState.cacheSize;
|
|
final isLoading = settingsState.isLoading;
|
|
|
|
return Container(
|
|
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.surface,
|
|
borderRadius: BorderRadius.circular(16),
|
|
border: Border.all(
|
|
color: AppColors.cyan.withOpacity(0.15),
|
|
width: 1,
|
|
),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Header
|
|
Row(
|
|
children: [
|
|
Container(
|
|
width: 36,
|
|
height: 36,
|
|
decoration: BoxDecoration(
|
|
color: AppColors.cyan.withOpacity(0.1),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: const Icon(
|
|
Icons.storage_outlined,
|
|
color: AppColors.cyan,
|
|
size: 20,
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Storage',
|
|
style: AppTextStyles.body.copyWith(
|
|
color: AppColors.onBackground,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
Text(
|
|
'Cache and offline data',
|
|
style: AppTextStyles.bodySmall.copyWith(
|
|
color: AppColors.muted,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 16),
|
|
// Cache size display
|
|
Container(
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.surfaceVariant.withOpacity(0.5),
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Cache Size',
|
|
style: AppTextStyles.body.copyWith(
|
|
color: AppColors.onSurface,
|
|
),
|
|
),
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
cacheSize,
|
|
style: AppTextStyles.h3.copyWith(
|
|
color: AppColors.cyan,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Icon(
|
|
Icons.folder_outlined,
|
|
color: AppColors.muted,
|
|
size: 32,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
// Clear cache button
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: OutlinedButton.icon(
|
|
onPressed: isLoading
|
|
? null
|
|
: () => _showClearCacheDialog(context, ref),
|
|
icon: isLoading
|
|
? const SizedBox(
|
|
width: 18,
|
|
height: 18,
|
|
child: CircularProgressIndicator(
|
|
strokeWidth: 2,
|
|
valueColor: AlwaysStoppedAnimation<Color>(
|
|
AppColors.cyan,
|
|
),
|
|
),
|
|
)
|
|
: const Icon(Icons.delete_outline, size: 18),
|
|
label: Text(
|
|
isLoading ? 'Clearing...' : 'Clear Cache',
|
|
style: AppTextStyles.button,
|
|
),
|
|
style: OutlinedButton.styleFrom(
|
|
padding: const EdgeInsets.symmetric(vertical: 14),
|
|
side: BorderSide(
|
|
color: AppColors.rose.withOpacity(0.5),
|
|
width: 1.5,
|
|
),
|
|
foregroundColor: AppColors.rose,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
void _showClearCacheDialog(BuildContext context, WidgetRef ref) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) => AlertDialog(
|
|
backgroundColor: AppColors.surface,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(16),
|
|
side: BorderSide(
|
|
color: AppColors.cyan.withOpacity(0.2),
|
|
width: 1,
|
|
),
|
|
),
|
|
title: Row(
|
|
children: [
|
|
Container(
|
|
width: 36,
|
|
height: 36,
|
|
decoration: BoxDecoration(
|
|
color: AppColors.rose.withOpacity(0.1),
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: const Icon(
|
|
Icons.warning_outlined,
|
|
color: AppColors.rose,
|
|
size: 20,
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Text(
|
|
'Clear Cache',
|
|
style: AppTextStyles.h3.copyWith(
|
|
color: AppColors.onBackground,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
content: Text(
|
|
'This will delete all cached data. You may need to re-download content for offline use.\n\nContinue?',
|
|
style: AppTextStyles.body.copyWith(
|
|
color: AppColors.onSurface,
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: Text(
|
|
'Cancel',
|
|
style: AppTextStyles.button.copyWith(
|
|
color: AppColors.muted,
|
|
),
|
|
),
|
|
),
|
|
ElevatedButton(
|
|
onPressed: () async {
|
|
Navigator.pop(context);
|
|
try {
|
|
await ref.read(settingsProvider.notifier).clearCache();
|
|
if (context.mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(
|
|
'Cache cleared successfully',
|
|
style: AppTextStyles.body.copyWith(
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
backgroundColor: AppColors.vert,
|
|
behavior: SnackBarBehavior.floating,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} catch (e) {
|
|
if (context.mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(
|
|
'Failed to clear cache: ${e.toString()}',
|
|
style: AppTextStyles.body.copyWith(
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
backgroundColor: AppColors.error,
|
|
behavior: SnackBarBehavior.floating,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: AppColors.rose,
|
|
foregroundColor: Colors.white,
|
|
),
|
|
child: Text(
|
|
'Clear',
|
|
style: AppTextStyles.button,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|