Skip to content

Commit

Permalink
Removed rectangular playing bar setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Komodo5197 committed Feb 15, 2024
1 parent 59d9ccd commit 659fafa
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 122 deletions.
65 changes: 24 additions & 41 deletions lib/components/now_playing_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,19 @@ import 'album_image.dart';

class NowPlayingBar extends ConsumerWidget {
const NowPlayingBar({
Key? key,
}) : super(key: key);
super.key,
});

BoxDecoration? getShadow(BuildContext context) => floatNowPlaying
? BoxDecoration(
color: Colors.transparent,
BoxDecoration? getShadow(BuildContext context) => BoxDecoration(
borderRadius: const BorderRadius.all(Radius.circular(20.0)),
boxShadow: [
BoxShadow(
blurRadius: 12.0,
spreadRadius: 13.0,
color: Theme.of(context).brightness == Brightness.light
? lightColorScheme.background.withOpacity(0.25)
: darkColorScheme.background.withOpacity(0.85))
])
: null;

bool get floatNowPlaying =>
FinampSettingsHelper.finampSettings.floatNowPlaying;

BorderRadiusGeometry get borderRadius =>
floatNowPlaying ? BorderRadius.circular(12.0) : BorderRadius.zero;
BoxShadow(
blurRadius: 10.0,
spreadRadius: 15.0,
color: Theme.of(context).brightness == Brightness.light
? lightColorScheme.background.withOpacity(0.25)
: darkColorScheme.background.withOpacity(0.85))
]);

