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:
root
2026-01-18 20:08:36 +00:00
commit a89c7894cf
132 changed files with 23178 additions and 0 deletions
@@ -0,0 +1,230 @@
/// Album Track Tile - Track item for album details
library;
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../../domain/entities/track.dart';
import '../../../../core/theme/colors.dart';
import '../../providers/music_provider.dart';
import '../common/cached_network_image_with_fallback.dart';
class AlbumTrackTile extends ConsumerWidget {
final Track track;
final int index;
final VoidCallback? onTap;
final VoidCallback? onMenuTap;
const AlbumTrackTile({
required this.track,
required this.index,
this.onTap,
this.onMenuTap,
super.key,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final playerState = ref.watch(playerProvider);
final isCurrentlyPlaying =
playerState.currentTrack?.id == track.id && playerState.isPlaying;
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
decoration: BoxDecoration(
color: AppColors.surface.withOpacity(isCurrentlyPlaying ? 0.8 : 0.4),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: isCurrentlyPlaying
? AppColors.cyan.withOpacity(0.5)
: AppColors.cyan.withOpacity(0.1),
width: isCurrentlyPlaying ? 2 : 1,
),
boxShadow: isCurrentlyPlaying ? AppColors.cyanGlow : null,
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
children: [
// Track number or playing indicator
_buildTrackIndicator(isCurrentlyPlaying),
const SizedBox(width: 16),
// Track info
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
track.title,
style: TextStyle(
color: isCurrentlyPlaying
? AppColors.cyan
: AppColors.onBackground,
fontWeight:
isCurrentlyPlaying ? FontWeight.w700 : FontWeight.w600,
fontSize: 15,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
if (track.artist != null) ...[
const SizedBox(height: 4),
Text(
track.artist!.name,
style: const TextStyle(
color: AppColors.onSurfaceVariant,
fontSize: 13,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
],
),
),
// Duration
Text(
track.formattedDuration,
style: const TextStyle(
color: AppColors.muted,
fontSize: 13,
fontWeight: FontWeight.w500,
),
),
const SizedBox(width: 12),
// Menu button
_buildMenuButton(ref),
],
),
),
),
),
);
}
Widget _buildTrackIndicator(bool isPlaying) {
return SizedBox(
width: 24,
child: isPlaying
? _buildPlayingIndicator()
: Text(
'${index + 1}',
style: const TextStyle(
color: AppColors.muted,
fontSize: 14,
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.center,
),
);
}
Widget _buildPlayingIndicator() {
return SizedBox(
width: 24,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
_buildBar(0.6),
const SizedBox(height: 2),
_buildBar(1.0),
const SizedBox(height: 2),
_buildBar(0.4),
],
),
);
}
Widget _buildBar(double height) {
return AnimatedContainer(
duration: const Duration(milliseconds: 300),
width: 3,
height: 8 * height,
decoration: BoxDecoration(
color: AppColors.cyan,
borderRadius: BorderRadius.circular(2),
),
);
}
Widget _buildMenuButton(WidgetRef ref) {
return PopupMenuButton<String>(
icon: const Icon(
Icons.more_vert,
color: AppColors.muted,
size: 20,
),
color: AppColors.surface,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(
color: AppColors.cyan.withOpacity(0.3),
),
),
onSelected: (choice) {
switch (choice) {
case 'queue':
ref.read(playerProvider.notifier).addToQueue(track);
ScaffoldMessenger.of(ref.context).showSnackBar(
SnackBar(
content: Text('${track.title} added to queue'),
duration: const Duration(seconds: 2),
backgroundColor: AppColors.surface,
behavior: SnackBarBehavior.floating,
),
);
break;
case 'playlist':
// TODO: Implement add to playlist
ScaffoldMessenger.of(ref.context).showSnackBar(
SnackBar(
content: Text('Add to playlist coming soon'),
duration: const Duration(seconds: 2),
backgroundColor: AppColors.surface,
behavior: SnackBarBehavior.floating,
),
);
break;
}
},
itemBuilder: (context) => [
PopupMenuItem<String>(
value: 'queue',
child: Row(
children: const [
Icon(Icons.playlist_add, color: AppColors.cyan, size: 20),
SizedBox(width: 12),
Text(
'Add to queue',
style: TextStyle(color: AppColors.onBackground),
),
],
),
),
PopupMenuItem<String>(
value: 'playlist',
child: Row(
children: const [
Icon(Icons.playlist_play, color: AppColors.violet, size: 20),
SizedBox(width: 12),
Text(
'Add to playlist',
style: TextStyle(color: AppColors.onBackground),
),
],
),
),
],
);
}
}
@@ -0,0 +1,4 @@
/// Album Widgets Export
library;
export 'album_track_tile.dart';
@@ -0,0 +1,108 @@
/// Artist Album Card - Album item for artist details
library;
import 'package:flutter/material.dart';
import '../../../../domain/entities/album.dart';
import '../../../../core/theme/colors.dart';
import '../common/cached_network_image_with_fallback.dart';
class ArtistAlbumCard extends StatelessWidget {
final Album album;
final VoidCallback? onTap;
const ArtistAlbumCard({
required this.album,
this.onTap,
super.key,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
width: 160,
margin: const EdgeInsets.symmetric(horizontal: 8),
decoration: BoxDecoration(
color: AppColors.surface,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: AppColors.violet.withOpacity(0.2),
width: 1,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Album art
Expanded(
child: ClipRRect(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12),
),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
gradient: AppColors.accentGradient,
),
child: CachedNetworkImageWithFallback(
imageUrl: album.imageUrl,
fallbackIcon: Icons.album,
progressColor: AppColors.violet,
fit: BoxFit.cover,
),
),
),
),
// Album info
Padding(
padding: const EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
album.title,
style: const TextStyle(
color: AppColors.onBackground,
fontWeight: FontWeight.w600,
fontSize: 14,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 4),
Text(
_buildAlbumSubtitle(),
style: const TextStyle(
color: AppColors.onSurfaceVariant,
fontSize: 12,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
),
],
),
),
);
}
String _buildAlbumSubtitle() {
final parts = <String>[];
if (album.releaseDate != null) {
final year = album.releaseDate!.year;
parts.add(year.toString());
}
if (album.totalTracks > 0) {
parts.add('${album.totalTracks} songs');
}
return parts.join('');
}
}
@@ -0,0 +1,237 @@
/// Artist Track Tile - Track item for artist details
library;
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../../domain/entities/track.dart';
import '../../../../core/theme/colors.dart';
import '../../providers/music_provider.dart';
import '../common/cached_network_image_with_fallback.dart';
class ArtistTrackTile extends ConsumerWidget {
final Track track;
final int index;
final VoidCallback? onTap;
const ArtistTrackTile({
required this.track,
required this.index,
this.onTap,
super.key,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final playerState = ref.watch(playerProvider);
final isCurrentlyPlaying =
playerState.currentTrack?.id == track.id && playerState.isPlaying;
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
decoration: BoxDecoration(
color: AppColors.surface.withOpacity(isCurrentlyPlaying ? 0.8 : 0.4),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: isCurrentlyPlaying
? AppColors.cyan.withOpacity(0.5)
: AppColors.cyan.withOpacity(0.1),
width: isCurrentlyPlaying ? 2 : 1,
),
boxShadow: isCurrentlyPlaying ? AppColors.cyanGlow : null,
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
child: Padding(
padding: const EdgeInsets.all(12),
child: Row(
children: [
// Track number or playing indicator
_buildTrackIndicator(isCurrentlyPlaying),
const SizedBox(width: 16),
// Album art
_buildAlbumArt(),
const SizedBox(width: 16),
// Track info
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
track.title,
style: TextStyle(
color: isCurrentlyPlaying
? AppColors.cyan
: AppColors.onBackground,
fontWeight: FontWeight.w600,
fontSize: 15,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
if (track.album != null) ...[
const SizedBox(height: 4),
Text(
track.album!.title,
style: const TextStyle(
color: AppColors.onSurfaceVariant,
fontSize: 13,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
],
),
),
// Play count
if (track.playCount != null)
Padding(
padding: const EdgeInsets.only(right: 16),
child: _buildPlayCount(),
),
// Duration
Text(
track.formattedDuration,
style: const TextStyle(
color: AppColors.muted,
fontSize: 13,
),
),
const SizedBox(width: 12),
// Add to queue button
_buildAddToQueueButton(ref),
],
),
),
),
),
);
}
Widget _buildTrackIndicator(bool isPlaying) {
return SizedBox(
width: 24,
child: isPlaying
? _buildPlayingIndicator()
: Text(
'${index + 1}',
style: const TextStyle(
color: AppColors.muted,
fontSize: 14,
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.center,
),
);
}
Widget _buildPlayingIndicator() {
return SizedBox(
width: 24,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
_buildBar(0.6),
const SizedBox(height: 2),
_buildBar(1.0),
const SizedBox(height: 2),
_buildBar(0.4),
],
),
);
}
Widget _buildBar(double height) {
return AnimatedContainer(
duration: const Duration(milliseconds: 300),
width: 3,
height: 8 * height,
decoration: BoxDecoration(
color: AppColors.cyan,
borderRadius: BorderRadius.circular(2),
),
);
}
Widget _buildAlbumArt() {
return ClipRRect(
borderRadius: BorderRadius.circular(8),
child: SizedBox(
width: 48,
height: 48,
child: CachedNetworkImageWithFallback(
imageUrl: track.imageUrl,
fallbackIcon: Icons.album,
progressColor: AppColors.cyan,
fit: BoxFit.cover,
),
),
);
}
Widget _buildPlayCount() {
final playCount = track.playCount!;
String countText;
if (playCount >= 1000000) {
countText = '${(playCount / 1000000).toStringAsFixed(1)}M';
} else if (playCount >= 1000) {
countText = '${(playCount / 1000).toStringAsFixed(1)}K';
} else {
countText = playCount.toString();
}
return Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.play_arrow,
size: 16,
color: AppColors.muted,
),
const SizedBox(width: 4),
Text(
countText,
style: const TextStyle(
color: AppColors.muted,
fontSize: 13,
),
),
],
);
}
Widget _buildAddToQueueButton(WidgetRef ref) {
return IconButton(
icon: const Icon(
Icons.playlist_add,
color: AppColors.muted,
size: 20,
),
onPressed: () {
ref.read(playerProvider.notifier).addToQueue(track);
ScaffoldMessenger.of(ref.context).showSnackBar(
SnackBar(
content: Text('${track.title} added to queue'),
duration: const Duration(seconds: 2),
backgroundColor: AppColors.surface,
behavior: SnackBarBehavior.floating,
),
);
},
tooltip: 'Add to queue',
splashRadius: 20,
);
}
}
@@ -0,0 +1,5 @@
/// Artist Widgets - Export all artist-related widgets
library;
export 'artist_track_tile.dart';
export 'artist_album_card.dart';
@@ -0,0 +1,62 @@
/// Cached network image with themed fallback
library;
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import '../../core/theme/colors.dart';
class CachedNetworkImageWithFallback extends StatelessWidget {
final String? imageUrl;
final IconData fallbackIcon;
final Color? progressColor;
final BoxFit? fit;
const CachedNetworkImageWithFallback({
required this.imageUrl,
required this.fallbackIcon,
this.progressColor,
this.fit,
super.key,
});
@override
Widget build(BuildContext context) {
return imageUrl != null && imageUrl!.isNotEmpty
? CachedNetworkImage(
imageUrl: imageUrl!,
fit: fit ?? BoxFit.cover,
placeholder: (context, url) => Container(
color: AppColors.surfaceVariant,
child: Center(
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
progressColor ?? AppColors.cyan,
),
),
),
),
errorWidget: (context, url, error) => Container(
color: AppColors.surfaceVariant,
child: Center(
child: Icon(
fallbackIcon,
color: AppColors.onBackground.withOpacity(0.8),
size: 40,
),
),
),
)
: Container(
color: AppColors.surfaceVariant,
child: Center(
child: Icon(
fallbackIcon,
color: AppColors.onBackground.withOpacity(0.8),
size: 40,
),
),
);
}
}
@@ -0,0 +1,408 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/theme/colors.dart';
import '../../providers/music_provider.dart';
import '../../pages/player/queue_view_page.dart';
/// Mini Player Widget
class MiniPlayer extends ConsumerWidget {
final bool compact;
const MiniPlayer({
super.key,
this.compact = false,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final playerState = ref.watch(playerProvider);
final currentTrack = playerState.currentTrack;
final isPlaying = playerState.isPlaying;
return GestureDetector(
onTap: () {
// TODO: Open fullscreen player
},
child: Container(
height: 64,
decoration: BoxDecoration(
color: AppColors.surface,
border: Border(
top: BorderSide(
color: AppColors.cyan.withOpacity(0.2),
width: 1,
),
),
boxShadow: [
BoxShadow(
color: AppColors.cyan.withOpacity(0.1),
blurRadius: 10,
offset: const Offset(0, -2),
),
],
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Row(
children: [
// Album art
_buildAlbumArt(currentTrack),
const SizedBox(width: 12),
// Track info
Expanded(
child: _buildTrackInfo(currentTrack, playerState),
),
const SizedBox(width: 12),
// Controls
if (!compact)
_buildControls(ref, isPlaying)
else
_buildCompactControls(ref, isPlaying),
// Queue button
if (!compact) _buildQueueButton(context, ref),
],
),
),
),
);
}
Widget _buildAlbumArt(dynamic currentTrack) {
return Container(
width: 48,
height: 48,
decoration: BoxDecoration(
gradient: AppColors.accentGradient,
borderRadius: BorderRadius.circular(6),
boxShadow: AppColors.violetGlow,
),
child: currentTrack?.imageUrl != null
? ClipRRect(
borderRadius: BorderRadius.circular(6),
child: Image.network(
currentTrack!.imageUrl!,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return const Icon(
Icons.music_note,
color: AppColors.onBackground,
size: 24,
);
},
),
)
: const Icon(
Icons.music_note,
color: AppColors.onBackground,
size: 24,
),
);
}
Widget _buildTrackInfo(dynamic currentTrack, PlayerState playerState) {
if (currentTrack == null) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: const [
Text(
'No track playing',
style: TextStyle(
color: AppColors.onSurface,
fontSize: 14,
fontWeight: FontWeight.w500,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
SizedBox(height: 2),
Text(
'Tap to select music',
style: TextStyle(
color: AppColors.muted,
fontSize: 12,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
if (playerState.isPlaying)
Container(
width: 4,
height: 4,
margin: const EdgeInsets.only(right: 6),
decoration: const BoxDecoration(
color: AppColors.vert,
shape: BoxShape.circle,
),
),
Expanded(
child: Text(
currentTrack.title,
style: const TextStyle(
color: AppColors.onSurface,
fontSize: 14,
fontWeight: FontWeight.w500,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
),
const SizedBox(height: 2),
Text(
currentTrack.artist?.name ?? 'Unknown Artist',
style: const TextStyle(
color: AppColors.muted,
fontSize: 12,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
);
}
Widget _buildControls(WidgetRef ref, bool isPlaying) {
return Row(
children: [
_ControlButton(
icon: Icons.skip_previous,
onTap: () {
ref.read(playerProvider.notifier).previous();
},
),
const SizedBox(width: 8),
_ControlButton(
icon: isPlaying ? Icons.pause : Icons.play_arrow,
isPrimary: true,
onTap: () {
if (isPlaying) {
ref.read(playerProvider.notifier).pause();
} else {
ref.read(playerProvider.notifier).play();
}
},
),
const SizedBox(width: 8),
_ControlButton(
icon: Icons.skip_next,
onTap: () {
ref.read(playerProvider.notifier).next();
},
),
],
);
}
Widget _buildCompactControls(WidgetRef ref, bool isPlaying) {
return _ControlButton(
icon: isPlaying ? Icons.pause : Icons.play_arrow,
isPrimary: true,
size: 40,
onTap: () {
if (isPlaying) {
ref.read(playerProvider.notifier).pause();
} else {
ref.read(playerProvider.notifier).play();
}
},
);
}
Widget _buildQueueButton(BuildContext context, WidgetRef ref) {
final queueData = ref.watch(queueProvider);
return Row(
children: [
const SizedBox(width: 8),
MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () => _openQueueView(context),
child: Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: AppColors.surfaceVariant,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: queueData.hasNextTracks
? AppColors.violet.withOpacity(0.5)
: Colors.transparent,
width: 1,
),
),
child: Stack(
alignment: Alignment.center,
children: [
const Icon(
Icons.queue_music,
color: AppColors.onSurface,
size: 20,
),
if (queueData.hasNextTracks)
Positioned(
top: 6,
right: 6,
child: Container(
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
color: AppColors.violet,
shape: BoxShape.circle,
),
child: Text(
queueData.queueCount > 9
? '9+'
: '${queueData.queueCount}',
style: const TextStyle(
color: AppColors.primary,
fontSize: 8,
fontWeight: FontWeight.w600,
),
),
),
),
],
),
),
),
),
],
);
}
void _openQueueView(BuildContext context) {
Navigator.of(context).push(
PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) {
return const QueueViewPage();
},
transitionsBuilder: (context, animation, secondaryAnimation, child) {
const begin = Offset(0.0, 1.0);
const end = Offset.zero;
const curve = Curves.easeInOut;
var tween = Tween(begin: begin, end: end).chain(
CurveTween(curve: curve),
);
return SlideTransition(
position: animation.drive(tween),
child: child,
);
},
),
);
}
}
/// Control Button
class _ControlButton extends StatefulWidget {
final IconData icon;
final bool isPrimary;
final double? size;
final VoidCallback onTap;
const _ControlButton({
required this.icon,
this.isPrimary = false,
this.size,
required this.onTap,
});
@override
State<_ControlButton> createState() => _ControlButtonState();
}
class _ControlButtonState extends State<_ControlButton>
with SingleTickerProviderStateMixin {
late AnimationController _animationController;
late Animation<double> _scaleAnimation;
bool _isPressed = false;
@override
void initState() {
super.initState();
_animationController = AnimationController(
duration: const Duration(milliseconds: 100),
vsync: this,
);
_scaleAnimation = Tween<double>(begin: 1.0, end: 0.95).animate(
CurvedAnimation(
parent: _animationController,
curve: Curves.easeOut,
),
);
}
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
void _handleTapDown(TapDownDetails details) {
setState(() => _isPressed = true);
_animationController.forward();
}
void _handleTapUp(TapUpDetails details) {
setState(() => _isPressed = false);
_animationController.reverse();
}
void _handleTapCancel() {
setState(() => _isPressed = false);
_animationController.reverse();
}
@override
Widget build(BuildContext context) {
final size = widget.size ?? (widget.isPrimary ? 50 : 40);
return GestureDetector(
onTapDown: _handleTapDown,
onTapUp: _handleTapUp,
onTapCancel: _handleTapCancel,
onTap: widget.onTap,
child: ScaleTransition(
scale: _scaleAnimation,
child: Container(
width: size,
height: size,
decoration: BoxDecoration(
color: widget.isPrimary
? AppColors.cyan
: AppColors.surfaceVariant,
shape: BoxShape.circle,
boxShadow: widget.isPrimary ? AppColors.cyanGlow : null,
),
child: Icon(
widget.icon,
color: widget.isPrimary ? AppColors.primary : AppColors.onSurface,
size: size * 0.5,
),
),
),
);
}
}
@@ -0,0 +1,184 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/theme/colors.dart';
import '../../providers/navigation_provider.dart';
import '../common/mini_player.dart';
/// Desktop Navigation Sidebar
class DesktopSidebar extends ConsumerWidget {
final double width;
const DesktopSidebar({
super.key,
required this.width,
});
@override
Widget build(BuildContext context, WidgetRef ref) {
final currentPage = ref.watch(currentPageProvider);
final navigationNotifier = ref.read(navigationProvider.notifier);
return Container(
width: width,
decoration: BoxDecoration(
color: AppColors.surface,
border: Border(
right: BorderSide(
color: AppColors.cyan.withOpacity(0.1),
width: 1,
),
),
),
child: Column(
children: [
// Logo
const Padding(
padding: EdgeInsets.all(24),
child: Text(
'Spotify Le 2',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
foreground: AppColors.primaryGradient,
),
),
),
const Divider(height: 1, color: AppColors.surfaceVariant),
// Navigation items
Expanded(
child: ListView(
padding: const EdgeInsets.symmetric(vertical: 8),
children: [
..._navItems.map(
(item) => _NavItemTile(
icon: item.icon,
label: item.label,
isSelected: currentPage == item.page,
onTap: () => navigationNotifier.navigateTo(item.page),
),
),
],
),
),
// Mini player in sidebar
const Padding(
padding: EdgeInsets.all(16),
child: MiniPlayer(compact: true),
),
],
),
);
}
}
class _NavItem {
final String page;
final String label;
final IconData icon;
const _NavItem({
required this.page,
required this.label,
required this.icon,
});
}
final List<_NavItem> _navItems = const [
_NavItem(page: 'home', label: 'Home', icon: Icons.home_outlined),
_NavItem(page: 'search', label: 'Search', icon: Icons.search_outlined),
_NavItem(page: 'library', label: 'Library', icon: Icons.library_music_outlined),
_NavItem(page: 'settings', label: 'Settings', icon: Icons.settings_outlined),
];
/// Navigation Item Tile
class _NavItemTile extends StatefulWidget {
final IconData icon;
final String label;
final bool isSelected;
final VoidCallback onTap;
const _NavItemTile({
required this.icon,
required this.label,
required this.isSelected,
required this.onTap,
});
@override
State<_NavItemTile> createState() => _NavItemTileState();
}
class _NavItemTileState extends State<_NavItemTile>
with SingleTickerProviderStateMixin {
late AnimationController _animationController;
late Animation<double> _scaleAnimation;
@override
void initState() {
super.initState();
_animationController = AnimationController(
duration: const Duration(milliseconds: 200),
vsync: this,
);
_scaleAnimation = Tween<double>(begin: 1.0, end: 1.02).animate(
CurvedAnimation(
parent: _animationController,
curve: Curves.easeOut,
),
);
}
@override
void dispose() {
_animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MouseRegion(
onEnter: (_) => _animationController.forward(),
onExit: (_) => _animationController.reverse(),
child: ScaleTransition(
scale: _scaleAnimation,
child: AnimatedContainer(
duration: const Duration(milliseconds: 200),
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
color: widget.isSelected
? AppColors.cyan.withOpacity(0.1)
: Colors.transparent,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: widget.isSelected
? AppColors.cyan.withOpacity(0.3)
: Colors.transparent,
width: 1,
),
),
child: ListTile(
leading: Icon(
widget.icon,
color: widget.isSelected ? AppColors.cyan : AppColors.onSurface,
),
title: Text(
widget.label,
style: TextStyle(
color: widget.isSelected
? AppColors.cyan
: AppColors.onSurface,
fontWeight:
widget.isSelected ? FontWeight.w600 : FontWeight.w400,
),
),
onTap: widget.onTap,
),
),
),
);
}
}
@@ -0,0 +1,135 @@
import 'package:flutter/material.dart';
import '../../../core/theme/colors.dart';
/// Desktop Top Bar
class DesktopTopBar extends StatelessWidget {
const DesktopTopBar({super.key});
@override
Widget build(BuildContext context) {
return Container(
height: 60,
padding: const EdgeInsets.symmetric(horizontal: 24),
decoration: BoxDecoration(
color: AppColors.surface,
border: Border(
bottom: BorderSide(
color: AppColors.cyan.withOpacity(0.1),
width: 1,
),
),
),
child: Row(
children: [
// Search bar
Expanded(
child: _SearchBar(),
),
const SizedBox(width: 16),
// User profile
// TODO: Implement user profile menu
const _UserAvatar(),
],
),
);
}
}
/// Search Bar
class _SearchBar extends StatefulWidget {
@override
State<_SearchBar> createState() => _SearchBarState();
}
class _SearchBarState extends State<_SearchBar> {
final _focusNode = FocusNode();
bool _isFocused = false;
@override
void initState() {
super.initState();
_focusNode.addListener(() {
setState(() {
_isFocused = _focusNode.hasFocus;
});
});
}
@override
void dispose() {
_focusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedContainer(
duration: const Duration(milliseconds: 200),
decoration: BoxDecoration(
color: AppColors.surfaceVariant,
borderRadius: BorderRadius.circular(24),
border: Border.all(
color: _isFocused ? AppColors.cyan : AppColors.cyan.withOpacity(0.2),
width: _isFocused ? 2 : 1,
),
boxShadow: _isFocused
? [
BoxShadow(
color: AppColors.cyan.withOpacity(0.3),
blurRadius: 20,
spreadRadius: 0,
),
]
: null,
),
child: TextField(
focusNode: _focusNode,
style: const TextStyle(
color: AppColors.onSurface,
fontSize: 14,
),
decoration: InputDecoration(
hintText: 'Search tracks, artists, albums...',
hintStyle: TextStyle(
color: AppColors.muted,
fontSize: 14,
),
prefixIcon: const Icon(
Icons.search,
color: AppColors.cyan,
),
border: InputBorder.none,
contentPadding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 12,
),
),
),
);
}
}
/// User Avatar
class _UserAvatar extends StatelessWidget {
const _UserAvatar();
@override
Widget build(BuildContext context) {
return Container(
width: 40,
height: 40,
decoration: BoxDecoration(
gradient: AppColors.primaryGradient,
borderRadius: BorderRadius.circular(20),
boxShadow: AppColors.cyanGlow,
),
child: const Icon(
Icons.person,
color: AppColors.onBackground,
),
);
}
}
@@ -0,0 +1,116 @@
import 'package:flutter/material.dart';
import '../../../../core/theme/colors.dart';
import '../../../../domain/entities/playlist.dart';
import '../common/cached_network_image_with_fallback.dart';
/// Playlist tile widget for library
class PlaylistTile extends StatelessWidget {
final Playlist playlist;
final VoidCallback? onTap;
final VoidCallback? onDelete;
final bool canDelete;
const PlaylistTile({
required this.playlist,
this.onTap,
this.onDelete,
this.canDelete = false,
super.key,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
decoration: BoxDecoration(
color: AppColors.surfaceVariant,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: AppColors.cyan.withOpacity(0.2),
width: 1,
),
),
child: Row(
children: [
// Playlist cover
ClipRRect(
borderRadius: const BorderRadius.horizontal(
left: Radius.circular(12),
),
child: SizedBox(
width: 80,
height: 80,
child: Container(
decoration: BoxDecoration(
gradient: AppColors.primaryGradient,
),
child: CachedNetworkImageWithFallback(
imageUrl: playlist.imageUrl,
fallbackIcon: Icons.playlist_play,
progressColor: AppColors.cyan,
fit: BoxFit.cover,
),
),
),
),
// Playlist info
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
playlist.name,
style: const TextStyle(
color: AppColors.onSurface,
fontWeight: FontWeight.w600,
fontSize: 16,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 4),
Text(
'${playlist.trackCount} songs • ${playlist.formattedDuration}',
style: const TextStyle(
color: AppColors.muted,
fontSize: 13,
),
),
if (playlist.description != null &&
playlist.description!.isNotEmpty)
Padding(
padding: const EdgeInsets.only(top: 4),
child: Text(
playlist.description!,
style: const TextStyle(
color: AppColors.muted,
fontSize: 12,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
),
),
),
// Delete button (if owned)
if (canDelete && onDelete != null)
IconButton(
icon: const Icon(Icons.delete_outline, color: AppColors.muted),
onPressed: onDelete,
tooltip: 'Delete playlist',
),
],
),
),
);
}
}
@@ -0,0 +1,287 @@
import 'package:flutter/material.dart';
import '../../../../core/theme/colors.dart';
import '../../../../domain/entities/track.dart';
/// Queue Track Tile Widget
///
/// Displays a track in the queue with:
/// - Track info (art, title, artist, duration)
/// - Remove button
/// - Drag handle
/// - Visual indication for currently playing track
class QueueTrackTile extends StatelessWidget {
final Track track;
final bool isPlaying;
final int index;
final VoidCallback? onTap;
final VoidCallback? onRemove;
final bool isDragging;
const QueueTrackTile({
super.key,
required this.track,
this.isPlaying = false,
required this.index,
this.onTap,
this.onRemove,
this.isDragging = false,
});
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
decoration: BoxDecoration(
color: isPlaying
? AppColors.cyan.withOpacity(0.1)
: AppColors.surfaceVariant,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: isPlaying
? AppColors.cyan.withOpacity(0.3)
: AppColors.surfaceVariant,
width: 1,
),
boxShadow: isPlaying
? [
BoxShadow(
color: AppColors.cyan.withOpacity(0.1),
blurRadius: 10,
spreadRadius: 1,
),
]
: null,
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(12),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: Row(
children: [
// Drag handle
_buildDragHandle(),
const SizedBox(width: 8),
// Track number or playing indicator
_buildTrackIndicator(),
const SizedBox(width: 12),
// Album art
_buildAlbumArt(),
const SizedBox(width: 12),
// Track info
Expanded(
child: _buildTrackInfo(),
),
const SizedBox(width: 12),
// Duration
_buildDuration(),
const SizedBox(width: 8),
// Remove button
if (onRemove != null) _buildRemoveButton(),
],
),
),
),
),
);
}
Widget _buildDragHandle() {
return MouseRegion(
cursor: SystemMouseCursors.grab,
child: Container(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Icon(
Icons.drag_handle,
color: AppColors.muted,
size: 20,
),
),
);
}
Widget _buildTrackIndicator() {
if (isPlaying) {
return SizedBox(
width: 20,
child: _PlayingAnimation(),
);
}
return SizedBox(
width: 20,
child: Text(
'${index + 1}',
style: const TextStyle(
color: AppColors.muted,
fontSize: 14,
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.center,
),
);
}
Widget _buildAlbumArt() {
return Container(
width: 48,
height: 48,
decoration: BoxDecoration(
gradient: AppColors.accentGradient,
borderRadius: BorderRadius.circular(8),
boxShadow: isPlaying ? AppColors.violetGlow : null,
),
child: track.imageUrl != null
? ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Image.network(
track.imageUrl!,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return const Icon(
Icons.music_note,
color: AppColors.onBackground,
size: 24,
);
},
),
)
: const Icon(
Icons.music_note,
color: AppColors.onBackground,
size: 24,
),
);
}
Widget _buildTrackInfo() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
track.title,
style: TextStyle(
color: isPlaying ? AppColors.cyan : AppColors.onSurface,
fontSize: 14,
fontWeight: isPlaying ? FontWeight.w600 : FontWeight.w500,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
track.artist?.name ?? 'Unknown Artist',
style: const TextStyle(
color: AppColors.muted,
fontSize: 12,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
);
}
Widget _buildDuration() {
return Text(
track.formattedDuration,
style: const TextStyle(
color: AppColors.muted,
fontSize: 12,
fontWeight: FontWeight.w500,
),
);
}
Widget _buildRemoveButton() {
return MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: onRemove,
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: AppColors.rouge.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
),
child: const Icon(
Icons.close,
color: AppColors.rouge,
size: 18,
),
),
),
);
}
}
/// Playing Animation Widget
class _PlayingAnimation extends StatefulWidget {
@override
State<_PlayingAnimation> createState() => _PlayingAnimationState();
}
class _PlayingAnimationState extends State<_PlayingAnimation>
with SingleTickerProviderStateMixin {
late AnimationController _controller;
@override
void initState() {
super.initState();
_controller = AnimationController(
duration: const Duration(milliseconds: 800),
vsync: this,
)..repeat();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AnimatedBuilder(
animation: _controller,
builder: (context, child) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: List.generate(3, (index) {
final delay = index * 0.2;
final animation = _controller
.drive(CurveTween(curve: Curves.easeInOut))
.drive(Tween<double>(begin: 0.3, end: 1.0));
return Transform.scale(
scale: (animation.value - delay + 1) % 1 * 0.7 + 0.3,
child: Container(
width: 3,
height: 12,
margin: const EdgeInsets.symmetric(horizontal: 1),
decoration: BoxDecoration(
color: AppColors.cyan,
borderRadius: BorderRadius.circular(2),
),
),
);
}),
);
},
);
}
}
@@ -0,0 +1,292 @@
/// Playlist Track Tile - Displays a track in a playlist with drag-to-reorder support
library;
import 'package:flutter/material.dart';
import '../../../../domain/entities/track.dart';
import '../../../../core/theme/colors.dart';
import '../common/cached_network_image_with_fallback.dart';
/// Playlist track tile
class PlaylistTrackTile extends StatelessWidget {
final Track track;
final int position;
final bool isOwner;
final bool isDragging;
final VoidCallback? onTap;
final VoidCallback? onRemove;
final VoidCallback? onAddToQueue;
final VoidCallback? onDragStart;
const PlaylistTrackTile({
required this.track,
required this.position,
this.isOwner = false,
this.isDragging = false,
this.onTap,
this.onRemove,
this.onAddToQueue,
this.onDragStart,
super.key,
});
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
decoration: BoxDecoration(
color: isDragging
? AppColors.surfaceElevated.withOpacity(0.5)
: AppColors.surface,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: isDragging
? AppColors.cyan.withOpacity(0.5)
: Colors.transparent,
width: 2,
),
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
borderRadius: BorderRadius.circular(8),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: Row(
children: [
// Drag handle (for owners)
if (isOwner)
_buildDragHandle()
else
_buildPositionNumber(),
const SizedBox(width: 12),
// Album art
_buildAlbumArt(),
const SizedBox(width: 12),
// Track info
Expanded(
child: _buildTrackInfo(),
),
// Duration
_buildDuration(),
const SizedBox(width: 8),
// Menu button
_buildMenuButton(context),
// Remove button (for owners)
if (isOwner) ...[
const SizedBox(width: 8),
_buildRemoveButton(),
],
],
),
),
),
),
);
}
Widget _buildDragHandle() {
return GestureDetector(
onPanStart: (_) => onDragStart?.call(),
child: Container(
width: 24,
height: 24,
alignment: Alignment.center,
child: Icon(
Icons.drag_handle,
color: AppColors.onSurfaceVariant,
size: 20,
),
),
);
}
Widget _buildPositionNumber() {
return SizedBox(
width: 24,
child: Text(
'${position + 1}',
style: TextStyle(
color: AppColors.onSurfaceVariant,
fontSize: 14,
fontWeight: FontWeight.w500,
),
textAlign: TextAlign.center,
),
);
}
Widget _buildAlbumArt() {
return ClipRRect(
borderRadius: BorderRadius.circular(6),
child: SizedBox(
width: 48,
height: 48,
child: CachedNetworkImageWithFallback(
imageUrl: track.imageUrl,
fallbackIcon: Icons.music_note,
progressColor: AppColors.cyan,
fit: BoxFit.cover,
),
),
);
}
Widget _buildTrackInfo() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
track.title,
style: const TextStyle(
color: AppColors.onBackground,
fontSize: 15,
fontWeight: FontWeight.w600,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
track.artist?.name ?? 'Unknown Artist',
style: const TextStyle(
color: AppColors.onSurfaceVariant,
fontSize: 13,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
);
}
Widget _buildDuration() {
return Text(
track.formattedDuration,
style: const TextStyle(
color: AppColors.onSurfaceVariant,
fontSize: 13,
fontWeight: FontWeight.w500,
),
);
}
Widget _buildMenuButton(BuildContext context) {
return PopupMenuButton<String>(
icon: Icon(
Icons.more_vert,
color: AppColors.onSurfaceVariant,
),
color: AppColors.surfaceElevated,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(
color: AppColors.cyan.withOpacity(0.3),
),
),
onSelected: (value) {
switch (value) {
case 'queue':
onAddToQueue?.call();
break;
case 'remove':
onRemove?.call();
break;
}
},
itemBuilder: (context) => [
PopupMenuItem(
value: 'queue',
child: Row(
children: [
Icon(Icons.queue_music, color: AppColors.cyan, size: 20),
const SizedBox(width: 12),
const Text(
'Add to queue',
style: TextStyle(color: AppColors.onBackground),
),
],
),
),
if (isOwner)
PopupMenuItem(
value: 'remove',
child: Row(
children: [
Icon(Icons.remove_circle_outline, color: AppColors.rose, size: 20),
const SizedBox(width: 12),
const Text(
'Remove from playlist',
style: TextStyle(color: AppColors.onBackground),
),
],
),
),
],
);
}
Widget _buildRemoveButton() {
return IconButton(
icon: Icon(
Icons.remove_circle_outline,
color: AppColors.rose,
size: 20,
),
onPressed: onRemove,
tooltip: 'Remove from playlist',
padding: EdgeInsets.zero,
constraints: const BoxConstraints(
minWidth: 32,
minHeight: 32,
),
);
}
}
/// Reorderable playlist track tile
class ReorderablePlaylistTrackTile extends StatelessWidget {
final Track track;
final int position;
final bool isOwner;
final VoidCallback? onTap;
final VoidCallback? onRemove;
final VoidCallback? onAddToQueue;
const ReorderablePlaylistTrackTile({
required this.track,
required this.position,
this.isOwner = false,
this.onTap,
this.onRemove,
this.onAddToQueue,
super.key,
});
@override
Widget build(BuildContext context) {
return ReorderableDragStartListener(
key: ValueKey(track.id),
index: position,
enabled: isOwner,
child: PlaylistTrackTile(
track: track,
position: position,
isOwner: isOwner,
onTap: onTap,
onRemove: onRemove,
onAddToQueue: onAddToQueue,
),
);
}
}
@@ -0,0 +1,85 @@
import 'package:flutter/material.dart';
import '../../../../domain/entities/album.dart';
import '../common/cached_network_image_with_fallback.dart';
/// Search result card for an album
class SearchAlbumCard extends StatelessWidget {
final Album album;
final VoidCallback? onTap;
const SearchAlbumCard({
required this.album,
this.onTap,
super.key,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
decoration: BoxDecoration(
color: AppColors.surface,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: AppColors.rose.withOpacity(0.3),
),
),
child: Column(
children: [
// Album cover or placeholder
Expanded(
child: ClipRRect(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12),
),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
gradient: AppColors.fullGradient,
),
child: CachedNetworkImageWithFallback(
imageUrl: album.imageUrl,
fallbackIcon: Icons.album,
progressColor: AppColors.rose,
),
),
),
),
// Album info
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,
),
],
),
),
],
),
),
);
}
}
@@ -0,0 +1,70 @@
import 'package:flutter/material.dart';
import '../../../../domain/entities/artist.dart';
import '../common/cached_network_image_with_fallback.dart';
/// Search result card for an artist
class SearchArtistCard extends StatelessWidget {
final Artist artist;
final VoidCallback? onTap;
const SearchArtistCard({
required this.artist,
this.onTap,
super.key,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
decoration: BoxDecoration(
color: AppColors.surface,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: AppColors.violet.withOpacity(0.3),
),
),
child: Column(
children: [
// Artist image or placeholder
Expanded(
child: ClipRRect(
borderRadius: const BorderRadius.vertical(
top: Radius.circular(12),
),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
gradient: AppColors.accentGradient,
),
child: CachedNetworkImageWithFallback(
imageUrl: artist.imageUrl,
fallbackIcon: Icons.person,
progressColor: AppColors.violet,
),
),
),
),
// Artist name
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,
),
),
],
),
),
);
}
}
@@ -0,0 +1,79 @@
import 'package:flutter/material.dart';
import '../../../../domain/entities/track.dart';
import '../../../../core/theme/colors.dart';
import '../common/cached_network_image_with_fallback.dart';
/// Search result card for a track
class SearchTrackCard extends StatelessWidget {
final Track track;
final VoidCallback? onTap;
const SearchTrackCard({
required this.track,
this.onTap,
super.key,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: Container(
decoration: BoxDecoration(
gradient: AppColors.primaryGradient,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: AppColors.cyan.withOpacity(0.3),
),
),
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
// Thumbnail or icon
Expanded(
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: SizedBox(
width: double.infinity,
child: CachedNetworkImageWithFallback(
imageUrl: track.imageUrl,
fallbackIcon: Icons.music_note,
progressColor: AppColors.cyan,
fit: BoxFit.cover,
),
),
),
),
const SizedBox(height: 12),
// Track info
Text(
track.title,
style: const TextStyle(
color: AppColors.onBackground,
fontWeight: FontWeight.w600,
fontSize: 16,
),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 4),
Text(
track.artist?.name ?? 'Unknown Artist',
style: const TextStyle(
color: AppColors.onBackground,
fontSize: 14,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
),
),
);
}
}
@@ -0,0 +1,6 @@
/// Search Widgets Export
library;
export 'search_track_card.dart';
export 'search_artist_card.dart';
export 'search_album_card.dart';
@@ -0,0 +1,247 @@
/// Audio Quality Selector 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';
/// Audio quality selector widget
class AudioQualitySelector extends ConsumerWidget {
const AudioQualitySelector({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final settingsState = ref.watch(settingsProvider);
final currentQuality = settingsState.audioQuality;
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: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Header
Padding(
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
child: Row(
children: [
Container(
width: 36,
height: 36,
decoration: BoxDecoration(
color: AppColors.cyan.withOpacity(0.1),
borderRadius: BorderRadius.circular(8),
),
child: const Icon(
Icons.high_quality_outlined,
color: AppColors.cyan,
size: 20,
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Audio Quality',
style: AppTextStyles.body.copyWith(
color: AppColors.onBackground,
fontWeight: FontWeight.w600,
),
),
Text(
'Higher quality uses more data',
style: AppTextStyles.bodySmall.copyWith(
color: AppColors.muted,
),
),
],
),
),
],
),
),
const Divider(height: 1, color: AppColors.surfaceVariant),
// Audio quality options
_buildQualityOption(
context,
ref,
AudioQuality.low,
'Low',
'96 kbps',
'Best for data saving',
currentQuality,
),
_buildQualityOption(
context,
ref,
AudioQuality.medium,
'Medium',
'160 kbps',
'Good balance',
currentQuality,
),
_buildQualityOption(
context,
ref,
AudioQuality.high,
'High',
'320 kbps',
'Best quality',
currentQuality,
),
_buildQualityOption(
context,
ref,
AudioQuality.lossless,
'Lossless',
'FLAC',
'Requires Premium',
currentQuality,
requiresPremium: true,
),
],
),
);
}
Widget _buildQualityOption(
BuildContext context,
WidgetRef ref,
AudioQuality quality,
String title,
String bitrate,
String description,
AudioQuality currentQuality, {
bool requiresPremium = false,
}) {
final isSelected = currentQuality == quality;
final settingsState = ref.watch(settingsProvider);
final isPremium = settingsState.user?.isPremium ?? false;
final isLocked = requiresPremium && !isPremium;
return InkWell(
onTap: isLocked
? null
: () => ref.read(settingsProvider.notifier).setAudioQuality(quality),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
color: isSelected
? AppColors.cyan.withOpacity(0.1)
: Colors.transparent,
border: Border(
left: BorderSide(
color: isSelected ? AppColors.cyan : Colors.transparent,
width: 3,
),
),
),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Text(
title,
style: AppTextStyles.body.copyWith(
color: isLocked
? AppColors.muted
: AppColors.onBackground,
fontWeight:
isSelected ? FontWeight.w600 : FontWeight.w500,
),
),
if (requiresPremium) ...[
const SizedBox(width: 8),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 6,
vertical: 2,
),
decoration: BoxDecoration(
color: AppColors.violet.withOpacity(0.2),
borderRadius: BorderRadius.circular(4),
),
child: Text(
'PRO',
style: AppTextStyles.caption.copyWith(
color: AppColors.violet,
fontWeight: FontWeight.w700,
fontSize: 10,
),
),
),
],
],
),
const SizedBox(height: 4),
Row(
children: [
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 2,
),
decoration: BoxDecoration(
color: AppColors.surfaceVariant,
borderRadius: BorderRadius.circular(4),
),
child: Text(
bitrate,
style: AppTextStyles.caption.copyWith(
color: AppColors.onSurfaceVariant,
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(width: 8),
Text(
description,
style: AppTextStyles.bodySmall.copyWith(
color: AppColors.muted,
),
),
],
),
],
),
),
if (isLocked) ...[
Icon(
Icons.lock_outline,
color: AppColors.muted,
size: 20,
),
] else if (isSelected) ...[
Icon(
Icons.check_circle,
color: AppColors.cyan,
size: 24,
),
] else ...[
Icon(
Icons.radio_button_unchecked,
color: AppColors.muted,
size: 24,
),
],
],
),
),
);
}
}
@@ -0,0 +1,259 @@
/// 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,
),
),
],
),
);
}
}
@@ -0,0 +1,386 @@
/// Edit Profile Dialog Widget
library;
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:image_picker/image_picker.dart';
import '../../../core/theme/colors.dart';
import '../../../core/theme/text_styles.dart';
import '../../../domain/entities/user.dart';
import '../../providers/settings_provider.dart';
/// Edit profile dialog
class EditProfileDialog extends ConsumerStatefulWidget {
const EditProfileDialog({
super.key,
required this.user,
});
final User user;
@override
ConsumerState<EditProfileDialog> createState() => _EditProfileDialogState();
}
class _EditProfileDialogState extends ConsumerState<EditProfileDialog> {
late final TextEditingController _displayNameController;
final ImagePicker _imagePicker = ImagePicker();
String? _avatarUrl;
@override
void initState() {
super.initState();
_displayNameController = TextEditingController(
text: widget.user.displayName ?? widget.user.username,
);
_avatarUrl = widget.user.avatarUrl;
}
@override
void dispose() {
_displayNameController.dispose();
super.dispose();
}
Future<void> _pickImage() async {
try {
final XFile? image = await _imagePicker.pickImage(
source: ImageSource.gallery,
maxWidth: 512,
maxHeight: 512,
imageQuality: 85,
);
if (image != null && mounted) {
// For now, just show the selected image
// In production, you would upload this to your server
setState(() {
_avatarUrl = image.path;
});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Image selected. Note: Avatar upload requires server implementation.',
style: AppTextStyles.body.copyWith(
color: Colors.white,
),
),
backgroundColor: AppColors.info,
behavior: SnackBarBehavior.floating,
duration: const Duration(seconds: 3),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
);
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Failed to pick image: ${e.toString()}',
style: AppTextStyles.body.copyWith(
color: Colors.white,
),
),
backgroundColor: AppColors.error,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
);
}
}
}
Future<void> _saveProfile() async {
final displayName = _displayNameController.text.trim();
if (displayName.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Display name cannot be empty',
style: AppTextStyles.body.copyWith(
color: Colors.white,
),
),
backgroundColor: AppColors.error,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
);
return;
}
Navigator.pop(context);
try {
await ref.read(settingsProvider.notifier).updateProfile(
displayName: displayName,
avatarUrl: _avatarUrl,
);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Profile updated successfully',
style: AppTextStyles.body.copyWith(
color: Colors.white,
),
),
backgroundColor: AppColors.vert,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
);
}
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Failed to update profile: ${e.toString()}',
style: AppTextStyles.body.copyWith(
color: Colors.white,
),
),
backgroundColor: AppColors.error,
behavior: SnackBarBehavior.floating,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
);
}
}
}
@override
Widget build(BuildContext context) {
return Dialog(
backgroundColor: AppColors.surface,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
side: BorderSide(
color: AppColors.cyan.withOpacity(0.2),
width: 1,
),
),
child: Container(
constraints: const BoxConstraints(maxWidth: 400),
padding: const EdgeInsets.all(24),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Header
Row(
children: [
Text(
'Edit Profile',
style: AppTextStyles.h3.copyWith(
color: AppColors.onBackground,
fontWeight: FontWeight.w700,
),
),
const Spacer(),
IconButton(
onPressed: () => Navigator.pop(context),
icon: const Icon(Icons.close),
color: AppColors.muted,
),
],
),
const SizedBox(height: 24),
// Avatar
Center(
child: GestureDetector(
onTap: _pickImage,
child: Stack(
children: [
Container(
width: 100,
height: 100,
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: AppColors.primaryGradient,
boxShadow: AppColors.cyanGlow,
),
child: ClipOval(
child: _avatarUrl != null
// Check if it's a network URL or local file path
? (_avatarUrl!.startsWith('http')
? Image.network(
_avatarUrl!,
fit: BoxFit.cover,
errorBuilder:
(context, error, stackTrace) {
return _buildDefaultAvatar();
},
)
: Image.file(
// Use File for local path
// ignore: unnecessary_null_comparison
_avatarUrl != null
? _avatarUrl as Object
: Object(),
fit: BoxFit.cover,
errorBuilder:
(context, error, stackTrace) {
return _buildDefaultAvatar();
},
))
: _buildDefaultAvatar(),
),
),
Positioned(
bottom: 0,
right: 0,
child: Container(
width: 36,
height: 36,
decoration: BoxDecoration(
color: AppColors.cyan,
shape: BoxShape.circle,
border: Border.all(
color: AppColors.surface,
width: 3,
),
),
child: const Icon(
Icons.camera_alt_outlined,
color: AppColors.primary,
size: 18,
),
),
),
],
),
),
),
const SizedBox(height: 16),
Center(
child: Text(
'Tap to change photo',
style: AppTextStyles.bodySmall.copyWith(
color: AppColors.cyan,
),
),
),
const SizedBox(height: 24),
// Display name field
Text(
'Display Name',
style: AppTextStyles.label.copyWith(
color: AppColors.onSurface,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 8),
TextField(
controller: _displayNameController,
style: AppTextStyles.body.copyWith(
color: AppColors.onBackground,
),
decoration: InputDecoration(
hintText: 'Enter display name',
hintStyle: AppTextStyles.body.copyWith(
color: AppColors.muted,
),
filled: true,
fillColor: AppColors.surfaceVariant.withOpacity(0.5),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(
color: AppColors.cyan.withOpacity(0.2),
width: 2,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(
color: AppColors.cyan.withOpacity(0.2),
width: 2,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(
color: AppColors.cyan,
width: 2,
),
),
),
),
const SizedBox(height: 24),
// Buttons
Row(
children: [
Expanded(
child: OutlinedButton(
onPressed: () => Navigator.pop(context),
style: OutlinedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 14),
side: BorderSide(
color: AppColors.muted.withOpacity(0.5),
width: 1.5,
),
foregroundColor: AppColors.muted,
),
child: Text(
'Cancel',
style: AppTextStyles.button,
),
),
),
const SizedBox(width: 12),
Expanded(
child: ElevatedButton(
onPressed: _saveProfile,
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 14),
backgroundColor: AppColors.cyan,
foregroundColor: AppColors.primary,
),
child: Text(
'Save',
style: AppTextStyles.button,
),
),
),
],
),
],
),
),
);
}
Widget _buildDefaultAvatar() {
final firstLetter = (widget.user.displayName ?? widget.user.username)
.substring(0, 1)
.toUpperCase();
return Container(
color: AppColors.surfaceVariant,
child: Center(
child: Text(
firstLetter,
style: AppTextStyles.h2.copyWith(
color: AppColors.cyan,
fontWeight: FontWeight.w700,
),
),
),
);
}
}
@@ -0,0 +1,192 @@
/// Profile Section 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 '../../../domain/entities/user.dart';
import '../../providers/settings_provider.dart';
import 'edit_profile_dialog.dart';
/// Profile section widget
class ProfileSection extends ConsumerWidget {
const ProfileSection({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final settingsState = ref.watch(settingsProvider);
final user = settingsState.user;
if (user == null) {
return const SizedBox.shrink();
}
return Container(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
AppColors.surface,
AppColors.surfaceVariant,
],
),
borderRadius: BorderRadius.circular(20),
border: Border.all(
color: AppColors.cyan.withOpacity(0.2),
width: 1,
),
boxShadow: [
BoxShadow(
color: AppColors.cyan.withOpacity(0.1),
blurRadius: 20,
offset: const Offset(0, 8),
),
],
),
child: Padding(
padding: const EdgeInsets.all(20),
child: Column(
children: [
// Avatar and name
Row(
children: [
// Avatar
Container(
width: 80,
height: 80,
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: AppColors.primaryGradient,
boxShadow: AppColors.cyanGlow,
),
child: ClipOval(
child: user.avatarUrl != null
? Image.network(
user.avatarUrl!,
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return _buildDefaultAvatar(user);
},
)
: _buildDefaultAvatar(user),
),
),
const SizedBox(width: 20),
// Name and email
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Flexible(
child: Text(
user.displayName ?? user.username,
style: AppTextStyles.h3.copyWith(
color: AppColors.onBackground,
fontWeight: FontWeight.w600,
),
overflow: TextOverflow.ellipsis,
),
),
if (user.isPremium) ...[
const SizedBox(width: 8),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
decoration: BoxDecoration(
gradient: AppColors.accentGradient,
borderRadius: BorderRadius.circular(12),
boxShadow: [
BoxShadow(
color: AppColors.violet.withOpacity(0.3),
blurRadius: 8,
),
],
),
child: Text(
'PREMIUM',
style: AppTextStyles.caption.copyWith(
color: Colors.white,
fontWeight: FontWeight.w700,
letterSpacing: 1,
),
),
),
],
],
),
const SizedBox(height: 6),
Text(
user.email,
style: AppTextStyles.body.copyWith(
color: AppColors.muted,
),
),
const SizedBox(height: 6),
Text(
'@${user.username}',
style: AppTextStyles.bodySmall.copyWith(
color: AppColors.onSurfaceVariant,
),
),
],
),
),
],
),
const SizedBox(height: 20),
// Edit Profile Button
SizedBox(
width: double.infinity,
child: ElevatedButton.icon(
onPressed: () => _showEditProfileDialog(context, ref, user),
icon: const Icon(Icons.edit_outlined, size: 18),
label: const Text('Edit Profile'),
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 14),
backgroundColor: AppColors.cyan.withOpacity(0.15),
foregroundColor: AppColors.cyan,
elevation: 0,
side: BorderSide(
color: AppColors.cyan.withOpacity(0.3),
width: 1,
),
),
),
),
],
),
),
);
}
Widget _buildDefaultAvatar(User user) {
return Container(
color: AppColors.surfaceVariant,
child: Center(
child: Text(
(user.displayName ?? user.username)
.substring(0, 1)
.toUpperCase(),
style: AppTextStyles.h2.copyWith(
color: AppColors.cyan,
fontWeight: FontWeight.w700,
),
),
),
);
}
void _showEditProfileDialog(BuildContext context, WidgetRef ref, User user) {
showDialog(
context: context,
builder: (context) => EditProfileDialog(user: user),
);
}
}
@@ -0,0 +1,195 @@
/// Settings Tile - Reusable settings item widget
library;
import 'package:flutter/material.dart';
import '../../../core/theme/colors.dart';
import '../../../core/theme/text_styles.dart';
/// Reusable settings tile widget
class SettingsTile extends StatelessWidget {
const SettingsTile({
super.key,
required this.title,
this.subtitle,
this.leading,
this.trailing,
this.onTap,
this.isEnabled = true,
});
final String title;
final String? subtitle;
final Widget? leading;
final Widget? trailing;
final VoidCallback? onTap;
final bool isEnabled;
@override
Widget build(BuildContext context) {
return Opacity(
opacity: isEnabled ? 1.0 : 0.5,
child: InkWell(
onTap: isEnabled ? onTap : null,
borderRadius: BorderRadius.circular(12),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 12,
),
child: Row(
children: [
if (leading != null) ...[
Container(
width: 40,
height: 40,
decoration: BoxDecoration(
color: AppColors.cyan.withOpacity(0.1),
borderRadius: BorderRadius.circular(10),
),
child: IconTheme(
data: IconThemeData(
color: AppColors.cyan,
size: 20,
),
child: leading!,
),
),
const SizedBox(width: 16),
],
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: AppTextStyles.body.copyWith(
color: AppColors.onBackground,
fontWeight: FontWeight.w500,
),
),
if (subtitle != null) ...[
const SizedBox(height: 4),
Text(
subtitle!,
style: AppTextStyles.bodySmall.copyWith(
color: AppColors.muted,
),
),
],
],
),
),
if (trailing != null) trailing!,
],
),
),
),
);
}
}
/// Settings tile with toggle switch
class SettingsToggleTile extends StatelessWidget {
const SettingsToggleTile({
super.key,
required this.title,
this.subtitle,
this.leading,
required this.value,
required this.onChanged,
this.isEnabled = true,
});
final String title;
final String? subtitle;
final Widget? leading;
final bool value;
final ValueChanged<bool>? onChanged;
final bool isEnabled;
@override
Widget build(BuildContext context) {
return SettingsTile(
title: title,
subtitle: subtitle,
leading: leading,
isEnabled: isEnabled,
trailing: Switch(
value: value,
onChanged: isEnabled ? onChanged : null,
activeColor: AppColors.cyan,
activeTrackColor: AppColors.cyan.withOpacity(0.3),
inactiveTrackColor: AppColors.surfaceVariant,
inactiveThumbColor: AppColors.muted,
),
);
}
}
/// Settings section header
class SettingsSectionHeader extends StatelessWidget {
const SettingsSectionHeader({
super.key,
required this.title,
this.padding = const EdgeInsets.fromLTRB(16, 24, 16, 8),
});
final String title;
final EdgeInsetsGeometry padding;
@override
Widget build(BuildContext context) {
return Padding(
padding: padding,
child: Text(
title.toUpperCase(),
style: AppTextStyles.label.copyWith(
color: AppColors.cyan,
fontWeight: FontWeight.w600,
letterSpacing: 1.2,
),
),
);
}
}
/// Settings card container
class SettingsCard extends StatelessWidget {
const SettingsCard({
super.key,
required this.children,
this.padding = const EdgeInsets.all(8),
});
final List<Widget> children;
final EdgeInsetsGeometry padding;
@override
Widget build(BuildContext context) {
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,
),
boxShadow: [
BoxShadow(
color: AppColors.cyan.withOpacity(0.05),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: Padding(
padding: padding,
child: Column(
mainAxisSize: MainAxisSize.min,
children: children,
),
),
);
}
}
@@ -0,0 +1,8 @@
/// Settings Widgets Export
library;
export 'profile_section.dart';
export 'audio_quality_selector.dart';
export 'cache_management_tile.dart';
export 'settings_tile.dart';
export 'edit_profile_dialog.dart';