Initial commit
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
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) {
|
||||
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,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user