Skip to content

Commit

Permalink
chore: separate lrc font size for miniplayer & fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Apr 27, 2024
1 parent 2010c46 commit d7afa9a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions lib/controller/settings_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ class SettingsController with SettingsFileWriter {
}.obs;

double fontScaleLRC = 1.0;
double fontScaleLRCFull = 1.0;

bool canAskForBatteryOptimizations = true;
bool didSupportNamida = false;
Expand Down Expand Up @@ -487,6 +488,7 @@ class SettingsController with SettingsFileWriter {
mediaItemsTrackSortingReverse.value = {for (final e in mediaItemsTrackSortingReverseInStorage.entries) MediaType.values.getEnum(e.key) ?? MediaType.track: e.value};

fontScaleLRC = json['fontScaleLRC'] ?? fontScaleLRC;
fontScaleLRCFull = json['fontScaleLRCFull'] ?? fontScaleLRC; // fallback to normal

canAskForBatteryOptimizations = json['canAskForBatteryOptimizations'] ?? canAskForBatteryOptimizations;
} catch (e) {
Expand Down Expand Up @@ -648,6 +650,7 @@ class SettingsController with SettingsFileWriter {
'mediaItemsTrackSortingReverse': mediaItemsTrackSortingReverse.map((key, value) => MapEntry(key.convertToString, value)),

'fontScaleLRC': fontScaleLRC,
'fontScaleLRCFull': fontScaleLRCFull,

'canAskForBatteryOptimizations': canAskForBatteryOptimizations,
};
Expand Down Expand Up @@ -802,6 +805,7 @@ class SettingsController with SettingsFileWriter {
DateRange? ytMostPlayedCustomDateRange,
bool? ytMostPlayedCustomisStartOfDay,
double? fontScaleLRC,
double? fontScaleLRCFull,
bool? didSupportNamida,
bool? canAskForBatteryOptimizations,
}) {
Expand Down Expand Up @@ -1032,6 +1036,7 @@ class SettingsController with SettingsFileWriter {
if (ytMostPlayedCustomisStartOfDay != null) this.ytMostPlayedCustomisStartOfDay.value = ytMostPlayedCustomisStartOfDay;

if (fontScaleLRC != null) this.fontScaleLRC = fontScaleLRC;
if (fontScaleLRCFull != null) this.fontScaleLRCFull = fontScaleLRCFull;

if (didSupportNamida != null) this.didSupportNamida = didSupportNamida;
if (canAskForBatteryOptimizations != null) this.canAskForBatteryOptimizations = canAskForBatteryOptimizations;
Expand Down
6 changes: 3 additions & 3 deletions lib/packages/lyrics_lrc_parsed_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ class LyricsLRCParsedViewState extends State<LyricsLRCParsedView> {
var lyrics = <LrcLine>[];
final timestampsMap = <Duration, (int, LrcLine)>{};

double _previousFontMultiplier = settings.fontScaleLRC;
double _fontMultiplier = settings.fontScaleLRC;
late double _previousFontMultiplier = widget.isFullScreenView ? settings.fontScaleLRCFull : settings.fontScaleLRC;
late double _fontMultiplier = widget.isFullScreenView ? settings.fontScaleLRCFull : settings.fontScaleLRC;

@override
void dispose() {
Expand Down Expand Up @@ -424,7 +424,7 @@ class LyricsLRCParsedViewState extends State<LyricsLRCParsedView> {
child: ScaleDetector(
onScaleStart: (details) => _previousFontMultiplier = _fontMultiplier,
onScaleUpdate: (details) => setState(() => _fontMultiplier = (details.scale * _previousFontMultiplier).clamp(0.5, 2.0)),
onScaleEnd: (details) => settings.save(fontScaleLRC: _fontMultiplier),
onScaleEnd: (details) => widget.isFullScreenView ? settings.save(fontScaleLRCFull: _fontMultiplier) : settings.save(fontScaleLRC: _fontMultiplier),
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: namida
description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter
publish_to: "none"
version: 2.0.8-beta+240427224
version: 2.0.9-beta+240427234

environment:
sdk: ">=3.1.4 <4.0.0"
Expand Down

0 comments on commit d7afa9a

Please sign in to comment.