Widget buildLoadingQueueBar(BuildContext context, Function()? retryCallback) {
const albumImageSize = 70.0;
Expand All @@ -57,17 +48,15 @@ class NowPlayingBar extends ConsumerWidget {
},
onTap: retryCallback,
child: Padding(
padding: floatNowPlaying
? const EdgeInsets.only(left: 12.0, bottom: 12.0, right: 12.0)
: EdgeInsets.zero,
padding: const EdgeInsets.only(left: 12.0, bottom: 12.0, right: 12.0),
child: Container(
decoration: getShadow(context),
child: Material(
shadowColor: Theme.of(context).colorScheme.primary.withOpacity(
Theme.of(context).brightness == Brightness.light
? 0.75
: 0.3),
borderRadius: borderRadius,
borderRadius: BorderRadius.circular(12.0),
clipBehavior: Clip.antiAlias,
color: Theme.of(context).brightness == Brightness.dark
? IconTheme.of(context).color!.withOpacity(0.1)
Expand All @@ -89,7 +78,7 @@ class NowPlayingBar extends ConsumerWidget {
? Colors.black
: Colors.white),
shape: RoundedRectangleBorder(
borderRadius: borderRadius,
borderRadius: BorderRadius.circular(12.0),
),
),
child: Row(
Expand Down Expand Up @@ -149,15 +138,13 @@ class NowPlayingBar extends ConsumerWidget {
},
onTap: () => Navigator.of(context).pushNamed(PlayerScreen.routeName),
child: Padding(
padding: floatNowPlaying
? const EdgeInsets.only(left: 12.0, bottom: 12.0, right: 12.0)
: EdgeInsets.zero,
padding: const EdgeInsets.only(left: 12.0, bottom: 12.0, right: 12.0),
child: Container(
decoration: getShadow(context),
child: Material(
shadowColor: Theme.of(context).colorScheme.primary.withOpacity(
Theme.of(context).brightness == Brightness.light ? 0.75 : 0.3),
borderRadius: borderRadius,
borderRadius: BorderRadius.circular(12.0),
clipBehavior: Clip.antiAlias,
color: Theme.of(context).brightness == Brightness.dark
? IconTheme.of(context).color!.withOpacity(0.1)
Expand Down Expand Up @@ -208,7 +195,7 @@ class NowPlayingBar extends ConsumerWidget {
? Colors.black
: Colors.white),
shape: RoundedRectangleBorder(
borderRadius: borderRadius,
borderRadius: BorderRadius.circular(12.0),
),
),
child: Row(
Expand Down Expand Up @@ -283,19 +270,15 @@ class NowPlayingBar extends ConsumerWidget {
color: IconTheme.of(context)
.color!
.withOpacity(0.75),
shape: RoundedRectangleBorder(
shape:
const RoundedRectangleBorder(
borderRadius:
floatNowPlaying
? BorderRadius.only(
topRight: Radius
.circular(
12),
bottomRight:
Radius
.circular(
12),
)
: BorderRadius.zero,
BorderRadius.only(
topRight:
Radius.circular(12),
bottomRight:
Radius.circular(12),
),
),
),
);
Expand Down
8 changes: 0 additions & 8 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1175,13 +1175,5 @@
"redownloadSubtitle": "Automatically redownload songs which are expected to be at a different quality due to parent collection changes.",
"@redownloadSubtitle": {
"description": "subtitle for download transcode setting which redownloads songs with higher allowed qualities"
},
"floatNowPlayingTitle": "Float Now-Playing Bar",
"@floatNowPlayingTitle": {
"description": "Title for theme setting which changes now-playing bar from floating to rectangular"
},
"floatNowPlayingSubtitle": "Show Now-Playing bar floating on top of other content.",
"@floatNowPlayingSubtitle": {
"description": "Subtitle for theme setting which changes now-playing bar from floating to rectangular"
}
}
5 changes: 0 additions & 5 deletions lib/models/finamp_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ const _defaultLoopMode = FinampLoopMode.all;
const _autoLoadLastQueueOnStartup = true;
const _shouldTranscodeDownloadsDefault = TranscodeDownloadsSetting.never;
const _shouldRedownloadTranscodesDefault = false;
const _floatNowPlayingDefault = true;

@HiveType(typeId: 28)
class FinampSettings {
Expand Down Expand Up @@ -130,7 +129,6 @@ class FinampSettings {
this.shouldTranscodeDownloads = _shouldTranscodeDownloadsDefault,
this.shouldRedownloadTranscodes = _shouldRedownloadTranscodesDefault,
this.swipeInsertQueueNext = _swipeInsertQueueNext,
this.floatNowPlaying = _floatNowPlayingDefault,
});

@HiveField(0, defaultValue: _isOfflineDefault)
Expand Down Expand Up @@ -274,9 +272,6 @@ class FinampSettings {
@HiveField(41, defaultValue: _autoLoadLastQueueOnStartup)
bool autoloadLastQueueOnStartup;

@HiveField(42, defaultValue: _floatNowPlayingDefault)
bool floatNowPlaying;

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

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

65 changes: 39 additions & 26 deletions lib/screens/blurred_player_screen_background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,48 @@ class BlurredPlayerScreenBackground extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final imageProvider = customImageProvider ?? ref.watch(currentAlbumImageProvider).value;
final imageProvider =
customImageProvider ?? ref.watch(currentAlbumImageProvider).value;

return AnimatedSwitcher(
duration: const Duration(milliseconds: 1000),
child: ClipRect(
key: ObjectKey(imageProvider),
child: imageProvider == null
? const SizedBox.shrink()
: OctoImage(
image: imageProvider,
fit: BoxFit.cover,
placeholderBuilder: (_) => const SizedBox.shrink(),
errorBuilder: (_, __, ___) => const SizedBox.shrink(),
imageBuilder: (context, child) => ColorFiltered(
colorFilter: ColorFilter.mode(
Theme.of(context).brightness == Brightness.dark
? Colors.black.withOpacity(clampDouble(0.675 * opacityFactor, 0.0, 1.0))
: Colors.white.withOpacity(clampDouble(0.75 * opacityFactor, 0.0, 1.0)),
BlendMode.srcOver),
child: ImageFiltered(
imageFilter: ImageFilter.blur(
sigmaX: 85,
sigmaY: 85,
tileMode: TileMode.mirror,
return ColorFiltered(
// Force total opacity to always be 100%
colorFilter: const ColorFilter.matrix(<double>[
1, 0, 0, 0, 0, // R
0, 1, 0, 0, 0, // G
0, 0, 1, 0, 0, // B
0, 0, 0, 2, 0, // A
]),
child: AnimatedSwitcher(
duration: const Duration(milliseconds: 1000),
child: ClipRect(
// Don't transition between images with identical files/urls
key: ValueKey(imageProvider.toString()),
child: imageProvider == null
? const SizedBox.shrink()
: OctoImage(
image: imageProvider,
fit: BoxFit.cover,
placeholderBuilder: (_) => const SizedBox.shrink(),
errorBuilder: (_, __, ___) => const SizedBox.shrink(),
imageBuilder: (context, child) => ColorFiltered(
colorFilter: ColorFilter.mode(
Theme.of(context).brightness == Brightness.dark
? Colors.black.withOpacity(
clampDouble(0.675 * opacityFactor, 0.0, 1.0))
: Colors.white.withOpacity(
clampDouble(0.75 * opacityFactor, 0.0, 1.0)),
BlendMode.srcOver),
child: ImageFiltered(
imageFilter: ImageFilter.blur(
sigmaX: 85,
sigmaY: 85,
tileMode: TileMode.mirror,
),
child: SizedBox.expand(child: child),
),
child: SizedBox.expand(child: child),
),
),
),
));
)),
);
}
}
30 changes: 0 additions & 30 deletions lib/screens/layout_settings_screen.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:hive/hive.dart';

import '../components/LayoutSettingsScreen/content_grid_view_cross_axis_count_list_tile.dart';
import '../components/LayoutSettingsScreen/content_view_type_dropdown_list_tile.dart';
import '../components/LayoutSettingsScreen/hide_song_artists_if_same_as_album_artists_selector.dart';
import '../components/LayoutSettingsScreen/show_cover_as_player_background_selector.dart';
import '../components/LayoutSettingsScreen/show_text_on_grid_view_selector.dart';
import '../components/LayoutSettingsScreen/theme_selector.dart';
import '../models/finamp_models.dart';
import '../services/finamp_settings_helper.dart';
import 'tabs_settings_screen.dart';

class LayoutSettingsScreen extends StatelessWidget {
Expand Down Expand Up @@ -40,34 +36,8 @@ class LayoutSettingsScreen extends StatelessWidget {
onTap: () =>
Navigator.of(context).pushNamed(TabsSettingsScreen.routeName),
),
const FloatNowPlayingSwitch(),
],
),
);
}
}

class FloatNowPlayingSwitch extends ConsumerWidget {
const FloatNowPlayingSwitch({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
bool? floatBar = ref.watch(FinampSettingsHelper.finampSettingsProvider
.select((value) => value.valueOrNull?.floatNowPlaying));

return SwitchListTile.adaptive(
title: Text(AppLocalizations.of(context)!.floatNowPlayingTitle),
subtitle: Text(AppLocalizations.of(context)!.floatNowPlayingSubtitle),
value: floatBar ?? true,
onChanged: floatBar == null
? null
: (value) async {
FinampSettings finampSettingsTemp =
FinampSettingsHelper.finampSettings;
finampSettingsTemp.floatNowPlaying = value;
await Hive.box<FinampSettings>("FinampSettings")
.put("FinampSettings", finampSettingsTemp);
},
);
}
}
18 changes: 11 additions & 7 deletions lib/screens/player_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ import 'package:finamp/color_schemes.g.dart';
import 'package:finamp/components/PlayerScreen/player_screen_appbar_title.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_tabler_icons/flutter_tabler_icons.dart';
import 'package:flutter_to_airplay/flutter_to_airplay.dart';
import 'package:flutter_vibrate/flutter_vibrate.dart';
import 'package:simple_gesture_detector/simple_gesture_detector.dart';
import 'package:flutter_to_airplay/flutter_to_airplay.dart';

import '../components/PlayerScreen/control_area.dart';
import '../components/PlayerScreen/song_info.dart';
import '../components/PlayerScreen/queue_button.dart';
import '../components/finamp_app_bar_button.dart';
import '../components/PlayerScreen/queue_list.dart';
import '../components/PlayerScreen/song_info.dart';
import '../components/finamp_app_bar_button.dart';
import '../services/finamp_settings_helper.dart';

import '../services/player_screen_theme_provider.dart';
import 'blurred_player_screen_background.dart';

Expand Down Expand Up @@ -81,7 +79,8 @@ class _PlayerScreenContent extends StatelessWidget {
child: AirPlayRoutePickerView(
tintColor: IconTheme.of(context).color ?? Colors.white,
activeTintColor: jellyfinBlueColor,
onShowPickerView: () => Vibrate.feedback(FeedbackType.selection),
onShowPickerView: () =>
Vibrate.feedback(FeedbackType.selection),
),
),
],
Expand All @@ -98,7 +97,12 @@ class _PlayerScreenContent extends StatelessWidget {
padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 0.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [Flexible(flex: 100, fit: FlexFit.tight, child: SongInfo()), Flexible(flex: 50, fit: FlexFit.loose, child: ControlArea()), Flexible(flex: 7, child: QueueButton())],
children: [
Flexible(flex: 100, fit: FlexFit.tight, child: SongInfo()),
Flexible(
flex: 50, fit: FlexFit.loose, child: ControlArea()),
Flexible(flex: 7, child: QueueButton())
],
),
),
),
Expand Down

0 comments on commit 659fafa

Please sign in to comment.