Skip to content

Commit

Permalink
Merge branch 'redesign' of https://github.com/jmshrv/finamp into rede…
Browse files Browse the repository at this point in the history
…sign-player-album-shadow

# Conflicts:
#	lib/services/keep_screen_on_helper.dart
  • Loading branch information
Komodo5197 committed Sep 12, 2024
2 parents 49f8b10 + defab64 commit 357a480
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 17 deletions.
18 changes: 14 additions & 4 deletions lib/components/PlayerScreen/progress_slider.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:io';

import 'package:audio_service/audio_service.dart';
import 'package:finamp/components/print_duration.dart';
import 'package:finamp/services/progress_state_stream.dart';
Expand Down Expand Up @@ -131,20 +133,28 @@ class _ProgressSliderDuration extends StatelessWidget {

@override
Widget build(BuildContext context) {
final showRemaining = Platform.isIOS || Platform.isMacOS;
final currentPosition = Duration(seconds: (position.inMilliseconds / 1000).round());
final roundedDuration = Duration(seconds: ((itemDuration?.inMilliseconds ?? 0) / 1000).round());
return Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
printDuration(
Duration(microseconds: position.inMicroseconds),
),
printDuration(currentPosition),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
height: 0.5, // reduce line height
),
),
Text(
printDuration(itemDuration),
printDuration(
// display remaining time if on iOS or macOS
showRemaining ?
(roundedDuration - currentPosition)
: roundedDuration
,
isRemaining: showRemaining,
),
style: Theme.of(context).textTheme.bodySmall?.copyWith(
height: 0.5, // reduce line height
),
Expand Down
13 changes: 10 additions & 3 deletions lib/components/print_duration.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Flutter doesn't have a nice way of formatting durations for some reason so I stole this code from StackOverflow
String printDuration(Duration? duration) {
String printDuration(Duration? duration, {bool isRemaining = false}) {
if (duration == null) {
return "00:00";
}
Expand All @@ -8,10 +8,17 @@ String printDuration(Duration? duration) {
String twoDigitMinutes = twoDigits(duration.inMinutes.remainder(60));
String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60));

String durationString;
if (duration.inHours >= 1) {
String twoDigitHours = twoDigits(duration.inHours);
return "$twoDigitHours:$twoDigitMinutes:$twoDigitSeconds";
durationString = "$twoDigitHours:$twoDigitMinutes:$twoDigitSeconds";
}

return "$twoDigitMinutes:$twoDigitSeconds";
durationString = "$twoDigitMinutes:$twoDigitSeconds";

if (isRemaining) {
durationString = "-$durationString";
}

return durationString;
}
7 changes: 4 additions & 3 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1638,10 +1638,11 @@
"@keepScreenOn": {
"description": "Option to keep the screen on while using the app"
},
"keepScreenOnSubtitle": "Keep the screen on while playing music or only while showing lyrics",
"keepScreenOnSubtitle": "When to keep the screen on",
"keepScreenOnDisabled": "Disabled",
"whilePlaying": "While Playing Music",
"whileLyrics": "While Showing Lyrics",
"keepScreenOnAlwaysOn": "Always On",
"keepScreenOnWhilePlaying": "While Playing Music",
"keepScreenOnWhileLyrics": "While Showing Lyrics",
"keepScreenOnWhilePluggedIn": "Keep Screen On only while plugged in",
"keepScreenOnWhilePluggedInSubtitle": "Ignore the Keep Screen On setting if device is unplugged"
}
12 changes: 9 additions & 3 deletions lib/models/finamp_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2193,8 +2193,10 @@ enum KeepScreenOnOption {
@HiveField(0)
disabled,
@HiveField(1)
whilePlaying,
alwaysOn,
@HiveField(2)
whilePlaying,
@HiveField(3)
whileLyrics;

/// Human-readable version of this enum. I've written longer descriptions on
Expand All @@ -2211,6 +2213,8 @@ enum KeepScreenOnOption {
switch (keepScreenOnOption) {
case KeepScreenOnOption.disabled:
return "Disabled";
case KeepScreenOnOption.alwaysOn:
return "Always On";
case KeepScreenOnOption.whilePlaying:
return "While Playing Music";
case KeepScreenOnOption.whileLyrics:
Expand All @@ -2223,10 +2227,12 @@ enum KeepScreenOnOption {
switch (keepScreenOnOption) {
case KeepScreenOnOption.disabled:
return AppLocalizations.of(context)!.keepScreenOnDisabled;
case KeepScreenOnOption.alwaysOn:
return AppLocalizations.of(context)!.keepScreenOnAlwaysOn;
case KeepScreenOnOption.whilePlaying:
return AppLocalizations.of(context)!.whilePlaying;
return AppLocalizations.of(context)!.keepScreenOnWhilePlaying;
case KeepScreenOnOption.whileLyrics:
return AppLocalizations.of(context)!.whileLyrics;
return AppLocalizations.of(context)!.keepScreenOnWhileLyrics;
}
}
}
13 changes: 9 additions & 4 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: 4 additions & 0 deletions lib/services/keep_screen_on_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class KeepScreenOnHelper {
case KeepScreenOnOption.disabled:
if (_keepingScreenOn) _turnOff();
break;
case KeepScreenOnOption.alwaysOn:
_turnOn();
break;
case KeepScreenOnOption.whilePlaying:
if (_isPlaying) {
_turnOn();
Expand All @@ -72,6 +75,7 @@ class KeepScreenOnHelper {
break;
}
}

_keepScreenOnLogger.fine(
"keepingScreenOn: $_keepingScreenOn | mainSetting: ${FinampSettingsHelper.finampSettings.keepScreenOnOption} | whilePluggedInSetting: ${FinampSettingsHelper.finampSettings.keepScreenOnWhilePluggedIn} | isPlaying: $_isPlaying | lyricsShowing: $_isLyricsShowing | isPluggedIn: $_isPluggedIn");
}
Expand Down

0 comments on commit 357a480

Please sign in to comment.