From a10bc5b8d89207ac86872dd25f3258e47c2141a5 Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Thu, 8 Dec 2022 22:09:48 +0600 Subject: [PATCH] feat: sidebar download count and proper progress color in playbutton --- lib/components/root/sidebar.dart | 13 ++++- lib/components/shared/playbutton_card.dart | 52 ++++++++++--------- .../track_table/track_collection_view.dart | 20 +++---- .../{CacheTrack.dart => cache_track.dart} | 2 +- .../{CacheTrack.g.dart => cache_track.g.dart} | 2 +- lib/extensions/video.dart | 2 +- lib/main.dart | 4 +- lib/provider/playback_provider.dart | 2 +- 8 files changed, 53 insertions(+), 44 deletions(-) rename lib/entities/{CacheTrack.dart => cache_track.dart} (98%) rename lib/entities/{CacheTrack.g.dart => cache_track.g.dart} (99%) diff --git a/lib/components/root/sidebar.dart b/lib/components/root/sidebar.dart index 816143400..9c61eadc5 100644 --- a/lib/components/root/sidebar.dart +++ b/lib/components/root/sidebar.dart @@ -94,7 +94,18 @@ class Sidebar extends HookConsumerWidget { final icon = Icon(e.icon); return MapEntry( PlatformSidebarItem( - icon: icon, + icon: Badge( + badgeColor: PlatformTheme.of(context).primaryColor!, + showBadge: e.title == "Library" && downloadCount > 0, + badgeContent: Text( + downloadCount.toString(), + style: const TextStyle( + color: Colors.white, + fontSize: 10, + ), + ), + child: icon, + ), title: Text( e.title, style: const TextStyle( diff --git a/lib/components/shared/playbutton_card.dart b/lib/components/shared/playbutton_card.dart index ea15af2aa..ce4f99b14 100644 --- a/lib/components/shared/playbutton_card.dart +++ b/lib/components/shared/playbutton_card.dart @@ -119,32 +119,34 @@ class PlaybuttonCard extends HookWidget { bottom: 10, end: 5, child: Builder(builder: (context) { - return Container( - decoration: BoxDecoration( - color: iconBgColor, - shape: BoxShape.circle, - ), - child: PlatformIconButton( - onPressed: onPlaybuttonPressed, - backgroundColor: - PlatformTheme.of(context).primaryColor, - hoverColor: PlatformTheme.of(context) - .primaryColor - ?.withOpacity(0.5), - icon: isLoading - ? const SizedBox( - height: 23, - width: 23, - child: - PlatformCircularProgressIndicator(), - ) - : Icon( - isPlaying - ? Icons.pause_rounded - : Icons.play_arrow_rounded, - color: Colors.white, + return PlatformIconButton( + onPressed: onPlaybuttonPressed, + backgroundColor: + PlatformTheme.of(context).primaryColor, + hoverColor: PlatformTheme.of(context) + .primaryColor + ?.withOpacity(0.5), + icon: isLoading + ? SizedBox( + height: 23, + width: 23, + child: PlatformCircularProgressIndicator( + color: + ThemeData.estimateBrightnessForColor( + PlatformTheme.of(context) + .primaryColor!, + ) == + Brightness.dark + ? Colors.white + : Colors.grey[900], ), - ), + ) + : Icon( + isPlaying + ? Icons.pause_rounded + : Icons.play_arrow_rounded, + color: Colors.white, + ), ); }), ) diff --git a/lib/components/shared/track_table/track_collection_view.dart b/lib/components/shared/track_table/track_collection_view.dart index d85acc605..5344456a0 100644 --- a/lib/components/shared/track_table/track_collection_view.dart +++ b/lib/components/shared/track_table/track_collection_view.dart @@ -68,21 +68,17 @@ class TrackCollectionView extends HookConsumerWidget { onPressed: onShare, ), if (heartBtn != null) heartBtn!, - + const SizedBox(width: 5), // play playlist - Container( - margin: const EdgeInsets.symmetric(vertical: 10), - child: PlatformFilledButton( - style: ButtonStyle( - shape: MaterialStateProperty.all(const CircleBorder()), - ), - onPressed: tracksSnapshot.data != null ? onPlay : null, - child: Icon( - isPlaying ? Icons.stop_rounded : Icons.play_arrow_rounded, - color: Theme.of(context).backgroundColor, - ), + PlatformIconButton( + backgroundColor: PlatformTheme.of(context).primaryColor, + onPressed: tracksSnapshot.data != null ? onPlay : null, + icon: Icon( + isPlaying ? Icons.stop_rounded : Icons.play_arrow_rounded, + color: PlatformTextTheme.of(context).body?.color, ), ), + const SizedBox(width: 10), ]; final controller = useScrollController(); diff --git a/lib/entities/CacheTrack.dart b/lib/entities/cache_track.dart similarity index 98% rename from lib/entities/CacheTrack.dart rename to lib/entities/cache_track.dart index 00b2263a0..bd42b9cf1 100644 --- a/lib/entities/CacheTrack.dart +++ b/lib/entities/cache_track.dart @@ -1,7 +1,7 @@ import 'package:hive/hive.dart'; import 'package:youtube_explode_dart/youtube_explode_dart.dart'; -part 'CacheTrack.g.dart'; +part 'cache_track.g.dart'; @HiveType(typeId: 2) class CacheTrackEngagement { diff --git a/lib/entities/CacheTrack.g.dart b/lib/entities/cache_track.g.dart similarity index 99% rename from lib/entities/CacheTrack.g.dart rename to lib/entities/cache_track.g.dart index 423d767e2..b04ef5551 100644 --- a/lib/entities/CacheTrack.g.dart +++ b/lib/entities/cache_track.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'CacheTrack.dart'; +part of 'cache_track.dart'; // ************************************************************************** // TypeAdapterGenerator diff --git a/lib/extensions/video.dart b/lib/extensions/video.dart index aee94dde5..37eca8336 100644 --- a/lib/extensions/video.dart +++ b/lib/extensions/video.dart @@ -1,4 +1,4 @@ -import 'package:spotube/entities/CacheTrack.dart'; +import 'package:spotube/entities/cache_track.dart'; import 'package:spotube/utils/duration.dart'; import 'package:youtube_explode_dart/youtube_explode_dart.dart'; diff --git a/lib/main.dart b/lib/main.dart index 26ba03b6d..5a80e69f1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -12,7 +12,7 @@ import 'package:platform_ui/platform_ui.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:spotube/collections/cache_keys.dart'; import 'package:spotube/components/shared/dialogs/replace_downloaded_dialog.dart'; -import 'package:spotube/entities/CacheTrack.dart'; +import 'package:spotube/entities/cache_track.dart'; import 'package:spotube/collections/routes.dart'; import 'package:spotube/collections/intents.dart'; import 'package:spotube/models/logger.dart'; @@ -40,7 +40,7 @@ void main() async { final savedSize = rawSize != null ? json.decode(rawSize) : null; final double? height = savedSize?["height"]; final double? width = savedSize?["width"]; - appWindow.minSize = const Size(900, 700); + appWindow.minSize = const Size(1020, 700); appWindow.alignment = Alignment.center; appWindow.title = "Spotube"; if (height != null && width != null && height >= 700 && width >= 359) { diff --git a/lib/provider/playback_provider.dart b/lib/provider/playback_provider.dart index 40530ab41..7645cc619 100644 --- a/lib/provider/playback_provider.dart +++ b/lib/provider/playback_provider.dart @@ -7,7 +7,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:hive/hive.dart'; import 'package:spotify/spotify.dart'; -import 'package:spotube/entities/CacheTrack.dart'; +import 'package:spotube/entities/cache_track.dart'; import 'package:spotube/extensions/video.dart'; import 'package:spotube/models/current_playlist.dart'; import 'package:spotube/models/logger.dart';