2020-07-26 12:20:42 +02:00
|
|
|
import 'package:feature_discovery/feature_discovery.dart';
|
2020-02-09 13:29:09 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2020-06-07 14:47:28 +02:00
|
|
|
import 'package:flutter/scheduler.dart';
|
2020-02-15 07:39:42 +01:00
|
|
|
import 'package:flutter/services.dart';
|
2020-02-09 13:29:09 +01:00
|
|
|
import 'package:flutter_downloader/flutter_downloader.dart';
|
2020-05-09 06:27:05 +02:00
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
2020-07-26 12:20:42 +02:00
|
|
|
import 'package:provider/provider.dart';
|
2020-03-01 13:17:06 +01:00
|
|
|
|
2020-05-09 06:27:05 +02:00
|
|
|
import 'generated/l10n.dart';
|
2020-07-26 12:20:42 +02:00
|
|
|
import 'home/home.dart';
|
|
|
|
import 'intro_slider/app_intro.dart';
|
2020-07-07 17:29:21 +02:00
|
|
|
import 'state/audio_state.dart';
|
2020-05-06 18:50:32 +02:00
|
|
|
import 'state/download_state.dart';
|
2020-07-26 12:20:42 +02:00
|
|
|
import 'state/podcast_group.dart';
|
2020-05-06 18:50:32 +02:00
|
|
|
import 'state/refresh_podcast.dart';
|
2020-07-26 12:20:42 +02:00
|
|
|
import 'state/setting_state.dart';
|
2020-04-06 14:18:08 +02:00
|
|
|
|
2020-03-14 04:14:24 +01:00
|
|
|
final SettingState themeSetting = SettingState();
|
2020-03-01 13:17:06 +01:00
|
|
|
Future main() async {
|
2020-06-07 14:47:28 +02:00
|
|
|
timeDilation = 1.0;
|
2020-03-01 13:17:06 +01:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
await themeSetting.initData();
|
2020-06-29 14:13:42 +02:00
|
|
|
await FlutterDownloader.initialize();
|
2020-02-09 13:29:09 +01:00
|
|
|
runApp(
|
|
|
|
MultiProvider(
|
|
|
|
providers: [
|
2020-04-29 19:32:45 +02:00
|
|
|
ChangeNotifierProvider(
|
|
|
|
create: (_) => themeSetting,
|
|
|
|
),
|
2020-03-14 04:14:24 +01:00
|
|
|
ChangeNotifierProvider(create: (_) => AudioPlayerNotifier()),
|
2020-03-01 13:17:06 +01:00
|
|
|
ChangeNotifierProvider(create: (_) => GroupList()),
|
2020-04-18 06:48:02 +02:00
|
|
|
ChangeNotifierProvider(create: (_) => RefreshWorker()),
|
|
|
|
ChangeNotifierProvider(
|
2020-06-29 14:13:42 +02:00
|
|
|
lazy: false,
|
2020-04-18 06:48:02 +02:00
|
|
|
create: (_) => DownloadState(),
|
2020-04-29 19:32:45 +02:00
|
|
|
)
|
2020-02-09 13:29:09 +01:00
|
|
|
],
|
|
|
|
child: MyApp(),
|
|
|
|
),
|
|
|
|
);
|
2020-07-26 12:20:42 +02:00
|
|
|
var systemUiOverlayStyle = SystemUiOverlayStyle(
|
2020-03-31 18:36:20 +02:00
|
|
|
statusBarColor: Colors.transparent,
|
|
|
|
systemNavigationBarColor: Colors.transparent);
|
2020-03-19 20:58:30 +01:00
|
|
|
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
|
2020-03-01 13:17:06 +01:00
|
|
|
await SystemChrome.setPreferredOrientations(
|
|
|
|
[DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);
|
|
|
|
}
|
|
|
|
|
2020-02-09 13:29:09 +01:00
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-03-01 13:17:06 +01:00
|
|
|
return Consumer<SettingState>(
|
|
|
|
builder: (_, setting, __) {
|
2020-06-07 14:47:28 +02:00
|
|
|
return FeatureDiscovery(
|
|
|
|
child: MaterialApp(
|
|
|
|
themeMode: setting.theme,
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
title: 'Tsacdop',
|
|
|
|
theme: lightTheme.copyWith(
|
|
|
|
accentColor: setting.accentSetColor,
|
|
|
|
cursorColor: setting.accentSetColor,
|
2020-08-01 17:07:55 +02:00
|
|
|
textSelectionHandleColor: setting.accentSetColor,
|
2020-06-07 14:47:28 +02:00
|
|
|
toggleableActiveColor: setting.accentSetColor),
|
|
|
|
darkTheme: ThemeData.dark().copyWith(
|
|
|
|
accentColor: setting.accentSetColor,
|
|
|
|
primaryColorDark: Colors.grey[800],
|
|
|
|
scaffoldBackgroundColor:
|
|
|
|
setting.realDark ? Colors.black87 : null,
|
|
|
|
primaryColor: setting.realDark ? Colors.black : null,
|
2020-07-25 12:32:05 +02:00
|
|
|
popupMenuTheme: PopupMenuThemeData().copyWith(
|
|
|
|
color: setting.realDark ? Colors.grey[900] : null),
|
2020-06-07 14:47:28 +02:00
|
|
|
appBarTheme: AppBarTheme(elevation: 0),
|
2020-07-25 12:32:05 +02:00
|
|
|
buttonTheme: ButtonThemeData(height: 32),
|
|
|
|
dialogBackgroundColor:
|
|
|
|
setting.realDark ? Colors.grey[900] : null,
|
2020-06-07 14:47:28 +02:00
|
|
|
cursorColor: setting.accentSetColor),
|
|
|
|
localizationsDelegates: [
|
|
|
|
S.delegate,
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
GlobalCupertinoLocalizations.delegate,
|
|
|
|
],
|
|
|
|
supportedLocales: S.delegate.supportedLocales,
|
|
|
|
home: setting.showIntro ? SlideIntro(goto: Goto.home) : Home(),
|
|
|
|
),
|
2020-03-01 13:17:06 +01:00
|
|
|
);
|
|
|
|
},
|
2020-02-09 13:29:09 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|