2025-08-01 22:39:07 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2025-08-02 03:04:20 +02:00
|
|
|
import 'pages/now_playing_page.dart';
|
|
|
|
import 'pages/library_page.dart';
|
|
|
|
import 'pages/settings_page.dart';
|
2025-08-01 22:39:07 +02:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
runApp(const MyApp());
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
|
|
// This widget is the root of your application.
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
2025-08-02 00:05:57 +02:00
|
|
|
title: 'SleepySound',
|
2025-08-01 22:39:07 +02:00
|
|
|
theme: ThemeData(
|
2025-08-02 03:10:13 +02:00
|
|
|
|
2025-08-01 22:39:07 +02:00
|
|
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
|
|
|
),
|
2025-08-02 00:45:58 +02:00
|
|
|
home: const MyHomePage(title: 'Now Playing'),
|
2025-08-01 22:39:07 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
|
|
const MyHomePage({super.key, required this.title});
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
2025-08-02 03:04:20 +02:00
|
|
|
int _selectedIndex = 0;
|
2025-08-01 22:39:07 +02:00
|
|
|
|
2025-08-02 03:04:20 +02:00
|
|
|
void _onItemTapped(int index) {
|
2025-08-01 22:39:07 +02:00
|
|
|
setState(() {
|
2025-08-02 03:04:20 +02:00
|
|
|
_selectedIndex = index;
|
2025-08-01 22:39:07 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2025-08-02 03:04:20 +02:00
|
|
|
Widget _getSelectedPage() {
|
|
|
|
switch (_selectedIndex) {
|
|
|
|
case 0:
|
|
|
|
return const NowPlayingPage();
|
|
|
|
case 1:
|
|
|
|
return const LibraryPage();
|
|
|
|
case 2:
|
|
|
|
return const SettingsPage();
|
|
|
|
default:
|
|
|
|
return const NowPlayingPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-08-01 22:39:07 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
2025-08-02 03:04:20 +02:00
|
|
|
title: Text(_getPageTitle()),
|
2025-08-01 22:39:07 +02:00
|
|
|
),
|
2025-08-02 03:04:20 +02:00
|
|
|
body: _getSelectedPage(),
|
|
|
|
bottomNavigationBar: BottomNavigationBar(
|
|
|
|
items: const <BottomNavigationBarItem>[
|
|
|
|
BottomNavigationBarItem(
|
|
|
|
icon: Icon(Icons.play_circle_filled),
|
|
|
|
label: 'Now Playing',
|
|
|
|
),
|
|
|
|
BottomNavigationBarItem(
|
|
|
|
icon: Icon(Icons.library_music),
|
2025-08-02 03:10:13 +02:00
|
|
|
label: 'Voting',
|
2025-08-02 03:04:20 +02:00
|
|
|
),
|
|
|
|
BottomNavigationBarItem(
|
2025-08-02 03:10:13 +02:00
|
|
|
icon: Icon(Icons.group),
|
|
|
|
label: 'Group',
|
2025-08-02 03:04:20 +02:00
|
|
|
),
|
|
|
|
],
|
|
|
|
currentIndex: _selectedIndex,
|
|
|
|
selectedItemColor: Colors.deepPurple,
|
|
|
|
onTap: _onItemTapped,
|
2025-08-01 22:39:07 +02:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2025-08-02 03:04:20 +02:00
|
|
|
|
|
|
|
String _getPageTitle() {
|
|
|
|
switch (_selectedIndex) {
|
|
|
|
case 0:
|
|
|
|
return 'Now Playing';
|
|
|
|
case 1:
|
2025-08-02 03:10:13 +02:00
|
|
|
return 'Voting';
|
2025-08-02 03:04:20 +02:00
|
|
|
case 2:
|
2025-08-02 03:10:13 +02:00
|
|
|
return 'Group';
|
2025-08-02 03:04:20 +02:00
|
|
|
default:
|
|
|
|
return 'Now Playing';
|
|
|
|
}
|
|
|
|
}
|
2025-08-01 22:39:07 +02:00
|
|
|
}
|