Skip to content

Commit

Permalink
added setting for optionally showing album covers on album screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaphasilor committed Oct 27, 2024
1 parent 69c533b commit dec8495
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 9 deletions.
22 changes: 16 additions & 6 deletions lib/components/AlbumScreen/track_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -659,22 +659,30 @@ class TrackListItemTile extends StatelessWidget {
contentPadding:
const EdgeInsets.symmetric(vertical: 0.0, horizontal: 0.0),
// tileColor: Theme.of(context).colorScheme.primary.withOpacity(0.5),
leading: showIndex
? Padding(
padding: const EdgeInsets.only(left: 8.0),
leading: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (showIndex)
Padding(
padding:
FinampSettingsHelper.finampSettings.showCoversOnAlbumScreen
? const EdgeInsets.only(left: 2.0, right: 6.0)
: const EdgeInsets.only(left: 6.0, right: 0.0),
child: SizedBox.fromSize(
size: const Size(20.0, defaultTileHeight),
size: const Size(22.0, defaultTileHeight),
child: Center(
child: Text(
actualIndex.toString(),
textAlign: TextAlign.end,
style: TextStyle(
color: Theme.of(context).textTheme.bodyMedium?.color,
fontSize: 16,
fontWeight: FontWeight.w500,
),
))),
)
: Stack(
),
if (FinampSettingsHelper.finampSettings.showCoversOnAlbumScreen)
Stack(
children: [
AlbumImage(
item: baseItem,
Expand Down Expand Up @@ -704,6 +712,8 @@ class TrackListItemTile extends StatelessWidget {
),
],
),
],
),
title: ConstrainedBox(
constraints: const BoxConstraints(
maxHeight: defaultTileHeight,
Expand Down
12 changes: 12 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1768,5 +1768,17 @@
"showFeatureChipsToggleSubtitle": "Show advanced track info like codec, bit rate, and more on the player screen.",
"@showFeatureChipsToggleSubtitle": {
"description": "Subtitle for the setting that controls if the feature chips showing advanced track info are shown on the player screen"
},
"albumScreen": "Album Screen",
"@albumScreen": {
"description": "Name for the view/screen that shows albums"
},
"showCoversOnAlbumScreenTitle": "Show Album Covers For Tracks",
"@showCoversOnAlbumScreenTitle": {
"description": "Title for the setting that controls if album covers are shown for each track separately on the album screen"
},
"showCoversOnAlbumScreenSubtitle": "Show album covers for each track separately on the album screen.",
"@showCoversOnAlbumScreenSubtitle": {
"description": "Subtitle for the setting that controls if album covers are shown for each track separately on the album screen"
}
}
3 changes: 3 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:audio_session/audio_session.dart';
import 'package:background_downloader/background_downloader.dart';
import 'package:finamp/color_schemes.g.dart';
import 'package:finamp/gen/assets.gen.dart';
import 'package:finamp/screens/album_settings_screen.dart';
import 'package:finamp/screens/downloads_settings_screen.dart';
import 'package:finamp/screens/interaction_settings_screen.dart';
import 'package:finamp/screens/login_screen.dart';
Expand Down Expand Up @@ -512,6 +513,8 @@ class _FinampState extends ConsumerState<Finamp> with WindowListener {
const LyricsSettingsScreen(),
LanguageSelectionScreen.routeName: (context) =>
const LanguageSelectionScreen(),
AlbumSettingsScreen.routeName: (context) =>
const AlbumSettingsScreen(),
},
initialRoute: SplashScreen.routeName,
navigatorObservers: [
Expand Down
7 changes: 6 additions & 1 deletion lib/models/finamp_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const _featureChipsConfigurationDefault =
FinampFeatureChipType.size,
FinampFeatureChipType.normalizationGain,
]);
const _showCoversOnAlbumScreenDefault = false;

@HiveType(typeId: 28)
class FinampSettings {
Expand Down Expand Up @@ -209,7 +210,8 @@ class FinampSettings {
_showSeekControlsOnMediaNotificationDefault,
this.keepScreenOnOption = _keepScreenOnOption,
this.keepScreenOnWhilePluggedIn = _keepScreenOnWhilePluggedIn,
this.featureChipsConfiguration = _featureChipsConfigurationDefault});
this.featureChipsConfiguration = _featureChipsConfigurationDefault,
this.showCoversOnAlbumScreen = _showCoversOnAlbumScreenDefault});

@HiveField(0, defaultValue: _isOfflineDefault)
bool isOffline;
Expand Down Expand Up @@ -449,6 +451,9 @@ class FinampSettings {
@HiveField(74, defaultValue: _featureChipsConfigurationDefault)
FinampFeatureChipsConfiguration featureChipsConfiguration;

@HiveField(75, defaultValue: _showCoversOnAlbumScreenDefault)
bool showCoversOnAlbumScreen;

static Future<FinampSettings> create() async {
final downloadLocation = await DownloadLocation.create(
name: "Internal Storage",
Expand Down
7 changes: 5 additions & 2 deletions lib/models/finamp_models.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions lib/screens/album_settings_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:hive/hive.dart';

import '../models/finamp_models.dart';
import '../services/finamp_settings_helper.dart';

class AlbumSettingsScreen extends StatelessWidget {
const AlbumSettingsScreen({super.key});

static const routeName = "/settings/layout/album";

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(AppLocalizations.of(context)!.albumScreen),
),
body: ListView(
children: const [
ShowCoversOnAlbumScreenToggle(),
],
),
);
}
}

class ShowCoversOnAlbumScreenToggle extends StatelessWidget {
const ShowCoversOnAlbumScreenToggle({super.key});

@override
Widget build(BuildContext context) {
return ValueListenableBuilder<Box<FinampSettings>>(
valueListenable: FinampSettingsHelper.finampSettingsListener,
builder: (context, box, child) {
bool? showCoversOnAlbumScreen =
box.get("FinampSettings")?.showCoversOnAlbumScreen;

return SwitchListTile.adaptive(
title:
Text(AppLocalizations.of(context)!.showCoversOnAlbumScreenTitle),
subtitle: Text(
AppLocalizations.of(context)!.showCoversOnAlbumScreenSubtitle),
value: showCoversOnAlbumScreen ?? false,
onChanged: showCoversOnAlbumScreen == null
? null
: (value) {
FinampSettings finampSettingsTemp =
box.get("FinampSettings")!;
finampSettingsTemp.showCoversOnAlbumScreen = value;
box.put("FinampSettings", finampSettingsTemp);
},
);
},
);
}
}
7 changes: 7 additions & 0 deletions lib/screens/layout_settings_screen.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:finamp/screens/album_settings_screen.dart';
import 'package:finamp/screens/customization_settings_screen.dart';
import 'package:finamp/components/LayoutSettingsScreen/show_artists_top_songs.dart';
import 'package:finamp/screens/player_settings_screen.dart';
Expand Down Expand Up @@ -53,6 +54,12 @@ class LayoutSettingsScreen extends StatelessWidget {
onTap: () => Navigator.of(context)
.pushNamed(LyricsSettingsScreen.routeName),
),
ListTile(
leading: const Icon(TablerIcons.disc),
title: Text(AppLocalizations.of(context)!.albumScreen),
onTap: () => Navigator.of(context)
.pushNamed(AlbumSettingsScreen.routeName),
),
ListTile(
leading: const Icon(Icons.tab),
title: Text(AppLocalizations.of(context)!.tabs),
Expand Down

0 comments on commit dec8495

Please sign in to comment.