72 lines
2.4 KiB
Dart
72 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../models/song.dart';
|
|
import '../utils/farb_theme.dart';
|
|
import 'metadaten_dialog.dart';
|
|
|
|
class SongTile extends StatelessWidget {
|
|
final Song song;
|
|
final bool istFavorit;
|
|
final ValueChanged<Song> onFavoriteToggle;
|
|
final ValueChanged<Song> onPlay;
|
|
final VoidCallback onMetadataChanged;
|
|
|
|
const SongTile({
|
|
super.key,
|
|
required this.song,
|
|
required this.istFavorit,
|
|
required this.onFavoriteToggle,
|
|
required this.onPlay,
|
|
required this.onMetadataChanged,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final hatDatei = song.dateiPfad.isNotEmpty;
|
|
return ListTile(
|
|
contentPadding: const EdgeInsets.symmetric(vertical: 2),
|
|
leading: Container(
|
|
width: 44, height: 44,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(10),
|
|
gradient: const LinearGradient(colors: [Color(0xFF1A0000), Color(0xFF660000)]),
|
|
),
|
|
child: const Center(child: Text('♪', style: TextStyle(fontSize: 18, color: Colors.white54))),
|
|
),
|
|
title: Text(song.titel, style: const TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white)),
|
|
subtitle: Text(song.kuenstler, style: const TextStyle(fontSize: 12, color: MeloTheme.textSekundaer)),
|
|
trailing: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
InkWell(
|
|
borderRadius: BorderRadius.circular(50),
|
|
onTap: () async {
|
|
final geaendert = await showDialog<bool>(
|
|
context: context,
|
|
builder: (_) => MetadatenDialog(song: song),
|
|
);
|
|
if (geaendert == true) onMetadataChanged();
|
|
},
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(6),
|
|
child: Icon(Icons.edit, size: 14, color: MeloTheme.textSekundaer),
|
|
),
|
|
),
|
|
InkWell(
|
|
borderRadius: BorderRadius.circular(50),
|
|
onTap: () => onFavoriteToggle(song),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(6),
|
|
child: Icon(
|
|
istFavorit ? Icons.favorite : Icons.favorite_border,
|
|
size: 16, color: MeloTheme.rot,
|
|
),
|
|
),
|
|
),
|
|
Text(song.dauerFormatiert, style: const TextStyle(fontSize: 12, color: MeloTheme.textSekundaer)),
|
|
],
|
|
),
|
|
onTap: hatDatei ? () => onPlay(song) : null,
|
|
);
|
|
}
|
|
}
|