2020-03-20 16:17:02 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2020-03-28 11:06:23 +01:00
|
|
|
import 'package:flutter/services.dart';
|
2020-03-28 09:39:59 +01:00
|
|
|
import 'package:provider/provider.dart';
|
2020-03-24 22:17:03 +01:00
|
|
|
|
2020-04-09 17:50:28 +02:00
|
|
|
import 'presentation/pages/currently_playing.dart';
|
2020-03-28 09:39:59 +01:00
|
|
|
import 'presentation/pages/home_page.dart';
|
|
|
|
import 'presentation/pages/library_page.dart';
|
|
|
|
import 'presentation/pages/settings_page.dart';
|
2020-04-09 17:50:28 +02:00
|
|
|
import 'presentation/state/audio_store.dart';
|
2020-04-07 21:25:01 +02:00
|
|
|
import 'presentation/state/music_data_store.dart';
|
2020-03-28 09:39:59 +01:00
|
|
|
import 'presentation/theming.dart';
|
2020-04-06 22:33:26 +02:00
|
|
|
import 'presentation/widgets/audio_service_widget.dart';
|
2020-04-09 17:50:28 +02:00
|
|
|
import 'presentation/widgets/injection_widget.dart';
|
2020-03-24 22:17:03 +01:00
|
|
|
import 'presentation/widgets/navbar.dart';
|
2020-03-20 16:17:02 +01:00
|
|
|
|
|
|
|
void main() => runApp(MyApp());
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
// This widget is the root of your application.
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-03-28 11:06:23 +01:00
|
|
|
SystemChrome.setPreferredOrientations([
|
|
|
|
DeviceOrientation.portraitUp,
|
|
|
|
]);
|
|
|
|
|
2020-04-09 17:50:28 +02:00
|
|
|
return InjectionWidget(
|
|
|
|
child: AudioServiceWidget(
|
|
|
|
child: MaterialApp(
|
|
|
|
title: 'mucke',
|
|
|
|
theme: theme(),
|
|
|
|
initialRoute: '/',
|
|
|
|
routes: {
|
|
|
|
'/': (context) => const RootPage(),
|
|
|
|
'/playing': (context) => const CurrentlyPlayingPage(),
|
|
|
|
},
|
2020-03-20 16:17:02 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class RootPage extends StatefulWidget {
|
2020-04-06 22:33:26 +02:00
|
|
|
const RootPage({Key key}) : super(key: key);
|
2020-03-20 16:17:02 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
_RootPageState createState() => _RootPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _RootPageState extends State<RootPage> {
|
2020-04-09 17:50:28 +02:00
|
|
|
var navIndex = 1;
|
2020-03-20 16:17:02 +01:00
|
|
|
|
2020-04-07 21:25:01 +02:00
|
|
|
final List<Widget> _pages = <Widget>[
|
2020-04-10 20:12:26 +02:00
|
|
|
const HomePage(),
|
2020-04-07 21:25:01 +02:00
|
|
|
const LibraryPage(
|
|
|
|
key: PageStorageKey('LibraryPage'),
|
|
|
|
),
|
|
|
|
const SettingsPage(
|
|
|
|
key: PageStorageKey('SettingsPage'),
|
|
|
|
),
|
|
|
|
];
|
2020-03-28 09:39:59 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
void didChangeDependencies() {
|
2020-04-07 21:25:01 +02:00
|
|
|
final MusicDataStore _musicStore = Provider.of<MusicDataStore>(context);
|
2020-04-10 20:12:26 +02:00
|
|
|
_musicStore.init();
|
2020-03-28 09:39:59 +01:00
|
|
|
|
2020-04-09 17:50:28 +02:00
|
|
|
final AudioStore _audioStore = Provider.of<AudioStore>(context);
|
|
|
|
_audioStore.init();
|
2020-04-06 22:33:26 +02:00
|
|
|
|
2020-03-28 09:39:59 +01:00
|
|
|
super.didChangeDependencies();
|
|
|
|
}
|
2020-03-20 16:17:02 +01:00
|
|
|
|
2020-04-09 17:50:28 +02:00
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
final AudioStore _audioStore = Provider.of<AudioStore>(context);
|
|
|
|
_audioStore.dispose();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2020-03-20 16:17:02 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-04-10 20:12:26 +02:00
|
|
|
print('RootPage.build');
|
2020-03-20 16:17:02 +01:00
|
|
|
return Scaffold(
|
2020-04-03 15:51:43 +02:00
|
|
|
body: IndexedStack(
|
|
|
|
index: navIndex,
|
|
|
|
children: _pages,
|
2020-04-03 13:55:15 +02:00
|
|
|
),
|
2020-03-20 16:17:02 +01:00
|
|
|
bottomNavigationBar: NavBar(
|
|
|
|
onTap: (int index) {
|
|
|
|
setState(() {
|
|
|
|
navIndex = index;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
currentIndex: navIndex,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|