Skip to content

Commit

Permalink
feat: show queue or radiohistory when the player is big enough (#888)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier authored Aug 22, 2024
1 parent 8a6ecaf commit fd2d6da
Show file tree
Hide file tree
Showing 9 changed files with 361 additions and 283 deletions.
68 changes: 38 additions & 30 deletions lib/common/view/header_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,37 +80,45 @@ class HeaderBar extends StatelessWidget
: YaruTitleBarStyle.undecorated;
}

return YaruWindowTitleBar(
titleSpacing: titleSpacing,
actions: [
if ((!context.showMasterPanel && Platform.isMacOS) && leading != null)
Padding(
padding: const EdgeInsets.only(left: 10),
child: leading,
),
...?actions,
],
leading: !context.showMasterPanel && Platform.isMacOS ? null : leading,
title: title,
border: BorderSide.none,
backgroundColor: backgroundColor ?? context.theme.scaffoldBackgroundColor,
style: theStyle,
foregroundColor: foregroundColor,
onClose: Platform.isLinux
? (context) {
switch (closeBtnAction) {
case CloseBtnAction.alwaysAsk:
showDialog(
context: context,
builder: (_) => const CloseWindowActionConfirmDialog(),
);
case CloseBtnAction.hideToTray:
YaruWindow.hide(context);
case CloseBtnAction.close:
YaruWindow.close(context);
return Theme(
data: context.t.copyWith(
appBarTheme: AppBarTheme.of(context).copyWith(
scrolledUnderElevation: 0,
),
),
child: YaruWindowTitleBar(
titleSpacing: titleSpacing,
actions: [
if ((!context.showMasterPanel && Platform.isMacOS) && leading != null)
Padding(
padding: const EdgeInsets.only(left: 10),
child: leading,
),
...?actions,
],
leading: !context.showMasterPanel && Platform.isMacOS ? null : leading,
title: title,
border: BorderSide.none,
backgroundColor:
backgroundColor ?? context.theme.scaffoldBackgroundColor,
style: theStyle,
foregroundColor: foregroundColor,
onClose: Platform.isLinux
? (context) {
switch (closeBtnAction) {
case CloseBtnAction.alwaysAsk:
showDialog(
context: context,
builder: (_) => const CloseWindowActionConfirmDialog(),
);
case CloseBtnAction.hideToTray:
YaruWindow.hide(context);
case CloseBtnAction.close:
YaruWindow.close(context);
}
}
}
: null,
: null,
),
);
}

Expand Down
4 changes: 4 additions & 0 deletions lib/player/player_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ class PlayerService {
Audio? get audio => _audio;
void _setAudio(Audio value) async {
if (value == _audio) return;
if (value.audioType != _audio?.audioType) {
_shuffle = false;
setRate(1);
}
_audio = value;
_audioController.add(true);
setMpvMetaData(null);
Expand Down
170 changes: 78 additions & 92 deletions lib/player/view/bottom_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,107 +43,93 @@ class BottomPlayer extends StatelessWidget with WatchItMixin {
m.queue.length > 1 || audio?.audioType == AudioType.local,
);

final bottomPlayerImage = ClipRRect(
borderRadius: BorderRadius.circular(4),
child: BottomPlayerImage(
audio: audio,
size: kBottomPlayerHeight - 24,
videoController: model.controller,
isVideo: isVideo,
isOnline: isOnline,
),
);

final titleAndArtist = BottomPlayerTitleArtist(
audio: audio,
);

final bottomPlayerControls = PlayerMainControls(
playPrevious: model.playPrevious,
playNext: model.playNext,
active: active,
);

final track = PlayerTrack(
active: active,
bottomPlayer: true,
);

final bottom = Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
final player = SizedBox(
height: kBottomPlayerHeight,
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(left: 10, right: 20),
child: bottomPlayerImage,
PlayerTrack(
active: active,
bottomPlayer: true,
),
Expanded(
flex: 4,
child: Row(
children: [
Flexible(
flex: 5,
child: titleAndArtist,
),
if (!smallWindow)
InkWell(
onTap: () => appModel.setFullWindowMode(true),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(left: 10),
child: switch (audio?.audioType) {
AudioType.local => LikeIcon(
audio: audio,
color: theme.colorScheme.onSurface,
padding: const EdgeInsets.only(left: 10, right: 20),
child: ClipRRect(
borderRadius: BorderRadius.circular(4),
child: BottomPlayerImage(
audio: audio,
size: kBottomPlayerHeight - 24,
videoController: model.controller,
isVideo: isVideo,
isOnline: isOnline,
),
),
),
Expanded(
flex: 4,
child: Row(
children: [
Flexible(
flex: 5,
child: BottomPlayerTitleArtist(
audio: audio,
),
),
AudioType.radio => RadioLikeIcon(audio: audio),
_ => const SizedBox.shrink(),
},
if (!smallWindow)
Padding(
padding: const EdgeInsets.only(left: 10),
child: switch (audio?.audioType) {
AudioType.local => LikeIcon(
audio: audio,
color: theme.colorScheme.onSurface,
),
AudioType.radio => RadioLikeIcon(audio: audio),
_ => const SizedBox.shrink(),
},
),
],
),
),
],
),
),
if (!smallWindow)
Expanded(
flex: 6,
child: bottomPlayerControls,
),
if (!smallWindow)
Flexible(
flex: 4,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
if (audio?.audioType == AudioType.podcast)
PlaybackRateButton(active: active),
const VolumeSliderPopup(),
if (showQueueButton) const QueueButton(),
IconButton(
tooltip: context.l10n.fullWindow,
icon: Icon(
Iconz().fullWindow,
color: theme.colorScheme.onSurface,
if (!smallWindow)
Expanded(
flex: 6,
child: PlayerMainControls(active: active),
),
onPressed: () => appModel.setFullWindowMode(true),
if (!smallWindow)
Flexible(
flex: 4,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
if (audio?.audioType == AudioType.podcast)
PlaybackRateButton(active: active),
const VolumeSliderPopup(),
if (showQueueButton) const QueueButton(),
IconButton(
tooltip: context.l10n.fullWindow,
icon: Icon(
Iconz().fullWindow,
color: theme.colorScheme.onSurface,
),
onPressed: () => appModel.setFullWindowMode(true),
),
],
),
)
else
PlayButton(active: active),
const SizedBox(
width: 10,
),
],
),
)
else
PlayButton(active: active),
const SizedBox(
width: 10,
),
],
),
);

final player = SizedBox(
height: kBottomPlayerHeight,
child: Column(
children: [
track,
InkWell(
onTap: () => appModel.setFullWindowMode(true),
child: bottom,
),
),
],
),
Expand Down
Loading

0 comments on commit fd2d6da

Please sign in to comment.