Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add toggle to disable fast scroller #562

Merged
merged 2 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions lib/components/LayoutSettingsScreen/FastScrollSelector.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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 FastScrollSelector extends StatelessWidget {
const FastScrollSelector({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return ValueListenableBuilder<Box<FinampSettings>>(
valueListenable: FinampSettingsHelper.finampSettingsListener,
builder: (_, box, __) {
return SwitchListTile.adaptive(
title: Text(AppLocalizations.of(context)!.showFastScroller),
value: FinampSettingsHelper.finampSettings.showFastScroller,
onChanged: (value) => FinampSettingsHelper.setShowFastScroller(value),
Comment on lines +16 to +19
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A subtitle with a short description of what the "fast scroller" is would be nice here :)

);
},
);
}
}
6 changes: 4 additions & 2 deletions lib/components/MusicScreen/music_screen_tab_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ class _MusicScreenTabViewState extends State<MusicScreenTabView>
}
},
),
widget.sortBy == SortBy.sortName
box.get("FinampSettings")!.showFastScroller &&
widget.sortBy == SortBy.sortName
? AlphabetList(
callback: scrollToLetter, sortOrder: lastSortOrder)
: const SizedBox.shrink(),
Expand Down Expand Up @@ -562,7 +563,8 @@ class _MusicScreenTabViewState extends State<MusicScreenTabView>
.contentGridViewCrossAxisCountPortrait,
),
),
widget.sortBy == SortBy.sortName
box.get("FinampSettings")!.showFastScroller &&
widget.sortBy == SortBy.sortName
? AlphabetList(
callback: scrollToLetter, sortOrder: lastSortOrder)
: const SizedBox.shrink(),
Expand Down
4 changes: 3 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@
"@disableGesture": {},
"disableGestureSubtitle": "Whether to disables gestures.",
"@disableGestureSubtitle": {},
"showFastScroller": "Show fast scroller",
"@showFastScroller": {},
"theme": "Theme",
"@theme": {},
"system": "System",
Expand Down Expand Up @@ -521,4 +523,4 @@
},
"noMusicLibrariesBody": "Finamp could not find any music libraries. Please ensure that your Jellyfin server contains at least one library with the content type set to \"Music\".",
"refresh": "REFRESH"
}
}
4 changes: 4 additions & 0 deletions lib/models/finamp_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const _sleepTimerSeconds = 1800; // 30 Minutes
const _showCoverAsPlayerBackground = true;
const _hideSongArtistsIfSameAsAlbumArtists = true;
const _disableGesture = false;
const _showFastScroller = true;
const _bufferDurationSeconds = 50;
const _tabOrder = TabContentType.values;

Expand Down Expand Up @@ -180,6 +181,9 @@ class FinampSettings {
@HiveField(24, defaultValue: false)
bool hasCompletedBlurhashImageMigrationIdFix;

@HiveField(25, defaultValue: _showFastScroller)
bool showFastScroller = _showFastScroller;

static Future<FinampSettings> create() async {
final internalSongDir = await getInternalSongDir();
final downloadLocation = DownloadLocation.create(
Expand Down
10 changes: 7 additions & 3 deletions lib/models/finamp_models.g.dart

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

4 changes: 3 additions & 1 deletion lib/screens/layout_settings_screen.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:finamp/components/LayoutSettingsScreen/FastScrollSelector.dart';
import 'package:finamp/components/LayoutSettingsScreen/disable_gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand Down Expand Up @@ -30,6 +31,7 @@ class LayoutSettingsScreen extends StatelessWidget {
const ShowCoverAsPlayerBackgroundSelector(),
const HideSongArtistsIfSameAsAlbumArtistsSelector(),
const DisableGestureSelector(),
const FastScrollSelector(),
const ThemeSelector(),
const Divider(),
ListTile(
Expand All @@ -42,4 +44,4 @@ class LayoutSettingsScreen extends StatelessWidget {
),
);
}
}
}
9 changes: 8 additions & 1 deletion lib/services/finamp_settings_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ class FinampSettingsHelper {
.put("FinampSettings", finampSettingsTemp);
}

static void setShowFastScroller(bool showFastScroller) {
FinampSettings finampSettingsTemp = finampSettings;
finampSettingsTemp.showFastScroller = showFastScroller;
Hive.box<FinampSettings>("FinampSettings")
.put("FinampSettings", finampSettingsTemp);
}

static void setBufferDuration(Duration bufferDuration) {
FinampSettings finampSettingsTemp = finampSettings;
finampSettingsTemp.bufferDuration = bufferDuration;
Expand Down Expand Up @@ -224,4 +231,4 @@ class FinampSettingsHelper {
),
);
}
}
}
2 changes: 1 addition & 1 deletion lib/services/jellyfin_api.chopper.dart

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

16 changes: 8 additions & 8 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,10 @@ packages:
dependency: "direct main"
description:
name: intl
sha256: a3715e3bc90294e971cb7dc063fbf3cd9ee0ebf8604ffeafabd9e6f16abbdbe6
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
url: "https://pub.dev"
source: hosted
version: "0.18.0"
version: "0.18.1"
io:
dependency: transitive
description:
Expand Down Expand Up @@ -619,18 +619,18 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.15"
version: "0.12.16"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.2.0"
version: "0.5.0"
meta:
dependency: transitive
description:
Expand Down Expand Up @@ -952,10 +952,10 @@ packages:
dependency: transitive
description:
name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
sqflite:
dependency: transitive
description:
Expand Down
Loading