## Critical Fixes - Fix CRITICAL-1: Empty scans no longer delete entire library - Use timestamp-based tombstone logic instead of path-based - Only mark missing if livePaths is not empty - Fix CRITICAL-2: Re-scanned files now return from deleted state - Add deleted=false to SongsCompanion.insert in both scanners ## High Priority Fixes - HIGH-1: Fix SQLite variable limit crash on large libraries - Replace isNotIn() with timestamp comparison (O(1) not O(n)) - HIGH-2: Fix UI freezing during scan - Throttle progress updates (every 50 files or end of scan) - HIGH-3: Add error handling for scan failures - Wrap scanFolders/scanAndroidMediaStore in try/catch - Display scanError banner in LibraryScreen - HIGH-4: Add error handling for playback failures - Wrap loadPlaylist in try/catch ## Medium Priority Fixes - MEDIUM-1: Replace ! with ?? to handle unknown ProcessingState - MEDIUM-2: Escape LIKE wildcards in search queries - MEDIUM-4: Display StreamBuilder errors instead of treating as empty - MEDIUM-8: Add tooltips to all IconButtons for accessibility - Add doc comments to public database APIs ## Testing - Add regression tests for CRITICAL-1 and CRITICAL-2 - All 9 existing tests pass Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
77 lines
2.3 KiB
Dart
77 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'library/database.dart';
|
|
import 'library/library_service.dart';
|
|
import 'library/song_list.dart';
|
|
|
|
/// Startseite: zuletzt hinzugefügte Songs, sonst ein Willkommens-Hinweis.
|
|
class HomeScreen extends StatelessWidget {
|
|
const HomeScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final db = context.read<MeloDb>();
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Melo',
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 26)),
|
|
),
|
|
body: StreamBuilder<List<Song>>(
|
|
stream: db.watchRecent(),
|
|
builder: (context, snapshot) {
|
|
if (snapshot.hasError) {
|
|
return Center(
|
|
child: Text('Fehler: ${snapshot.error}',
|
|
style: const TextStyle(color: Colors.white54)),
|
|
);
|
|
}
|
|
final songs = snapshot.data ?? const [];
|
|
if (songs.isEmpty) return const _Welcome();
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const Padding(
|
|
padding: EdgeInsets.fromLTRB(16, 8, 16, 8),
|
|
child: Text('Zuletzt hinzugefügt',
|
|
style:
|
|
TextStyle(fontSize: 18, fontWeight: FontWeight.w600)),
|
|
),
|
|
Expanded(child: SongList(songs)),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _Welcome extends StatelessWidget {
|
|
const _Welcome();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final lib = context.read<LibraryService>();
|
|
return Center(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
const Icon(Icons.music_note, size: 72, color: Colors.white24),
|
|
const SizedBox(height: 12),
|
|
const Text('Willkommen bei Melo',
|
|
style: TextStyle(fontSize: 18)),
|
|
const SizedBox(height: 4),
|
|
const Text('Füge deine Musik hinzu, um loszulegen',
|
|
style: TextStyle(color: Colors.white54)),
|
|
const SizedBox(height: 20),
|
|
FilledButton.icon(
|
|
icon: const Icon(Icons.create_new_folder_outlined),
|
|
label: Text(addMusicLabel),
|
|
onPressed: lib.pickFolderAndScan,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|