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>
289 lines
7.6 KiB
Dart
289 lines
7.6 KiB
Dart
/// Search Page - Desktop Layout
|
|
library;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../../../core/theme/colors.dart';
|
|
import '../../providers/search_provider.dart';
|
|
import '../../providers/music_provider.dart';
|
|
import '../../../domain/entities/track.dart';
|
|
import '../../../domain/entities/artist.dart';
|
|
import '../../../domain/entities/album.dart';
|
|
import '../../widgets/search/search_track_card.dart';
|
|
import '../../widgets/search/search_artist_card.dart';
|
|
import '../../widgets/search/search_album_card.dart';
|
|
|
|
class SearchDesktopPage extends ConsumerStatefulWidget {
|
|
const SearchDesktopPage({super.key});
|
|
|
|
@override
|
|
ConsumerState<SearchDesktopPage> createState() => _SearchDesktopPageState();
|
|
}
|
|
|
|
class _SearchDesktopPageState extends ConsumerState<SearchDesktopPage> {
|
|
final _controller = TextEditingController();
|
|
final _focusNode = FocusNode();
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
_focusNode.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
children: [
|
|
// Search bar
|
|
Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: _buildSearchBar(),
|
|
),
|
|
// Results
|
|
Expanded(
|
|
child: _buildResults(),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildSearchBar() {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: AppColors.surfaceVariant,
|
|
borderRadius: BorderRadius.circular(28),
|
|
border: Border.all(
|
|
color: AppColors.cyan.withOpacity(0.2),
|
|
width: 2,
|
|
),
|
|
),
|
|
child: TextField(
|
|
controller: _controller,
|
|
focusNode: _focusNode,
|
|
style: const TextStyle(color: AppColors.onSurface, fontSize: 16),
|
|
decoration: InputDecoration(
|
|
hintText: 'What do you want to listen to?',
|
|
hintStyle: const TextStyle(color: AppColors.muted),
|
|
prefixIcon: const Icon(Icons.search, color: AppColors.cyan),
|
|
suffixIcon: _controller.text.isNotEmpty
|
|
? IconButton(
|
|
icon: const Icon(Icons.clear, color: AppColors.muted),
|
|
onPressed: () {
|
|
_controller.clear();
|
|
ref.read(searchProvider.notifier).clear();
|
|
},
|
|
)
|
|
: null,
|
|
border: InputBorder.none,
|
|
contentPadding:
|
|
const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
|
),
|
|
onChanged: (value) {
|
|
ref.read(searchProvider.notifier).search(value);
|
|
setState(() {});
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildResults() {
|
|
final searchState = ref.watch(searchProvider);
|
|
|
|
if (searchState.query.isEmpty) {
|
|
return _buildEmptyState();
|
|
}
|
|
|
|
if (searchState.isSearching) {
|
|
return const Center(
|
|
child: CircularProgressIndicator(color: AppColors.cyan),
|
|
);
|
|
}
|
|
|
|
if (searchState.error != null) {
|
|
return _buildErrorState(searchState.error ?? 'Unknown error');
|
|
}
|
|
|
|
if (searchState.totalResults == 0) {
|
|
return _buildNoResultsState();
|
|
}
|
|
|
|
return CustomScrollView(
|
|
slivers: [
|
|
// Tracks section
|
|
if (searchState.tracks.isNotEmpty)
|
|
SliverToBoxAdapter(
|
|
child: _buildSection('Tracks', searchState.tracks),
|
|
),
|
|
|
|
// Artists section
|
|
if (searchState.artists.isNotEmpty)
|
|
SliverToBoxAdapter(
|
|
child: _buildSection('Artists', searchState.artists),
|
|
),
|
|
|
|
// Albums section
|
|
if (searchState.albums.isNotEmpty)
|
|
SliverToBoxAdapter(
|
|
child: _buildSection('Albums', searchState.albums),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildSection(String title, List<dynamic> items) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.fromLTRB(24, 24, 24, 12),
|
|
child: Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.cyan,
|
|
),
|
|
),
|
|
),
|
|
GridView.builder(
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
padding: const EdgeInsets.symmetric(horizontal: 24),
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 4,
|
|
mainAxisSpacing: 16,
|
|
crossAxisSpacing: 16,
|
|
childAspectRatio: 1,
|
|
),
|
|
itemCount: items.length,
|
|
itemBuilder: (context, index) {
|
|
return _buildResultCard(items[index]);
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget _buildResultCard(dynamic item) {
|
|
final playerNotifier = ref.read(playerProvider.notifier);
|
|
|
|
if (item is Track) {
|
|
// It's a track - play on tap
|
|
return SearchTrackCard(
|
|
track: item,
|
|
onTap: () => _playTrack(item, playerNotifier),
|
|
);
|
|
} else if (item is Artist) {
|
|
// It's an artist - show details (TODO: navigate)
|
|
return SearchArtistCard(
|
|
artist: item,
|
|
onTap: () => _showArtistDetails(item),
|
|
);
|
|
} else if (item is Album) {
|
|
// It's an album - show details (TODO: navigate)
|
|
return SearchAlbumCard(
|
|
album: item,
|
|
onTap: () => _showAlbumDetails(item),
|
|
);
|
|
}
|
|
|
|
return const SizedBox.shrink();
|
|
}
|
|
|
|
void _playTrack(Track track, PlayerNotifier playerNotifier) {
|
|
// Set as queue and play
|
|
playerNotifier.setQueue([track], startIndex: 0);
|
|
playerNotifier.loadTrack(track);
|
|
playerNotifier.play();
|
|
}
|
|
|
|
void _showArtistDetails(Artist artist) {
|
|
// TODO: Navigate to artist details page
|
|
print('Show artist: ${artist.name}');
|
|
}
|
|
|
|
void _showAlbumDetails(Album album) {
|
|
// TODO: Navigate to album details page
|
|
print('Show album: ${album.title}');
|
|
}
|
|
|
|
Widget _buildEmptyState() {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
Icons.search,
|
|
size: 64,
|
|
color: AppColors.muted,
|
|
),
|
|
const SizedBox(height: 16),
|
|
const Text(
|
|
'Search for your favorite music',
|
|
style: TextStyle(
|
|
fontSize: 18,
|
|
color: AppColors.muted,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildErrorState(String error) {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
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,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildNoResultsState() {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(
|
|
Icons.music_off,
|
|
size: 64,
|
|
color: AppColors.muted,
|
|
),
|
|
const SizedBox(height: 16),
|
|
const Text(
|
|
'No results found',
|
|
style: TextStyle(
|
|
fontSize: 18,
|
|
color: AppColors.muted,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|