From 2717f1bed9bfd0896cdf4501346098be8b648150 Mon Sep 17 00:00:00 2001 From: richard Date: Fri, 9 Aug 2024 14:53:12 +0200 Subject: [PATCH 1/3] refactor: updated deps --- lib/services/player_service.dart | 2 +- pubspec.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/services/player_service.dart b/lib/services/player_service.dart index fb69054..9449399 100644 --- a/lib/services/player_service.dart +++ b/lib/services/player_service.dart @@ -47,7 +47,7 @@ class PlayerService { Future _init() async { await JustAudioBackground.init( androidNotificationChannelId: 'com.richard.youtube_downloader.player', - androidNotificationChannelName: 'YouTube Dowloader', + androidNotificationChannelName: 'YouTube Downloader', androidNotificationOngoing: true, preloadArtwork: true, ); diff --git a/pubspec.yaml b/pubspec.yaml index 47437cb..954ed8f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -35,8 +35,8 @@ dependencies: youtube_explode_dart: ^2.2.1 path_provider: ^2.0.15 http: ^1.0.0 - just_audio: ^0.9.34 - just_audio_background: ^0.0.1-beta.10 + just_audio: ^0.9.39 + just_audio_background: ^0.0.1-beta.13 cached_network_image: ^3.2.3 audio_video_progress_bar: ^1.0.1 flutter_keyboard_visibility: ^5.4.1 From 50d5befe3cbd0fbb639389af4b7a6678ae64ccdf Mon Sep 17 00:00:00 2001 From: richard Date: Fri, 9 Aug 2024 16:06:41 +0200 Subject: [PATCH 2/3] fix: updated android api 34 permissions --- android/app/src/main/AndroidManifest.xml | 21 ++++++++++++--------- lib/main.dart | 4 ++-- lib/services/notifications_service.dart | 4 ++-- pubspec.lock | 16 ++++++++-------- pubspec.yaml | 16 ++++++++-------- 5 files changed, 32 insertions(+), 29 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 2216b9a..f4db871 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,17 @@ + + + + + + + + + + + - - - - - - - - - \ No newline at end of file + diff --git a/lib/main.dart b/lib/main.dart index 2fe432f..23e7419 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -4,9 +4,9 @@ import 'package:youtube_downloader/app.dart'; import 'package:youtube_downloader/services/services.dart'; import 'package:youtube_downloader/controllers/controllers.dart'; -void main() { +Future main() async { + await _injectServices(); runApp(const YouTubeDownloaderApp()); - _injectServices(); } Future _injectServices() async { diff --git a/lib/services/notifications_service.dart b/lib/services/notifications_service.dart index 7e1ce44..cc4336c 100644 --- a/lib/services/notifications_service.dart +++ b/lib/services/notifications_service.dart @@ -7,7 +7,7 @@ class NotificationsService { final AndroidNotificationDetails _downloadCompletedAndroidDetails = const AndroidNotificationDetails( - 'youtube_downloader_notification_channel', + 'com.richard.youtube_downloader.download_info', 'YouTube Downloader', importance: Importance.max, priority: Priority.max, @@ -17,7 +17,7 @@ class NotificationsService { final AndroidNotificationDetails _downloadInProgressAndroidDetails = const AndroidNotificationDetails( - 'youtube_downloader_notification_channel', + 'com.richard.youtube_downloader.download_info', 'YouTube Downloader', importance: Importance.low, priority: Priority.low, diff --git a/pubspec.lock b/pubspec.lock index 2957cb8..7e7cd48 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -61,10 +61,10 @@ packages: dependency: "direct main" description: name: audio_video_progress_bar - sha256: "67f3a5ea70d48b48caaf29f5a0606284a6aa3a393736daf9e82bec985d2f9b70" + sha256: "552b1f73c56c4c88407999e0a8507176f60c56de3e6d63bc20a0eab48467d4c9" url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "2.0.3" boolean_selector: dependency: transitive description: @@ -194,10 +194,10 @@ packages: dependency: "direct main" description: name: flutter_keyboard_visibility - sha256: "4983655c26ab5b959252ee204c2fffa4afeb4413cd030455194ec0caa3b8e7cb" + sha256: "98664be7be0e3ffca00de50f7f6a287ab62c763fc8c762e0a21584584a3ff4f8" url: "https://pub.dev" source: hosted - version: "5.4.1" + version: "6.0.0" flutter_keyboard_visibility_linux: dependency: transitive description: @@ -242,10 +242,10 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c" url: "https://pub.dev" source: hosted - version: "2.0.3" + version: "4.0.0" flutter_local_notifications: dependency: "direct main" description: @@ -412,10 +412,10 @@ packages: dependency: transitive description: name: lints - sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "4.0.0" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 954ed8f..3159b6e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -33,17 +33,17 @@ dependencies: shared_preferences: ^2.3.1 get: ^4.6.6 youtube_explode_dart: ^2.2.1 - path_provider: ^2.0.15 - http: ^1.0.0 + path_provider: ^2.1.4 + http: ^1.2.2 just_audio: ^0.9.39 just_audio_background: ^0.0.1-beta.13 - cached_network_image: ^3.2.3 - audio_video_progress_bar: ^1.0.1 - flutter_keyboard_visibility: ^5.4.1 + cached_network_image: ^3.4.0 + audio_video_progress_bar: ^2.0.3 + flutter_keyboard_visibility: ^6.0.0 text_scroll: ^0.2.0 - shimmer_animation: ^2.1.0+1 + shimmer_animation: ^2.2.1 flutter_local_notifications: ^17.2.2 - icons_launcher: ^2.1.2 + icons_launcher: ^2.1.7 dev_dependencies: flutter_test: @@ -54,7 +54,7 @@ dev_dependencies: # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. - flutter_lints: ^2.0.0 + flutter_lints: ^4.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec From 0b65f6a836ef140a438da050a8e93024c5f543a9 Mon Sep 17 00:00:00 2001 From: richard Date: Fri, 9 Aug 2024 16:37:52 +0200 Subject: [PATCH 3/3] feat: play downloaded result from download page --- lib/pages/search_page.dart | 15 +++- lib/widgets/navigation.dart | 13 ++- lib/widgets/result_tile.dart | 149 ++++++++++++++++++----------------- 3 files changed, 101 insertions(+), 76 deletions(-) diff --git a/lib/pages/search_page.dart b/lib/pages/search_page.dart index 6c0abc9..d307b15 100644 --- a/lib/pages/search_page.dart +++ b/lib/pages/search_page.dart @@ -10,6 +10,9 @@ import 'package:youtube_downloader/widgets/widgets.dart'; class SearchPage extends StatelessWidget { final VideoSearchController _searchController = Get.find(); + + final PlayerController _playerController = Get.find(); + final DownloadController _downloadController = Get.find(); final Debouncer _searchDebouncer = Debouncer(milliseconds: 200); @@ -63,7 +66,8 @@ class SearchPage extends StatelessWidget { key: ValueKey(result.id), result: result, saved: saved, - downloadCallback: () => _downloadController.download(result), + tapCallback: () => + saved ? _playResult(result) : _downloadController.download(result), ); } @@ -109,4 +113,13 @@ class SearchPage extends StatelessWidget { } }); } + + void _playResult(AudioInfo result) { + try { + final Audio audio = _downloadController.audios.firstWhere( + (Audio a) => a.id == result.id, + ); + _playerController.setCurrentAudioAndPlay(audio); + } catch (e) {} + } } diff --git a/lib/widgets/navigation.dart b/lib/widgets/navigation.dart index d26584a..43afcf3 100644 --- a/lib/widgets/navigation.dart +++ b/lib/widgets/navigation.dart @@ -8,7 +8,7 @@ import 'package:youtube_downloader/controllers/controllers.dart'; class Navigation extends StatelessWidget { final PlayerController _playerController = Get.find(); - static const double _navigationHeight = 80; + static const double _navigationHeight = 83; static const double _playerHeight = 72; static const double _margin = 5; @@ -116,10 +116,19 @@ class Navigation extends StatelessWidget { label, style: TextStyle( color: color, - fontSize: 11, + fontSize: 12, fontWeight: FontWeight.w700, ), ), + const SizedBox(height: 2), + Container( + height: 2, + width: 35, + decoration: BoxDecoration( + color: active ? AppColors.red : Colors.transparent, + borderRadius: BorderRadius.circular(5), + ), + ) ], ), ), diff --git a/lib/widgets/result_tile.dart b/lib/widgets/result_tile.dart index 647c462..9755c1a 100644 --- a/lib/widgets/result_tile.dart +++ b/lib/widgets/result_tile.dart @@ -6,89 +6,92 @@ import 'package:youtube_downloader/models/models.dart'; class ResultTile extends StatelessWidget { final AudioInfo _result; final bool _saved; - final Function _downloadCallback; + final Function _tapCallback; - const ResultTile({super.key, result, saved, downloadCallback}) + const ResultTile({super.key, result, saved, tapCallback}) : _result = result, _saved = saved, - _downloadCallback = downloadCallback; + _tapCallback = tapCallback; @override Widget build(BuildContext context) { final String duration = printDuration(_result.duration); final String channel = _result.channel; - return Padding( - padding: const EdgeInsets.fromLTRB(18, 10, 18, 10), - child: Row( - children: [ - SizedBox( - height: 65, - width: 65, - child: VideoThumbnail( - radius: 5, - url: _result.thumbnailMinResUrl, - ), - ), - Expanded( - child: Padding( - padding: const EdgeInsets.only(left: 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - _result.title, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - color: AppColors.white, - fontWeight: FontWeight.w800, - fontSize: 16, - ), - ), - Text( - channel, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - color: AppColors.lightGray, - fontSize: 14, - fontWeight: FontWeight.w400, - ), + return InkWell( + onTap: () => _tapCallback(), + child: Padding( + padding: const EdgeInsets.fromLTRB(18, 10, 18, 10), + child: Row( + children: [ + SizedBox( + height: 65, + width: 65, + child: VideoThumbnail( + radius: 5, + url: _result.thumbnailMinResUrl, + ), + ), + Expanded( + child: Padding( + padding: const EdgeInsets.only(left: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _result.title, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: AppColors.white, + fontWeight: FontWeight.w800, + fontSize: 16, + ), + ), + Text( + channel, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: AppColors.lightGray, + fontSize: 14, + fontWeight: FontWeight.w400, + ), + ), + Text( + duration, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + color: AppColors.lightGray, + fontSize: 14, + fontWeight: FontWeight.w400, + ), + ) + ], ), - Text( - duration, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - color: AppColors.lightGray, - fontSize: 14, - fontWeight: FontWeight.w400, - ), - ) - ], + ), ), - ), + if (!_saved) + Container( + height: 44, + width: 44, + margin: const EdgeInsets.only(left: 2), + child: const Icon( + AppIcons.download, + size: 22, + color: AppColors.lightGray, + ), + ), + if (_saved) + Container( + height: 44, + width: 44, + margin: const EdgeInsets.only(left: 8, right: 2), + child: const Icon( + AppIcons.cloudCheck, + size: 22, + color: AppColors.gray, + ), + ), + ], ), - if (!_saved) - IconButton( - padding: const EdgeInsets.only(left: 2), - color: AppColors.white, - onPressed: () => _downloadCallback(), - icon: const Icon( - AppIcons.download, - size: 22, - ), - ), - if (_saved) - Container( - height: 44, - width: 44, - margin: const EdgeInsets.only(left: 8, right: 2), - child: const Icon( - AppIcons.cloudCheck, - size: 22, - color: AppColors.gray, - ), - ), - ], - ), - ); + )); } }