Initial commit: AudiOhm - Alternative Spotify avec streaming YouTube
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>
This commit is contained in:
@@ -0,0 +1,542 @@
|
||||
/// Library Page - Desktop Layout
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../../core/theme/colors.dart';
|
||||
import '../../providers/library_provider.dart';
|
||||
import '../../widgets/library/playlist_tile.dart';
|
||||
import '../../../domain/entities/track.dart';
|
||||
import '../../../domain/entities/album.dart';
|
||||
import '../../../domain/entities/artist.dart';
|
||||
|
||||
class LibraryDesktopPage extends ConsumerStatefulWidget {
|
||||
const LibraryDesktopPage({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<LibraryDesktopPage> createState() =>
|
||||
_LibraryDesktopPageState();
|
||||
}
|
||||
|
||||
class _LibraryDesktopPageState extends ConsumerState<LibraryDesktopPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: 4, vsync: this);
|
||||
// Load library on init
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
ref.read(libraryProvider.notifier).loadLibrary();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final libraryState = ref.watch(libraryProvider);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
// Header with tabs
|
||||
_buildHeader(libraryState),
|
||||
|
||||
// Content based on selected tab
|
||||
Expanded(
|
||||
child: _buildContent(libraryState),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader(dynamic libraryState) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surfaceVariant.withOpacity(0.5),
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: AppColors.cyan.withOpacity(0.2),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.library_music,
|
||||
color: AppColors.cyan,
|
||||
size: 32,
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
const Text(
|
||||
'Your Library',
|
||||
style: TextStyle(
|
||||
color: AppColors.onSurface,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
if (libraryState.totalItems > 0)
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh, color: AppColors.cyan),
|
||||
onPressed: () {
|
||||
ref.read(libraryProvider.notifier).refresh();
|
||||
},
|
||||
tooltip: 'Refresh',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContent(dynamic libraryState) {
|
||||
if (libraryState.isLoading) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(color: AppColors.cyan),
|
||||
);
|
||||
}
|
||||
|
||||
if (libraryState.error != null) {
|
||||
return _buildErrorState(libraryState.error ?? 'Unknown error');
|
||||
}
|
||||
|
||||
return TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
_buildPlaylistsTab(libraryState.playlists),
|
||||
_buildLikedSongsTab(libraryState.likedSongs),
|
||||
_buildAlbumsTab(libraryState.savedAlbums),
|
||||
_buildArtistsTab(libraryState.followedArtists),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPlaylistsTab(List<dynamic> playlists) {
|
||||
if (playlists.isEmpty) {
|
||||
return _buildEmptyState(
|
||||
icon: Icons.playlist_play,
|
||||
message: 'No playlists yet',
|
||||
submessage: 'Create your first playlist to get started',
|
||||
);
|
||||
}
|
||||
|
||||
return GridView.builder(
|
||||
padding: const EdgeInsets.all(24),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 4,
|
||||
mainAxisSpacing: 16,
|
||||
crossAxisSpacing: 16,
|
||||
childAspectRatio: 2.5,
|
||||
),
|
||||
itemCount: playlists.length,
|
||||
itemBuilder: (context, index) {
|
||||
final playlist = playlists[index];
|
||||
return PlaylistTile(
|
||||
playlist: playlist,
|
||||
onTap: () => _openPlaylist(playlist),
|
||||
canDelete: true,
|
||||
onDelete: () => _confirmDeletePlaylist(playlist),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLikedSongsTab(List<dynamic> likedSongs) {
|
||||
if (likedSongs.isEmpty) {
|
||||
return _buildEmptyState(
|
||||
icon: Icons.favorite_border,
|
||||
message: 'No liked songs',
|
||||
submessage: 'Like songs to see them here',
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
padding: const EdgeInsets.all(24),
|
||||
itemCount: likedSongs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final track = likedSongs[index] as Track;
|
||||
return _buildTrackTile(track, index);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAlbumsTab(List<dynamic> albums) {
|
||||
if (albums.isEmpty) {
|
||||
return _buildEmptyState(
|
||||
icon: Icons.album,
|
||||
message: 'No saved albums',
|
||||
submessage: 'Save albums to see them here',
|
||||
);
|
||||
}
|
||||
|
||||
return GridView.builder(
|
||||
padding: const EdgeInsets.all(24),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 4,
|
||||
mainAxisSpacing: 16,
|
||||
crossAxisSpacing: 16,
|
||||
childAspectRatio: 1,
|
||||
),
|
||||
itemCount: albums.length,
|
||||
itemBuilder: (context, index) {
|
||||
final album = albums[index] as Album;
|
||||
return _buildAlbumCard(album);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildArtistsTab(List<dynamic> artists) {
|
||||
if (artists.isEmpty) {
|
||||
return _buildEmptyState(
|
||||
icon: Icons.person,
|
||||
message: 'No followed artists',
|
||||
submessage: 'Follow artists to see them here',
|
||||
);
|
||||
}
|
||||
|
||||
return GridView.builder(
|
||||
padding: const EdgeInsets.all(24),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 4,
|
||||
mainAxisSpacing: 16,
|
||||
crossAxisSpacing: 16,
|
||||
childAspectRatio: 1,
|
||||
),
|
||||
itemCount: artists.length,
|
||||
itemBuilder: (context, index) {
|
||||
final artist = artists[index] as Artist;
|
||||
return _buildArtistCard(artist);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTrackTile(Track track, int index) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surfaceVariant,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: AppColors.cyan.withOpacity(0.1),
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
leading: Text(
|
||||
'${index + 1}',
|
||||
style: const TextStyle(
|
||||
color: AppColors.muted,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
track.title,
|
||||
style: const TextStyle(
|
||||
color: AppColors.onSurface,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
subtitle: Text(
|
||||
track.artist?.name ?? 'Unknown Artist',
|
||||
style: const TextStyle(
|
||||
color: AppColors.muted,
|
||||
),
|
||||
),
|
||||
trailing: Text(
|
||||
track.formattedDuration,
|
||||
style: const TextStyle(
|
||||
color: AppColors.muted,
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
// TODO: Play track
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAlbumCard(Album album) {
|
||||
return GestureDetector(
|
||||
onTap: () => _openAlbum(album),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surface,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: AppColors.rose.withOpacity(0.3),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
gradient: AppColors.accentGradient,
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(12),
|
||||
),
|
||||
),
|
||||
child: album.imageUrl != null
|
||||
? ClipRRect(
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(12),
|
||||
),
|
||||
child: Image.network(
|
||||
album.imageUrl!,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return const Icon(
|
||||
Icons.album,
|
||||
size: 64,
|
||||
color: AppColors.muted,
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
: const Icon(
|
||||
Icons.album,
|
||||
size: 64,
|
||||
color: AppColors.muted,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
album.title,
|
||||
style: const TextStyle(
|
||||
color: AppColors.onSurface,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
if (album.artist != null)
|
||||
Text(
|
||||
album.artist!.name,
|
||||
style: const TextStyle(
|
||||
color: AppColors.muted,
|
||||
fontSize: 12,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildArtistCard(Artist artist) {
|
||||
return GestureDetector(
|
||||
onTap: () => _openArtist(artist),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.surface,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: AppColors.violet.withOpacity(0.3),
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Container(
|
||||
width: 100,
|
||||
height: 100,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
gradient: AppColors.primaryGradient,
|
||||
),
|
||||
child: artist.imageUrl != null
|
||||
? ClipOval(
|
||||
child: Image.network(
|
||||
artist.imageUrl!,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
return const Icon(
|
||||
Icons.person,
|
||||
size: 48,
|
||||
color: AppColors.muted,
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
: const Icon(
|
||||
Icons.person,
|
||||
size: 48,
|
||||
color: AppColors.muted,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Text(
|
||||
artist.name,
|
||||
style: const TextStyle(
|
||||
color: AppColors.onSurface,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildEmptyState({
|
||||
required IconData icon,
|
||||
required String message,
|
||||
required String submessage,
|
||||
}) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 64,
|
||||
color: AppColors.muted,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
message,
|
||||
style: const TextStyle(
|
||||
fontSize: 18,
|
||||
color: AppColors.onSurface,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
submessage,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.muted,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildErrorState(String error) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error_outline,
|
||||
size: 64,
|
||||
color: AppColors.error,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'Something went wrong',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
color: AppColors.error,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
error,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
color: AppColors.muted,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
ref.read(libraryProvider.notifier).refresh();
|
||||
},
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: const Text('Retry'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.cyan,
|
||||
foregroundColor: AppColors.primary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _openPlaylist(dynamic playlist) {
|
||||
// TODO: Navigate to playlist details
|
||||
print('Opening playlist: ${playlist.name}');
|
||||
}
|
||||
|
||||
void _confirmDeletePlaylist(dynamic playlist) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
backgroundColor: AppColors.surfaceVariant,
|
||||
title: const Text(
|
||||
'Delete Playlist?',
|
||||
style: TextStyle(color: AppColors.onSurface),
|
||||
),
|
||||
content: Text(
|
||||
'Are you sure you want to delete "${playlist.name}"? This action cannot be undone.',
|
||||
style: const TextStyle(color: AppColors.muted),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text(
|
||||
'Cancel',
|
||||
style: TextStyle(color: AppColors.muted),
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
ref.read(libraryProvider.notifier).deletePlaylist(playlist.id);
|
||||
},
|
||||
child: const Text(
|
||||
'Delete',
|
||||
style: TextStyle(color: AppColors.error),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _openAlbum(Album album) {
|
||||
// TODO: Navigate to album details
|
||||
print('Opening album: ${album.title}');
|
||||
}
|
||||
|
||||
void _openArtist(Artist artist) {
|
||||
// TODO: Navigate to artist details
|
||||
print('Opening artist: ${artist.name}');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user