Initial commit
This commit is contained in:
+116
@@ -0,0 +1,116 @@
|
||||
import 'package:audio_service/audio_service.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'home_screen.dart';
|
||||
import 'library/database.dart';
|
||||
import 'library/library_screen.dart';
|
||||
import 'library/library_service.dart';
|
||||
import 'library/search_screen.dart';
|
||||
import 'player/audio_handler.dart';
|
||||
import 'player/mini_player.dart';
|
||||
import 'shared/theme.dart';
|
||||
|
||||
late final MeloAudioHandler _handler;
|
||||
late final MeloDb _db;
|
||||
late final LibraryService _library;
|
||||
|
||||
Future<void> main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
_db = MeloDb();
|
||||
_library = LibraryService(_db);
|
||||
_handler = await AudioService.init(
|
||||
builder: () => MeloAudioHandler(),
|
||||
config: const AudioServiceConfig(
|
||||
androidNotificationChannelId: 'de.baka.melo.audio',
|
||||
androidNotificationChannelName: 'Melo',
|
||||
androidNotificationOngoing: true,
|
||||
),
|
||||
);
|
||||
runApp(const MeloApp());
|
||||
}
|
||||
|
||||
class MeloApp extends StatelessWidget {
|
||||
const MeloApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
Provider<MeloAudioHandler>.value(value: _handler),
|
||||
Provider<MeloDb>.value(value: _db),
|
||||
ChangeNotifierProvider<LibraryService>.value(value: _library),
|
||||
],
|
||||
child: MaterialApp(
|
||||
title: 'Melo',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: MeloTheme.dark,
|
||||
home: const HomeShell(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class HomeShell extends StatefulWidget {
|
||||
const HomeShell({super.key});
|
||||
|
||||
@override
|
||||
State<HomeShell> createState() => _HomeShellState();
|
||||
}
|
||||
|
||||
class _HomeShellState extends State<HomeShell> {
|
||||
int _index = 0;
|
||||
|
||||
static const _tabs = <Widget>[
|
||||
HomeScreen(),
|
||||
LibraryScreen(),
|
||||
SearchScreen(),
|
||||
_Placeholder(label: 'Playlists', hint: 'Playlists & Favoriten (P3)'),
|
||||
_Placeholder(label: 'Recaps', hint: 'Wöchentlich/Monatlich/Jährlich (P5)'),
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(child: IndexedStack(index: _index, children: _tabs)),
|
||||
const MiniPlayer(),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: _index,
|
||||
onTap: (i) => setState(() => _index = i),
|
||||
items: const [
|
||||
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.library_music), label: 'Bibliothek'),
|
||||
BottomNavigationBarItem(icon: Icon(Icons.search), label: 'Suche'),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.playlist_play), label: 'Playlists'),
|
||||
BottomNavigationBarItem(icon: Icon(Icons.bar_chart), label: 'Recaps'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Placeholder extends StatelessWidget {
|
||||
const _Placeholder({required this.label, required this.hint});
|
||||
final String label;
|
||||
final String hint;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(label, style: Theme.of(context).textTheme.headlineSmall),
|
||||
const SizedBox(height: 8),
|
||||
Text(hint, style: const TextStyle(color: Colors.white54)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user