Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playertrack: yaru padding #606

Merged
merged 5 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions lib/src/app/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import '../../app.dart';
import '../../build_context_x.dart';
import '../../constants.dart';
import '../../external_path.dart';
import '../../library.dart';
import '../../patch_notes.dart';
import '../../player.dart';
import '../../settings.dart';
import 'master_detail_page.dart';

class App extends ConsumerStatefulWidget {
Expand All @@ -26,6 +28,11 @@ class _AppState extends ConsumerState<App> with WidgetsBindingObserver {

WidgetsBinding.instance.addObserver(this);

final libraryModel = ref.read(libraryModelProvider);
final appModel = ref.read(appModelProvider);
final settingsModel = ref.read(settingsModelProvider);
final playerModel = ref.read(playerModelProvider);

if (!isMobile) {
YaruWindow.of(context).onClose(
() async {
Expand All @@ -37,8 +44,20 @@ class _AppState extends ConsumerState<App> with WidgetsBindingObserver {

WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted) return;
showPatchNotes(context, ref);
getService<ExternalPathService>().init();

appModel.init().then(
(_) {
libraryModel.init().then(
(_) {
playerModel.init().then((_) {
if (settingsModel.recentPatchNotesDisposed == false) {
showPatchNotes(context, ref);
}
}).then((_) => getService<ExternalPathService>().init());
},
);
},
);
});
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/app/app_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ class AppModel extends SafeChangeNotifier {
}

final appModelProvider = ChangeNotifierProvider(
(ref) => AppModel(connectivity: getService<Connectivity>())..init(),
(ref) => AppModel(connectivity: getService<Connectivity>()),
);
10 changes: 5 additions & 5 deletions lib/src/app/musicpod.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class YaruMusicPodApp extends StatelessWidget {
return YaruTheme(
builder: (context, yaru, child) {
return _MusicPodApp(
hightContrastTheme: yaruHighContrastLight,
highContrastTheme: yaruHighContrastLight,
highContrastDarkTheme: yaruHighContrastDark,
lightTheme: yaru.theme?.copyWith(
actionIconTheme: ActionIconThemeData(
Expand Down Expand Up @@ -81,13 +81,13 @@ class _MusicPodApp extends StatefulWidget {
this.lightTheme,
this.darkTheme,
this.accent,
this.hightContrastTheme,
this.highContrastTheme,
this.highContrastDarkTheme,
});

final ThemeData? lightTheme,
darkTheme,
hightContrastTheme,
highContrastTheme,
highContrastDarkTheme;
final Color? accent;

Expand Down Expand Up @@ -117,10 +117,10 @@ class _MusicPodAppState extends State<_MusicPodApp> {
final themeIndex = ref
.watch(settingsModelProvider.select((value) => value.themeIndex));
return MaterialApp(
highContrastTheme: widget.hightContrastTheme,
highContrastDarkTheme: widget.highContrastDarkTheme,
debugShowCheckedModeBanner: false,
themeMode: ThemeMode.values[themeIndex],
highContrastTheme: widget.highContrastTheme,
highContrastDarkTheme: widget.highContrastDarkTheme,
theme: widget.lightTheme ??
m3Theme(color: widget.accent ?? Colors.greenAccent),
darkTheme: widget.darkTheme ??
Expand Down
7 changes: 2 additions & 5 deletions lib/src/common/like_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,8 @@ class LikeButton extends StatelessWidget {
),
PopupMenuItem(
padding: EdgeInsets.zero,
child: Padding(
padding: const EdgeInsets.only(left: 5),
child: StreamProviderRow(
text: '${audio.artist ?? ''} - ${audio.title ?? ''}',
),
child: StreamProviderRow(
text: '${audio.artist ?? ''} - ${audio.title ?? ''}',
),
),
];
Expand Down
4 changes: 2 additions & 2 deletions lib/src/common/round_image_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class RoundImageContainer extends StatelessWidget {
const RoundImageContainer({
super.key,
this.images,
this.fallBackText,
required this.fallBackText,
});

final Set<Uint8List>? images;
final String? fallBackText;
final String fallBackText;

@override
Widget build(BuildContext context) {
Expand Down
36 changes: 0 additions & 36 deletions lib/src/common/unknown_page.dart

This file was deleted.

2 changes: 1 addition & 1 deletion lib/src/library/library_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -350,5 +350,5 @@ class LibraryModel extends SafeChangeNotifier {
}

final libraryModelProvider = ChangeNotifierProvider<LibraryModel>((ref) {
return LibraryModel(getService<LibraryService>())..init();
return LibraryModel(getService<LibraryService>());
});
39 changes: 10 additions & 29 deletions lib/src/local_audio/artist_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import '../../local_audio.dart';
import '../../player.dart';
import '../../settings.dart';
import '../../utils.dart';
import '../common/unknown_page.dart';
import '../l10n/l10n.dart';
import 'genre_page.dart';

Expand All @@ -30,12 +29,6 @@ class ArtistPage extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final pageId =
artistAudios?.firstWhereOrNull((e) => e.artist != null)?.artist;
if (pageId == null) {
return const UnknownPage();
}

final libraryModel = ref.read(libraryModelProvider);
final model = ref.read(localAudioModelProvider);

Expand Down Expand Up @@ -65,8 +58,7 @@ class ArtistPage extends ConsumerWidget {
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10),
child: StreamProviderRow(
text:
artistAudios?.firstWhereOrNull((e) => e.artist != null)?.artist,
text: artistAudios?.firstOrNull?.artist,
),
),
listModeToggle,
Expand All @@ -75,13 +67,8 @@ class ArtistPage extends ConsumerWidget {

void onAlbumTap(text) {
final audios = model.findAlbum(Audio(album: text));
if (audios == null ||
audios.none((a) => a.artist != null && a.album != null) == true) {
return;
}
final id = generateAlbumId(
audios.firstWhere((e) => e.artist != null && e.album != null),
);
if (audios?.firstOrNull == null) return;
final id = generateAlbumId(audios!.first);
if (id == null) return;

Navigator.of(context).push(
Expand Down Expand Up @@ -111,8 +98,7 @@ class ArtistPage extends ConsumerWidget {

final roundImageContainer = RoundImageContainer(
images: images,
fallBackText:
artistAudios?.firstWhereOrNull((e) => e.artist != null)?.artist,
fallBackText: artistAudios?.firstOrNull?.artist ?? 'a',
);

if (!useGridView) {
Expand All @@ -123,14 +109,12 @@ class ArtistPage extends ConsumerWidget {
onSubTitleTab: onSubTitleTab,
audioPageType: AudioPageType.artist,
headerLabel: context.l10n.artist,
headerTitle:
artistAudios?.firstWhereOrNull((e) => e.artist != null)?.artist,
headerTitle: artistAudios?.firstOrNull?.artist,
image: roundImageContainer,
imageRadius: BorderRadius.circular(10000),
headerSubtile:
artistAudios?.firstWhereOrNull((e) => e.genre != null)?.genre,
headerSubtile: artistAudios?.firstOrNull?.genre,
audios: artistAudios,
pageId: pageId,
pageId: artistAudios?.firstOrNull?.artist ?? artistAudios.toString(),
controlPanelButton: controlPanelButton,
);
}
Expand Down Expand Up @@ -169,8 +153,7 @@ class _ArtistAlbumsCardGrid extends StatelessWidget {
final showWindowControls =
ref.watch(appModelProvider.select((a) => a.showWindowControls));

final artist =
artistAudios?.firstWhereOrNull((e) => e.artist != null)?.artist;
final artist = artistAudios?.firstOrNull?.artist;
final model = ref.read(localAudioModelProvider);
final playerModel = ref.read(playerModelProvider);

Expand All @@ -190,11 +173,9 @@ class _ArtistAlbumsCardGrid extends StatelessWidget {
children: [
AudioPageHeader(
imageRadius: BorderRadius.circular(10000),
title: artist,
title: artistAudios?.firstOrNull?.artist ?? '',
image: image,
subTitle: artistAudios
?.firstWhereOrNull((e) => e.genre != null)
?.genre,
subTitle: artistAudios?.firstOrNull?.genre,
label: context.l10n.artist,
onLabelTab: onLabelTab,
onSubTitleTab: onSubTitleTab,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/player/player_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,5 @@ class PlayerModel extends SafeChangeNotifier {
}

final playerModelProvider = ChangeNotifierProvider<PlayerModel>((ref) {
return PlayerModel(service: getService<PlayerService>())..init();
return PlayerModel(service: getService<PlayerService>());
});
7 changes: 6 additions & 1 deletion lib/src/player/player_track.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ class PlayerTrack extends ConsumerWidget {
),
],
),
Expanded(child: slider),
Expanded(
child: Padding(
padding: EdgeInsets.only(top: bottomPlayer ? 0 : 3),
child: slider,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expand Down
4 changes: 2 additions & 2 deletions lib/src/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ const alphabetColors = {
'Z': Colors.deepOrangeAccent,
};

Color getAlphabetColor(String? text, [Color fallBackColor = Colors.black]) {
final letter = text == null || text.isEmpty == true ? null : text[0];
Color getAlphabetColor(String text, [Color fallBackColor = Colors.black]) {
final letter = text.isEmpty ? null : text[0];
return alphabetColors[letter?.toUpperCase()] ?? fallBackColor;
}

Expand Down
5 changes: 3 additions & 2 deletions lib/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,10 @@ Future<Uri?> createUriFromAudio(Audio audio) async {
String? generateAlbumId(Audio audio) {
final albumName = audio.album;
final artistName = audio.artist;
return albumName == null || artistName == null
final id = albumName == null && artistName == null
? null
: '$artistName:$albumName';
: '${artistName ?? ''}:${albumName ?? ''}';
return id;
}

/// | Bytes | extension | Description |
Expand Down