Skip to content

Commit

Permalink
chore: refactor to detangle podcast logic and player UI (#975)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier authored Oct 22, 2024
1 parent 78bd83b commit 59851fe
Show file tree
Hide file tree
Showing 26 changed files with 723 additions and 762 deletions.
8 changes: 5 additions & 3 deletions lib/app/view/scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,21 @@ class _MusicPodScaffoldState extends State<MusicPodScaffold> {
children: [
const Expanded(child: MasterDetailPage()),
if (!playerToTheRight || isMobile)
const PlayerView(mode: PlayerPosition.bottom),
const PlayerView(position: PlayerPosition.bottom),
],
),
),
if (playerToTheRight)
const SizedBox(
width: kSideBarPlayerWidth,
child: PlayerView(mode: PlayerPosition.sideBar),
child: PlayerView(position: PlayerPosition.sideBar),
),
],
),
if (isFullScreen == true)
const Scaffold(body: PlayerView(mode: PlayerPosition.fullWindow)),
const Scaffold(
body: PlayerView(position: PlayerPosition.fullWindow),
),
],
);
}
Expand Down
39 changes: 1 addition & 38 deletions lib/common/view/snackbars.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';

import '../../l10n/l10n.dart';
import '../../radio/radio_model.dart';

ScaffoldFeatureController<SnackBar, SnackBarClosedReason> showSnackBar({
required BuildContext context,
Widget? content,
SnackBar? snackBar,
Duration? duration,
clear = true,
bool clear = true,
}) {
if (clear) {
ScaffoldMessenger.of(context).clearSnackBars();
Expand All @@ -22,36 +18,3 @@ ScaffoldFeatureController<SnackBar, SnackBarClosedReason> showSnackBar({
),
);
}

SnackBar buildConnectSnackBar({
required String? connectedHost,
required BuildContext context,
}) {
return SnackBar(
duration: connectedHost != null
? const Duration(seconds: 1)
: const Duration(seconds: 30),
content: Text(
connectedHost != null
? '${context.l10n.connectedTo}: $connectedHost'
: context.l10n.noRadioServerFound,
),
action: (connectedHost == null)
? SnackBarAction(
onPressed: () async {
final connectedHost = await di<RadioModel>().init();
if (context.mounted) {
showSnackBar(
context: context,
content: buildConnectSnackBar(
connectedHost: connectedHost,
context: context,
),
);
}
},
label: context.l10n.tryReconnect,
)
: null,
);
}
158 changes: 0 additions & 158 deletions lib/player/player_mixin.dart

This file was deleted.

13 changes: 6 additions & 7 deletions lib/player/view/bottom_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ import '../../extensions/build_context_x.dart';
import '../../l10n/l10n.dart';
import '../../player/player_model.dart';
import 'bottom_player_image.dart';
import 'bottom_player_title_artist.dart';
import 'play_button.dart';
import 'playback_rate_button.dart';
import 'player_main_controls.dart';
import 'player_title_and_artist.dart';
import 'player_track.dart';
import 'player_view.dart';
import 'queue_button.dart';
import 'volume_popup.dart';

class BottomPlayer extends StatelessWidget with WatchItMixin {
const BottomPlayer({
super.key,
});
const BottomPlayer({super.key});

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -74,10 +73,10 @@ class BottomPlayer extends StatelessWidget with WatchItMixin {
flex: 4,
child: Row(
children: [
Flexible(
const Flexible(
flex: 5,
child: BottomPlayerTitleArtist(
audio: audio,
child: PlayerTitleAndArtist(
playerPosition: PlayerPosition.bottom,
),
),
if (!smallWindow)
Expand Down
72 changes: 0 additions & 72 deletions lib/player/view/bottom_player_title_artist.dart

This file was deleted.

6 changes: 3 additions & 3 deletions lib/player/view/full_height_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import '../../radio/view/radio_history_list.dart';
import 'blurred_full_height_player_image.dart';
import 'full_height_player_image.dart';
import 'full_height_player_top_controls.dart';
import 'full_height_title_and_artist.dart';
import 'player_title_and_artist.dart';
import 'full_height_video_player.dart';
import 'player_main_controls.dart';
import 'player_track.dart';
Expand Down Expand Up @@ -58,8 +58,8 @@ class FullHeightPlayer extends StatelessWidget with WatchItMixin {
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 30),
child: FullHeightTitleAndArtist(
audio: audio,
child: PlayerTitleAndArtist(
playerPosition: playerPosition,
),
),
const SizedBox(
Expand Down
Loading

0 comments on commit 59851fe

Please sign in to comment.