2020-10-28 13:08:45 +01:00
|
|
|
import 'package:feature_discovery/feature_discovery.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/scheduler.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_downloader/flutter_downloader.dart';
|
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
2021-01-06 17:28:53 +01:00
|
|
|
import 'package:tsacdop/playlists/playlist_home.dart';
|
|
|
|
import 'package:tuple/tuple.dart';
|
2020-10-28 13:08:45 +01:00
|
|
|
|
|
|
|
import 'generated/l10n.dart';
|
|
|
|
import 'home/home.dart';
|
|
|
|
import 'intro_slider/app_intro.dart';
|
|
|
|
import 'state/audio_state.dart';
|
|
|
|
import 'state/download_state.dart';
|
|
|
|
import 'state/podcast_group.dart';
|
|
|
|
import 'state/refresh_podcast.dart';
|
|
|
|
import 'state/search_state.dart';
|
|
|
|
import 'state/setting_state.dart';
|
|
|
|
|
2020-11-06 15:08:26 +01:00
|
|
|
///Initial theme settings
|
2020-10-28 13:08:45 +01:00
|
|
|
final SettingState themeSetting = SettingState();
|
|
|
|
Future main() async {
|
|
|
|
timeDilation = 1.0;
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
await themeSetting.initData();
|
|
|
|
await FlutterDownloader.initialize();
|
|
|
|
runApp(
|
|
|
|
MultiProvider(
|
|
|
|
providers: [
|
|
|
|
ChangeNotifierProvider(
|
|
|
|
create: (_) => themeSetting,
|
|
|
|
),
|
|
|
|
ChangeNotifierProvider(create: (_) => AudioPlayerNotifier()),
|
|
|
|
ChangeNotifierProvider(create: (_) => GroupList()),
|
|
|
|
ChangeNotifierProvider(create: (_) => RefreshWorker()),
|
|
|
|
ChangeNotifierProvider(create: (_) => SearchState()),
|
|
|
|
ChangeNotifierProvider(
|
|
|
|
lazy: false,
|
|
|
|
create: (_) => DownloadState(),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
child: MyApp(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
var systemUiOverlayStyle = SystemUiOverlayStyle(
|
|
|
|
statusBarColor: Colors.transparent,
|
|
|
|
systemNavigationBarColor: Colors.transparent);
|
|
|
|
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
|
|
|
|
await SystemChrome.setPreferredOrientations(
|
|
|
|
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-01-06 17:28:53 +01:00
|
|
|
return Selector<SettingState, Tuple3<ThemeMode, ThemeData, ThemeData>>(
|
|
|
|
selector: (_, setting) =>
|
|
|
|
Tuple3(setting.theme, setting.lightTheme, setting.darkTheme),
|
|
|
|
builder: (_, data, child) {
|
2020-10-28 13:08:45 +01:00
|
|
|
return FeatureDiscovery(
|
|
|
|
child: MaterialApp(
|
2021-01-06 17:28:53 +01:00
|
|
|
themeMode: data.item1,
|
2020-10-28 13:08:45 +01:00
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
title: 'Tsacdop',
|
2021-01-06 17:28:53 +01:00
|
|
|
theme: data.item2,
|
|
|
|
darkTheme: data.item3,
|
2020-10-28 13:08:45 +01:00
|
|
|
localizationsDelegates: [
|
|
|
|
S.delegate,
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
GlobalCupertinoLocalizations.delegate,
|
|
|
|
],
|
|
|
|
supportedLocales: S.delegate.supportedLocales,
|
2021-01-06 17:28:53 +01:00
|
|
|
home: context.read<SettingState>().showIntro
|
|
|
|
? SlideIntro(goto: Goto.home)
|
|
|
|
: context.read<SettingState>().openPlaylistDefault
|
|
|
|
? PlaylistHome()
|
|
|
|
: Home(),
|
2020-10-28 13:08:45 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
2021-01-06 17:28:53 +01:00
|
|
|
//child: FeatureDiscovery(child: Home()),
|
2020-10-28 13:08:45 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|