diff --git a/Sources/justMUSIC/assets/images/loadingPlaceholder.gif b/Sources/justMUSIC/assets/images/loadingPlaceholder.gif new file mode 100644 index 0000000..490bf64 Binary files /dev/null and b/Sources/justMUSIC/assets/images/loadingPlaceholder.gif differ diff --git a/Sources/justMUSIC/lib/components/music_list_component.dart b/Sources/justMUSIC/lib/components/music_list_component.dart index 2173ce4..7aa8dfb 100644 --- a/Sources/justMUSIC/lib/components/music_list_component.dart +++ b/Sources/justMUSIC/lib/components/music_list_component.dart @@ -1,10 +1,14 @@ import 'package:flutter/Material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:justmusic/components/play_button_component.dart'; -import 'package:justmusic/values/constants.dart'; +import '../model/Music.dart'; class MusicListComponent extends StatelessWidget { - const MusicListComponent({Key? key}) : super(key: key); + final Music music; + const MusicListComponent({ + Key? key, + required this.music, + }) : super(key: key); @override Widget build(BuildContext context) { @@ -12,14 +16,26 @@ class MusicListComponent extends StatelessWidget { padding: const EdgeInsets.only(bottom: 14), child: Row( children: [ - const ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(5)), - child: Image( - image: AssetImage("assets/images/exemple_cover.png"), - width: 60, - height: 60, - ), - ), + LayoutBuilder( + builder: (BuildContext context, BoxConstraints constraints) { + if (music.cover != null) { + return ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(5)), + child: FadeInImage.assetNetwork( + height: 60, + width: 60, + fit: BoxFit.cover, + placeholder: "assets/images/loadingPlaceholder.gif", + image: music.cover!), + ); + } else { + return Image( + image: AssetImage("assets/images/exemple_cover.png"), + height: 60, + width: 60, + ); + } + }), const SizedBox( width: 10, ), @@ -39,7 +55,7 @@ class MusicListComponent extends StatelessWidget { alignment: WrapAlignment.end, children: [ Text( - "A.C. Milan", + music.title ?? "Unknown", overflow: TextOverflow.ellipsis, style: GoogleFonts.plusJakartaSans( fontSize: 16, @@ -54,7 +70,7 @@ class MusicListComponent extends StatelessWidget { ], ), Text( - "Booba", + music.artists.first.name ?? "Unknown", overflow: TextOverflow.ellipsis, style: GoogleFonts.plusJakartaSans( color: Colors.grey, fontWeight: FontWeight.w400), @@ -63,7 +79,9 @@ class MusicListComponent extends StatelessWidget { ), ), Spacer(), - PlayButtonComponent() + PlayButtonComponent( + urlPreview: music.previewUrl, + ) ], ), ); diff --git a/Sources/justMUSIC/lib/components/play_button_component.dart b/Sources/justMUSIC/lib/components/play_button_component.dart index 3c20faa..5c3c2e2 100644 --- a/Sources/justMUSIC/lib/components/play_button_component.dart +++ b/Sources/justMUSIC/lib/components/play_button_component.dart @@ -2,10 +2,11 @@ import 'package:audioplayers/audioplayers.dart'; import 'package:flutter/Material.dart'; import 'package:flutter_animated_play_button/flutter_animated_play_button.dart'; import 'package:ionicons/ionicons.dart'; -import 'package:justmusic/values/constants.dart'; class PlayButtonComponent extends StatefulWidget { - const PlayButtonComponent({Key? key}) : super(key: key); + final String? urlPreview; + const PlayButtonComponent({Key? key, required this.urlPreview}) + : super(key: key); @override State createState() => _PlayButtonComponentState(); @@ -37,11 +38,14 @@ class _PlayButtonComponentState extends State { return isPlaying ? GestureDetector( onTap: switchStatePlaying, - child: Icon( - Ionicons.play_circle_outline, - color: Colors.grey.withOpacity(0.3), - size: 30, - ), + child: Container( + width: 30, + height: 30, + child: Icon( + Ionicons.play_circle_outline, + color: Colors.grey.withOpacity(0.3), + size: 30, + )), ) : GestureDetector( onTap: switchStatePlaying, @@ -57,8 +61,9 @@ class _PlayButtonComponentState extends State { } Future playSong() async { - await player.play(UrlSource( - 'https://p.scdn.co/mp3-preview/d38052978a79adced2187cd8b6497bb10bedc452?cid=eb2aab666a43490f82eef0bb064d363f')); + if (widget.urlPreview != null) { + await player.play(UrlSource(widget.urlPreview ?? "")); + } } Future stopSong() async { diff --git a/Sources/justMUSIC/lib/screens/search_song_screen.dart b/Sources/justMUSIC/lib/screens/search_song_screen.dart index 8bf482c..c427c3a 100644 --- a/Sources/justMUSIC/lib/screens/search_song_screen.dart +++ b/Sources/justMUSIC/lib/screens/search_song_screen.dart @@ -66,10 +66,11 @@ class _SearchSongScreenState extends State { child: TextField( keyboardAppearance: Brightness.dark, onEditingComplete: resetFullScreen, - onSubmitted: (value) { - setState(() async { - filteredData = await MyApp.musicViewModel - .getMusicsWithName(value ?? ""); + onSubmitted: (value) async { + filteredData = + await MyApp.musicViewModel.getMusicsWithName(value); + setState(() { + filteredData = filteredData; }); }, cursorColor: Colors.white, @@ -109,12 +110,11 @@ class _SearchSongScreenState extends State { behavior: ScrollBehavior().copyWith(scrollbars: false), child: SizedBox( height: 200, - child: SingleChildScrollView( - child: ListView.builder( - itemCount: filteredData.length, - itemBuilder: (context, index) { - return Container(); - })), + child: ListView.builder( + itemCount: filteredData.length, + itemBuilder: (context, index) { + return MusicListComponent(music: filteredData[index]); + }), ), )) ], diff --git a/Sources/justMUSIC/pubspec.lock b/Sources/justMUSIC/pubspec.lock index 706cf83..843edcb 100644 --- a/Sources/justMUSIC/pubspec.lock +++ b/Sources/justMUSIC/pubspec.lock @@ -5,160 +5,140 @@ packages: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.11.0" + version: "2.9.0" audioplayers: dependency: "direct main" description: name: audioplayers - sha256: "61583554386721772f9309f509e17712865b38565a903c761f96b1115a979282" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "4.1.0" audioplayers_android: dependency: transitive description: name: audioplayers_android - sha256: dbdc9b7f2aa2440314c638aa55aadd45c7705e8340d5eddf2e3fb8da32d4ae2c - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "3.0.2" audioplayers_darwin: dependency: transitive description: name: audioplayers_darwin - sha256: "6aea96df1d12f7ad5a71d88c6d1b22a216211a9564219920124c16768e456e9d" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "4.1.0" audioplayers_linux: dependency: transitive description: name: audioplayers_linux - sha256: "396b62ac62c92dd26c3bc5106583747f57a8b325ebd2b41e5576f840cfc61338" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.1.0" audioplayers_platform_interface: dependency: transitive description: name: audioplayers_platform_interface - sha256: f7daaed4659143094151ecf6bacd927d29ab8acffba98c110c59f0b81ae51143 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "5.0.1" audioplayers_web: dependency: transitive description: name: audioplayers_web - sha256: ec84fd46eed1577148ed4113f5998a36a18da4fce7170c37ce3e21b631393339 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "3.1.0" audioplayers_windows: dependency: transitive description: name: audioplayers_windows - sha256: "1d3aaac98a192b8488167711ba1e67d8b96333e8d0572ede4e2912e5bbce69a3" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.2" auto_size_text: dependency: "direct main" description: name: auto_size_text - sha256: "3f5261cd3fb5f2a9ab4e2fc3fba84fd9fcaac8821f20a1d4e71f557521b22599" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "3.0.0" boolean_selector: dependency: transitive description: name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" characters: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.2.1" circular_reveal_animation: dependency: "direct main" description: name: circular_reveal_animation - sha256: "198f5a1fa27384dcf950807e0ae07a0da857c04df6233f7468755ee9db102b0c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.1" clock: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.1.1" collection: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.17.1" + version: "1.16.0" crypto: dependency: transitive description: name: crypto - sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "3.0.2" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.0.5" custom_draggable_widget: dependency: "direct main" description: name: custom_draggable_widget - sha256: "15718003ebcebb84acdf0c625831a880d139a284d8de9d943ef0d0a669f10159" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.0.2" fake_async: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.3.1" ffi: dependency: transitive description: name: ffi - sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.2" file: dependency: transitive description: name: file - sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "6.1.4" flutter: @@ -170,32 +150,28 @@ packages: dependency: "direct main" description: name: flutter_animated_play_button - sha256: dd955a450a4514e935e2f410afbd03b3bcf5f31b933a8f1334199caa3c6a81e2 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.3.0" flutter_lints: dependency: "direct dev" description: name: flutter_lints - sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.2" flutter_screenutil: dependency: "direct main" description: name: flutter_screenutil - sha256: "0a122936b450324cbdfd51be0819cc6fcebb093eb65585e9cd92263f7a1a8a39" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "5.7.0" flutter_signin_button: dependency: "direct main" description: name: flutter_signin_button - sha256: a063ecc5d5308377e103c9c3a89084abf15fca4440636233af6a13abacd5dcae - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.0" flutter_test: @@ -212,176 +188,154 @@ packages: dependency: transitive description: name: font_awesome_flutter - sha256: "1f93e5799f0e6c882819e8393a05c6ca5226010f289190f2242ec19f3f0fdba5" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "9.2.0" google_fonts: dependency: "direct main" description: name: google_fonts - sha256: "6b6f10f0ce3c42f6552d1c70d2c28d764cf22bb487f50f66cca31dcd5194f4d6" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "4.0.4" gradiantbutton: dependency: "direct main" description: name: gradiantbutton - sha256: c88ac8567242630cd14231e2a6a861da4e40a02a9a0310af360e05634890d172 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.0.1" gradient_borders: dependency: "direct main" description: name: gradient_borders - sha256: "69eeaff519d145a4c6c213ada1abae386bcc8981a4970d923e478ce7ba19e309" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.0.0" http: dependency: "direct main" description: name: http - sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.13.5" http_parser: dependency: transitive description: name: http_parser - sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "4.0.2" ionicons: dependency: "direct main" description: name: ionicons - sha256: "5496bc65a16115ecf05b15b78f494ee4a8869504357668f0a11d689e970523cf" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.2.2" js: dependency: transitive description: name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.6.7" + version: "0.6.4" lints: dependency: transitive description: name: lints - sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.1" matcher: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.12.15" + version: "0.12.12" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.1.5" meta: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.9.1" + version: "1.8.0" modal_bottom_sheet: dependency: "direct main" description: name: modal_bottom_sheet - sha256: ef533916a2c3089571c32bd34e410faca77a6849a3f28f748e0794525c5658a0 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.1.2" path: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.8.3" + version: "1.8.2" path_provider: dependency: transitive description: name: path_provider - sha256: "3087813781ab814e4157b172f1a11c46be20179fcc9bea043e0fba36bc0acaa2" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.15" path_provider_android: dependency: transitive description: name: path_provider_android - sha256: "2cec049d282c7f13c594b4a73976b0b4f2d7a1838a6dd5aaf7bd9719196bee86" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.27" path_provider_foundation: dependency: transitive description: name: path_provider_foundation - sha256: "916731ccbdce44d545414dd9961f26ba5fbaa74bcbb55237d8e65a623a8c7297" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.2.4" path_provider_linux: dependency: transitive description: name: path_provider_linux - sha256: ffbb8cc9ed2c9ec0e4b7a541e56fd79b138e8f47d2fb86815f15358a349b3b57 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.1.11" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - sha256: "57585299a729335f1298b43245842678cb9f43a6310351b18fb577d6e33165ec" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.0.6" path_provider_windows: dependency: transitive description: name: path_provider_windows - sha256: "1cb68ba4cd3a795033de62ba1b7b4564dace301f952de6bfb3cd91b202b6ee96" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.1.7" platform: dependency: transitive description: name: platform - sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "3.1.0" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - sha256: "43798d895c929056255600343db8f049921cbec94d31ec87f1dc5c16c01935dd" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "2.1.5" sky_engine: @@ -393,130 +347,114 @@ packages: dependency: "direct main" description: name: smooth_corner - sha256: "1e920cffd9644d6f51f9a99674652f8c00f2e9074b275f3edde0de1441ba78e9" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" source_span: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.9.1" + version: "1.9.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.11.0" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.1" synchronized: dependency: transitive description: name: synchronized - sha256: "5fcbd27688af6082f5abd611af56ee575342c30e87541d0245f7ff99faa02c60" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "3.1.0" term_glyph: dependency: transitive description: name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.2.1" test_api: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "0.5.1" + version: "0.4.12" text_scroll: dependency: "direct main" description: name: text_scroll - sha256: "7869d86a6fdd725dee56bdd150216a99f0372b82fbfcac319214dbd5f36e1908" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "0.2.0" top_snackbar_flutter: dependency: "direct main" description: name: top_snackbar_flutter - sha256: "22d14664a13db6ac714934c3382bd8d4daa57fb888a672f922df71981c5a5cb2" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "3.1.0" typed_data: dependency: transitive description: name: typed_data - sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.3.2" uuid: dependency: transitive description: name: uuid - sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "3.0.7" vector_math: dependency: transitive description: name: vector_math - sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted - version: "2.1.4" + version: "2.1.2" win32: dependency: transitive description: name: win32 - sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "4.1.4" xdg_directories: dependency: transitive description: name: xdg_directories - sha256: e0b1147eec179d3911f1f19b59206448f78195ca1d20514134e10641b7d7fbff - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.0.1" zoom_tap_animation: dependency: "direct main" description: name: zoom_tap_animation - sha256: d9f7a73cab65aa1546ba6886b5e21d3c8ccccb34e4e5f770301c306d4868bee0 - url: "https://pub.dev" + url: "https://pub.dartlang.org" source: hosted version: "1.1.0" sdks: - dart: ">=3.0.0-0 <4.0.0" + dart: ">=2.18.2 <3.0.0" flutter: ">=3.3.0" diff --git a/Sources/justMUSIC/pubspec.yaml b/Sources/justMUSIC/pubspec.yaml index 339aa4f..1a52f91 100644 --- a/Sources/justMUSIC/pubspec.yaml +++ b/Sources/justMUSIC/pubspec.yaml @@ -79,6 +79,7 @@ flutter: # To add assets to your application, add an assets section, like this: assets: - assets/images/ + - assets/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware