mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
refactor(preferences): use Drift sql db for preferences
This commit is contained in:
parent
a35eece00c
commit
3fb003ea60
@ -8,11 +8,11 @@ import 'package:spotube/components/dialogs/playlist_add_track_dialog.dart';
|
||||
import 'package:spotube/components/tracks_view/track_view_props.dart';
|
||||
import 'package:spotube/components/tracks_view/track_view_provider.dart';
|
||||
import 'package:spotube/extensions/context.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/provider/download_manager_provider.dart';
|
||||
import 'package:spotube/provider/history/history.dart';
|
||||
import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
|
||||
class TrackViewBodyOptions extends HookConsumerWidget {
|
||||
const TrackViewBodyOptions({super.key});
|
||||
|
@ -2,8 +2,9 @@ import 'dart:io';
|
||||
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:spotube/hooks/configurators/use_window_listener.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
|
||||
import 'package:local_notifier/local_notifier.dart';
|
||||
import 'package:spotube/utils/platform.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
54
lib/models/database/database.dart
Normal file
54
lib/models/database/database.dart
Normal file
@ -0,0 +1,54 @@
|
||||
library database;
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
import 'package:spotube/services/sourced_track/enums.dart';
|
||||
import 'package:flutter/material.dart' hide Table;
|
||||
import 'package:spotube/modules/settings/color_scheme_picker_dialog.dart';
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:sqlite3/sqlite3.dart';
|
||||
import 'package:sqlite3_flutter_libs/sqlite3_flutter_libs.dart';
|
||||
|
||||
part 'database.g.dart';
|
||||
|
||||
part 'tables/preferences.dart';
|
||||
part 'typeconverters/color.dart';
|
||||
part 'typeconverters/locale.dart';
|
||||
part 'typeconverters/string_list.dart';
|
||||
|
||||
@DriftDatabase(tables: [PreferencesTable])
|
||||
class AppDatabase extends _$AppDatabase {
|
||||
AppDatabase() : super(_openConnection());
|
||||
|
||||
@override
|
||||
int get schemaVersion => 1;
|
||||
}
|
||||
|
||||
LazyDatabase _openConnection() {
|
||||
// the LazyDatabase util lets us find the right location for the file async.
|
||||
return LazyDatabase(() async {
|
||||
// put the database file, called db.sqlite here, into the documents folder
|
||||
// for your app.
|
||||
final dbFolder = await getApplicationDocumentsDirectory();
|
||||
final file = File(join(dbFolder.path, 'db.sqlite'));
|
||||
|
||||
// Also work around limitations on old Android versions
|
||||
if (Platform.isAndroid) {
|
||||
await applyWorkaroundToOpenSqlite3OnOldAndroidVersions();
|
||||
}
|
||||
|
||||
// Make sqlite3 pick a more suitable location for temporary files - the
|
||||
// one from the system may be inaccessible due to sandboxing.
|
||||
final cacheBase = (await getTemporaryDirectory()).path;
|
||||
// We can't access /tmp on Android, which sqlite3 would try by default.
|
||||
// Explicitly tell it about the correct temporary directory.
|
||||
sqlite3.tempDirectory = cacheBase;
|
||||
|
||||
return NativeDatabase.createInBackground(file);
|
||||
});
|
||||
}
|
1707
lib/models/database/database.g.dart
Normal file
1707
lib/models/database/database.g.dart
Normal file
File diff suppressed because it is too large
Load Diff
125
lib/models/database/tables/preferences.dart
Normal file
125
lib/models/database/tables/preferences.dart
Normal file
@ -0,0 +1,125 @@
|
||||
part of '../database.dart';
|
||||
|
||||
enum LayoutMode {
|
||||
compact,
|
||||
extended,
|
||||
adaptive,
|
||||
}
|
||||
|
||||
enum CloseBehavior {
|
||||
minimizeToTray,
|
||||
close,
|
||||
}
|
||||
|
||||
enum AudioSource {
|
||||
youtube,
|
||||
piped,
|
||||
jiosaavn;
|
||||
|
||||
String get label => name[0].toUpperCase() + name.substring(1);
|
||||
}
|
||||
|
||||
enum MusicCodec {
|
||||
m4a._("M4a (Best for downloaded music)"),
|
||||
weba._("WebA (Best for streamed music)\nDoesn't support audio metadata");
|
||||
|
||||
final String label;
|
||||
const MusicCodec._(this.label);
|
||||
}
|
||||
|
||||
enum SearchMode {
|
||||
youtube._("YouTube"),
|
||||
youtubeMusic._("YouTube Music");
|
||||
|
||||
final String label;
|
||||
|
||||
const SearchMode._(this.label);
|
||||
|
||||
factory SearchMode.fromString(String key) {
|
||||
return SearchMode.values.firstWhere((e) => e.name == key);
|
||||
}
|
||||
}
|
||||
|
||||
class PreferencesTable extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
TextColumn get audioQuality => textEnum<SourceQualities>()
|
||||
.withDefault(Constant(SourceQualities.high.name))();
|
||||
BoolColumn get albumColorSync =>
|
||||
boolean().withDefault(const Constant(true))();
|
||||
BoolColumn get amoledDarkTheme =>
|
||||
boolean().withDefault(const Constant(false))();
|
||||
BoolColumn get checkUpdate => boolean().withDefault(const Constant(true))();
|
||||
BoolColumn get normalizeAudio =>
|
||||
boolean().withDefault(const Constant(false))();
|
||||
BoolColumn get showSystemTrayIcon =>
|
||||
boolean().withDefault(const Constant(false))();
|
||||
BoolColumn get systemTitleBar =>
|
||||
boolean().withDefault(const Constant(false))();
|
||||
BoolColumn get skipNonMusic => boolean().withDefault(const Constant(false))();
|
||||
TextColumn get closeBehavior => textEnum<CloseBehavior>()
|
||||
.withDefault(Constant(CloseBehavior.close.name))();
|
||||
TextColumn get accentColorScheme => text()
|
||||
.withDefault(const Constant("Blue:0xFF2196F3"))
|
||||
.map(const SpotubeColorConverter())();
|
||||
TextColumn get layoutMode =>
|
||||
textEnum<LayoutMode>().withDefault(Constant(LayoutMode.adaptive.name))();
|
||||
TextColumn get locale => text()
|
||||
.withDefault(
|
||||
const Constant('{"languageCode":"system","countryCode":"system"}'),
|
||||
)
|
||||
.map(const LocaleConverter())();
|
||||
TextColumn get market =>
|
||||
textEnum<Market>().withDefault(Constant(Market.US.name))();
|
||||
TextColumn get searchMode =>
|
||||
textEnum<SearchMode>().withDefault(Constant(SearchMode.youtube.name))();
|
||||
TextColumn get downloadLocation => text().withDefault(const Constant(""))();
|
||||
TextColumn get localLibraryLocation =>
|
||||
text().withDefault(const Constant("")).map(const StringListConverter())();
|
||||
TextColumn get pipedInstance =>
|
||||
text().withDefault(const Constant("https://pipedapi.kavin.rocks"))();
|
||||
TextColumn get themeMode =>
|
||||
textEnum<ThemeMode>().withDefault(Constant(ThemeMode.system.name))();
|
||||
TextColumn get audioSource =>
|
||||
textEnum<AudioSource>().withDefault(Constant(AudioSource.youtube.name))();
|
||||
TextColumn get streamMusicCodec =>
|
||||
textEnum<SourceCodecs>().withDefault(Constant(SourceCodecs.weba.name))();
|
||||
TextColumn get downloadMusicCodec =>
|
||||
textEnum<SourceCodecs>().withDefault(Constant(SourceCodecs.m4a.name))();
|
||||
BoolColumn get discordPresence =>
|
||||
boolean().withDefault(const Constant(true))();
|
||||
BoolColumn get endlessPlayback =>
|
||||
boolean().withDefault(const Constant(true))();
|
||||
BoolColumn get enableConnect =>
|
||||
boolean().withDefault(const Constant(false))();
|
||||
|
||||
// Default values as PreferencesTableData
|
||||
static PreferencesTableData defaults() {
|
||||
return PreferencesTableData(
|
||||
id: 0,
|
||||
audioQuality: SourceQualities.high,
|
||||
albumColorSync: true,
|
||||
amoledDarkTheme: false,
|
||||
checkUpdate: true,
|
||||
normalizeAudio: false,
|
||||
showSystemTrayIcon: false,
|
||||
systemTitleBar: false,
|
||||
skipNonMusic: false,
|
||||
closeBehavior: CloseBehavior.close,
|
||||
accentColorScheme: SpotubeColor(Colors.blue.value, name: "Blue"),
|
||||
layoutMode: LayoutMode.adaptive,
|
||||
locale: const Locale("system", "system"),
|
||||
market: Market.US,
|
||||
searchMode: SearchMode.youtube,
|
||||
downloadLocation: "",
|
||||
localLibraryLocation: [],
|
||||
pipedInstance: "https://pipedapi.kavin.rocks",
|
||||
themeMode: ThemeMode.system,
|
||||
audioSource: AudioSource.youtube,
|
||||
streamMusicCodec: SourceCodecs.weba,
|
||||
downloadMusicCodec: SourceCodecs.m4a,
|
||||
discordPresence: true,
|
||||
endlessPlayback: true,
|
||||
enableConnect: false,
|
||||
);
|
||||
}
|
||||
}
|
29
lib/models/database/typeconverters/color.dart
Normal file
29
lib/models/database/typeconverters/color.dart
Normal file
@ -0,0 +1,29 @@
|
||||
part of '../database.dart';
|
||||
|
||||
class ColorConverter extends TypeConverter<Color, int> {
|
||||
const ColorConverter();
|
||||
|
||||
@override
|
||||
Color fromSql(int fromDb) {
|
||||
return Color(fromDb);
|
||||
}
|
||||
|
||||
@override
|
||||
int toSql(Color value) {
|
||||
return value.value;
|
||||
}
|
||||
}
|
||||
|
||||
class SpotubeColorConverter extends TypeConverter<SpotubeColor, String> {
|
||||
const SpotubeColorConverter();
|
||||
|
||||
@override
|
||||
SpotubeColor fromSql(String fromDb) {
|
||||
return SpotubeColor.fromString(fromDb);
|
||||
}
|
||||
|
||||
@override
|
||||
String toSql(SpotubeColor value) {
|
||||
return value.toString();
|
||||
}
|
||||
}
|
19
lib/models/database/typeconverters/locale.dart
Normal file
19
lib/models/database/typeconverters/locale.dart
Normal file
@ -0,0 +1,19 @@
|
||||
part of '../database.dart';
|
||||
|
||||
class LocaleConverter extends TypeConverter<Locale, String> {
|
||||
const LocaleConverter();
|
||||
|
||||
@override
|
||||
Locale fromSql(String fromDb) {
|
||||
final rawMap = jsonDecode(fromDb) as Map<String, dynamic>;
|
||||
return Locale(rawMap["languageCode"], rawMap["countryCode"]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toSql(Locale value) {
|
||||
return jsonEncode({
|
||||
"languageCode": value.languageCode,
|
||||
"countryCode": value.countryCode,
|
||||
});
|
||||
}
|
||||
}
|
15
lib/models/database/typeconverters/string_list.dart
Normal file
15
lib/models/database/typeconverters/string_list.dart
Normal file
@ -0,0 +1,15 @@
|
||||
part of '../database.dart';
|
||||
|
||||
class StringListConverter extends TypeConverter<List<String>, String> {
|
||||
const StringListConverter();
|
||||
|
||||
@override
|
||||
List<String> fromSql(String fromDb) {
|
||||
return fromDb.split(",");
|
||||
}
|
||||
|
||||
@override
|
||||
String toSql(List<String> value) {
|
||||
return value.join(",");
|
||||
}
|
||||
}
|
@ -14,10 +14,11 @@ import 'package:spotube/extensions/constrains.dart';
|
||||
import 'package:spotube/extensions/context.dart';
|
||||
import 'package:spotube/extensions/duration.dart';
|
||||
import 'package:spotube/hooks/utils/use_debounce.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart';
|
||||
import 'package:spotube/provider/server/active_sourced_track.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
|
||||
import 'package:spotube/services/sourced_track/models/source_info.dart';
|
||||
import 'package:spotube/services/sourced_track/models/video_info.dart';
|
||||
import 'package:spotube/services/sourced_track/sourced_track.dart';
|
||||
|
@ -6,6 +6,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
|
||||
import 'package:spotube/collections/assets.gen.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/modules/player/player_actions.dart';
|
||||
import 'package:spotube/modules/player/player_overlay.dart';
|
||||
import 'package:spotube/modules/player/player_track_details.dart';
|
||||
@ -20,7 +21,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:spotube/provider/authentication_provider.dart';
|
||||
import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
|
||||
import 'package:spotube/provider/volume_provider.dart';
|
||||
import 'package:spotube/utils/platform.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
@ -9,6 +9,7 @@ import 'package:sidebarx/sidebarx.dart';
|
||||
import 'package:spotube/collections/assets.gen.dart';
|
||||
import 'package:spotube/collections/side_bar_tiles.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/modules/connect/connect_device.dart';
|
||||
import 'package:spotube/components/image/universal_image.dart';
|
||||
import 'package:spotube/extensions/constrains.dart';
|
||||
@ -23,7 +24,7 @@ import 'package:spotube/provider/authentication_provider.dart';
|
||||
import 'package:spotube/provider/spotify/spotify.dart';
|
||||
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
|
||||
import 'package:spotube/utils/platform.dart';
|
||||
import 'package:spotube/utils/service_utils.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
@ -10,9 +10,10 @@ import 'package:spotube/collections/side_bar_tiles.dart';
|
||||
import 'package:spotube/extensions/constrains.dart';
|
||||
import 'package:spotube/extensions/context.dart';
|
||||
import 'package:spotube/hooks/utils/use_brightness_value.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/provider/download_manager_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
|
||||
import 'package:spotube/utils/service_utils.dart';
|
||||
|
||||
final navigationPanelHeight = StateProvider<double>((ref) => 50);
|
||||
|
@ -4,11 +4,11 @@ import 'package:gap/gap.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:spotube/collections/assets.gen.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/modules/getting_started/blur_card.dart';
|
||||
import 'package:spotube/extensions/context.dart';
|
||||
import 'package:spotube/extensions/string.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
|
||||
final audioSourceToIconMap = {
|
||||
AudioSource.youtube: const Icon(
|
||||
|
@ -55,14 +55,14 @@ class GettingStartedPageLanguageRegionSection extends HookConsumerWidget {
|
||||
),
|
||||
const Gap(16),
|
||||
DropdownMenu(
|
||||
initialSelection: preferences.recommendationMarket,
|
||||
initialSelection: preferences.market,
|
||||
onSelected: (value) {
|
||||
if (value == null) return;
|
||||
ref
|
||||
.read(userPreferencesProvider.notifier)
|
||||
.setRecommendationMarket(value);
|
||||
},
|
||||
hintText: preferences.recommendationMarket.name,
|
||||
hintText: preferences.market.name,
|
||||
label: Text(context.l10n.market_place_region),
|
||||
inputDecorationTheme:
|
||||
const InputDecorationTheme(isDense: true),
|
||||
|
@ -39,7 +39,7 @@ class PlaylistGeneratorPage extends HookConsumerWidget {
|
||||
final genresCollection = ref.watch(categoryGenresProvider);
|
||||
|
||||
final limit = useValueNotifier<int>(10);
|
||||
final market = useValueNotifier<Market>(preferences.recommendationMarket);
|
||||
final market = useValueNotifier<Market>(preferences.market);
|
||||
|
||||
final genres = useState<List<String>>([]);
|
||||
final artists = useState<List<Artist>>([]);
|
||||
|
@ -3,12 +3,12 @@ import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/modules/settings/color_scheme_picker_dialog.dart';
|
||||
import 'package:spotube/modules/settings/section_card_with_heading.dart';
|
||||
import 'package:spotube/components/adaptive/adaptive_select_tile.dart';
|
||||
import 'package:spotube/extensions/context.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
|
||||
class SettingsAppearanceSection extends HookConsumerWidget {
|
||||
final bool isGettingStarted;
|
||||
|
@ -2,11 +2,12 @@ import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/modules/settings/section_card_with_heading.dart';
|
||||
import 'package:spotube/components/adaptive/adaptive_select_tile.dart';
|
||||
import 'package:spotube/extensions/context.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
|
||||
import 'package:spotube/utils/platform.dart';
|
||||
|
||||
class SettingsDesktopSection extends HookConsumerWidget {
|
||||
|
@ -57,7 +57,7 @@ class SettingsLanguageRegionSection extends HookConsumerWidget {
|
||||
secondary: const Icon(SpotubeIcons.shoppingBag),
|
||||
title: Text(context.l10n.market_place_region),
|
||||
subtitle: Text(context.l10n.recommendation_country),
|
||||
value: preferences.recommendationMarket,
|
||||
value: preferences.market,
|
||||
onChanged: (value) {
|
||||
if (value == null) return;
|
||||
preferencesNotifier.setRecommendationMarket(value);
|
||||
|
@ -6,12 +6,13 @@ import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:piped_client/piped_client.dart';
|
||||
import 'package:spotube/collections/spotube_icons.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/modules/settings/section_card_with_heading.dart';
|
||||
import 'package:spotube/components/adaptive/adaptive_select_tile.dart';
|
||||
import 'package:spotube/extensions/context.dart';
|
||||
import 'package:spotube/provider/piped_instances_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
|
||||
import 'package:spotube/services/sourced_track/enums.dart';
|
||||
|
||||
class SettingsPlaybackSection extends HookConsumerWidget {
|
||||
|
4
lib/provider/database/database.dart
Normal file
4
lib/provider/database/database.dart
Normal file
@ -0,0 +1,4 @@
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
|
||||
final databaseProvider = Provider((ref) => AppDatabase());
|
@ -14,7 +14,7 @@ import 'package:spotube/provider/proxy_playlist/proxy_playlist.dart';
|
||||
import 'package:spotube/provider/scrobbler_provider.dart';
|
||||
import 'package:spotube/provider/server/sourced_track.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
|
||||
import 'package:spotube/services/audio_player/audio_player.dart';
|
||||
import 'package:spotube/services/audio_services/audio_services.dart';
|
||||
import 'package:spotube/provider/discord_provider.dart';
|
||||
|
@ -1,10 +1,11 @@
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/services/logger/logger.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:spotube/models/skip_segment.dart';
|
||||
import 'package:spotube/provider/server/active_sourced_track.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
|
||||
import 'package:spotube/services/dio/dio.dart';
|
||||
|
||||
class SourcedSegments {
|
||||
|
@ -7,7 +7,6 @@ import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart';
|
||||
import 'package:spotube/provider/server/active_sourced_track.dart';
|
||||
import 'package:spotube/provider/server/sourced_track.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
import 'package:spotube/services/logger/logger.dart';
|
||||
|
||||
class ServerPlaybackRoutes {
|
||||
|
@ -30,7 +30,7 @@ class AlbumReleasesNotifier
|
||||
|
||||
@override
|
||||
fetch(int offset, int limit) async {
|
||||
final market = ref.read(userPreferencesProvider).recommendationMarket;
|
||||
final market = ref.read(userPreferencesProvider).market;
|
||||
|
||||
final albums = await spotify.browse
|
||||
.newReleases(country: market)
|
||||
@ -43,7 +43,7 @@ class AlbumReleasesNotifier
|
||||
build() async {
|
||||
ref.watch(spotifyProvider);
|
||||
ref.watch(
|
||||
userPreferencesProvider.select((s) => s.recommendationMarket),
|
||||
userPreferencesProvider.select((s) => s.market),
|
||||
);
|
||||
ref.watch(allFollowedArtistsProvider);
|
||||
|
||||
|
@ -30,7 +30,7 @@ class ArtistAlbumsNotifier extends AutoDisposeFamilyPaginatedAsyncNotifier<
|
||||
|
||||
@override
|
||||
fetch(arg, offset, limit) async {
|
||||
final market = ref.read(userPreferencesProvider).recommendationMarket;
|
||||
final market = ref.read(userPreferencesProvider).market;
|
||||
final albums = await spotify.artists
|
||||
.albums(arg, country: market)
|
||||
.getPage(limit, offset);
|
||||
@ -44,7 +44,7 @@ class ArtistAlbumsNotifier extends AutoDisposeFamilyPaginatedAsyncNotifier<
|
||||
|
||||
ref.watch(spotifyProvider);
|
||||
ref.watch(
|
||||
userPreferencesProvider.select((s) => s.recommendationMarket),
|
||||
userPreferencesProvider.select((s) => s.market),
|
||||
);
|
||||
final albums = await fetch(arg, 0, 20);
|
||||
return ArtistAlbumsState(
|
||||
|
@ -6,8 +6,7 @@ final artistTopTracksProvider =
|
||||
ref.cacheFor();
|
||||
|
||||
final spotify = ref.watch(spotifyProvider);
|
||||
final market = ref
|
||||
.watch(userPreferencesProvider.select((s) => s.recommendationMarket));
|
||||
final market = ref.watch(userPreferencesProvider.select((s) => s.market));
|
||||
final tracks = await spotify.artists.topTracks(artistId, market);
|
||||
|
||||
return tracks.toList();
|
||||
|
@ -3,8 +3,7 @@ part of '../spotify.dart';
|
||||
final categoriesProvider = FutureProvider(
|
||||
(ref) async {
|
||||
final spotify = ref.watch(spotifyProvider);
|
||||
final market = ref
|
||||
.watch(userPreferencesProvider.select((s) => s.recommendationMarket));
|
||||
final market = ref.watch(userPreferencesProvider.select((s) => s.market));
|
||||
final locale = ref.watch(userPreferencesProvider.select((s) => s.locale));
|
||||
final categories = await spotify.categories
|
||||
.list(
|
||||
|
@ -33,7 +33,7 @@ class CategoryPlaylistsNotifier extends AutoDisposeFamilyPaginatedAsyncNotifier<
|
||||
final preferences = ref.read(userPreferencesProvider);
|
||||
final playlists = await Pages<PlaylistSimple?>(
|
||||
spotify,
|
||||
"v1/browse/categories/$arg/playlists?country=${preferences.recommendationMarket.name}&locale=${preferences.locale}",
|
||||
"v1/browse/categories/$arg/playlists?country=${preferences.market.name}&locale=${preferences.locale}",
|
||||
(json) => json == null ? null : PlaylistSimple.fromJson(json),
|
||||
'playlists',
|
||||
(json) => PlaylistsFeatured.fromJson(json),
|
||||
@ -48,7 +48,7 @@ class CategoryPlaylistsNotifier extends AutoDisposeFamilyPaginatedAsyncNotifier<
|
||||
|
||||
ref.watch(spotifyProvider);
|
||||
ref.watch(userPreferencesProvider.select((s) => s.locale));
|
||||
ref.watch(userPreferencesProvider.select((s) => s.recommendationMarket));
|
||||
ref.watch(userPreferencesProvider.select((s) => s.market));
|
||||
|
||||
final playlists = await fetch(arg, 0, 8);
|
||||
|
||||
|
@ -5,7 +5,7 @@ final generatePlaylistProvider = FutureProvider.autoDispose
|
||||
(ref, input) async {
|
||||
final spotify = ref.watch(spotifyProvider);
|
||||
final market = ref.watch(
|
||||
userPreferencesProvider.select((s) => s.recommendationMarket),
|
||||
userPreferencesProvider.select((s) => s.market),
|
||||
);
|
||||
|
||||
final recommendation = await spotify.recommendations
|
||||
|
@ -42,7 +42,7 @@ class SearchNotifier<Y> extends AutoDisposeFamilyPaginatedAsyncNotifier<Y,
|
||||
.get(
|
||||
ref.read(searchTermStateProvider),
|
||||
types: [arg],
|
||||
market: ref.read(userPreferencesProvider).recommendationMarket,
|
||||
market: ref.read(userPreferencesProvider).market,
|
||||
)
|
||||
.getPage(limit, offset);
|
||||
|
||||
@ -56,7 +56,7 @@ class SearchNotifier<Y> extends AutoDisposeFamilyPaginatedAsyncNotifier<Y,
|
||||
ref.watch(searchTermStateProvider);
|
||||
ref.watch(spotifyProvider);
|
||||
ref.watch(
|
||||
userPreferencesProvider.select((value) => value.recommendationMarket),
|
||||
userPreferencesProvider.select((value) => value.market),
|
||||
);
|
||||
|
||||
final results = await fetch(arg, 0, 10);
|
||||
|
@ -5,7 +5,7 @@ import 'package:spotube/provider/user_preferences/user_preferences_provider.dart
|
||||
|
||||
final homeViewProvider = FutureProvider((ref) async {
|
||||
final country = ref.watch(
|
||||
userPreferencesProvider.select((s) => s.recommendationMarket),
|
||||
userPreferencesProvider.select((s) => s.market),
|
||||
);
|
||||
final spTCookie = ref.watch(
|
||||
authenticationProvider.select((s) => s?.getCookie("sp_t")),
|
||||
|
@ -8,7 +8,7 @@ final homeSectionViewProvider =
|
||||
FutureProvider.family<SpotifyHomeFeedSection?, String>(
|
||||
(ref, sectionUri) async {
|
||||
final country = ref.watch(
|
||||
userPreferencesProvider.select((s) => s.recommendationMarket),
|
||||
userPreferencesProvider.select((s) => s.market),
|
||||
);
|
||||
final spTCookie = ref.watch(
|
||||
authenticationProvider.select((s) => s?.getCookie("sp_t")),
|
||||
|
@ -4,7 +4,7 @@ final viewProvider = FutureProvider.family<Map<String, dynamic>, String>(
|
||||
(ref, viewName) async {
|
||||
final customSpotify = ref.watch(customSpotifyEndpointProvider);
|
||||
final market = ref.watch(
|
||||
userPreferencesProvider.select((s) => s.recommendationMarket),
|
||||
userPreferencesProvider.select((s) => s.market),
|
||||
);
|
||||
final locale = ref.watch(
|
||||
userPreferencesProvider.select((s) => s.locale),
|
||||
|
@ -1,54 +1,116 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/modules/settings/color_scheme_picker_dialog.dart';
|
||||
import 'package:spotube/provider/database/database.dart';
|
||||
import 'package:spotube/provider/palette_provider.dart';
|
||||
import 'package:spotube/provider/proxy_playlist/player_listeners.dart';
|
||||
import 'package:spotube/provider/proxy_playlist/proxy_playlist_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
import 'package:spotube/services/audio_player/audio_player.dart';
|
||||
import 'package:spotube/services/sourced_track/enums.dart';
|
||||
|
||||
import 'package:spotube/utils/persisted_state_notifier.dart';
|
||||
import 'package:spotube/utils/platform.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
class UserPreferencesNotifier extends PersistedStateNotifier<UserPreferences> {
|
||||
final Ref ref;
|
||||
typedef UserPreferences = PreferencesTableData;
|
||||
|
||||
UserPreferencesNotifier(this.ref)
|
||||
: super(UserPreferences.withDefaults(), "preferences");
|
||||
class UserPreferencesNotifier extends Notifier<PreferencesTableData> {
|
||||
@override
|
||||
build() {
|
||||
final db = ref.watch(databaseProvider);
|
||||
|
||||
void reset() {
|
||||
state = UserPreferences.withDefaults();
|
||||
(db.select(db.preferencesTable)..where((tbl) => tbl.id.equals(0)))
|
||||
.getSingleOrNull()
|
||||
.then((result) async {
|
||||
if (result == null) {
|
||||
await db.into(db.preferencesTable).insert(
|
||||
PreferencesTableCompanion.insert(
|
||||
id: const Value(0),
|
||||
downloadLocation: Value(await _getDefaultDownloadDirectory()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
state = await (db.select(db.preferencesTable)
|
||||
..where((tbl) => tbl.id.equals(0)))
|
||||
.getSingle();
|
||||
|
||||
final subscription = (db.select(db.preferencesTable)
|
||||
..where((tbl) => tbl.id.equals(0)))
|
||||
.watchSingle()
|
||||
.listen((event) async {
|
||||
state = event;
|
||||
|
||||
if (kIsDesktop) {
|
||||
await windowManager.setTitleBarStyle(
|
||||
state.systemTitleBar ? TitleBarStyle.normal : TitleBarStyle.hidden,
|
||||
);
|
||||
}
|
||||
|
||||
await audioPlayer.setAudioNormalization(state.normalizeAudio);
|
||||
});
|
||||
|
||||
ref.onDispose(() {
|
||||
subscription.cancel();
|
||||
});
|
||||
});
|
||||
|
||||
return PreferencesTable.defaults();
|
||||
}
|
||||
|
||||
Future<String> _getDefaultDownloadDirectory() async {
|
||||
if (kIsAndroid) return "/storage/emulated/0/Download/Spotube";
|
||||
|
||||
if (kIsMacOS) {
|
||||
return join((await getLibraryDirectory()).path, "Caches");
|
||||
}
|
||||
|
||||
return getDownloadsDirectory().then((dir) {
|
||||
return join(dir!.path, "Spotube");
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> setData(PreferencesTableCompanion data) async {
|
||||
final db = ref.read(databaseProvider);
|
||||
|
||||
final query = db.update(db.preferencesTable)..where((t) => t.id.equals(0));
|
||||
|
||||
await query.write(data);
|
||||
}
|
||||
|
||||
Future<void> reset() async {
|
||||
final db = ref.read(databaseProvider);
|
||||
|
||||
final query = db.update(db.preferencesTable)..where((t) => t.id.equals(0));
|
||||
|
||||
await query.replace(PreferencesTableCompanion.insert());
|
||||
}
|
||||
|
||||
void setStreamMusicCodec(SourceCodecs codec) {
|
||||
state = state.copyWith(streamMusicCodec: codec);
|
||||
setData(PreferencesTableCompanion(streamMusicCodec: Value(codec)));
|
||||
}
|
||||
|
||||
void setDownloadMusicCodec(SourceCodecs codec) {
|
||||
state = state.copyWith(downloadMusicCodec: codec);
|
||||
setData(PreferencesTableCompanion(downloadMusicCodec: Value(codec)));
|
||||
}
|
||||
|
||||
void setThemeMode(ThemeMode mode) {
|
||||
state = state.copyWith(themeMode: mode);
|
||||
setData(PreferencesTableCompanion(themeMode: Value(mode)));
|
||||
}
|
||||
|
||||
void setRecommendationMarket(Market country) {
|
||||
state = state.copyWith(recommendationMarket: country);
|
||||
setData(PreferencesTableCompanion(market: Value(country)));
|
||||
}
|
||||
|
||||
void setAccentColorScheme(SpotubeColor color) {
|
||||
state = state.copyWith(accentColorScheme: color);
|
||||
setData(PreferencesTableCompanion(accentColorScheme: Value(color)));
|
||||
}
|
||||
|
||||
void setAlbumColorSync(bool sync) {
|
||||
state = state.copyWith(albumColorSync: sync);
|
||||
setData(PreferencesTableCompanion(albumColorSync: Value(sync)));
|
||||
|
||||
if (!sync) {
|
||||
ref.read(paletteProvider.notifier).state = null;
|
||||
@ -58,126 +120,87 @@ class UserPreferencesNotifier extends PersistedStateNotifier<UserPreferences> {
|
||||
}
|
||||
|
||||
void setCheckUpdate(bool check) {
|
||||
state = state.copyWith(checkUpdate: check);
|
||||
setData(PreferencesTableCompanion(checkUpdate: Value(check)));
|
||||
}
|
||||
|
||||
void setAudioQuality(SourceQualities quality) {
|
||||
state = state.copyWith(audioQuality: quality);
|
||||
setData(PreferencesTableCompanion(audioQuality: Value(quality)));
|
||||
}
|
||||
|
||||
void setDownloadLocation(String downloadDir) {
|
||||
if (downloadDir.isEmpty) return;
|
||||
state = state.copyWith(downloadLocation: downloadDir);
|
||||
setData(PreferencesTableCompanion(downloadLocation: Value(downloadDir)));
|
||||
}
|
||||
|
||||
void setLocalLibraryLocation(List<String> localLibraryDirs) {
|
||||
//if (localLibraryDir.isEmpty) return;
|
||||
state = state.copyWith(localLibraryLocation: localLibraryDirs);
|
||||
setData(PreferencesTableCompanion(
|
||||
localLibraryLocation: Value(localLibraryDirs)));
|
||||
}
|
||||
|
||||
void setLayoutMode(LayoutMode mode) {
|
||||
state = state.copyWith(layoutMode: mode);
|
||||
setData(PreferencesTableCompanion(layoutMode: Value(mode)));
|
||||
}
|
||||
|
||||
void setCloseBehavior(CloseBehavior behavior) {
|
||||
state = state.copyWith(closeBehavior: behavior);
|
||||
setData(PreferencesTableCompanion(closeBehavior: Value(behavior)));
|
||||
}
|
||||
|
||||
void setShowSystemTrayIcon(bool show) {
|
||||
state = state.copyWith(showSystemTrayIcon: show);
|
||||
setData(PreferencesTableCompanion(showSystemTrayIcon: Value(show)));
|
||||
}
|
||||
|
||||
void setLocale(Locale locale) {
|
||||
state = state.copyWith(locale: locale);
|
||||
setData(PreferencesTableCompanion(locale: Value(locale)));
|
||||
}
|
||||
|
||||
void setPipedInstance(String instance) {
|
||||
state = state.copyWith(pipedInstance: instance);
|
||||
setData(PreferencesTableCompanion(pipedInstance: Value(instance)));
|
||||
}
|
||||
|
||||
void setSearchMode(SearchMode mode) {
|
||||
state = state.copyWith(searchMode: mode);
|
||||
setData(PreferencesTableCompanion(searchMode: Value(mode)));
|
||||
}
|
||||
|
||||
void setSkipNonMusic(bool skip) {
|
||||
state = state.copyWith(skipNonMusic: skip);
|
||||
setData(PreferencesTableCompanion(skipNonMusic: Value(skip)));
|
||||
}
|
||||
|
||||
void setAudioSource(AudioSource type) {
|
||||
state = state.copyWith(audioSource: type);
|
||||
setData(PreferencesTableCompanion(audioSource: Value(type)));
|
||||
}
|
||||
|
||||
void setSystemTitleBar(bool isSystemTitleBar) {
|
||||
state = state.copyWith(systemTitleBar: isSystemTitleBar);
|
||||
if (kIsDesktop) {
|
||||
windowManager.setTitleBarStyle(
|
||||
isSystemTitleBar ? TitleBarStyle.normal : TitleBarStyle.hidden,
|
||||
);
|
||||
}
|
||||
setData(
|
||||
PreferencesTableCompanion(
|
||||
systemTitleBar: Value(isSystemTitleBar),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void setDiscordPresence(bool discordPresence) {
|
||||
state = state.copyWith(discordPresence: discordPresence);
|
||||
setData(PreferencesTableCompanion(discordPresence: Value(discordPresence)));
|
||||
}
|
||||
|
||||
void setAmoledDarkTheme(bool isAmoled) {
|
||||
state = state.copyWith(amoledDarkTheme: isAmoled);
|
||||
setData(PreferencesTableCompanion(amoledDarkTheme: Value(isAmoled)));
|
||||
}
|
||||
|
||||
void setNormalizeAudio(bool normalize) {
|
||||
state = state.copyWith(normalizeAudio: normalize);
|
||||
setData(PreferencesTableCompanion(normalizeAudio: Value(normalize)));
|
||||
audioPlayer.setAudioNormalization(normalize);
|
||||
}
|
||||
|
||||
void setEndlessPlayback(bool endless) {
|
||||
state = state.copyWith(endlessPlayback: endless);
|
||||
setData(PreferencesTableCompanion(endlessPlayback: Value(endless)));
|
||||
}
|
||||
|
||||
void setEnableConnect(bool enable) {
|
||||
state = state.copyWith(enableConnect: enable);
|
||||
}
|
||||
|
||||
Future<String> _getDefaultDownloadDirectory() async {
|
||||
if (kIsAndroid) return "/storage/emulated/0/Download/Spotube";
|
||||
|
||||
if (kIsMacOS) {
|
||||
return path.join((await getLibraryDirectory()).path, "Caches");
|
||||
}
|
||||
|
||||
return getDownloadsDirectory().then((dir) {
|
||||
return path.join(dir!.path, "Spotube");
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr<void> onInit() async {
|
||||
if (state.downloadLocation.isEmpty) {
|
||||
state = state.copyWith(
|
||||
downloadLocation: await _getDefaultDownloadDirectory(),
|
||||
);
|
||||
}
|
||||
|
||||
if (kIsDesktop) {
|
||||
await windowManager.setTitleBarStyle(
|
||||
state.systemTitleBar ? TitleBarStyle.normal : TitleBarStyle.hidden,
|
||||
);
|
||||
}
|
||||
|
||||
await audioPlayer.setAudioNormalization(state.normalizeAudio);
|
||||
}
|
||||
|
||||
@override
|
||||
FutureOr<UserPreferences> fromJson(Map<String, dynamic> json) {
|
||||
return UserPreferences.fromJson(json);
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return state.toJson();
|
||||
setData(PreferencesTableCompanion(enableConnect: Value(enable)));
|
||||
}
|
||||
}
|
||||
|
||||
final userPreferencesProvider =
|
||||
StateNotifierProvider<UserPreferencesNotifier, UserPreferences>(
|
||||
(ref) => UserPreferencesNotifier(ref),
|
||||
NotifierProvider<UserPreferencesNotifier, PreferencesTableData>(
|
||||
() => UserPreferencesNotifier(),
|
||||
);
|
||||
|
@ -1,142 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
import 'package:spotube/modules/settings/color_scheme_picker_dialog.dart';
|
||||
import 'package:spotube/services/sourced_track/enums.dart';
|
||||
|
||||
part 'user_preferences_state.g.dart';
|
||||
part 'user_preferences_state.freezed.dart';
|
||||
|
||||
@JsonEnum()
|
||||
enum LayoutMode {
|
||||
compact,
|
||||
extended,
|
||||
adaptive,
|
||||
}
|
||||
|
||||
@JsonEnum()
|
||||
enum CloseBehavior {
|
||||
minimizeToTray,
|
||||
close,
|
||||
}
|
||||
|
||||
@JsonEnum()
|
||||
enum AudioSource {
|
||||
youtube,
|
||||
piped,
|
||||
jiosaavn;
|
||||
|
||||
String get label => name[0].toUpperCase() + name.substring(1);
|
||||
}
|
||||
|
||||
@JsonEnum()
|
||||
enum MusicCodec {
|
||||
m4a._("M4a (Best for downloaded music)"),
|
||||
weba._("WebA (Best for streamed music)\nDoesn't support audio metadata");
|
||||
|
||||
final String label;
|
||||
const MusicCodec._(this.label);
|
||||
}
|
||||
|
||||
@JsonEnum()
|
||||
enum SearchMode {
|
||||
youtube._("YouTube"),
|
||||
youtubeMusic._("YouTube Music");
|
||||
|
||||
final String label;
|
||||
|
||||
const SearchMode._(this.label);
|
||||
|
||||
factory SearchMode.fromString(String key) {
|
||||
return SearchMode.values.firstWhere((e) => e.name == key);
|
||||
}
|
||||
}
|
||||
|
||||
@freezed
|
||||
class UserPreferences with _$UserPreferences {
|
||||
const factory UserPreferences({
|
||||
@Default(SourceQualities.high) SourceQualities audioQuality,
|
||||
@Default(true) bool albumColorSync,
|
||||
@Default(false) bool amoledDarkTheme,
|
||||
@Default(true) bool checkUpdate,
|
||||
@Default(false) bool normalizeAudio,
|
||||
@Default(false) bool showSystemTrayIcon,
|
||||
@Default(false) bool skipNonMusic,
|
||||
@Default(false) bool systemTitleBar,
|
||||
@Default(CloseBehavior.close) CloseBehavior closeBehavior,
|
||||
@Default(SpotubeColor(0xFF2196F3, name: "Blue"))
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._accentColorSchemeFromJson,
|
||||
toJson: UserPreferences._accentColorSchemeToJson,
|
||||
readValue: UserPreferences._accentColorSchemeReadValue,
|
||||
)
|
||||
SpotubeColor accentColorScheme,
|
||||
@Default(LayoutMode.adaptive) LayoutMode layoutMode,
|
||||
@Default(Locale("system", "system"))
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._localeFromJson,
|
||||
toJson: UserPreferences._localeToJson,
|
||||
readValue: UserPreferences._localeReadValue,
|
||||
)
|
||||
Locale locale,
|
||||
@Default(Market.US) Market recommendationMarket,
|
||||
@Default(SearchMode.youtube) SearchMode searchMode,
|
||||
@Default("") String downloadLocation,
|
||||
@Default([]) List<String> localLibraryLocation,
|
||||
@Default("https://pipedapi.kavin.rocks") String pipedInstance,
|
||||
@Default(ThemeMode.system) ThemeMode themeMode,
|
||||
@Default(AudioSource.youtube) AudioSource audioSource,
|
||||
@Default(SourceCodecs.weba) SourceCodecs streamMusicCodec,
|
||||
@Default(SourceCodecs.m4a) SourceCodecs downloadMusicCodec,
|
||||
@Default(true) bool discordPresence,
|
||||
@Default(true) bool endlessPlayback,
|
||||
@Default(false) bool enableConnect,
|
||||
}) = _UserPreferences;
|
||||
factory UserPreferences.fromJson(Map<String, dynamic> json) =>
|
||||
_$UserPreferencesFromJson(json);
|
||||
|
||||
factory UserPreferences.withDefaults() => UserPreferences.fromJson({});
|
||||
|
||||
static SpotubeColor _accentColorSchemeFromJson(Map<String, dynamic> json) {
|
||||
return SpotubeColor.fromString(json["color"]);
|
||||
}
|
||||
|
||||
static Map<String, dynamic>? _accentColorSchemeReadValue(
|
||||
Map<dynamic, dynamic> json, String key) {
|
||||
if (json[key] is String) {
|
||||
return {"color": json[key]};
|
||||
}
|
||||
|
||||
return json[key] as Map<String, dynamic>?;
|
||||
}
|
||||
|
||||
static Map<String, dynamic> _accentColorSchemeToJson(SpotubeColor color) {
|
||||
return {"color": color.toString()};
|
||||
}
|
||||
|
||||
static Locale _localeFromJson(Map<String, dynamic> json) {
|
||||
return Locale(json["languageCode"], json["countryCode"]);
|
||||
}
|
||||
|
||||
static Map<String, dynamic> _localeToJson(Locale locale) {
|
||||
return {
|
||||
"languageCode": locale.languageCode,
|
||||
"countryCode": locale.countryCode,
|
||||
};
|
||||
}
|
||||
|
||||
static Map<String, dynamic>? _localeReadValue(
|
||||
Map<dynamic, dynamic> json, String key) {
|
||||
if (json[key] is String) {
|
||||
final map = jsonDecode(json[key]);
|
||||
return {
|
||||
"languageCode": map["lc"],
|
||||
"countryCode": map["cc"],
|
||||
};
|
||||
}
|
||||
|
||||
return json[key] as Map<String, dynamic>?;
|
||||
}
|
||||
}
|
@ -1,751 +0,0 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'user_preferences_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
UserPreferences _$UserPreferencesFromJson(Map<String, dynamic> json) {
|
||||
return _UserPreferences.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$UserPreferences {
|
||||
SourceQualities get audioQuality => throw _privateConstructorUsedError;
|
||||
bool get albumColorSync => throw _privateConstructorUsedError;
|
||||
bool get amoledDarkTheme => throw _privateConstructorUsedError;
|
||||
bool get checkUpdate => throw _privateConstructorUsedError;
|
||||
bool get normalizeAudio => throw _privateConstructorUsedError;
|
||||
bool get showSystemTrayIcon => throw _privateConstructorUsedError;
|
||||
bool get skipNonMusic => throw _privateConstructorUsedError;
|
||||
bool get systemTitleBar => throw _privateConstructorUsedError;
|
||||
CloseBehavior get closeBehavior => throw _privateConstructorUsedError;
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._accentColorSchemeFromJson,
|
||||
toJson: UserPreferences._accentColorSchemeToJson,
|
||||
readValue: UserPreferences._accentColorSchemeReadValue)
|
||||
SpotubeColor get accentColorScheme => throw _privateConstructorUsedError;
|
||||
LayoutMode get layoutMode => throw _privateConstructorUsedError;
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._localeFromJson,
|
||||
toJson: UserPreferences._localeToJson,
|
||||
readValue: UserPreferences._localeReadValue)
|
||||
Locale get locale => throw _privateConstructorUsedError;
|
||||
Market get recommendationMarket => throw _privateConstructorUsedError;
|
||||
SearchMode get searchMode => throw _privateConstructorUsedError;
|
||||
String get downloadLocation => throw _privateConstructorUsedError;
|
||||
List<String> get localLibraryLocation => throw _privateConstructorUsedError;
|
||||
String get pipedInstance => throw _privateConstructorUsedError;
|
||||
ThemeMode get themeMode => throw _privateConstructorUsedError;
|
||||
AudioSource get audioSource => throw _privateConstructorUsedError;
|
||||
SourceCodecs get streamMusicCodec => throw _privateConstructorUsedError;
|
||||
SourceCodecs get downloadMusicCodec => throw _privateConstructorUsedError;
|
||||
bool get discordPresence => throw _privateConstructorUsedError;
|
||||
bool get endlessPlayback => throw _privateConstructorUsedError;
|
||||
bool get enableConnect => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$UserPreferencesCopyWith<UserPreferences> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $UserPreferencesCopyWith<$Res> {
|
||||
factory $UserPreferencesCopyWith(
|
||||
UserPreferences value, $Res Function(UserPreferences) then) =
|
||||
_$UserPreferencesCopyWithImpl<$Res, UserPreferences>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{SourceQualities audioQuality,
|
||||
bool albumColorSync,
|
||||
bool amoledDarkTheme,
|
||||
bool checkUpdate,
|
||||
bool normalizeAudio,
|
||||
bool showSystemTrayIcon,
|
||||
bool skipNonMusic,
|
||||
bool systemTitleBar,
|
||||
CloseBehavior closeBehavior,
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._accentColorSchemeFromJson,
|
||||
toJson: UserPreferences._accentColorSchemeToJson,
|
||||
readValue: UserPreferences._accentColorSchemeReadValue)
|
||||
SpotubeColor accentColorScheme,
|
||||
LayoutMode layoutMode,
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._localeFromJson,
|
||||
toJson: UserPreferences._localeToJson,
|
||||
readValue: UserPreferences._localeReadValue)
|
||||
Locale locale,
|
||||
Market recommendationMarket,
|
||||
SearchMode searchMode,
|
||||
String downloadLocation,
|
||||
List<String> localLibraryLocation,
|
||||
String pipedInstance,
|
||||
ThemeMode themeMode,
|
||||
AudioSource audioSource,
|
||||
SourceCodecs streamMusicCodec,
|
||||
SourceCodecs downloadMusicCodec,
|
||||
bool discordPresence,
|
||||
bool endlessPlayback,
|
||||
bool enableConnect});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$UserPreferencesCopyWithImpl<$Res, $Val extends UserPreferences>
|
||||
implements $UserPreferencesCopyWith<$Res> {
|
||||
_$UserPreferencesCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? audioQuality = null,
|
||||
Object? albumColorSync = null,
|
||||
Object? amoledDarkTheme = null,
|
||||
Object? checkUpdate = null,
|
||||
Object? normalizeAudio = null,
|
||||
Object? showSystemTrayIcon = null,
|
||||
Object? skipNonMusic = null,
|
||||
Object? systemTitleBar = null,
|
||||
Object? closeBehavior = null,
|
||||
Object? accentColorScheme = null,
|
||||
Object? layoutMode = null,
|
||||
Object? locale = null,
|
||||
Object? recommendationMarket = null,
|
||||
Object? searchMode = null,
|
||||
Object? downloadLocation = null,
|
||||
Object? localLibraryLocation = null,
|
||||
Object? pipedInstance = null,
|
||||
Object? themeMode = null,
|
||||
Object? audioSource = null,
|
||||
Object? streamMusicCodec = null,
|
||||
Object? downloadMusicCodec = null,
|
||||
Object? discordPresence = null,
|
||||
Object? endlessPlayback = null,
|
||||
Object? enableConnect = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
audioQuality: null == audioQuality
|
||||
? _value.audioQuality
|
||||
: audioQuality // ignore: cast_nullable_to_non_nullable
|
||||
as SourceQualities,
|
||||
albumColorSync: null == albumColorSync
|
||||
? _value.albumColorSync
|
||||
: albumColorSync // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
amoledDarkTheme: null == amoledDarkTheme
|
||||
? _value.amoledDarkTheme
|
||||
: amoledDarkTheme // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
checkUpdate: null == checkUpdate
|
||||
? _value.checkUpdate
|
||||
: checkUpdate // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
normalizeAudio: null == normalizeAudio
|
||||
? _value.normalizeAudio
|
||||
: normalizeAudio // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
showSystemTrayIcon: null == showSystemTrayIcon
|
||||
? _value.showSystemTrayIcon
|
||||
: showSystemTrayIcon // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
skipNonMusic: null == skipNonMusic
|
||||
? _value.skipNonMusic
|
||||
: skipNonMusic // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
systemTitleBar: null == systemTitleBar
|
||||
? _value.systemTitleBar
|
||||
: systemTitleBar // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
closeBehavior: null == closeBehavior
|
||||
? _value.closeBehavior
|
||||
: closeBehavior // ignore: cast_nullable_to_non_nullable
|
||||
as CloseBehavior,
|
||||
accentColorScheme: null == accentColorScheme
|
||||
? _value.accentColorScheme
|
||||
: accentColorScheme // ignore: cast_nullable_to_non_nullable
|
||||
as SpotubeColor,
|
||||
layoutMode: null == layoutMode
|
||||
? _value.layoutMode
|
||||
: layoutMode // ignore: cast_nullable_to_non_nullable
|
||||
as LayoutMode,
|
||||
locale: null == locale
|
||||
? _value.locale
|
||||
: locale // ignore: cast_nullable_to_non_nullable
|
||||
as Locale,
|
||||
recommendationMarket: null == recommendationMarket
|
||||
? _value.recommendationMarket
|
||||
: recommendationMarket // ignore: cast_nullable_to_non_nullable
|
||||
as Market,
|
||||
searchMode: null == searchMode
|
||||
? _value.searchMode
|
||||
: searchMode // ignore: cast_nullable_to_non_nullable
|
||||
as SearchMode,
|
||||
downloadLocation: null == downloadLocation
|
||||
? _value.downloadLocation
|
||||
: downloadLocation // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
localLibraryLocation: null == localLibraryLocation
|
||||
? _value.localLibraryLocation
|
||||
: localLibraryLocation // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
pipedInstance: null == pipedInstance
|
||||
? _value.pipedInstance
|
||||
: pipedInstance // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
themeMode: null == themeMode
|
||||
? _value.themeMode
|
||||
: themeMode // ignore: cast_nullable_to_non_nullable
|
||||
as ThemeMode,
|
||||
audioSource: null == audioSource
|
||||
? _value.audioSource
|
||||
: audioSource // ignore: cast_nullable_to_non_nullable
|
||||
as AudioSource,
|
||||
streamMusicCodec: null == streamMusicCodec
|
||||
? _value.streamMusicCodec
|
||||
: streamMusicCodec // ignore: cast_nullable_to_non_nullable
|
||||
as SourceCodecs,
|
||||
downloadMusicCodec: null == downloadMusicCodec
|
||||
? _value.downloadMusicCodec
|
||||
: downloadMusicCodec // ignore: cast_nullable_to_non_nullable
|
||||
as SourceCodecs,
|
||||
discordPresence: null == discordPresence
|
||||
? _value.discordPresence
|
||||
: discordPresence // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
endlessPlayback: null == endlessPlayback
|
||||
? _value.endlessPlayback
|
||||
: endlessPlayback // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
enableConnect: null == enableConnect
|
||||
? _value.enableConnect
|
||||
: enableConnect // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$UserPreferencesImplCopyWith<$Res>
|
||||
implements $UserPreferencesCopyWith<$Res> {
|
||||
factory _$$UserPreferencesImplCopyWith(_$UserPreferencesImpl value,
|
||||
$Res Function(_$UserPreferencesImpl) then) =
|
||||
__$$UserPreferencesImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{SourceQualities audioQuality,
|
||||
bool albumColorSync,
|
||||
bool amoledDarkTheme,
|
||||
bool checkUpdate,
|
||||
bool normalizeAudio,
|
||||
bool showSystemTrayIcon,
|
||||
bool skipNonMusic,
|
||||
bool systemTitleBar,
|
||||
CloseBehavior closeBehavior,
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._accentColorSchemeFromJson,
|
||||
toJson: UserPreferences._accentColorSchemeToJson,
|
||||
readValue: UserPreferences._accentColorSchemeReadValue)
|
||||
SpotubeColor accentColorScheme,
|
||||
LayoutMode layoutMode,
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._localeFromJson,
|
||||
toJson: UserPreferences._localeToJson,
|
||||
readValue: UserPreferences._localeReadValue)
|
||||
Locale locale,
|
||||
Market recommendationMarket,
|
||||
SearchMode searchMode,
|
||||
String downloadLocation,
|
||||
List<String> localLibraryLocation,
|
||||
String pipedInstance,
|
||||
ThemeMode themeMode,
|
||||
AudioSource audioSource,
|
||||
SourceCodecs streamMusicCodec,
|
||||
SourceCodecs downloadMusicCodec,
|
||||
bool discordPresence,
|
||||
bool endlessPlayback,
|
||||
bool enableConnect});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$UserPreferencesImplCopyWithImpl<$Res>
|
||||
extends _$UserPreferencesCopyWithImpl<$Res, _$UserPreferencesImpl>
|
||||
implements _$$UserPreferencesImplCopyWith<$Res> {
|
||||
__$$UserPreferencesImplCopyWithImpl(
|
||||
_$UserPreferencesImpl _value, $Res Function(_$UserPreferencesImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? audioQuality = null,
|
||||
Object? albumColorSync = null,
|
||||
Object? amoledDarkTheme = null,
|
||||
Object? checkUpdate = null,
|
||||
Object? normalizeAudio = null,
|
||||
Object? showSystemTrayIcon = null,
|
||||
Object? skipNonMusic = null,
|
||||
Object? systemTitleBar = null,
|
||||
Object? closeBehavior = null,
|
||||
Object? accentColorScheme = null,
|
||||
Object? layoutMode = null,
|
||||
Object? locale = null,
|
||||
Object? recommendationMarket = null,
|
||||
Object? searchMode = null,
|
||||
Object? downloadLocation = null,
|
||||
Object? localLibraryLocation = null,
|
||||
Object? pipedInstance = null,
|
||||
Object? themeMode = null,
|
||||
Object? audioSource = null,
|
||||
Object? streamMusicCodec = null,
|
||||
Object? downloadMusicCodec = null,
|
||||
Object? discordPresence = null,
|
||||
Object? endlessPlayback = null,
|
||||
Object? enableConnect = null,
|
||||
}) {
|
||||
return _then(_$UserPreferencesImpl(
|
||||
audioQuality: null == audioQuality
|
||||
? _value.audioQuality
|
||||
: audioQuality // ignore: cast_nullable_to_non_nullable
|
||||
as SourceQualities,
|
||||
albumColorSync: null == albumColorSync
|
||||
? _value.albumColorSync
|
||||
: albumColorSync // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
amoledDarkTheme: null == amoledDarkTheme
|
||||
? _value.amoledDarkTheme
|
||||
: amoledDarkTheme // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
checkUpdate: null == checkUpdate
|
||||
? _value.checkUpdate
|
||||
: checkUpdate // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
normalizeAudio: null == normalizeAudio
|
||||
? _value.normalizeAudio
|
||||
: normalizeAudio // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
showSystemTrayIcon: null == showSystemTrayIcon
|
||||
? _value.showSystemTrayIcon
|
||||
: showSystemTrayIcon // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
skipNonMusic: null == skipNonMusic
|
||||
? _value.skipNonMusic
|
||||
: skipNonMusic // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
systemTitleBar: null == systemTitleBar
|
||||
? _value.systemTitleBar
|
||||
: systemTitleBar // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
closeBehavior: null == closeBehavior
|
||||
? _value.closeBehavior
|
||||
: closeBehavior // ignore: cast_nullable_to_non_nullable
|
||||
as CloseBehavior,
|
||||
accentColorScheme: null == accentColorScheme
|
||||
? _value.accentColorScheme
|
||||
: accentColorScheme // ignore: cast_nullable_to_non_nullable
|
||||
as SpotubeColor,
|
||||
layoutMode: null == layoutMode
|
||||
? _value.layoutMode
|
||||
: layoutMode // ignore: cast_nullable_to_non_nullable
|
||||
as LayoutMode,
|
||||
locale: null == locale
|
||||
? _value.locale
|
||||
: locale // ignore: cast_nullable_to_non_nullable
|
||||
as Locale,
|
||||
recommendationMarket: null == recommendationMarket
|
||||
? _value.recommendationMarket
|
||||
: recommendationMarket // ignore: cast_nullable_to_non_nullable
|
||||
as Market,
|
||||
searchMode: null == searchMode
|
||||
? _value.searchMode
|
||||
: searchMode // ignore: cast_nullable_to_non_nullable
|
||||
as SearchMode,
|
||||
downloadLocation: null == downloadLocation
|
||||
? _value.downloadLocation
|
||||
: downloadLocation // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
localLibraryLocation: null == localLibraryLocation
|
||||
? _value._localLibraryLocation
|
||||
: localLibraryLocation // ignore: cast_nullable_to_non_nullable
|
||||
as List<String>,
|
||||
pipedInstance: null == pipedInstance
|
||||
? _value.pipedInstance
|
||||
: pipedInstance // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
themeMode: null == themeMode
|
||||
? _value.themeMode
|
||||
: themeMode // ignore: cast_nullable_to_non_nullable
|
||||
as ThemeMode,
|
||||
audioSource: null == audioSource
|
||||
? _value.audioSource
|
||||
: audioSource // ignore: cast_nullable_to_non_nullable
|
||||
as AudioSource,
|
||||
streamMusicCodec: null == streamMusicCodec
|
||||
? _value.streamMusicCodec
|
||||
: streamMusicCodec // ignore: cast_nullable_to_non_nullable
|
||||
as SourceCodecs,
|
||||
downloadMusicCodec: null == downloadMusicCodec
|
||||
? _value.downloadMusicCodec
|
||||
: downloadMusicCodec // ignore: cast_nullable_to_non_nullable
|
||||
as SourceCodecs,
|
||||
discordPresence: null == discordPresence
|
||||
? _value.discordPresence
|
||||
: discordPresence // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
endlessPlayback: null == endlessPlayback
|
||||
? _value.endlessPlayback
|
||||
: endlessPlayback // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
enableConnect: null == enableConnect
|
||||
? _value.enableConnect
|
||||
: enableConnect // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$UserPreferencesImpl implements _UserPreferences {
|
||||
const _$UserPreferencesImpl(
|
||||
{this.audioQuality = SourceQualities.high,
|
||||
this.albumColorSync = true,
|
||||
this.amoledDarkTheme = false,
|
||||
this.checkUpdate = true,
|
||||
this.normalizeAudio = false,
|
||||
this.showSystemTrayIcon = false,
|
||||
this.skipNonMusic = false,
|
||||
this.systemTitleBar = false,
|
||||
this.closeBehavior = CloseBehavior.close,
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._accentColorSchemeFromJson,
|
||||
toJson: UserPreferences._accentColorSchemeToJson,
|
||||
readValue: UserPreferences._accentColorSchemeReadValue)
|
||||
this.accentColorScheme = const SpotubeColor(0xFF2196F3, name: "Blue"),
|
||||
this.layoutMode = LayoutMode.adaptive,
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._localeFromJson,
|
||||
toJson: UserPreferences._localeToJson,
|
||||
readValue: UserPreferences._localeReadValue)
|
||||
this.locale = const Locale("system", "system"),
|
||||
this.recommendationMarket = Market.US,
|
||||
this.searchMode = SearchMode.youtube,
|
||||
this.downloadLocation = "",
|
||||
final List<String> localLibraryLocation = const [],
|
||||
this.pipedInstance = "https://pipedapi.kavin.rocks",
|
||||
this.themeMode = ThemeMode.system,
|
||||
this.audioSource = AudioSource.youtube,
|
||||
this.streamMusicCodec = SourceCodecs.weba,
|
||||
this.downloadMusicCodec = SourceCodecs.m4a,
|
||||
this.discordPresence = true,
|
||||
this.endlessPlayback = true,
|
||||
this.enableConnect = false})
|
||||
: _localLibraryLocation = localLibraryLocation;
|
||||
|
||||
factory _$UserPreferencesImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$UserPreferencesImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final SourceQualities audioQuality;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool albumColorSync;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool amoledDarkTheme;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool checkUpdate;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool normalizeAudio;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool showSystemTrayIcon;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool skipNonMusic;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool systemTitleBar;
|
||||
@override
|
||||
@JsonKey()
|
||||
final CloseBehavior closeBehavior;
|
||||
@override
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._accentColorSchemeFromJson,
|
||||
toJson: UserPreferences._accentColorSchemeToJson,
|
||||
readValue: UserPreferences._accentColorSchemeReadValue)
|
||||
final SpotubeColor accentColorScheme;
|
||||
@override
|
||||
@JsonKey()
|
||||
final LayoutMode layoutMode;
|
||||
@override
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._localeFromJson,
|
||||
toJson: UserPreferences._localeToJson,
|
||||
readValue: UserPreferences._localeReadValue)
|
||||
final Locale locale;
|
||||
@override
|
||||
@JsonKey()
|
||||
final Market recommendationMarket;
|
||||
@override
|
||||
@JsonKey()
|
||||
final SearchMode searchMode;
|
||||
@override
|
||||
@JsonKey()
|
||||
final String downloadLocation;
|
||||
final List<String> _localLibraryLocation;
|
||||
@override
|
||||
@JsonKey()
|
||||
List<String> get localLibraryLocation {
|
||||
if (_localLibraryLocation is EqualUnmodifiableListView)
|
||||
return _localLibraryLocation;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_localLibraryLocation);
|
||||
}
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final String pipedInstance;
|
||||
@override
|
||||
@JsonKey()
|
||||
final ThemeMode themeMode;
|
||||
@override
|
||||
@JsonKey()
|
||||
final AudioSource audioSource;
|
||||
@override
|
||||
@JsonKey()
|
||||
final SourceCodecs streamMusicCodec;
|
||||
@override
|
||||
@JsonKey()
|
||||
final SourceCodecs downloadMusicCodec;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool discordPresence;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool endlessPlayback;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool enableConnect;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UserPreferences(audioQuality: $audioQuality, albumColorSync: $albumColorSync, amoledDarkTheme: $amoledDarkTheme, checkUpdate: $checkUpdate, normalizeAudio: $normalizeAudio, showSystemTrayIcon: $showSystemTrayIcon, skipNonMusic: $skipNonMusic, systemTitleBar: $systemTitleBar, closeBehavior: $closeBehavior, accentColorScheme: $accentColorScheme, layoutMode: $layoutMode, locale: $locale, recommendationMarket: $recommendationMarket, searchMode: $searchMode, downloadLocation: $downloadLocation, localLibraryLocation: $localLibraryLocation, pipedInstance: $pipedInstance, themeMode: $themeMode, audioSource: $audioSource, streamMusicCodec: $streamMusicCodec, downloadMusicCodec: $downloadMusicCodec, discordPresence: $discordPresence, endlessPlayback: $endlessPlayback, enableConnect: $enableConnect)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$UserPreferencesImpl &&
|
||||
(identical(other.audioQuality, audioQuality) ||
|
||||
other.audioQuality == audioQuality) &&
|
||||
(identical(other.albumColorSync, albumColorSync) ||
|
||||
other.albumColorSync == albumColorSync) &&
|
||||
(identical(other.amoledDarkTheme, amoledDarkTheme) ||
|
||||
other.amoledDarkTheme == amoledDarkTheme) &&
|
||||
(identical(other.checkUpdate, checkUpdate) ||
|
||||
other.checkUpdate == checkUpdate) &&
|
||||
(identical(other.normalizeAudio, normalizeAudio) ||
|
||||
other.normalizeAudio == normalizeAudio) &&
|
||||
(identical(other.showSystemTrayIcon, showSystemTrayIcon) ||
|
||||
other.showSystemTrayIcon == showSystemTrayIcon) &&
|
||||
(identical(other.skipNonMusic, skipNonMusic) ||
|
||||
other.skipNonMusic == skipNonMusic) &&
|
||||
(identical(other.systemTitleBar, systemTitleBar) ||
|
||||
other.systemTitleBar == systemTitleBar) &&
|
||||
(identical(other.closeBehavior, closeBehavior) ||
|
||||
other.closeBehavior == closeBehavior) &&
|
||||
(identical(other.accentColorScheme, accentColorScheme) ||
|
||||
other.accentColorScheme == accentColorScheme) &&
|
||||
(identical(other.layoutMode, layoutMode) ||
|
||||
other.layoutMode == layoutMode) &&
|
||||
(identical(other.locale, locale) || other.locale == locale) &&
|
||||
(identical(other.recommendationMarket, recommendationMarket) ||
|
||||
other.recommendationMarket == recommendationMarket) &&
|
||||
(identical(other.searchMode, searchMode) ||
|
||||
other.searchMode == searchMode) &&
|
||||
(identical(other.downloadLocation, downloadLocation) ||
|
||||
other.downloadLocation == downloadLocation) &&
|
||||
const DeepCollectionEquality()
|
||||
.equals(other._localLibraryLocation, _localLibraryLocation) &&
|
||||
(identical(other.pipedInstance, pipedInstance) ||
|
||||
other.pipedInstance == pipedInstance) &&
|
||||
(identical(other.themeMode, themeMode) ||
|
||||
other.themeMode == themeMode) &&
|
||||
(identical(other.audioSource, audioSource) ||
|
||||
other.audioSource == audioSource) &&
|
||||
(identical(other.streamMusicCodec, streamMusicCodec) ||
|
||||
other.streamMusicCodec == streamMusicCodec) &&
|
||||
(identical(other.downloadMusicCodec, downloadMusicCodec) ||
|
||||
other.downloadMusicCodec == downloadMusicCodec) &&
|
||||
(identical(other.discordPresence, discordPresence) ||
|
||||
other.discordPresence == discordPresence) &&
|
||||
(identical(other.endlessPlayback, endlessPlayback) ||
|
||||
other.endlessPlayback == endlessPlayback) &&
|
||||
(identical(other.enableConnect, enableConnect) ||
|
||||
other.enableConnect == enableConnect));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode => Object.hashAll([
|
||||
runtimeType,
|
||||
audioQuality,
|
||||
albumColorSync,
|
||||
amoledDarkTheme,
|
||||
checkUpdate,
|
||||
normalizeAudio,
|
||||
showSystemTrayIcon,
|
||||
skipNonMusic,
|
||||
systemTitleBar,
|
||||
closeBehavior,
|
||||
accentColorScheme,
|
||||
layoutMode,
|
||||
locale,
|
||||
recommendationMarket,
|
||||
searchMode,
|
||||
downloadLocation,
|
||||
const DeepCollectionEquality().hash(_localLibraryLocation),
|
||||
pipedInstance,
|
||||
themeMode,
|
||||
audioSource,
|
||||
streamMusicCodec,
|
||||
downloadMusicCodec,
|
||||
discordPresence,
|
||||
endlessPlayback,
|
||||
enableConnect
|
||||
]);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$UserPreferencesImplCopyWith<_$UserPreferencesImpl> get copyWith =>
|
||||
__$$UserPreferencesImplCopyWithImpl<_$UserPreferencesImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$UserPreferencesImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _UserPreferences implements UserPreferences {
|
||||
const factory _UserPreferences(
|
||||
{final SourceQualities audioQuality,
|
||||
final bool albumColorSync,
|
||||
final bool amoledDarkTheme,
|
||||
final bool checkUpdate,
|
||||
final bool normalizeAudio,
|
||||
final bool showSystemTrayIcon,
|
||||
final bool skipNonMusic,
|
||||
final bool systemTitleBar,
|
||||
final CloseBehavior closeBehavior,
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._accentColorSchemeFromJson,
|
||||
toJson: UserPreferences._accentColorSchemeToJson,
|
||||
readValue: UserPreferences._accentColorSchemeReadValue)
|
||||
final SpotubeColor accentColorScheme,
|
||||
final LayoutMode layoutMode,
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._localeFromJson,
|
||||
toJson: UserPreferences._localeToJson,
|
||||
readValue: UserPreferences._localeReadValue)
|
||||
final Locale locale,
|
||||
final Market recommendationMarket,
|
||||
final SearchMode searchMode,
|
||||
final String downloadLocation,
|
||||
final List<String> localLibraryLocation,
|
||||
final String pipedInstance,
|
||||
final ThemeMode themeMode,
|
||||
final AudioSource audioSource,
|
||||
final SourceCodecs streamMusicCodec,
|
||||
final SourceCodecs downloadMusicCodec,
|
||||
final bool discordPresence,
|
||||
final bool endlessPlayback,
|
||||
final bool enableConnect}) = _$UserPreferencesImpl;
|
||||
|
||||
factory _UserPreferences.fromJson(Map<String, dynamic> json) =
|
||||
_$UserPreferencesImpl.fromJson;
|
||||
|
||||
@override
|
||||
SourceQualities get audioQuality;
|
||||
@override
|
||||
bool get albumColorSync;
|
||||
@override
|
||||
bool get amoledDarkTheme;
|
||||
@override
|
||||
bool get checkUpdate;
|
||||
@override
|
||||
bool get normalizeAudio;
|
||||
@override
|
||||
bool get showSystemTrayIcon;
|
||||
@override
|
||||
bool get skipNonMusic;
|
||||
@override
|
||||
bool get systemTitleBar;
|
||||
@override
|
||||
CloseBehavior get closeBehavior;
|
||||
@override
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._accentColorSchemeFromJson,
|
||||
toJson: UserPreferences._accentColorSchemeToJson,
|
||||
readValue: UserPreferences._accentColorSchemeReadValue)
|
||||
SpotubeColor get accentColorScheme;
|
||||
@override
|
||||
LayoutMode get layoutMode;
|
||||
@override
|
||||
@JsonKey(
|
||||
fromJson: UserPreferences._localeFromJson,
|
||||
toJson: UserPreferences._localeToJson,
|
||||
readValue: UserPreferences._localeReadValue)
|
||||
Locale get locale;
|
||||
@override
|
||||
Market get recommendationMarket;
|
||||
@override
|
||||
SearchMode get searchMode;
|
||||
@override
|
||||
String get downloadLocation;
|
||||
@override
|
||||
List<String> get localLibraryLocation;
|
||||
@override
|
||||
String get pipedInstance;
|
||||
@override
|
||||
ThemeMode get themeMode;
|
||||
@override
|
||||
AudioSource get audioSource;
|
||||
@override
|
||||
SourceCodecs get streamMusicCodec;
|
||||
@override
|
||||
SourceCodecs get downloadMusicCodec;
|
||||
@override
|
||||
bool get discordPresence;
|
||||
@override
|
||||
bool get endlessPlayback;
|
||||
@override
|
||||
bool get enableConnect;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$UserPreferencesImplCopyWith<_$UserPreferencesImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
@ -1,388 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user_preferences_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$UserPreferencesImpl _$$UserPreferencesImplFromJson(Map json) =>
|
||||
_$UserPreferencesImpl(
|
||||
audioQuality:
|
||||
$enumDecodeNullable(_$SourceQualitiesEnumMap, json['audioQuality']) ??
|
||||
SourceQualities.high,
|
||||
albumColorSync: json['albumColorSync'] as bool? ?? true,
|
||||
amoledDarkTheme: json['amoledDarkTheme'] as bool? ?? false,
|
||||
checkUpdate: json['checkUpdate'] as bool? ?? true,
|
||||
normalizeAudio: json['normalizeAudio'] as bool? ?? false,
|
||||
showSystemTrayIcon: json['showSystemTrayIcon'] as bool? ?? false,
|
||||
skipNonMusic: json['skipNonMusic'] as bool? ?? false,
|
||||
systemTitleBar: json['systemTitleBar'] as bool? ?? false,
|
||||
closeBehavior:
|
||||
$enumDecodeNullable(_$CloseBehaviorEnumMap, json['closeBehavior']) ??
|
||||
CloseBehavior.close,
|
||||
accentColorScheme: UserPreferences._accentColorSchemeReadValue(
|
||||
json, 'accentColorScheme') ==
|
||||
null
|
||||
? const SpotubeColor(0xFF2196F3, name: "Blue")
|
||||
: UserPreferences._accentColorSchemeFromJson(
|
||||
UserPreferences._accentColorSchemeReadValue(
|
||||
json, 'accentColorScheme') as Map<String, dynamic>),
|
||||
layoutMode:
|
||||
$enumDecodeNullable(_$LayoutModeEnumMap, json['layoutMode']) ??
|
||||
LayoutMode.adaptive,
|
||||
locale: UserPreferences._localeReadValue(json, 'locale') == null
|
||||
? const Locale("system", "system")
|
||||
: UserPreferences._localeFromJson(
|
||||
UserPreferences._localeReadValue(json, 'locale')
|
||||
as Map<String, dynamic>),
|
||||
recommendationMarket:
|
||||
$enumDecodeNullable(_$MarketEnumMap, json['recommendationMarket']) ??
|
||||
Market.US,
|
||||
searchMode:
|
||||
$enumDecodeNullable(_$SearchModeEnumMap, json['searchMode']) ??
|
||||
SearchMode.youtube,
|
||||
downloadLocation: json['downloadLocation'] as String? ?? "",
|
||||
localLibraryLocation: (json['localLibraryLocation'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
.toList() ??
|
||||
const [],
|
||||
pipedInstance:
|
||||
json['pipedInstance'] as String? ?? "https://pipedapi.kavin.rocks",
|
||||
themeMode: $enumDecodeNullable(_$ThemeModeEnumMap, json['themeMode']) ??
|
||||
ThemeMode.system,
|
||||
audioSource:
|
||||
$enumDecodeNullable(_$AudioSourceEnumMap, json['audioSource']) ??
|
||||
AudioSource.youtube,
|
||||
streamMusicCodec: $enumDecodeNullable(
|
||||
_$SourceCodecsEnumMap, json['streamMusicCodec']) ??
|
||||
SourceCodecs.weba,
|
||||
downloadMusicCodec: $enumDecodeNullable(
|
||||
_$SourceCodecsEnumMap, json['downloadMusicCodec']) ??
|
||||
SourceCodecs.m4a,
|
||||
discordPresence: json['discordPresence'] as bool? ?? true,
|
||||
endlessPlayback: json['endlessPlayback'] as bool? ?? true,
|
||||
enableConnect: json['enableConnect'] as bool? ?? false,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$UserPreferencesImplToJson(
|
||||
_$UserPreferencesImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'audioQuality': _$SourceQualitiesEnumMap[instance.audioQuality]!,
|
||||
'albumColorSync': instance.albumColorSync,
|
||||
'amoledDarkTheme': instance.amoledDarkTheme,
|
||||
'checkUpdate': instance.checkUpdate,
|
||||
'normalizeAudio': instance.normalizeAudio,
|
||||
'showSystemTrayIcon': instance.showSystemTrayIcon,
|
||||
'skipNonMusic': instance.skipNonMusic,
|
||||
'systemTitleBar': instance.systemTitleBar,
|
||||
'closeBehavior': _$CloseBehaviorEnumMap[instance.closeBehavior]!,
|
||||
'accentColorScheme':
|
||||
UserPreferences._accentColorSchemeToJson(instance.accentColorScheme),
|
||||
'layoutMode': _$LayoutModeEnumMap[instance.layoutMode]!,
|
||||
'locale': UserPreferences._localeToJson(instance.locale),
|
||||
'recommendationMarket': _$MarketEnumMap[instance.recommendationMarket]!,
|
||||
'searchMode': _$SearchModeEnumMap[instance.searchMode]!,
|
||||
'downloadLocation': instance.downloadLocation,
|
||||
'localLibraryLocation': instance.localLibraryLocation,
|
||||
'pipedInstance': instance.pipedInstance,
|
||||
'themeMode': _$ThemeModeEnumMap[instance.themeMode]!,
|
||||
'audioSource': _$AudioSourceEnumMap[instance.audioSource]!,
|
||||
'streamMusicCodec': _$SourceCodecsEnumMap[instance.streamMusicCodec]!,
|
||||
'downloadMusicCodec': _$SourceCodecsEnumMap[instance.downloadMusicCodec]!,
|
||||
'discordPresence': instance.discordPresence,
|
||||
'endlessPlayback': instance.endlessPlayback,
|
||||
'enableConnect': instance.enableConnect,
|
||||
};
|
||||
|
||||
const _$SourceQualitiesEnumMap = {
|
||||
SourceQualities.high: 'high',
|
||||
SourceQualities.medium: 'medium',
|
||||
SourceQualities.low: 'low',
|
||||
};
|
||||
|
||||
const _$CloseBehaviorEnumMap = {
|
||||
CloseBehavior.minimizeToTray: 'minimizeToTray',
|
||||
CloseBehavior.close: 'close',
|
||||
};
|
||||
|
||||
const _$LayoutModeEnumMap = {
|
||||
LayoutMode.compact: 'compact',
|
||||
LayoutMode.extended: 'extended',
|
||||
LayoutMode.adaptive: 'adaptive',
|
||||
};
|
||||
|
||||
const _$MarketEnumMap = {
|
||||
Market.AD: 'AD',
|
||||
Market.AE: 'AE',
|
||||
Market.AF: 'AF',
|
||||
Market.AG: 'AG',
|
||||
Market.AI: 'AI',
|
||||
Market.AL: 'AL',
|
||||
Market.AM: 'AM',
|
||||
Market.AO: 'AO',
|
||||
Market.AQ: 'AQ',
|
||||
Market.AR: 'AR',
|
||||
Market.AS: 'AS',
|
||||
Market.AT: 'AT',
|
||||
Market.AU: 'AU',
|
||||
Market.AW: 'AW',
|
||||
Market.AX: 'AX',
|
||||
Market.AZ: 'AZ',
|
||||
Market.BA: 'BA',
|
||||
Market.BB: 'BB',
|
||||
Market.BD: 'BD',
|
||||
Market.BE: 'BE',
|
||||
Market.BF: 'BF',
|
||||
Market.BG: 'BG',
|
||||
Market.BH: 'BH',
|
||||
Market.BI: 'BI',
|
||||
Market.BJ: 'BJ',
|
||||
Market.BL: 'BL',
|
||||
Market.BM: 'BM',
|
||||
Market.BN: 'BN',
|
||||
Market.BO: 'BO',
|
||||
Market.BQ: 'BQ',
|
||||
Market.BR: 'BR',
|
||||
Market.BS: 'BS',
|
||||
Market.BT: 'BT',
|
||||
Market.BV: 'BV',
|
||||
Market.BW: 'BW',
|
||||
Market.BY: 'BY',
|
||||
Market.BZ: 'BZ',
|
||||
Market.CA: 'CA',
|
||||
Market.CC: 'CC',
|
||||
Market.CD: 'CD',
|
||||
Market.CF: 'CF',
|
||||
Market.CG: 'CG',
|
||||
Market.CH: 'CH',
|
||||
Market.CI: 'CI',
|
||||
Market.CK: 'CK',
|
||||
Market.CL: 'CL',
|
||||
Market.CM: 'CM',
|
||||
Market.CN: 'CN',
|
||||
Market.CO: 'CO',
|
||||
Market.CR: 'CR',
|
||||
Market.CU: 'CU',
|
||||
Market.CV: 'CV',
|
||||
Market.CW: 'CW',
|
||||
Market.CX: 'CX',
|
||||
Market.CY: 'CY',
|
||||
Market.CZ: 'CZ',
|
||||
Market.DE: 'DE',
|
||||
Market.DJ: 'DJ',
|
||||
Market.DK: 'DK',
|
||||
Market.DM: 'DM',
|
||||
Market.DO: 'DO',
|
||||
Market.DZ: 'DZ',
|
||||
Market.EC: 'EC',
|
||||
Market.EE: 'EE',
|
||||
Market.EG: 'EG',
|
||||
Market.EH: 'EH',
|
||||
Market.ER: 'ER',
|
||||
Market.ES: 'ES',
|
||||
Market.ET: 'ET',
|
||||
Market.FI: 'FI',
|
||||
Market.FJ: 'FJ',
|
||||
Market.FK: 'FK',
|
||||
Market.FM: 'FM',
|
||||
Market.FO: 'FO',
|
||||
Market.FR: 'FR',
|
||||
Market.GA: 'GA',
|
||||
Market.GB: 'GB',
|
||||
Market.GD: 'GD',
|
||||
Market.GE: 'GE',
|
||||
Market.GF: 'GF',
|
||||
Market.GG: 'GG',
|
||||
Market.GH: 'GH',
|
||||
Market.GI: 'GI',
|
||||
Market.GL: 'GL',
|
||||
Market.GM: 'GM',
|
||||
Market.GN: 'GN',
|
||||
Market.GP: 'GP',
|
||||
Market.GQ: 'GQ',
|
||||
Market.GR: 'GR',
|
||||
Market.GS: 'GS',
|
||||
Market.GT: 'GT',
|
||||
Market.GU: 'GU',
|
||||
Market.GW: 'GW',
|
||||
Market.GY: 'GY',
|
||||
Market.HK: 'HK',
|
||||
Market.HM: 'HM',
|
||||
Market.HN: 'HN',
|
||||
Market.HR: 'HR',
|
||||
Market.HT: 'HT',
|
||||
Market.HU: 'HU',
|
||||
Market.ID: 'ID',
|
||||
Market.IE: 'IE',
|
||||
Market.IL: 'IL',
|
||||
Market.IM: 'IM',
|
||||
Market.IN: 'IN',
|
||||
Market.IO: 'IO',
|
||||
Market.IQ: 'IQ',
|
||||
Market.IR: 'IR',
|
||||
Market.IS: 'IS',
|
||||
Market.IT: 'IT',
|
||||
Market.JE: 'JE',
|
||||
Market.JM: 'JM',
|
||||
Market.JO: 'JO',
|
||||
Market.JP: 'JP',
|
||||
Market.KE: 'KE',
|
||||
Market.KG: 'KG',
|
||||
Market.KH: 'KH',
|
||||
Market.KI: 'KI',
|
||||
Market.KM: 'KM',
|
||||
Market.KN: 'KN',
|
||||
Market.KP: 'KP',
|
||||
Market.KR: 'KR',
|
||||
Market.KW: 'KW',
|
||||
Market.KY: 'KY',
|
||||
Market.KZ: 'KZ',
|
||||
Market.LA: 'LA',
|
||||
Market.LB: 'LB',
|
||||
Market.LC: 'LC',
|
||||
Market.LI: 'LI',
|
||||
Market.LK: 'LK',
|
||||
Market.LR: 'LR',
|
||||
Market.LS: 'LS',
|
||||
Market.LT: 'LT',
|
||||
Market.LU: 'LU',
|
||||
Market.LV: 'LV',
|
||||
Market.LY: 'LY',
|
||||
Market.MA: 'MA',
|
||||
Market.MC: 'MC',
|
||||
Market.MD: 'MD',
|
||||
Market.ME: 'ME',
|
||||
Market.MF: 'MF',
|
||||
Market.MG: 'MG',
|
||||
Market.MH: 'MH',
|
||||
Market.MK: 'MK',
|
||||
Market.ML: 'ML',
|
||||
Market.MM: 'MM',
|
||||
Market.MN: 'MN',
|
||||
Market.MO: 'MO',
|
||||
Market.MP: 'MP',
|
||||
Market.MQ: 'MQ',
|
||||
Market.MR: 'MR',
|
||||
Market.MS: 'MS',
|
||||
Market.MT: 'MT',
|
||||
Market.MU: 'MU',
|
||||
Market.MV: 'MV',
|
||||
Market.MW: 'MW',
|
||||
Market.MX: 'MX',
|
||||
Market.MY: 'MY',
|
||||
Market.MZ: 'MZ',
|
||||
Market.NA: 'NA',
|
||||
Market.NC: 'NC',
|
||||
Market.NE: 'NE',
|
||||
Market.NF: 'NF',
|
||||
Market.NG: 'NG',
|
||||
Market.NI: 'NI',
|
||||
Market.NL: 'NL',
|
||||
Market.NO: 'NO',
|
||||
Market.NP: 'NP',
|
||||
Market.NR: 'NR',
|
||||
Market.NU: 'NU',
|
||||
Market.NZ: 'NZ',
|
||||
Market.OM: 'OM',
|
||||
Market.PA: 'PA',
|
||||
Market.PE: 'PE',
|
||||
Market.PF: 'PF',
|
||||
Market.PG: 'PG',
|
||||
Market.PH: 'PH',
|
||||
Market.PK: 'PK',
|
||||
Market.PL: 'PL',
|
||||
Market.PM: 'PM',
|
||||
Market.PN: 'PN',
|
||||
Market.PR: 'PR',
|
||||
Market.PS: 'PS',
|
||||
Market.PT: 'PT',
|
||||
Market.PW: 'PW',
|
||||
Market.PY: 'PY',
|
||||
Market.QA: 'QA',
|
||||
Market.RE: 'RE',
|
||||
Market.RO: 'RO',
|
||||
Market.RS: 'RS',
|
||||
Market.RU: 'RU',
|
||||
Market.RW: 'RW',
|
||||
Market.SA: 'SA',
|
||||
Market.SB: 'SB',
|
||||
Market.SC: 'SC',
|
||||
Market.SD: 'SD',
|
||||
Market.SE: 'SE',
|
||||
Market.SG: 'SG',
|
||||
Market.SH: 'SH',
|
||||
Market.SI: 'SI',
|
||||
Market.SJ: 'SJ',
|
||||
Market.SK: 'SK',
|
||||
Market.SL: 'SL',
|
||||
Market.SM: 'SM',
|
||||
Market.SN: 'SN',
|
||||
Market.SO: 'SO',
|
||||
Market.SR: 'SR',
|
||||
Market.SS: 'SS',
|
||||
Market.ST: 'ST',
|
||||
Market.SV: 'SV',
|
||||
Market.SX: 'SX',
|
||||
Market.SY: 'SY',
|
||||
Market.SZ: 'SZ',
|
||||
Market.TC: 'TC',
|
||||
Market.TD: 'TD',
|
||||
Market.TF: 'TF',
|
||||
Market.TG: 'TG',
|
||||
Market.TH: 'TH',
|
||||
Market.TJ: 'TJ',
|
||||
Market.TK: 'TK',
|
||||
Market.TL: 'TL',
|
||||
Market.TM: 'TM',
|
||||
Market.TN: 'TN',
|
||||
Market.TO: 'TO',
|
||||
Market.TR: 'TR',
|
||||
Market.TT: 'TT',
|
||||
Market.TV: 'TV',
|
||||
Market.TW: 'TW',
|
||||
Market.TZ: 'TZ',
|
||||
Market.UA: 'UA',
|
||||
Market.UG: 'UG',
|
||||
Market.UM: 'UM',
|
||||
Market.US: 'US',
|
||||
Market.UY: 'UY',
|
||||
Market.UZ: 'UZ',
|
||||
Market.VA: 'VA',
|
||||
Market.VC: 'VC',
|
||||
Market.VE: 'VE',
|
||||
Market.VG: 'VG',
|
||||
Market.VI: 'VI',
|
||||
Market.VN: 'VN',
|
||||
Market.VU: 'VU',
|
||||
Market.WF: 'WF',
|
||||
Market.WS: 'WS',
|
||||
Market.XK: 'XK',
|
||||
Market.YE: 'YE',
|
||||
Market.YT: 'YT',
|
||||
Market.ZA: 'ZA',
|
||||
Market.ZM: 'ZM',
|
||||
Market.ZW: 'ZW',
|
||||
};
|
||||
|
||||
const _$SearchModeEnumMap = {
|
||||
SearchMode.youtube: 'youtube',
|
||||
SearchMode.youtubeMusic: 'youtubeMusic',
|
||||
};
|
||||
|
||||
const _$ThemeModeEnumMap = {
|
||||
ThemeMode.system: 'system',
|
||||
ThemeMode.light: 'light',
|
||||
ThemeMode.dark: 'dark',
|
||||
};
|
||||
|
||||
const _$AudioSourceEnumMap = {
|
||||
AudioSource.youtube: 'youtube',
|
||||
AudioSource.piped: 'piped',
|
||||
AudioSource.jiosaavn: 'jiosaavn',
|
||||
};
|
||||
|
||||
const _$SourceCodecsEnumMap = {
|
||||
SourceCodecs.m4a: 'm4a',
|
||||
SourceCodecs.weba: 'weba',
|
||||
};
|
@ -1,5 +1,6 @@
|
||||
import 'package:piped_client/piped_client.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
|
||||
import 'package:youtube_explode_dart/youtube_explode_dart.dart';
|
||||
|
||||
class YoutubeVideoInfo {
|
||||
|
@ -5,8 +5,9 @@ import 'package:collection/collection.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
|
||||
import 'package:spotube/services/sourced_track/enums.dart';
|
||||
import 'package:spotube/services/sourced_track/exceptions.dart';
|
||||
import 'package:spotube/services/sourced_track/models/source_info.dart';
|
||||
|
@ -2,9 +2,10 @@ import 'package:collection/collection.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:piped_client/piped_client.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
import 'package:spotube/models/database/database.dart';
|
||||
import 'package:spotube/models/source_match.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_provider.dart';
|
||||
import 'package:spotube/provider/user_preferences/user_preferences_state.dart';
|
||||
|
||||
import 'package:spotube/services/sourced_track/enums.dart';
|
||||
import 'package:spotube/services/sourced_track/exceptions.dart';
|
||||
import 'package:spotube/services/sourced_track/models/source_info.dart';
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <local_notifier/local_notifier_plugin.h>
|
||||
#include <media_kit_libs_linux/media_kit_libs_linux_plugin.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||
#include <system_theme/system_theme_plugin.h>
|
||||
#include <system_tray/system_tray_plugin.h>
|
||||
#include <tray_manager/tray_manager_plugin.h>
|
||||
@ -41,6 +42,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
|
||||
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
|
||||
g_autoptr(FlPluginRegistrar) sqlite3_flutter_libs_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "Sqlite3FlutterLibsPlugin");
|
||||
sqlite3_flutter_libs_plugin_register_with_registrar(sqlite3_flutter_libs_registrar);
|
||||
g_autoptr(FlPluginRegistrar) system_theme_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "SystemThemePlugin");
|
||||
system_theme_plugin_register_with_registrar(system_theme_registrar);
|
||||
|
@ -10,6 +10,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
||||
local_notifier
|
||||
media_kit_libs_linux
|
||||
screen_retriever
|
||||
sqlite3_flutter_libs
|
||||
system_theme
|
||||
system_tray
|
||||
tray_manager
|
||||
|
@ -20,6 +20,7 @@ import path_provider_foundation
|
||||
import screen_retriever
|
||||
import shared_preferences_foundation
|
||||
import sqflite
|
||||
import sqlite3_flutter_libs
|
||||
import system_theme
|
||||
import system_tray
|
||||
import tray_manager
|
||||
@ -42,6 +43,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||
Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin"))
|
||||
SystemThemePlugin.register(with: registry.registrar(forPlugin: "SystemThemePlugin"))
|
||||
SystemTrayPlugin.register(with: registry.registrar(forPlugin: "SystemTrayPlugin"))
|
||||
TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin"))
|
||||
|
@ -39,6 +39,21 @@ PODS:
|
||||
- sqflite (0.0.3):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- sqlite3 (3.46.0):
|
||||
- sqlite3/common (= 3.46.0)
|
||||
- sqlite3/common (3.46.0)
|
||||
- sqlite3/fts5 (3.46.0):
|
||||
- sqlite3/common
|
||||
- sqlite3/perf-threadsafe (3.46.0):
|
||||
- sqlite3/common
|
||||
- sqlite3/rtree (3.46.0):
|
||||
- sqlite3/common
|
||||
- sqlite3_flutter_libs (0.0.1):
|
||||
- FlutterMacOS
|
||||
- sqlite3 (~> 3.46.0)
|
||||
- sqlite3/fts5
|
||||
- sqlite3/perf-threadsafe
|
||||
- sqlite3/rtree
|
||||
- system_theme (0.0.1):
|
||||
- FlutterMacOS
|
||||
- system_tray (0.0.1):
|
||||
@ -69,6 +84,7 @@ DEPENDENCIES:
|
||||
- screen_retriever (from `Flutter/ephemeral/.symlinks/plugins/screen_retriever/macos`)
|
||||
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||
- sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`)
|
||||
- sqlite3_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos`)
|
||||
- system_theme (from `Flutter/ephemeral/.symlinks/plugins/system_theme/macos`)
|
||||
- system_tray (from `Flutter/ephemeral/.symlinks/plugins/system_tray/macos`)
|
||||
- tray_manager (from `Flutter/ephemeral/.symlinks/plugins/tray_manager/macos`)
|
||||
@ -78,6 +94,7 @@ DEPENDENCIES:
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
- OrderedSet
|
||||
- sqlite3
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
app_links:
|
||||
@ -116,6 +133,8 @@ EXTERNAL SOURCES:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin
|
||||
sqflite:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/sqflite/darwin
|
||||
sqlite3_flutter_libs:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos
|
||||
system_theme:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/system_theme/macos
|
||||
system_tray:
|
||||
@ -147,6 +166,8 @@ SPEC CHECKSUMS:
|
||||
screen_retriever: 59634572a57080243dd1bf715e55b6c54f241a38
|
||||
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
|
||||
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
|
||||
sqlite3: 154b084339ede06960a5b3c8160066adc9176b7d
|
||||
sqlite3_flutter_libs: 1be4459672f8168ded2d8667599b8e3ca5e72b83
|
||||
system_theme: c7b9f6659a5caa26c9bc2284da096781e9a6fcbc
|
||||
system_tray: e53c972838c69589ff2e77d6d3abfd71332f9e5d
|
||||
tray_manager: 9064e219c56d75c476e46b9a21182087930baf90
|
||||
|
48
pubspec.lock
48
pubspec.lock
@ -289,6 +289,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
checked_yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -507,6 +515,22 @@ packages:
|
||||
url: "https://github.com/thielepaul/flutter-draggable-scrollbar.git"
|
||||
source: git
|
||||
version: "0.1.0"
|
||||
drift:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: drift
|
||||
sha256: "6acedc562ffeed308049f78fb1906abad3d65714580b6745441ee6d50ec564cd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.18.0"
|
||||
drift_dev:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: drift_dev
|
||||
sha256: d9b020736ea85fff1568699ce18b89fabb3f0f042e8a7a05e84a3ec20d39acde
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.18.0"
|
||||
duration:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -1997,6 +2021,30 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.5.4"
|
||||
sqlite3:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: sqlite3
|
||||
sha256: b384f598b813b347c5a7e5ffad82cbaff1bec3d1561af267041e66f6f0899295
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.3"
|
||||
sqlite3_flutter_libs:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: sqlite3_flutter_libs
|
||||
sha256: "9f89a7e7dc36eac2035808427eba1c3fbd79e59c3a22093d8dace6d36b1fe89e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.23"
|
||||
sqlparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sqlparser
|
||||
sha256: ade9a67fd70d0369329ed3373208de7ebd8662470e8c396fc8d0d60f9acdfc9f
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.36.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -121,6 +121,9 @@ dependencies:
|
||||
tray_manager: ^0.2.2
|
||||
http: ^1.2.1
|
||||
riverpod: ^2.5.1
|
||||
drift: ^2.18.0
|
||||
sqlite3_flutter_libs: ^0.5.23
|
||||
sqlite3: ^2.4.3
|
||||
|
||||
dev_dependencies:
|
||||
build_runner: ^2.4.11
|
||||
@ -143,6 +146,7 @@ dev_dependencies:
|
||||
pub_api_client: ^2.4.0
|
||||
xml: ^6.5.0
|
||||
io: ^1.0.4
|
||||
drift_dev: ^2.18.0
|
||||
|
||||
dependency_overrides:
|
||||
uuid: ^4.4.0
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <media_kit_libs_windows_audio/media_kit_libs_windows_audio_plugin_c_api.h>
|
||||
#include <permission_handler_windows/permission_handler_windows_plugin.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <sqlite3_flutter_libs/sqlite3_flutter_libs_plugin.h>
|
||||
#include <system_theme/system_theme_plugin.h>
|
||||
#include <system_tray/system_tray_plugin.h>
|
||||
#include <tray_manager/tray_manager_plugin.h>
|
||||
@ -40,6 +41,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
|
||||
ScreenRetrieverPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ScreenRetrieverPlugin"));
|
||||
Sqlite3FlutterLibsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("Sqlite3FlutterLibsPlugin"));
|
||||
SystemThemePluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("SystemThemePlugin"));
|
||||
SystemTrayPluginRegisterWithRegistrar(
|
||||
|
@ -12,6 +12,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
||||
media_kit_libs_windows_audio
|
||||
permission_handler_windows
|
||||
screen_retriever
|
||||
sqlite3_flutter_libs
|
||||
system_theme
|
||||
system_tray
|
||||
tray_manager
|
||||
|
Loading…
Reference in New Issue
Block a user