redesign app phase 2
This commit is contained in:
+84
-68
@@ -9,6 +9,7 @@ import 'package:finamp/screens/interaction_settings_screen.dart';
|
||||
import 'package:finamp/services/finamp_settings_helper.dart';
|
||||
import 'package:finamp/services/finamp_user_helper.dart';
|
||||
import 'package:finamp/services/offline_listen_helper.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_downloader/flutter_downloader.dart';
|
||||
@@ -122,6 +123,10 @@ Future<void> _setupDownloader() async {
|
||||
GetIt.instance.registerSingleton(DownloadUpdateStream());
|
||||
GetIt.instance<DownloadUpdateStream>().setupSendPort();
|
||||
|
||||
if (!_isDownloaderSupported) {
|
||||
return;
|
||||
}
|
||||
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await FlutterDownloader.initialize(debug: true);
|
||||
|
||||
@@ -132,6 +137,15 @@ Future<void> _setupDownloader() async {
|
||||
FlutterDownloader.registerCallback(_DummyCallback.callback);
|
||||
}
|
||||
|
||||
bool get _isDownloaderSupported {
|
||||
if (kIsWeb) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return defaultTargetPlatform == TargetPlatform.android ||
|
||||
defaultTargetPlatform == TargetPlatform.iOS;
|
||||
}
|
||||
|
||||
Future<void> setupHive() async {
|
||||
await Hive.initFlutter();
|
||||
Hive.registerAdapter(BaseItemDtoAdapter());
|
||||
@@ -301,76 +315,78 @@ class Finamp extends StatelessWidget {
|
||||
valueListenable: LocaleHelper.localeListener,
|
||||
builder: (_, __, ___) {
|
||||
return ValueListenableBuilder<Box<ThemeMode>>(
|
||||
valueListenable: ThemeModeHelper.themeModeListener,
|
||||
builder: (_, box, __) {
|
||||
return MaterialApp(
|
||||
title: "Finamp",
|
||||
routes: {
|
||||
SplashScreen.routeName: (context) => const SplashScreen(),
|
||||
UserSelector.routeName: (context) => const UserSelector(),
|
||||
ViewSelector.routeName: (context) => const ViewSelector(),
|
||||
MusicScreen.routeName: (context) => const MusicScreen(),
|
||||
AlbumScreen.routeName: (context) => const AlbumScreen(),
|
||||
ArtistScreen.routeName: (context) => const ArtistScreen(),
|
||||
AddToPlaylistScreen.routeName: (context) =>
|
||||
const AddToPlaylistScreen(),
|
||||
PlayerScreen.routeName: (context) => const PlayerScreen(),
|
||||
DownloadsScreen.routeName: (context) =>
|
||||
const DownloadsScreen(),
|
||||
DownloadsErrorScreen.routeName: (context) =>
|
||||
const DownloadsErrorScreen(),
|
||||
LogsScreen.routeName: (context) => const LogsScreen(),
|
||||
SettingsScreen.routeName: (context) =>
|
||||
const SettingsScreen(),
|
||||
TranscodingSettingsScreen.routeName: (context) =>
|
||||
const TranscodingSettingsScreen(),
|
||||
DownloadsSettingsScreen.routeName: (context) =>
|
||||
const DownloadsSettingsScreen(),
|
||||
AddDownloadLocationScreen.routeName: (context) =>
|
||||
const AddDownloadLocationScreen(),
|
||||
AudioServiceSettingsScreen.routeName: (context) =>
|
||||
const AudioServiceSettingsScreen(),
|
||||
InteractionSettingsScreen.routeName: (context) =>
|
||||
const InteractionSettingsScreen(),
|
||||
TabsSettingsScreen.routeName: (context) =>
|
||||
const TabsSettingsScreen(),
|
||||
LayoutSettingsScreen.routeName: (context) =>
|
||||
const LayoutSettingsScreen(),
|
||||
LanguageSelectionScreen.routeName: (context) =>
|
||||
const LanguageSelectionScreen(),
|
||||
},
|
||||
initialRoute: SplashScreen.routeName,
|
||||
theme: ThemeData(
|
||||
brightness: Brightness.light,
|
||||
colorScheme: lightColorScheme,
|
||||
appBarTheme: const AppBarTheme(
|
||||
systemOverlayStyle: SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.light,
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
),
|
||||
valueListenable: ThemeModeHelper.themeModeListener,
|
||||
builder: (_, box, __) {
|
||||
return MaterialApp(
|
||||
title: "Finamp",
|
||||
routes: {
|
||||
SplashScreen.routeName: (context) => const SplashScreen(),
|
||||
UserSelector.routeName: (context) => const UserSelector(),
|
||||
ViewSelector.routeName: (context) => const ViewSelector(),
|
||||
MusicScreen.routeName: (context) => const MusicScreen(),
|
||||
AlbumScreen.routeName: (context) => const AlbumScreen(),
|
||||
ArtistScreen.routeName: (context) => const ArtistScreen(),
|
||||
AddToPlaylistScreen.routeName: (context) =>
|
||||
const AddToPlaylistScreen(),
|
||||
PlayerScreen.routeName: (context) => const PlayerScreen(),
|
||||
DownloadsScreen.routeName: (context) =>
|
||||
const DownloadsScreen(),
|
||||
DownloadsErrorScreen.routeName: (context) =>
|
||||
const DownloadsErrorScreen(),
|
||||
LogsScreen.routeName: (context) => const LogsScreen(),
|
||||
SettingsScreen.routeName: (context) =>
|
||||
const SettingsScreen(),
|
||||
TranscodingSettingsScreen.routeName: (context) =>
|
||||
const TranscodingSettingsScreen(),
|
||||
DownloadsSettingsScreen.routeName: (context) =>
|
||||
const DownloadsSettingsScreen(),
|
||||
AddDownloadLocationScreen.routeName: (context) =>
|
||||
const AddDownloadLocationScreen(),
|
||||
AudioServiceSettingsScreen.routeName: (context) =>
|
||||
const AudioServiceSettingsScreen(),
|
||||
InteractionSettingsScreen.routeName: (context) =>
|
||||
const InteractionSettingsScreen(),
|
||||
TabsSettingsScreen.routeName: (context) =>
|
||||
const TabsSettingsScreen(),
|
||||
LayoutSettingsScreen.routeName: (context) =>
|
||||
const LayoutSettingsScreen(),
|
||||
LanguageSelectionScreen.routeName: (context) =>
|
||||
const LanguageSelectionScreen(),
|
||||
},
|
||||
initialRoute: SplashScreen.routeName,
|
||||
theme: ThemeData(
|
||||
useMaterial3: true,
|
||||
brightness: Brightness.light,
|
||||
colorScheme: lightColorScheme,
|
||||
appBarTheme: const AppBarTheme(
|
||||
systemOverlayStyle: SystemUiOverlayStyle(
|
||||
statusBarBrightness: Brightness.light,
|
||||
statusBarIconBrightness: Brightness.dark,
|
||||
),
|
||||
),
|
||||
darkTheme: ThemeData(
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: darkColorScheme,
|
||||
),
|
||||
themeMode: box.get("ThemeMode"),
|
||||
localizationsDelegates: const [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
// We awkwardly put English as the first supported locale so
|
||||
// that basicLocaleListResolution falls back to it instead of
|
||||
// the first language in supportedLocales (Arabic as of writing)
|
||||
localeListResolutionCallback: (locales, supportedLocales) =>
|
||||
basicLocaleListResolution(locales,
|
||||
[const Locale("en")].followedBy(supportedLocales)),
|
||||
locale: LocaleHelper.locale,
|
||||
);
|
||||
},
|
||||
),
|
||||
darkTheme: ThemeData(
|
||||
useMaterial3: true,
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: darkColorScheme,
|
||||
),
|
||||
themeMode: box.get("ThemeMode"),
|
||||
localizationsDelegates: const [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
// We awkwardly put English as the first supported locale so
|
||||
// that basicLocaleListResolution falls back to it instead of
|
||||
// the first language in supportedLocales (Arabic as of writing)
|
||||
localeListResolutionCallback: (locales, supportedLocales) =>
|
||||
basicLocaleListResolution(locales,
|
||||
[const Locale("en")].followedBy(supportedLocales)),
|
||||
locale: LocaleHelper.locale,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user