Skip to content

Commit

Permalink
fix: playlist reordering and update credits with @TheShadowOfHassen and
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier authored Sep 7, 2024
1 parent 06cf7d3 commit 50399d3
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 337 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ MusicPod is a local music, radio, television and podcast player for Linux Deskto

The app icon has been made by [Stuart Jaggers](https://github.com/ubuntujaggers), thank you very much Stuart!

### Flatpak

Thanks [TheShadowOfHassen](https://github.com/TheShadowOfHassen) for packaging MusicPod as a [Flatpak](https://flathub.org/apps/org.feichtmeier.Musicpod)!

### Libraries used

Thanks to all the [MPV](https://github.com/mpv-player/mpv) contributors!
Expand Down
1 change: 0 additions & 1 deletion distribute_options.yaml

This file was deleted.

10 changes: 9 additions & 1 deletion lib/app/app_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,19 @@ class AppModel extends SafeChangeNotifier {
}

Future<List<Contributor>> getContributors() async {
return _gitHub.repositories
final list = await _gitHub.repositories
.listContributors(
RepositorySlug.full(kGitHubShortLink),
)
.where((c) => c.type == 'User')
.toList();
return [
...list,
Contributor(
login: 'ubuntujaggers',
htmlUrl: 'https://github.com/ubuntujaggers',
avatarUrl: 'https://avatars.githubusercontent.com/u/38893390?v=4',
),
];
}
}
2 changes: 1 addition & 1 deletion lib/app/view/master_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ List<MasterItem> createMasterItems({required LibraryModel libraryModel}) {
titleBuilder: (context) => Text(playlist.key),
subtitleBuilder: (context) => Text(context.l10n.playlist),
pageId: playlist.key,
pageBuilder: (_) => PlaylistPage(playlist: playlist),
pageBuilder: (_) => PlaylistPage(pageId: playlist.key),
iconBuilder: (selected) => SideBarFallBackImage(
color: getAlphabetColor(playlist.key),
child: Icon(
Expand Down
6 changes: 3 additions & 3 deletions lib/common/view/audio_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AudioTile extends StatefulWidget with WatchItStatefulWidgetMixin {
required this.pause,
required this.resume,
this.onSubTitleTap,
this.startPlaylist,
this.onTap,
required this.audioPageType,
required this.showLeading,
this.selectedColor,
Expand All @@ -41,7 +41,7 @@ class AudioTile extends StatefulWidget with WatchItStatefulWidgetMixin {

final bool isPlayerPlaying;
final Future<void> Function() resume;
final void Function()? startPlaylist;
final void Function()? onTap;
final void Function() pause;
final void Function(String text)? onSubTitleTap;
final LibraryModel libraryModel;
Expand Down Expand Up @@ -105,7 +105,7 @@ class _AudioTileState extends State<AudioTile> {
widget.resume();
}
} else {
widget.startPlaylist?.call();
widget.onTap?.call();
}
},
title: Padding(
Expand Down
2 changes: 1 addition & 1 deletion lib/common/view/sliver_audio_tile_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SliverAudioTileList extends StatelessWidget with WatchItMixin {
onSubTitleTap: onSubTitleTab,
isPlayerPlaying: isPlaying,
pause: playerModel.pause,
startPlaylist: () => playerModel.startPlaylist(
onTap: () => playerModel.startPlaylist(
audios: audios,
listName: pageId,
index: index,
Expand Down
44 changes: 24 additions & 20 deletions lib/playlists/view/playlist_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,31 @@ import '../../search/search_type.dart';
import 'manual_add_dialog.dart';
import 'playlst_add_audios_dialog.dart';

class PlaylistPage extends StatelessWidget {
class PlaylistPage extends StatelessWidget with WatchItMixin {
const PlaylistPage({
super.key,
required this.playlist,
required this.pageId,
});

final MapEntry<String, List<Audio>> playlist;
final String pageId;

@override
Widget build(BuildContext context) {
final model = di<LocalAudioModel>();
final libraryModel = di<LibraryModel>();
final playlist = libraryModel.getPlaylistById(pageId);
// This is needed to be notified about both size changes and also reordering
watchPropertyValue((LibraryModel m) => m.playlists[pageId]?.length);
watchPropertyValue((LibraryModel m) => m.playlists[pageId]?.hashCode);

return DropRegion(
formats: Formats.standardFormats,
hitTestBehavior: HitTestBehavior.opaque,
onDropEnded: (e) async {
Future.delayed(
const Duration(milliseconds: 300),
).then(
(_) => libraryModel.updatePlaylist(playlist.key, playlist.value),
(_) => libraryModel.updatePlaylist(pageId, playlist ?? []),
);
},
onPerformDrop: (e) async {
Expand All @@ -69,7 +74,7 @@ class PlaylistPage extends StatelessWidget {
if (file.isValidMedia) {
final data = await readMetadata(file, getImage: true);
var audio = Audio.fromMetadata(path: file.path, data: data);
playlist.value.add(audio);
playlist?.add(audio);
}
},
onError: (_) {},
Expand Down Expand Up @@ -129,28 +134,31 @@ class PlaylistPage extends StatelessWidget {
pageId: artist,
);
},
image: PlaylistHeaderImage(playlist: playlist),
audios: playlist.value,
pageId: playlist.key,
image: _PlaylistHeaderImage(
playlist: playlist ?? [],
pageId: pageId,
),
audios: playlist ?? [],
pageId: pageId,
),
),
);
}
}

class PlaylistHeaderImage extends StatelessWidget {
const PlaylistHeaderImage({
super.key,
class _PlaylistHeaderImage extends StatelessWidget {
const _PlaylistHeaderImage({
required this.playlist,
required this.pageId,
});

final MapEntry<String, List<Audio>> playlist;
final String pageId;
final List<Audio> playlist;

@override
Widget build(BuildContext context) {
final model = di<LocalAudioModel>();
final playlistImages =
model.findLocalCovers(audios: playlist.value, limit: 16);
final playlistImages = model.findLocalCovers(audios: playlist, limit: 16);
final length = playlistImages == null ? 0 : playlistImages.take(16).length;

final padding = length == 1 ? 0.0 : 8.0;
Expand Down Expand Up @@ -199,7 +207,7 @@ class PlaylistHeaderImage extends StatelessWidget {
}

return FallBackHeaderImage(
color: getAlphabetColor(playlist.key),
color: getAlphabetColor(pageId),
child: image,
);
}
Expand Down Expand Up @@ -230,10 +238,6 @@ class _PlaylistPageBody extends StatelessWidget with WatchItMixin {
final playerModel = di<PlayerModel>();
final currentAudio = watchPropertyValue((PlayerModel m) => m.audio);

watchPropertyValue(
(LibraryModel m) => m.playlists[pageId]?.length,
);

final audioPageHeader = AudioPageHeader(
title: pageId,
subTitle: '${audios.length} ${context.l10n.titles}',
Expand Down Expand Up @@ -280,7 +284,7 @@ class _PlaylistPageBody extends StatelessWidget with WatchItMixin {
key: ValueKey(audio.path ?? audio.url),
isPlayerPlaying: isPlaying,
pause: playerModel.pause,
startPlaylist: () => playerModel.startPlaylist(
onTap: () => playerModel.startPlaylist(
audios: audios,
listName: pageId,
index: index,
Expand Down
50 changes: 32 additions & 18 deletions lib/settings/view/about_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:yaru/yaru.dart';

import '../../app/app_model.dart';
import '../../common/view/progress.dart';
import '../../common/view/safe_network_image.dart';
import '../../common/view/tapable_text.dart';
import '../../constants.dart';
import '../../extensions/build_context_x.dart';
Expand All @@ -32,6 +33,7 @@ class _AboutPageState extends State<AboutPage> {
@override
Widget build(BuildContext context) {
final theme = context.t;
const radius = Radius.circular(8);

final linkStyle = theme.textTheme.bodyLarge
?.copyWith(color: Colors.lightBlue, overflow: TextOverflow.visible);
Expand Down Expand Up @@ -135,29 +137,41 @@ class _AboutPageState extends State<AboutPage> {
gridDelegate:
const SliverGridDelegateWithMaxCrossAxisExtent(
maxCrossAxisExtent: _kTileSize,
mainAxisExtent: _kTileSize,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
mainAxisSpacing: 5,
crossAxisSpacing: 5,
),
itemCount: snapshot.data!.length,
itemBuilder: (context, index) {
final e = snapshot.data!.elementAt(index);
return InkWell(
borderRadius: BorderRadius.circular(100),
onTap: e.htmlUrl == null
? null
: () => launchUrl(Uri.parse(e.htmlUrl!)),
child: CircleAvatar(
backgroundImage: e.avatarUrl != null
? NetworkImage(
e.avatarUrl!,
)
: null,
child: e.avatarUrl == null
? const YaruPlaceholderIcon(
return Tooltip(
message: e.login,
child: YaruBanner(
padding: EdgeInsets.zero,
onTap: e.htmlUrl == null
? null
: () =>
launchUrl(Uri.parse(e.htmlUrl!)),
child: SizedBox.square(
dimension: _kTileSize,
child: ClipRRect(
borderRadius:
const BorderRadius.all(radius),
child: SafeNetworkImage(
fit: BoxFit.cover,
url: e.avatarUrl,
fallBackIcon:
const YaruPlaceholderIcon(
borderRadius:
BorderRadiusDirectional
.vertical(
top: radius,
bottom: radius,
),
size: Size.square(_kTileSize),
)
: null,
),
),
),
),
),
);
},
Expand Down
10 changes: 0 additions & 10 deletions macos/packaging/dmg/make_config.yaml

This file was deleted.

Loading

0 comments on commit 50399d3

Please sign in to comment.