From 920fff6870cd8f43f95819b48cbf17b7ad651145 Mon Sep 17 00:00:00 2001 From: Moritz Weber Date: Sun, 11 Apr 2021 15:44:10 +0200 Subject: [PATCH] some ui stuff and skip --- .../actors/platform_integration_actor.dart | 12 ++++- lib/injection_container.dart | 2 + lib/presentation/pages/currently_playing.dart | 49 +++++++++++++---- lib/presentation/widgets/album_art.dart | 52 ------------------- lib/presentation/widgets/like_button.dart | 2 + lib/presentation/widgets/next_button.dart | 2 +- .../widgets/song_customization_buttons.dart | 47 +++++++++-------- ...platform_integration_data_source_impl.dart | 10 ++++ 8 files changed, 89 insertions(+), 87 deletions(-) diff --git a/lib/domain/actors/platform_integration_actor.dart b/lib/domain/actors/platform_integration_actor.dart index 58ddf9b..397c625 100644 --- a/lib/domain/actors/platform_integration_actor.dart +++ b/lib/domain/actors/platform_integration_actor.dart @@ -1,9 +1,11 @@ import '../repositories/platform_integration_repository.dart'; import '../usecases/pause.dart'; import '../usecases/play.dart'; +import '../usecases/seek_to_next.dart'; +import '../usecases/seek_to_previous.dart'; class PlatformIntegrationActor { - PlatformIntegrationActor(this._platformIntegrationInfoRepository, this._pause, this._play) { + PlatformIntegrationActor(this._platformIntegrationInfoRepository, this._pause, this._play, this._seekToNext, this._seekToPrevious) { _platformIntegrationInfoRepository.eventStream .listen((event) => _handlePlatformIntegrationEvent(event)); } @@ -12,6 +14,8 @@ class PlatformIntegrationActor { final Pause _pause; final Play _play; + final SeekToNext _seekToNext; + final SeekToPrevious _seekToPrevious; void _handlePlatformIntegrationEvent(PlatformIntegrationEvent event) { switch (event.type) { @@ -21,6 +25,12 @@ class PlatformIntegrationActor { case PlatformIntegrationEventType.pause: _pause(); break; + case PlatformIntegrationEventType.skipNext: + _seekToNext(); + break; + case PlatformIntegrationEventType.skipPrevious: + _seekToPrevious(); + break; default: } } diff --git a/lib/injection_container.dart b/lib/injection_container.dart index 507be6a..7a977c4 100644 --- a/lib/injection_container.dart +++ b/lib/injection_container.dart @@ -295,6 +295,8 @@ Future setupGetIt() async { getIt(), getIt(), getIt(), + getIt(), + getIt(), ), ); diff --git a/lib/presentation/pages/currently_playing.dart b/lib/presentation/pages/currently_playing.dart index 2b7991e..b22f195 100644 --- a/lib/presentation/pages/currently_playing.dart +++ b/lib/presentation/pages/currently_playing.dart @@ -56,8 +56,8 @@ class CurrentlyPlayingPage extends StatelessWidget { stops: const [ 0.0, 0.2, - 0.55, - 0.7, + 0.6, + 0.75, 1.0, ], ), @@ -108,11 +108,11 @@ class CurrentlyPlayingPage extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, ), const Spacer( - flex: 1, + flex: 10, ), Expanded( - flex: 1000, - child: Center( + flex: 720, + child: Center( child: Padding( padding: const EdgeInsets.symmetric( horizontal: 8.0, @@ -125,14 +125,41 @@ class CurrentlyPlayingPage extends StatelessWidget { ), ), const Spacer( - flex: 60, + flex: 50, ), - const Padding( - padding: EdgeInsets.only(left: 2.0, right: 2.0), - child: SongCustomizationButtons(), + Padding( + padding: const EdgeInsets.only(left: 12.0, right: 12.0), + child: Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + song.title, + overflow: TextOverflow.fade, + softWrap: false, + maxLines: 1, + style: TEXT_BIG.copyWith( + ), + ), + Text( + song.artist, + style: TEXT_SUBTITLE.copyWith( + color: Colors.grey[100], + ), + ), + ], + ), + ), ), const Spacer( - flex: 30, + flex: 50, + ), + const Padding( + padding: EdgeInsets.only(left: 6.0, right: 6.0), + child: SongCustomizationButtons(), + ), + const Spacer( + flex: 20, ), const Padding( padding: EdgeInsets.symmetric(horizontal: 2.0), @@ -146,7 +173,7 @@ class CurrentlyPlayingPage extends StatelessWidget { child: TimeProgressIndicator(), ), const Spacer( - flex: 100, + flex: 60, ), ], ), diff --git a/lib/presentation/widgets/album_art.dart b/lib/presentation/widgets/album_art.dart index 2f197a3..7358780 100644 --- a/lib/presentation/widgets/album_art.dart +++ b/lib/presentation/widgets/album_art.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import '../../domain/entities/song.dart'; -import '../theming.dart'; import '../utils.dart'; class AlbumArt extends StatelessWidget { @@ -31,57 +30,6 @@ class AlbumArt extends StatelessWidget { fit: BoxFit.cover, ), ), - Positioned( - bottom: 0, - left: 0, - right: 0, - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - song.title, - overflow: TextOverflow.ellipsis, - // softWrap: false, - maxLines: 2, - style: TEXT_BIG.copyWith( - shadows: [ - const Shadow( - blurRadius: 2.0, - color: Colors.black87, - offset: Offset(.5, .5), - ), - const Shadow( - blurRadius: 8.0, - color: Colors.black54, - offset: Offset(0, 0), - ), - ], - ), - ), - Text( - song.artist, - style: TEXT_SUBTITLE.copyWith( - color: Colors.grey[100], - shadows: [ - const Shadow( - blurRadius: 2.0, - color: Colors.black87, - offset: Offset(.5, .5), - ), - const Shadow( - blurRadius: 8.0, - color: Colors.black54, - offset: Offset(0, 0), - ), - ], - ), - ), - ], - ), - ), - ), ], ), ), diff --git a/lib/presentation/widgets/like_button.dart b/lib/presentation/widgets/like_button.dart index 18adfe2..35c9ef3 100644 --- a/lib/presentation/widgets/like_button.dart +++ b/lib/presentation/widgets/like_button.dart @@ -29,6 +29,7 @@ class LikeButton extends StatelessWidget { color: Colors.white24, ), onPressed: () => musicDataStore.incrementLikeCount(song), + visualDensity: VisualDensity.compact, ); } else { return IconButton( @@ -56,6 +57,7 @@ class LikeButton extends StatelessWidget { } return musicDataStore.resetLikeCount(song); }, + visualDensity: VisualDensity.compact, ); } }, diff --git a/lib/presentation/widgets/next_button.dart b/lib/presentation/widgets/next_button.dart index f201a23..39bfa7c 100644 --- a/lib/presentation/widgets/next_button.dart +++ b/lib/presentation/widgets/next_button.dart @@ -33,7 +33,7 @@ class NextButton extends StatelessWidget { } return IconButton( icon: const Icon( - Icons.skip_next, + Icons.skip_next_rounded, ), iconSize: iconSize, onPressed: null, diff --git a/lib/presentation/widgets/song_customization_buttons.dart b/lib/presentation/widgets/song_customization_buttons.dart index 8d7d7b4..bc6092a 100644 --- a/lib/presentation/widgets/song_customization_buttons.dart +++ b/lib/presentation/widgets/song_customization_buttons.dart @@ -17,31 +17,34 @@ class SongCustomizationButtons extends StatelessWidget { return Observer( builder: (BuildContext context) { - print('building buttons'); final Song song = audioStore.currentSongStream.value; - return Row( - children: [ - IconButton( - icon: Icon( - song.next == null ? Icons.link_off : Icons.link, - color: song.next == null ? Colors.white24 : Colors.white, + return Container( + child: Row( + children: [ + IconButton( + icon: Icon( + song.next == null ? Icons.link_off : Icons.link, + color: song.next == null ? Colors.white24 : Colors.white, + ), + iconSize: 20.0, + onPressed: () => musicDataStore.toggleNextSongLink(song), + visualDensity: VisualDensity.compact, ), - iconSize: 20.0, - onPressed: () => musicDataStore.toggleNextSongLink(song), - ), - const Spacer(), - const LikeButton(), - const Spacer(), - IconButton( - icon: Icon( - Icons.remove_circle_outline_rounded, - size: 20.0, - color: song.blocked ? Colors.white : Colors.white24, + const LikeButton( + iconSize: 20.0, ), - onPressed: () => musicDataStore.setSongBlocked(song, !song.blocked), - ), - ], - mainAxisAlignment: MainAxisAlignment.center, + IconButton( + icon: Icon( + Icons.remove_circle_outline_rounded, + size: 20.0, + color: song.blocked ? Colors.white : Colors.white24, + ), + onPressed: () => musicDataStore.setSongBlocked(song, !song.blocked), + visualDensity: VisualDensity.compact, + ), + ], + mainAxisAlignment: MainAxisAlignment.spaceBetween, + ), ); }, ); diff --git a/lib/system/datasources/platform_integration_data_source_impl.dart b/lib/system/datasources/platform_integration_data_source_impl.dart index d475532..aac14ae 100644 --- a/lib/system/datasources/platform_integration_data_source_impl.dart +++ b/lib/system/datasources/platform_integration_data_source_impl.dart @@ -25,6 +25,16 @@ class PlatformIntegrationDataSourceImpl extends BaseAudioHandler _eventSubject.add(PlatformIntegrationEvent(type: PlatformIntegrationEventType.pause)); } + @override + Future skipToNext() async { + _eventSubject.add(PlatformIntegrationEvent(type: PlatformIntegrationEventType.skipNext)); + } + + @override + Future skipToPrevious() async { + _eventSubject.add(PlatformIntegrationEvent(type: PlatformIntegrationEventType.skipPrevious)); + } + // PlatformIntegrationDataSource interface @override