Skip to content

Commit

Permalink
fix: mobile home and queue (#1096)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier authored Dec 15, 2024
1 parent afccd48 commit f90d11c
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 27 deletions.
23 changes: 19 additions & 4 deletions lib/common/view/no_search_result_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,31 @@ class NoSearchResultPage extends StatelessWidget {
}
}

class SliverFillNoSearchResultPage extends StatelessWidget {
const SliverFillNoSearchResultPage({super.key, this.message, this.icon});
class SliverNoSearchResultPage extends StatelessWidget {
const SliverNoSearchResultPage({
super.key,
this.message,
this.icon,
this.expand = true,
});

final Widget? message;
final Widget? icon;
final bool expand;

@override
Widget build(BuildContext context) {
return SliverFillRemaining(
hasScrollBody: false,
if (expand) {
return SliverFillRemaining(
hasScrollBody: false,
child: NoSearchResultPage(
icon: icon,
message: message,
),
);
}

return SliverToBoxAdapter(
child: NoSearchResultPage(
icon: icon,
message: message,
Expand Down
1 change: 1 addition & 0 deletions lib/home/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class HomePage extends StatelessWidget with WatchItMixin {
SliverPadding(
padding: padding,
sliver: const SliverPodcastSearchResults(
expand: false,
take: 3,
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/local_audio/view/album_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AlbumsView extends StatelessWidget with WatchItMixin {
}

if (albums!.isEmpty) {
return SliverFillNoSearchResultPage(
return SliverNoSearchResultPage(
icon: noResultIcon,
message: noResultMessage,
);
Expand Down
4 changes: 2 additions & 2 deletions lib/local_audio/view/artists_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ArtistsView extends StatelessWidget {
}

if (artists!.isEmpty) {
return SliverFillNoSearchResultPage(
return SliverNoSearchResultPage(
icon: noResultIcon,
message: noResultMessage,
);
Expand Down Expand Up @@ -104,7 +104,7 @@ class AlbumArtistsView extends StatelessWidget {
}

if (albumArtists!.isEmpty) {
return SliverFillNoSearchResultPage(
return SliverNoSearchResultPage(
icon: noResultIcon,
message: noResultMessage,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/local_audio/view/genres_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GenresView extends StatelessWidget {
}

if (genres!.isEmpty) {
return SliverFillNoSearchResultPage(
return SliverNoSearchResultPage(
icon: noResultIcon,
message: noResultMessage,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/local_audio/view/local_audio_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class _LocalAudioPageState extends State<LocalAudioPage> {
bottom: bottomPlayerPageGap,
),
sliver: audios != null && audios.isEmpty
? SliverFillNoSearchResultPage(
? SliverNoSearchResultPage(
icon: const AnimatedEmoji(AnimatedEmojis.bird),
message: Column(
mainAxisSize: MainAxisSize.min,
Expand Down
2 changes: 1 addition & 1 deletion lib/local_audio/view/titles_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TitlesView extends StatelessWidget {
}

if (audios!.isEmpty) {
return SliverFillNoSearchResultPage(
return SliverNoSearchResultPage(
icon: noResultIcon,
message: noResultMessage,
);
Expand Down
7 changes: 4 additions & 3 deletions lib/player/player_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,10 @@ class PlayerService {
audio: _audio,
duration: _duration?.toString(),
position: _position?.toString(),
queue:
_queue.audios.length <= 100 ? _queue.audios.take(100).toList() : null,
queueName: _queue.audios.length <= 100 ? _queue.name : null,
queue: _queue.audios.length > 100
? _queue.audios.take(100).toList()
: _queue.audios,
queueName: _queue.name,
volume: _volume.toString(),
rate: _rate.toString(),
);
Expand Down
42 changes: 33 additions & 9 deletions lib/player/view/queue/queue_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import '../../../common/view/modals.dart';
import '../../../common/view/ui_constants.dart';
import '../../../extensions/build_context_x.dart';
import '../../../l10n/l10n.dart';
import '../../../radio/view/radio_history_list.dart';
import '../../player_model.dart';
import 'queue_body.dart';
import 'queue_dialog.dart';
Expand All @@ -34,6 +35,18 @@ class QueueButton extends StatelessWidget with WatchItMixin {
(PlayerModel m) => m.audio?.audioType == AudioType.radio,
);

final queueOrHistory = radio
? const SizedBox(
width: 400,
height: 500,
child: RadioHistoryList(
simpleList: true,
),
)
: QueueBody(
selectedColor: theme.colorScheme.onSurface,
);

return switch (_mode) {
_QueueButtonMode.icon => IconButton(
isSelected: isSelected ??
Expand All @@ -45,12 +58,22 @@ class QueueButton extends StatelessWidget with WatchItMixin {
Iconz.playlist,
color: color ?? theme.colorScheme.onSurface,
),
onPressed: () => onPressed(playerToTheRight, isFullScreen, context),
onPressed: () => onPressed(
playerToTheRight: playerToTheRight,
isFullScreen: isFullScreen,
context: context,
bottomSheetContent: queueOrHistory,
),
),
_QueueButtonMode.text => TextButton(
onPressed: () => onPressed(playerToTheRight, isFullScreen, context),
onPressed: () => onPressed(
playerToTheRight: playerToTheRight,
isFullScreen: isFullScreen,
context: context,
bottomSheetContent: queueOrHistory,
),
child: Text(
context.l10n.queue,
radio ? context.l10n.hearingHistory : context.l10n.queue,
style: context.textTheme.bodyLarge?.copyWith(
color: context.colorScheme.onSurface,
),
Expand All @@ -59,11 +82,12 @@ class QueueButton extends StatelessWidget with WatchItMixin {
};
}

void onPressed(
bool playerToTheRight,
bool? isFullScreen,
BuildContext context,
) {
void onPressed({
required bool playerToTheRight,
required bool? isFullScreen,
required BuildContext context,
required Widget bottomSheetContent,
}) {
if ((playerToTheRight || isFullScreen == true) && !isMobilePlatform) {
di<AppModel>().setOrToggleQueueOverlay();
} else {
Expand All @@ -72,7 +96,7 @@ class QueueButton extends StatelessWidget with WatchItMixin {
isScrollControlled: true,
showDragHandle: true,
content: ModalMode.platformModalMode == ModalMode.bottomSheet
? const QueueBody()
? bottomSheetContent
: const QueueDialog(),
mode: ModalMode.platformModalMode,
);
Expand Down
2 changes: 1 addition & 1 deletion lib/search/view/sliver_local_search_results.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class _SliverLocalSearchResultState extends State<SliverLocalSearchResult> {
final searchQuery = watchPropertyValue((SearchModel m) => m.searchQuery);

if (searchQuery == null || searchQuery.isEmpty == true) {
return SliverFillNoSearchResultPage(
return SliverNoSearchResultPage(
icon: const AnimatedEmoji(AnimatedEmojis.drum),
message: Text(
context.l10n.search,
Expand Down
21 changes: 19 additions & 2 deletions lib/search/view/sliver_podcast_search_results.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';

import '../../app/connectivity_model.dart';
import '../../common/view/loading_grid.dart';
import '../../common/view/no_search_result_page.dart';
import '../../common/view/offline_page.dart';
import '../../common/view/progress.dart';
Expand All @@ -14,9 +15,14 @@ import 'podcast_card.dart';

class SliverPodcastSearchResults extends StatefulWidget
with WatchItStatefulWidgetMixin {
const SliverPodcastSearchResults({super.key, this.take});
const SliverPodcastSearchResults({
super.key,
this.take,
this.expand = true,
});

final int? take;
final bool expand;

@override
State<SliverPodcastSearchResults> createState() =>
Expand Down Expand Up @@ -54,8 +60,19 @@ class _SliverPodcastSearchResultsState
final searchResultItems =
widget.take != null ? results?.take(widget.take!) : results;

if (!widget.expand) {
if (searchResultItems == null) {
return SliverLoadingGrid(limit: widget.take ?? 100);
} else if (searchResultItems.isEmpty) {
return const SliverNoSearchResultPage(
expand: false,
);
}
}

if (searchResultItems == null || searchResultItems.isEmpty) {
return SliverFillNoSearchResultPage(
return SliverNoSearchResultPage(
expand: widget.expand,
icon: loading
? const SizedBox.shrink()
: searchResultItems == null
Expand Down
4 changes: 2 additions & 2 deletions lib/search/view/sliver_radio_search_results.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ class SliverRadioSearchResults extends StatelessWidget with WatchItMixin {

if (radioSearchResult == null ||
(searchQuery?.isEmpty == true && radioSearchResult.isEmpty == true)) {
return SliverFillNoSearchResultPage(
return SliverNoSearchResultPage(
icon: const AnimatedEmoji(AnimatedEmojis.drum),
message:
Text('${context.l10n.search} ${searchType.localize(context.l10n)}'),
);
}
if (radioSearchResult.isEmpty && !loading) {
return SliverFillNoSearchResultPage(
return SliverNoSearchResultPage(
icon: const AnimatedEmoji(AnimatedEmojis.rabbit),
message: Text(context.l10n.noStationFound),
);
Expand Down

0 comments on commit f90d11c

Please sign in to comment.