2020-08-28 11:28:58 +02:00
|
|
|
import 'package:audio_session/audio_session.dart';
|
2021-05-09 22:10:48 +02:00
|
|
|
import 'package:fimber/fimber.dart';
|
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';
|
2021-05-09 22:10:48 +02:00
|
|
|
import 'package:flutter_fimber_filelogger/flutter_fimber_filelogger.dart';
|
2020-04-12 12:34:19 +02:00
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
2021-05-10 19:19:54 +02:00
|
|
|
import 'package:get_it/get_it.dart';
|
2020-03-24 22:17:03 +01:00
|
|
|
|
2021-05-16 18:04:35 +02:00
|
|
|
import 'domain/actors/persistence_actor.dart';
|
2020-05-27 21:54:33 +02:00
|
|
|
import 'injection_container.dart';
|
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';
|
2021-08-28 21:12:56 +02:00
|
|
|
import 'presentation/pages/search_page.dart';
|
2020-04-12 12:34:19 +02:00
|
|
|
import 'presentation/state/navigation_store.dart';
|
2020-03-28 09:39:59 +01:00
|
|
|
import 'presentation/theming.dart';
|
2020-03-24 22:17:03 +01:00
|
|
|
import 'presentation/widgets/navbar.dart';
|
2020-03-20 16:17:02 +01:00
|
|
|
|
2020-05-27 21:54:33 +02:00
|
|
|
Future<void> main() async {
|
2020-06-03 20:32:59 +02:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
2020-05-27 21:54:33 +02:00
|
|
|
await setupGetIt();
|
2020-08-28 11:28:58 +02:00
|
|
|
|
|
|
|
final session = await AudioSession.instance;
|
|
|
|
await session.configure(const AudioSessionConfiguration.music());
|
|
|
|
|
2021-05-09 22:10:48 +02:00
|
|
|
Fimber.plantTree(
|
|
|
|
FileLoggerTree(
|
|
|
|
levels: FileLoggerLevels.ALL,
|
|
|
|
numberOfDays: 10,
|
|
|
|
logDateFormat: 'HH:mm:ss',
|
|
|
|
),
|
|
|
|
);
|
|
|
|
Fimber.plantTree(DebugTree());
|
2020-09-19 20:30:41 +02:00
|
|
|
|
2021-05-16 18:04:35 +02:00
|
|
|
await GetIt.I<PersistenceActor>().init();
|
2021-05-13 17:21:35 +02:00
|
|
|
|
2020-05-27 21:54:33 +02:00
|
|
|
runApp(MyApp());
|
|
|
|
}
|
2020-03-20 16:17:02 +01:00
|
|
|
|
|
|
|
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,
|
|
|
|
]);
|
|
|
|
|
2021-05-10 19:19:54 +02:00
|
|
|
return 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 {
|
2021-06-20 13:49:21 +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-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'),
|
|
|
|
),
|
2021-06-27 15:58:46 +02:00
|
|
|
const SearchPage(
|
|
|
|
key: PageStorageKey('SearchPage'),
|
2020-04-07 21:25:01 +02:00
|
|
|
),
|
|
|
|
];
|
2020-03-28 09:39:59 +01:00
|
|
|
|
2020-04-09 17:50:28 +02:00
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2020-03-20 16:17:02 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-05-10 19:19:54 +02:00
|
|
|
final NavigationStore navStore = GetIt.I<NavigationStore>();
|
2020-04-12 12:34:19 +02:00
|
|
|
|
2020-04-10 20:12:26 +02:00
|
|
|
print('RootPage.build');
|
2021-06-20 19:10:24 +02:00
|
|
|
return WillPopScope(
|
|
|
|
child: Observer(
|
|
|
|
builder: (BuildContext context) => Scaffold(
|
|
|
|
body: IndexedStack(
|
|
|
|
index: navStore.navIndex,
|
|
|
|
children: _pages,
|
|
|
|
),
|
|
|
|
bottomNavigationBar: NavBar(
|
|
|
|
onTap: (int index) => navStore.setNavIndex(index),
|
|
|
|
currentIndex: navStore.navIndex,
|
|
|
|
),
|
2020-04-12 12:34:19 +02:00
|
|
|
),
|
2020-03-20 16:17:02 +01:00
|
|
|
),
|
2021-06-20 19:10:24 +02:00
|
|
|
onWillPop: () => navStore.onWillPop(),
|
2020-03-20 16:17:02 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|