From 147a1ebb8fa9bf573965b60960c52628269dfc9e Mon Sep 17 00:00:00 2001 From: Feichtmeier Date: Thu, 21 Nov 2024 22:25:32 +0100 Subject: [PATCH] feat: improve mobile tiles and page option buttons with bottom sheets --- lib/common/view/audio_tile.dart | 24 ++-- lib/common/view/audio_tile_bottom_sheet.dart | 103 ++++++++++-------- lib/common/view/audio_tile_option_button.dart | 64 +++++++---- lib/common/view/explore_online_popup.dart | 38 ------- .../view/stream_provider_share_button.dart | 2 +- lib/library/library_model.dart | 14 ++- lib/library/library_service.dart | 28 +++-- lib/local_audio/view/album_page.dart | 13 ++- lib/local_audio/view/artist_page.dart | 12 +- lib/player/player_model.dart | 4 +- lib/player/player_service.dart | 8 +- .../view/add_to_playlist_dialog.dart | 6 +- .../view/add_to_playlist_navigator.dart | 38 ++++--- .../view/playlst_add_audios_dialog.dart | 5 +- lib/podcasts/view/podcast_audio_tile.dart | 2 +- lib/podcasts/view/podcast_page.dart | 15 ++- needs_translation.json | 14 --- 17 files changed, 221 insertions(+), 169 deletions(-) delete mode 100644 lib/common/view/explore_online_popup.dart diff --git a/lib/common/view/audio_tile.dart b/lib/common/view/audio_tile.dart index 51f90af48..3560bf81c 100644 --- a/lib/common/view/audio_tile.dart +++ b/lib/common/view/audio_tile.dart @@ -56,10 +56,7 @@ class _AudioTileState extends State { final theme = context.theme; final l10n = context.l10n; final playerModel = di(); - final liked = watchPropertyValue((LibraryModel m) => m.liked(widget.audio)); - final starred = watchPropertyValue( - (LibraryModel m) => m.isStarredStation(widget.audio.uuid), - ); + final selectedColor = widget.selectedColor ?? theme.contrastyPrimary; final color = widget.selected && widget.isPlayerPlaying ? selectedColor : null; @@ -145,7 +142,6 @@ class _AudioTileState extends State { ), trailing: _AudioTileTrail( hovered: _hovered, - liked: liked || starred, audio: widget.audio, selected: widget.selected, isPlayerPlaying: widget.isPlayerPlaying, @@ -154,6 +150,7 @@ class _AudioTileState extends State { selectedColor: selectedColor, showDuration: !isMobile, showLikeIcon: !isMobile, + alwaysShowOptionButton: isMobile, ), ); @@ -182,10 +179,10 @@ class _AudioTileTrail extends StatelessWidget with WatchItMixin { required this.pageId, required this.audioPageType, required this.hovered, - required this.liked, required this.selectedColor, required this.showLikeIcon, required this.showDuration, + required this.alwaysShowOptionButton, }); final Audio audio; @@ -194,21 +191,28 @@ class _AudioTileTrail extends StatelessWidget with WatchItMixin { final String pageId; final AudioPageType audioPageType; final bool hovered; - final bool liked; final Color selectedColor; final bool showLikeIcon, showDuration; + final bool alwaysShowOptionButton; @override Widget build(BuildContext context) { + final liked = watchPropertyValue((LibraryModel m) => m.liked(audio)); + final starred = watchPropertyValue( + (LibraryModel m) => m.isStarredStation(audio.uuid), + ); return Row( mainAxisSize: MainAxisSize.min, children: [ Opacity( - opacity: hovered || selected ? 1 : 0, + opacity: alwaysShowOptionButton || hovered || selected ? 1 : 0, child: AudioTileOptionButton( + title: Text(audio.title ?? ''), + subTitle: Text(audio.artist ?? ''), selected: selected && isPlayerPlaying, playlistId: pageId, - audio: audio, + audios: [audio], + searchTerm: '${audio.artist ?? ''} - ${audio.title ?? ''}', allowRemove: (audioPageType == AudioPageType.playlist || audioPageType == AudioPageType.likedAudio) && audio.audioType != AudioType.radio, @@ -219,7 +223,7 @@ class _AudioTileTrail extends StatelessWidget with WatchItMixin { ), if (showLikeIcon) Opacity( - opacity: hovered || selected || liked ? 1 : 0, + opacity: hovered || selected || liked || starred ? 1 : 0, child: switch (audio.audioType) { AudioType.radio => RadioLikeIcon( audio: audio, diff --git a/lib/common/view/audio_tile_bottom_sheet.dart b/lib/common/view/audio_tile_bottom_sheet.dart index 007d7af24..2a258e4be 100644 --- a/lib/common/view/audio_tile_bottom_sheet.dart +++ b/lib/common/view/audio_tile_bottom_sheet.dart @@ -1,3 +1,5 @@ +import 'package:collection/collection.dart'; + import '../../constants.dart'; import '../../extensions/build_context_x.dart'; import '../../l10n/l10n.dart'; @@ -7,6 +9,7 @@ import '../../playlists/view/add_to_playlist_dialog.dart'; import '../data/audio.dart'; import 'audio_tile_image.dart'; import 'icons.dart'; +import 'like_all_icon.dart'; import 'like_icon.dart'; import 'meta_data_dialog.dart'; import 'package:flutter/material.dart'; @@ -19,14 +22,20 @@ import 'theme.dart'; class AudioTileBottomSheet extends StatelessWidget { const AudioTileBottomSheet({ super.key, - required this.audio, required this.allowRemove, required this.playlistId, + required this.searchTerm, + required this.title, + required this.subTitle, + required this.audios, }); - final Audio audio; final bool allowRemove; final String playlistId; + final String searchTerm; + final Widget title; + final Widget subTitle; + final List