diff --git a/lib/providers/user_preferences.dart b/lib/providers/user_preferences.dart index 6fe6a85..1c6b5a3 100644 --- a/lib/providers/user_preferences.dart +++ b/lib/providers/user_preferences.dart @@ -9,7 +9,6 @@ import 'package:rhythm_box/services/color.dart'; import 'package:rhythm_box/services/database/database.dart'; import 'package:rhythm_box/services/sourced_track/enums.dart'; import 'package:spotify/spotify.dart'; -import 'package:window_manager/window_manager.dart'; import 'package:flutter/material.dart'; import 'package:path/path.dart'; import 'package:path_provider/path_provider.dart'; @@ -49,14 +48,6 @@ class UserPreferencesProvider extends GetxController { .listen((event) async { state.value = event; - if (PlatformInfo.isDesktop) { - await windowManager.setTitleBarStyle( - state.value.systemTitleBar - ? TitleBarStyle.normal - : TitleBarStyle.hidden, - ); - } - await audioPlayer.setAudioNormalization(state.value.normalizeAudio); }); } @@ -171,10 +162,6 @@ class UserPreferencesProvider extends GetxController { setData(PreferencesTableCompanion(discordPresence: Value(discordPresence))); } - void setAmoledDarkTheme(bool isAmoled) { - setData(PreferencesTableCompanion(amoledDarkTheme: Value(isAmoled))); - } - void setNormalizeAudio(bool normalize) { setData(PreferencesTableCompanion(normalizeAudio: Value(normalize))); audioPlayer.setAudioNormalization(normalize); @@ -184,7 +171,7 @@ class UserPreferencesProvider extends GetxController { setData(PreferencesTableCompanion(endlessPlayback: Value(endless))); } - void setEnableConnect(bool enable) { - setData(PreferencesTableCompanion(enableConnect: Value(enable))); + void setPlayerWakelock(bool wakelock) { + setData(PreferencesTableCompanion(playerWakelock: Value(wakelock))); } } diff --git a/lib/screens/player/view.dart b/lib/screens/player/view.dart index ecf621a..0a610de 100644 --- a/lib/screens/player/view.dart +++ b/lib/screens/player/view.dart @@ -10,6 +10,7 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:media_kit/media_kit.dart'; import 'package:rhythm_box/providers/audio_player.dart'; import 'package:rhythm_box/providers/auth.dart'; +import 'package:rhythm_box/providers/user_preferences.dart'; import 'package:rhythm_box/screens/player/queue.dart'; import 'package:rhythm_box/screens/player/siblings.dart'; import 'package:rhythm_box/services/artist.dart'; @@ -20,6 +21,7 @@ import 'package:rhythm_box/services/audio_services/image.dart'; import 'package:rhythm_box/widgets/lyrics/synced_lyrics.dart'; import 'package:rhythm_box/widgets/tracks/heart_button.dart'; import 'package:rhythm_box/widgets/tracks/querying_track_info.dart'; +import 'package:wakelock_plus/wakelock_plus.dart'; class PlayerScreen extends StatefulWidget { const PlayerScreen({super.key}); @@ -33,6 +35,8 @@ class _PlayerScreenState extends State { late final QueryingTrackInfoProvider _query = Get.find(); late final AuthenticationProvider _auth = Get.find(); + late final UserPreferencesProvider _preferences = Get.find(); + String? get _albumArt => (_playback.state.value.activeTrack?.album?.images).asUrlString( index: @@ -56,6 +60,20 @@ class _PlayerScreenState extends State { static const double maxAlbumSize = 360; + @override + void activate() { + super.activate(); + if (_preferences.state.value.playerWakelock) { + WakelockPlus.enable(); + } + } + + @override + void deactivate() { + super.deactivate(); + WakelockPlus.disable(); + } + @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index 9a5dc75..65918d3 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -123,6 +123,17 @@ class _SettingsScreenState extends State { onChanged: _preferences.setNormalizeAudio, ), ), + Obx( + () => SwitchListTile( + contentPadding: const EdgeInsets.symmetric(horizontal: 24), + secondary: const Icon(Icons.screen_lock_portrait), + title: const Text('Player Wakelock'), + subtitle: const Text( + 'Keep your screen doesn\'t lock in player screen'), + value: _preferences.state.value.playerWakelock, + onChanged: _preferences.setPlayerWakelock, + ), + ), const Divider(thickness: 0.3, height: 1), ListTile( contentPadding: const EdgeInsets.symmetric(horizontal: 24), diff --git a/lib/services/database/database.g.dart b/lib/services/database/database.g.dart index 6f76ca8..aafaa71 100644 --- a/lib/services/database/database.g.dart +++ b/lib/services/database/database.g.dart @@ -317,16 +317,6 @@ class $PreferencesTableTable extends PreferencesTable defaultConstraints: GeneratedColumn.constraintIsAlways( 'CHECK ("album_color_sync" IN (0, 1))'), defaultValue: const Constant(true)); - static const VerificationMeta _amoledDarkThemeMeta = - const VerificationMeta('amoledDarkTheme'); - @override - late final GeneratedColumn amoledDarkTheme = GeneratedColumn( - 'amoled_dark_theme', aliasedName, false, - type: DriftSqlType.bool, - requiredDuringInsert: false, - defaultConstraints: GeneratedColumn.constraintIsAlways( - 'CHECK ("amoled_dark_theme" IN (0, 1))'), - defaultValue: const Constant(false)); static const VerificationMeta _checkUpdateMeta = const VerificationMeta('checkUpdate'); @override @@ -524,22 +514,21 @@ class $PreferencesTableTable extends PreferencesTable defaultConstraints: GeneratedColumn.constraintIsAlways( 'CHECK ("endless_playback" IN (0, 1))'), defaultValue: const Constant(true)); - static const VerificationMeta _enableConnectMeta = - const VerificationMeta('enableConnect'); + static const VerificationMeta _playerWakelockMeta = + const VerificationMeta('playerWakelock'); @override - late final GeneratedColumn enableConnect = GeneratedColumn( - 'enable_connect', aliasedName, false, + late final GeneratedColumn playerWakelock = GeneratedColumn( + 'player_wakelock', aliasedName, false, type: DriftSqlType.bool, requiredDuringInsert: false, defaultConstraints: GeneratedColumn.constraintIsAlways( - 'CHECK ("enable_connect" IN (0, 1))'), - defaultValue: const Constant(false)); + 'CHECK ("player_wakelock" IN (0, 1))'), + defaultValue: const Constant(true)); @override List get $columns => [ id, audioQuality, albumColorSync, - amoledDarkTheme, checkUpdate, normalizeAudio, showSystemTrayIcon, @@ -560,7 +549,7 @@ class $PreferencesTableTable extends PreferencesTable downloadMusicCodec, discordPresence, endlessPlayback, - enableConnect + playerWakelock ]; @override String get aliasedName => _alias ?? actualTableName; @@ -583,12 +572,6 @@ class $PreferencesTableTable extends PreferencesTable albumColorSync.isAcceptableOrUnknown( data['album_color_sync']!, _albumColorSyncMeta)); } - if (data.containsKey('amoled_dark_theme')) { - context.handle( - _amoledDarkThemeMeta, - amoledDarkTheme.isAcceptableOrUnknown( - data['amoled_dark_theme']!, _amoledDarkThemeMeta)); - } if (data.containsKey('check_update')) { context.handle( _checkUpdateMeta, @@ -655,11 +638,11 @@ class $PreferencesTableTable extends PreferencesTable endlessPlayback.isAcceptableOrUnknown( data['endless_playback']!, _endlessPlaybackMeta)); } - if (data.containsKey('enable_connect')) { + if (data.containsKey('player_wakelock')) { context.handle( - _enableConnectMeta, - enableConnect.isAcceptableOrUnknown( - data['enable_connect']!, _enableConnectMeta)); + _playerWakelockMeta, + playerWakelock.isAcceptableOrUnknown( + data['player_wakelock']!, _playerWakelockMeta)); } return context; } @@ -677,8 +660,6 @@ class $PreferencesTableTable extends PreferencesTable DriftSqlType.string, data['${effectivePrefix}audio_quality'])!), albumColorSync: attachedDatabase.typeMapping .read(DriftSqlType.bool, data['${effectivePrefix}album_color_sync'])!, - amoledDarkTheme: attachedDatabase.typeMapping.read( - DriftSqlType.bool, data['${effectivePrefix}amoled_dark_theme'])!, checkUpdate: attachedDatabase.typeMapping .read(DriftSqlType.bool, data['${effectivePrefix}check_update'])!, normalizeAudio: attachedDatabase.typeMapping @@ -731,8 +712,8 @@ class $PreferencesTableTable extends PreferencesTable .read(DriftSqlType.bool, data['${effectivePrefix}discord_presence'])!, endlessPlayback: attachedDatabase.typeMapping .read(DriftSqlType.bool, data['${effectivePrefix}endless_playback'])!, - enableConnect: attachedDatabase.typeMapping - .read(DriftSqlType.bool, data['${effectivePrefix}enable_connect'])!, + playerWakelock: attachedDatabase.typeMapping + .read(DriftSqlType.bool, data['${effectivePrefix}player_wakelock'])!, ); } @@ -776,7 +757,6 @@ class PreferencesTableData extends DataClass final int id; final SourceQualities audioQuality; final bool albumColorSync; - final bool amoledDarkTheme; final bool checkUpdate; final bool normalizeAudio; final bool showSystemTrayIcon; @@ -797,12 +777,11 @@ class PreferencesTableData extends DataClass final SourceCodecs downloadMusicCodec; final bool discordPresence; final bool endlessPlayback; - final bool enableConnect; + final bool playerWakelock; const PreferencesTableData( {required this.id, required this.audioQuality, required this.albumColorSync, - required this.amoledDarkTheme, required this.checkUpdate, required this.normalizeAudio, required this.showSystemTrayIcon, @@ -823,7 +802,7 @@ class PreferencesTableData extends DataClass required this.downloadMusicCodec, required this.discordPresence, required this.endlessPlayback, - required this.enableConnect}); + required this.playerWakelock}); @override Map toColumns(bool nullToAbsent) { final map = {}; @@ -833,7 +812,6 @@ class PreferencesTableData extends DataClass $PreferencesTableTable.$converteraudioQuality.toSql(audioQuality)); } map['album_color_sync'] = Variable(albumColorSync); - map['amoled_dark_theme'] = Variable(amoledDarkTheme); map['check_update'] = Variable(checkUpdate); map['normalize_audio'] = Variable(normalizeAudio); map['show_system_tray_icon'] = Variable(showSystemTrayIcon); @@ -891,7 +869,7 @@ class PreferencesTableData extends DataClass } map['discord_presence'] = Variable(discordPresence); map['endless_playback'] = Variable(endlessPlayback); - map['enable_connect'] = Variable(enableConnect); + map['player_wakelock'] = Variable(playerWakelock); return map; } @@ -900,7 +878,6 @@ class PreferencesTableData extends DataClass id: Value(id), audioQuality: Value(audioQuality), albumColorSync: Value(albumColorSync), - amoledDarkTheme: Value(amoledDarkTheme), checkUpdate: Value(checkUpdate), normalizeAudio: Value(normalizeAudio), showSystemTrayIcon: Value(showSystemTrayIcon), @@ -921,7 +898,7 @@ class PreferencesTableData extends DataClass downloadMusicCodec: Value(downloadMusicCodec), discordPresence: Value(discordPresence), endlessPlayback: Value(endlessPlayback), - enableConnect: Value(enableConnect), + playerWakelock: Value(playerWakelock), ); } @@ -933,7 +910,6 @@ class PreferencesTableData extends DataClass audioQuality: $PreferencesTableTable.$converteraudioQuality .fromJson(serializer.fromJson(json['audioQuality'])), albumColorSync: serializer.fromJson(json['albumColorSync']), - amoledDarkTheme: serializer.fromJson(json['amoledDarkTheme']), checkUpdate: serializer.fromJson(json['checkUpdate']), normalizeAudio: serializer.fromJson(json['normalizeAudio']), showSystemTrayIcon: serializer.fromJson(json['showSystemTrayIcon']), @@ -964,7 +940,7 @@ class PreferencesTableData extends DataClass .fromJson(serializer.fromJson(json['downloadMusicCodec'])), discordPresence: serializer.fromJson(json['discordPresence']), endlessPlayback: serializer.fromJson(json['endlessPlayback']), - enableConnect: serializer.fromJson(json['enableConnect']), + playerWakelock: serializer.fromJson(json['playerWakelock']), ); } @override @@ -975,7 +951,6 @@ class PreferencesTableData extends DataClass 'audioQuality': serializer.toJson( $PreferencesTableTable.$converteraudioQuality.toJson(audioQuality)), 'albumColorSync': serializer.toJson(albumColorSync), - 'amoledDarkTheme': serializer.toJson(amoledDarkTheme), 'checkUpdate': serializer.toJson(checkUpdate), 'normalizeAudio': serializer.toJson(normalizeAudio), 'showSystemTrayIcon': serializer.toJson(showSystemTrayIcon), @@ -1007,7 +982,7 @@ class PreferencesTableData extends DataClass .toJson(downloadMusicCodec)), 'discordPresence': serializer.toJson(discordPresence), 'endlessPlayback': serializer.toJson(endlessPlayback), - 'enableConnect': serializer.toJson(enableConnect), + 'playerWakelock': serializer.toJson(playerWakelock), }; } @@ -1015,7 +990,6 @@ class PreferencesTableData extends DataClass {int? id, SourceQualities? audioQuality, bool? albumColorSync, - bool? amoledDarkTheme, bool? checkUpdate, bool? normalizeAudio, bool? showSystemTrayIcon, @@ -1036,12 +1010,11 @@ class PreferencesTableData extends DataClass SourceCodecs? downloadMusicCodec, bool? discordPresence, bool? endlessPlayback, - bool? enableConnect}) => + bool? playerWakelock}) => PreferencesTableData( id: id ?? this.id, audioQuality: audioQuality ?? this.audioQuality, albumColorSync: albumColorSync ?? this.albumColorSync, - amoledDarkTheme: amoledDarkTheme ?? this.amoledDarkTheme, checkUpdate: checkUpdate ?? this.checkUpdate, normalizeAudio: normalizeAudio ?? this.normalizeAudio, showSystemTrayIcon: showSystemTrayIcon ?? this.showSystemTrayIcon, @@ -1062,7 +1035,7 @@ class PreferencesTableData extends DataClass downloadMusicCodec: downloadMusicCodec ?? this.downloadMusicCodec, discordPresence: discordPresence ?? this.discordPresence, endlessPlayback: endlessPlayback ?? this.endlessPlayback, - enableConnect: enableConnect ?? this.enableConnect, + playerWakelock: playerWakelock ?? this.playerWakelock, ); PreferencesTableData copyWithCompanion(PreferencesTableCompanion data) { return PreferencesTableData( @@ -1073,9 +1046,6 @@ class PreferencesTableData extends DataClass albumColorSync: data.albumColorSync.present ? data.albumColorSync.value : this.albumColorSync, - amoledDarkTheme: data.amoledDarkTheme.present - ? data.amoledDarkTheme.value - : this.amoledDarkTheme, checkUpdate: data.checkUpdate.present ? data.checkUpdate.value : this.checkUpdate, normalizeAudio: data.normalizeAudio.present @@ -1126,9 +1096,9 @@ class PreferencesTableData extends DataClass endlessPlayback: data.endlessPlayback.present ? data.endlessPlayback.value : this.endlessPlayback, - enableConnect: data.enableConnect.present - ? data.enableConnect.value - : this.enableConnect, + playerWakelock: data.playerWakelock.present + ? data.playerWakelock.value + : this.playerWakelock, ); } @@ -1138,7 +1108,6 @@ class PreferencesTableData extends DataClass ..write('id: $id, ') ..write('audioQuality: $audioQuality, ') ..write('albumColorSync: $albumColorSync, ') - ..write('amoledDarkTheme: $amoledDarkTheme, ') ..write('checkUpdate: $checkUpdate, ') ..write('normalizeAudio: $normalizeAudio, ') ..write('showSystemTrayIcon: $showSystemTrayIcon, ') @@ -1159,7 +1128,7 @@ class PreferencesTableData extends DataClass ..write('downloadMusicCodec: $downloadMusicCodec, ') ..write('discordPresence: $discordPresence, ') ..write('endlessPlayback: $endlessPlayback, ') - ..write('enableConnect: $enableConnect') + ..write('playerWakelock: $playerWakelock') ..write(')')) .toString(); } @@ -1169,7 +1138,6 @@ class PreferencesTableData extends DataClass id, audioQuality, albumColorSync, - amoledDarkTheme, checkUpdate, normalizeAudio, showSystemTrayIcon, @@ -1190,7 +1158,7 @@ class PreferencesTableData extends DataClass downloadMusicCodec, discordPresence, endlessPlayback, - enableConnect + playerWakelock ]); @override bool operator ==(Object other) => @@ -1199,7 +1167,6 @@ class PreferencesTableData extends DataClass other.id == this.id && other.audioQuality == this.audioQuality && other.albumColorSync == this.albumColorSync && - other.amoledDarkTheme == this.amoledDarkTheme && other.checkUpdate == this.checkUpdate && other.normalizeAudio == this.normalizeAudio && other.showSystemTrayIcon == this.showSystemTrayIcon && @@ -1220,14 +1187,13 @@ class PreferencesTableData extends DataClass other.downloadMusicCodec == this.downloadMusicCodec && other.discordPresence == this.discordPresence && other.endlessPlayback == this.endlessPlayback && - other.enableConnect == this.enableConnect); + other.playerWakelock == this.playerWakelock); } class PreferencesTableCompanion extends UpdateCompanion { final Value id; final Value audioQuality; final Value albumColorSync; - final Value amoledDarkTheme; final Value checkUpdate; final Value normalizeAudio; final Value showSystemTrayIcon; @@ -1248,12 +1214,11 @@ class PreferencesTableCompanion extends UpdateCompanion { final Value downloadMusicCodec; final Value discordPresence; final Value endlessPlayback; - final Value enableConnect; + final Value playerWakelock; const PreferencesTableCompanion({ this.id = const Value.absent(), this.audioQuality = const Value.absent(), this.albumColorSync = const Value.absent(), - this.amoledDarkTheme = const Value.absent(), this.checkUpdate = const Value.absent(), this.normalizeAudio = const Value.absent(), this.showSystemTrayIcon = const Value.absent(), @@ -1274,13 +1239,12 @@ class PreferencesTableCompanion extends UpdateCompanion { this.downloadMusicCodec = const Value.absent(), this.discordPresence = const Value.absent(), this.endlessPlayback = const Value.absent(), - this.enableConnect = const Value.absent(), + this.playerWakelock = const Value.absent(), }); PreferencesTableCompanion.insert({ this.id = const Value.absent(), this.audioQuality = const Value.absent(), this.albumColorSync = const Value.absent(), - this.amoledDarkTheme = const Value.absent(), this.checkUpdate = const Value.absent(), this.normalizeAudio = const Value.absent(), this.showSystemTrayIcon = const Value.absent(), @@ -1301,13 +1265,12 @@ class PreferencesTableCompanion extends UpdateCompanion { this.downloadMusicCodec = const Value.absent(), this.discordPresence = const Value.absent(), this.endlessPlayback = const Value.absent(), - this.enableConnect = const Value.absent(), + this.playerWakelock = const Value.absent(), }); static Insertable custom({ Expression? id, Expression? audioQuality, Expression? albumColorSync, - Expression? amoledDarkTheme, Expression? checkUpdate, Expression? normalizeAudio, Expression? showSystemTrayIcon, @@ -1328,13 +1291,12 @@ class PreferencesTableCompanion extends UpdateCompanion { Expression? downloadMusicCodec, Expression? discordPresence, Expression? endlessPlayback, - Expression? enableConnect, + Expression? playerWakelock, }) { return RawValuesInsertable({ if (id != null) 'id': id, if (audioQuality != null) 'audio_quality': audioQuality, if (albumColorSync != null) 'album_color_sync': albumColorSync, - if (amoledDarkTheme != null) 'amoled_dark_theme': amoledDarkTheme, if (checkUpdate != null) 'check_update': checkUpdate, if (normalizeAudio != null) 'normalize_audio': normalizeAudio, if (showSystemTrayIcon != null) @@ -1358,7 +1320,7 @@ class PreferencesTableCompanion extends UpdateCompanion { 'download_music_codec': downloadMusicCodec, if (discordPresence != null) 'discord_presence': discordPresence, if (endlessPlayback != null) 'endless_playback': endlessPlayback, - if (enableConnect != null) 'enable_connect': enableConnect, + if (playerWakelock != null) 'player_wakelock': playerWakelock, }); } @@ -1366,7 +1328,6 @@ class PreferencesTableCompanion extends UpdateCompanion { {Value? id, Value? audioQuality, Value? albumColorSync, - Value? amoledDarkTheme, Value? checkUpdate, Value? normalizeAudio, Value? showSystemTrayIcon, @@ -1387,12 +1348,11 @@ class PreferencesTableCompanion extends UpdateCompanion { Value? downloadMusicCodec, Value? discordPresence, Value? endlessPlayback, - Value? enableConnect}) { + Value? playerWakelock}) { return PreferencesTableCompanion( id: id ?? this.id, audioQuality: audioQuality ?? this.audioQuality, albumColorSync: albumColorSync ?? this.albumColorSync, - amoledDarkTheme: amoledDarkTheme ?? this.amoledDarkTheme, checkUpdate: checkUpdate ?? this.checkUpdate, normalizeAudio: normalizeAudio ?? this.normalizeAudio, showSystemTrayIcon: showSystemTrayIcon ?? this.showSystemTrayIcon, @@ -1413,7 +1373,7 @@ class PreferencesTableCompanion extends UpdateCompanion { downloadMusicCodec: downloadMusicCodec ?? this.downloadMusicCodec, discordPresence: discordPresence ?? this.discordPresence, endlessPlayback: endlessPlayback ?? this.endlessPlayback, - enableConnect: enableConnect ?? this.enableConnect, + playerWakelock: playerWakelock ?? this.playerWakelock, ); } @@ -1431,9 +1391,6 @@ class PreferencesTableCompanion extends UpdateCompanion { if (albumColorSync.present) { map['album_color_sync'] = Variable(albumColorSync.value); } - if (amoledDarkTheme.present) { - map['amoled_dark_theme'] = Variable(amoledDarkTheme.value); - } if (checkUpdate.present) { map['check_update'] = Variable(checkUpdate.value); } @@ -1511,8 +1468,8 @@ class PreferencesTableCompanion extends UpdateCompanion { if (endlessPlayback.present) { map['endless_playback'] = Variable(endlessPlayback.value); } - if (enableConnect.present) { - map['enable_connect'] = Variable(enableConnect.value); + if (playerWakelock.present) { + map['player_wakelock'] = Variable(playerWakelock.value); } return map; } @@ -1523,7 +1480,6 @@ class PreferencesTableCompanion extends UpdateCompanion { ..write('id: $id, ') ..write('audioQuality: $audioQuality, ') ..write('albumColorSync: $albumColorSync, ') - ..write('amoledDarkTheme: $amoledDarkTheme, ') ..write('checkUpdate: $checkUpdate, ') ..write('normalizeAudio: $normalizeAudio, ') ..write('showSystemTrayIcon: $showSystemTrayIcon, ') @@ -1544,7 +1500,7 @@ class PreferencesTableCompanion extends UpdateCompanion { ..write('downloadMusicCodec: $downloadMusicCodec, ') ..write('discordPresence: $discordPresence, ') ..write('endlessPlayback: $endlessPlayback, ') - ..write('enableConnect: $enableConnect') + ..write('playerWakelock: $playerWakelock') ..write(')')) .toString(); } @@ -3980,7 +3936,6 @@ typedef $$PreferencesTableTableCreateCompanionBuilder Value id, Value audioQuality, Value albumColorSync, - Value amoledDarkTheme, Value checkUpdate, Value normalizeAudio, Value showSystemTrayIcon, @@ -4001,14 +3956,13 @@ typedef $$PreferencesTableTableCreateCompanionBuilder Value downloadMusicCodec, Value discordPresence, Value endlessPlayback, - Value enableConnect, + Value playerWakelock, }); typedef $$PreferencesTableTableUpdateCompanionBuilder = PreferencesTableCompanion Function({ Value id, Value audioQuality, Value albumColorSync, - Value amoledDarkTheme, Value checkUpdate, Value normalizeAudio, Value showSystemTrayIcon, @@ -4029,7 +3983,7 @@ typedef $$PreferencesTableTableUpdateCompanionBuilder Value downloadMusicCodec, Value discordPresence, Value endlessPlayback, - Value enableConnect, + Value playerWakelock, }); class $$PreferencesTableTableTableManager extends RootTableManager< @@ -4053,7 +4007,6 @@ class $$PreferencesTableTableTableManager extends RootTableManager< Value id = const Value.absent(), Value audioQuality = const Value.absent(), Value albumColorSync = const Value.absent(), - Value amoledDarkTheme = const Value.absent(), Value checkUpdate = const Value.absent(), Value normalizeAudio = const Value.absent(), Value showSystemTrayIcon = const Value.absent(), @@ -4074,13 +4027,12 @@ class $$PreferencesTableTableTableManager extends RootTableManager< Value downloadMusicCodec = const Value.absent(), Value discordPresence = const Value.absent(), Value endlessPlayback = const Value.absent(), - Value enableConnect = const Value.absent(), + Value playerWakelock = const Value.absent(), }) => PreferencesTableCompanion( id: id, audioQuality: audioQuality, albumColorSync: albumColorSync, - amoledDarkTheme: amoledDarkTheme, checkUpdate: checkUpdate, normalizeAudio: normalizeAudio, showSystemTrayIcon: showSystemTrayIcon, @@ -4101,13 +4053,12 @@ class $$PreferencesTableTableTableManager extends RootTableManager< downloadMusicCodec: downloadMusicCodec, discordPresence: discordPresence, endlessPlayback: endlessPlayback, - enableConnect: enableConnect, + playerWakelock: playerWakelock, ), createCompanionCallback: ({ Value id = const Value.absent(), Value audioQuality = const Value.absent(), Value albumColorSync = const Value.absent(), - Value amoledDarkTheme = const Value.absent(), Value checkUpdate = const Value.absent(), Value normalizeAudio = const Value.absent(), Value showSystemTrayIcon = const Value.absent(), @@ -4128,13 +4079,12 @@ class $$PreferencesTableTableTableManager extends RootTableManager< Value downloadMusicCodec = const Value.absent(), Value discordPresence = const Value.absent(), Value endlessPlayback = const Value.absent(), - Value enableConnect = const Value.absent(), + Value playerWakelock = const Value.absent(), }) => PreferencesTableCompanion.insert( id: id, audioQuality: audioQuality, albumColorSync: albumColorSync, - amoledDarkTheme: amoledDarkTheme, checkUpdate: checkUpdate, normalizeAudio: normalizeAudio, showSystemTrayIcon: showSystemTrayIcon, @@ -4155,7 +4105,7 @@ class $$PreferencesTableTableTableManager extends RootTableManager< downloadMusicCodec: downloadMusicCodec, discordPresence: discordPresence, endlessPlayback: endlessPlayback, - enableConnect: enableConnect, + playerWakelock: playerWakelock, ), )); } @@ -4180,11 +4130,6 @@ class $$PreferencesTableTableFilterComposer builder: (column, joinBuilders) => ColumnFilters(column, joinBuilders: joinBuilders)); - ColumnFilters get amoledDarkTheme => $state.composableBuilder( - column: $state.table.amoledDarkTheme, - builder: (column, joinBuilders) => - ColumnFilters(column, joinBuilders: joinBuilders)); - ColumnFilters get checkUpdate => $state.composableBuilder( column: $state.table.checkUpdate, builder: (column, joinBuilders) => @@ -4307,8 +4252,8 @@ class $$PreferencesTableTableFilterComposer builder: (column, joinBuilders) => ColumnFilters(column, joinBuilders: joinBuilders)); - ColumnFilters get enableConnect => $state.composableBuilder( - column: $state.table.enableConnect, + ColumnFilters get playerWakelock => $state.composableBuilder( + column: $state.table.playerWakelock, builder: (column, joinBuilders) => ColumnFilters(column, joinBuilders: joinBuilders)); } @@ -4331,11 +4276,6 @@ class $$PreferencesTableTableOrderingComposer builder: (column, joinBuilders) => ColumnOrderings(column, joinBuilders: joinBuilders)); - ColumnOrderings get amoledDarkTheme => $state.composableBuilder( - column: $state.table.amoledDarkTheme, - builder: (column, joinBuilders) => - ColumnOrderings(column, joinBuilders: joinBuilders)); - ColumnOrderings get checkUpdate => $state.composableBuilder( column: $state.table.checkUpdate, builder: (column, joinBuilders) => @@ -4436,8 +4376,8 @@ class $$PreferencesTableTableOrderingComposer builder: (column, joinBuilders) => ColumnOrderings(column, joinBuilders: joinBuilders)); - ColumnOrderings get enableConnect => $state.composableBuilder( - column: $state.table.enableConnect, + ColumnOrderings get playerWakelock => $state.composableBuilder( + column: $state.table.playerWakelock, builder: (column, joinBuilders) => ColumnOrderings(column, joinBuilders: joinBuilders)); } diff --git a/lib/services/database/tables/preferences.dart b/lib/services/database/tables/preferences.dart index 6c5a6df..6aa59ad 100755 --- a/lib/services/database/tables/preferences.dart +++ b/lib/services/database/tables/preferences.dart @@ -45,8 +45,6 @@ class PreferencesTable extends Table { .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))(); @@ -88,8 +86,8 @@ class PreferencesTable extends Table { boolean().withDefault(const Constant(true))(); BoolColumn get endlessPlayback => boolean().withDefault(const Constant(true))(); - BoolColumn get enableConnect => - boolean().withDefault(const Constant(false))(); + BoolColumn get playerWakelock => + boolean().withDefault(const Constant(true))(); // Default values as PreferencesTableData static PreferencesTableData defaults() { @@ -97,7 +95,6 @@ class PreferencesTable extends Table { id: 0, audioQuality: SourceQualities.high, albumColorSync: true, - amoledDarkTheme: false, checkUpdate: true, normalizeAudio: false, showSystemTrayIcon: false, @@ -118,7 +115,7 @@ class PreferencesTable extends Table { downloadMusicCodec: SourceCodecs.m4a, discordPresence: true, endlessPlayback: true, - enableConnect: false, + playerWakelock: true, ); } } diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 302ade2..ccd2c91 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -19,6 +19,7 @@ import shared_preferences_foundation import sqflite import sqlite3_flutter_libs import url_launcher_macos +import wakelock_plus import window_manager func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { @@ -36,5 +37,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) Sqlite3FlutterLibsPlugin.register(with: registry.registrar(forPlugin: "Sqlite3FlutterLibsPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) + WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) } diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index 25f35b8..4dd6574 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -259,7 +259,7 @@ attributes = { BuildIndependentTargetsInParallel = YES; LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1540; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 331C80D4294CF70F00263BE5 = { diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index df2d904..dca9cc4 100644 --- a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@