2024-08-29 07:02:49 +00:00
|
|
|
import 'package:desktop_webview_window/desktop_webview_window.dart';
|
2024-08-26 05:29:17 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:get/get.dart';
|
2024-08-26 17:49:05 +00:00
|
|
|
import 'package:media_kit/media_kit.dart';
|
2024-08-29 07:02:49 +00:00
|
|
|
import 'package:rhythm_box/platform.dart';
|
2024-08-26 17:49:05 +00:00
|
|
|
import 'package:rhythm_box/providers/audio_player.dart';
|
2024-08-27 08:37:31 +00:00
|
|
|
import 'package:rhythm_box/providers/audio_player_stream.dart';
|
2024-08-29 07:02:49 +00:00
|
|
|
import 'package:rhythm_box/providers/auth.dart';
|
2024-08-27 08:37:31 +00:00
|
|
|
import 'package:rhythm_box/providers/database.dart';
|
2024-08-29 15:03:41 +00:00
|
|
|
import 'package:rhythm_box/providers/endless_playback.dart';
|
2024-08-27 08:37:31 +00:00
|
|
|
import 'package:rhythm_box/providers/history.dart';
|
|
|
|
import 'package:rhythm_box/providers/palette.dart';
|
2024-08-29 17:38:02 +00:00
|
|
|
import 'package:rhythm_box/providers/recent_played.dart';
|
2024-08-27 08:37:31 +00:00
|
|
|
import 'package:rhythm_box/providers/scrobbler.dart';
|
|
|
|
import 'package:rhythm_box/providers/skip_segments.dart';
|
2024-08-26 12:26:07 +00:00
|
|
|
import 'package:rhythm_box/providers/spotify.dart';
|
2024-08-27 08:37:31 +00:00
|
|
|
import 'package:rhythm_box/providers/user_preferences.dart';
|
2024-08-29 16:28:12 +00:00
|
|
|
import 'package:rhythm_box/providers/volume.dart';
|
2024-08-26 05:29:17 +00:00
|
|
|
import 'package:rhythm_box/router.dart';
|
2024-08-29 07:02:49 +00:00
|
|
|
import 'package:rhythm_box/services/kv_store/encrypted_kv_store.dart';
|
|
|
|
import 'package:rhythm_box/services/kv_store/kv_store.dart';
|
2024-08-28 10:41:32 +00:00
|
|
|
import 'package:rhythm_box/services/lyrics/provider.dart';
|
2024-08-26 17:49:05 +00:00
|
|
|
import 'package:rhythm_box/services/server/active_sourced_track.dart';
|
|
|
|
import 'package:rhythm_box/services/server/routes/playback.dart';
|
|
|
|
import 'package:rhythm_box/services/server/server.dart';
|
|
|
|
import 'package:rhythm_box/services/server/sourced_track.dart';
|
2024-08-29 17:56:21 +00:00
|
|
|
import 'package:rhythm_box/shells/system_shell.dart';
|
2024-08-26 05:29:17 +00:00
|
|
|
import 'package:rhythm_box/translations.dart';
|
2024-08-27 06:35:16 +00:00
|
|
|
import 'package:rhythm_box/widgets/tracks/querying_track_info.dart';
|
2024-08-29 07:02:49 +00:00
|
|
|
import 'package:smtc_windows/smtc_windows.dart';
|
|
|
|
import 'package:window_manager/window_manager.dart';
|
|
|
|
|
|
|
|
Future<void> main(List<String> rawArgs) async {
|
|
|
|
if (rawArgs.contains('web_view_title_bar')) {
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
if (runWebViewTitleBarWidget(rawArgs)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2024-08-26 05:29:17 +00:00
|
|
|
|
2024-08-26 17:49:05 +00:00
|
|
|
MediaKit.ensureInitialized();
|
2024-08-29 07:02:49 +00:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
|
|
|
if (PlatformInfo.isDesktop) {
|
2024-08-29 17:56:21 +00:00
|
|
|
await windowManager.ensureInitialized();
|
2024-08-29 07:02:49 +00:00
|
|
|
await windowManager.setPreventClose(true);
|
|
|
|
}
|
|
|
|
if (PlatformInfo.isWindows) {
|
|
|
|
await SMTCWindows.initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
await KVStoreService.initialize();
|
|
|
|
await EncryptedKvStoreService.initialize();
|
2024-08-26 17:49:05 +00:00
|
|
|
|
2024-08-30 11:53:53 +00:00
|
|
|
runApp(const RhythmApp());
|
2024-08-26 05:29:17 +00:00
|
|
|
}
|
|
|
|
|
2024-08-30 11:53:53 +00:00
|
|
|
class RhythmApp extends StatelessWidget {
|
|
|
|
const RhythmApp({super.key});
|
2024-08-26 05:29:17 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return GetMaterialApp.router(
|
|
|
|
title: 'DietaryGuard',
|
|
|
|
routerDelegate: router.routerDelegate,
|
|
|
|
routeInformationParser: router.routeInformationParser,
|
|
|
|
routeInformationProvider: router.routeInformationProvider,
|
|
|
|
backButtonDispatcher: router.backButtonDispatcher,
|
|
|
|
locale: Get.deviceLocale,
|
|
|
|
theme: ThemeData(
|
|
|
|
colorScheme: ColorScheme.fromSeed(
|
|
|
|
seedColor: Colors.orange,
|
|
|
|
brightness: Brightness.light,
|
|
|
|
),
|
|
|
|
useMaterial3: true,
|
|
|
|
),
|
|
|
|
darkTheme: ThemeData(
|
|
|
|
colorScheme: ColorScheme.fromSeed(
|
|
|
|
seedColor: Colors.orange,
|
|
|
|
brightness: Brightness.dark,
|
|
|
|
),
|
|
|
|
useMaterial3: true,
|
|
|
|
),
|
|
|
|
themeMode: ThemeMode.system,
|
|
|
|
translations: AppTranslations(),
|
|
|
|
onInit: () => _initializeProviders(context),
|
2024-08-29 17:56:21 +00:00
|
|
|
builder: (context, child) {
|
|
|
|
return SystemShell(
|
|
|
|
child: ScaffoldMessenger(
|
|
|
|
child: child ?? const SizedBox(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
2024-08-26 05:29:17 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-08-26 12:26:07 +00:00
|
|
|
void _initializeProviders(BuildContext context) async {
|
|
|
|
Get.lazyPut(() => SpotifyProvider());
|
2024-08-28 10:41:32 +00:00
|
|
|
Get.lazyPut(() => SyncedLyricsProvider());
|
2024-08-27 08:37:31 +00:00
|
|
|
|
2024-08-27 15:14:54 +00:00
|
|
|
Get.put(DatabaseProvider());
|
2024-08-29 07:02:49 +00:00
|
|
|
Get.put(AuthenticationProvider());
|
2024-08-27 15:14:54 +00:00
|
|
|
|
2024-08-27 12:49:48 +00:00
|
|
|
Get.put(AudioPlayerProvider());
|
2024-08-27 08:37:31 +00:00
|
|
|
Get.put(ActiveSourcedTrackProvider());
|
|
|
|
Get.put(AudioPlayerStreamProvider());
|
|
|
|
|
|
|
|
Get.put(PlaybackHistoryProvider());
|
|
|
|
Get.put(SegmentsProvider());
|
|
|
|
Get.put(PaletteProvider());
|
|
|
|
Get.put(ScrobblerProvider());
|
|
|
|
Get.put(UserPreferencesProvider());
|
2024-08-26 18:22:47 +00:00
|
|
|
|
2024-08-27 06:35:16 +00:00
|
|
|
Get.put(QueryingTrackInfoProvider());
|
|
|
|
Get.put(SourcedTrackProvider());
|
2024-08-29 15:07:49 +00:00
|
|
|
Get.put(EndlessPlaybackProvider());
|
2024-08-29 16:28:12 +00:00
|
|
|
Get.put(VolumeProvider());
|
2024-08-29 17:38:02 +00:00
|
|
|
Get.put(RecentlyPlayedProvider());
|
2024-08-27 06:35:16 +00:00
|
|
|
|
2024-08-26 18:22:47 +00:00
|
|
|
Get.put(ServerPlaybackRoutesProvider());
|
|
|
|
Get.put(PlaybackServerProvider());
|
2024-08-26 12:26:07 +00:00
|
|
|
}
|
2024-08-26 05:29:17 +00:00
|
|
|
}
|