From 1abcd1a5a9f51f87561564c93501e45bb06242ae Mon Sep 17 00:00:00 2001 From: Lucas Delanier Date: Sun, 30 Jul 2023 02:44:01 +0200 Subject: [PATCH 1/2] fix playing song --- Sources/justMUSIC/android/build.gradle | 2 +- .../lib/components/buttonPostComponent.dart | 15 ++ .../components/editable_post_component.dart | 129 +++++++++++----- .../justMUSIC/lib/screens/feed_screen.dart | 1 + .../justMUSIC/lib/screens/post_screen.dart | 5 +- Sources/justMUSIC/lib/values/constants.dart | 1 + Sources/justMUSIC/pubspec.lock | 144 ++++++++++++++++-- Sources/justMUSIC/pubspec.yaml | 1 + 8 files changed, 239 insertions(+), 59 deletions(-) create mode 100644 Sources/justMUSIC/lib/components/buttonPostComponent.dart diff --git a/Sources/justMUSIC/android/build.gradle b/Sources/justMUSIC/android/build.gradle index 3cdaac9..36cfe3f 100644 --- a/Sources/justMUSIC/android/build.gradle +++ b/Sources/justMUSIC/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.9.0' repositories { google() mavenCentral() diff --git a/Sources/justMUSIC/lib/components/buttonPostComponent.dart b/Sources/justMUSIC/lib/components/buttonPostComponent.dart new file mode 100644 index 0000000..10be7f9 --- /dev/null +++ b/Sources/justMUSIC/lib/components/buttonPostComponent.dart @@ -0,0 +1,15 @@ +import 'package:flutter/Material.dart'; + +import '../values/constants.dart'; + +class ButtonPostComponent extends StatelessWidget { + const ButtonPostComponent({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.fromLTRB(20, 5, 20, 5), + color: postbutton, + ); + } +} diff --git a/Sources/justMUSIC/lib/components/editable_post_component.dart b/Sources/justMUSIC/lib/components/editable_post_component.dart index b25b1c8..234974a 100644 --- a/Sources/justMUSIC/lib/components/editable_post_component.dart +++ b/Sources/justMUSIC/lib/components/editable_post_component.dart @@ -1,71 +1,116 @@ +import 'dart:io'; + import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/Material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:image_picker/image_picker.dart'; import 'package:justmusic/values/constants.dart'; class EditablePostComponent extends StatefulWidget { - const EditablePostComponent({Key? key}) : super(key: key); + final Function callback; + const EditablePostComponent({Key? key, required this.callback}) + : super(key: key); @override State createState() => _EditablePostComponentState(); } class _EditablePostComponentState extends State { + final ImagePicker picker = ImagePicker(); + File? image; + + Future pickImage() async { + try { + final image = await ImagePicker().pickImage(source: ImageSource.gallery); + if (image == null) return; + final imageTemp = File(image.path); + setState(() { + this.image = imageTemp; + }); + } on PlatformException catch (e) { + print('Failed to pick image: $e'); + } + } + @override Widget build(BuildContext context) { return ClipRRect( borderRadius: BorderRadius.circular(25), child: Container( - constraints: BoxConstraints(maxWidth: 400), + constraints: BoxConstraints(maxWidth: 400, minHeight: 500), width: double.infinity, color: warningBttnColor, - child: Column( + child: Stack( + alignment: Alignment.topCenter, children: [ AspectRatio( - aspectRatio: 1 / 1, - child: Container( - decoration: BoxDecoration( - // add border - border: Border.all(width: 3.0, color: grayColor), - // set border radius - borderRadius: BorderRadius.circular(20), - ), - child: ClipRRect( - borderRadius: BorderRadius.circular(18), - // implement image - child: const Image( - image: AssetImage("assets/images/exemple_cover.png"), - fit: BoxFit.cover, - width: double.infinity, + aspectRatio: 1 / 1, + child: GestureDetector( + onTap: () { + print("cc"); + widget.callback; + }, + child: Container( + decoration: BoxDecoration( + // add border + border: Border.all(width: 3.0, color: grayColor), + // set border radius + borderRadius: BorderRadius.circular(20), + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(18), + // implement image + child: const Image( + image: AssetImage("assets/images/exemple_cover.png"), + fit: BoxFit.cover, + width: double.infinity, + ), + ), ), + )), + Positioned( + bottom: 40, + child: Padding( + padding: EdgeInsets.fromLTRB(15, 25, 15, 25), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AutoSizeText( + "France, Lyon", + style: GoogleFonts.plusJakartaSans( + color: Colors.white, fontSize: 13.sp), + maxFontSize: 20, + ), + image == null + ? GestureDetector( + child: Image( + image: + AssetImage("assets/images/camera_icon.png"), + width: 30, + ), + onTap: () { + print("cc2"); + + pickImage(); + }, + ) + : Container( + height: 80, + width: 80, + child: Image.file(image!), + ), + AutoSizeText( + "10 Juil. 2023", + style: GoogleFonts.plusJakartaSans( + color: Colors.white, fontSize: 13.sp), + maxFontSize: 20, + ), + ], ), ), ), - Padding( - padding: EdgeInsets.fromLTRB(15, 25, 15, 25), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AutoSizeText( - "France, Lyon", - style: GoogleFonts.plusJakartaSans( - color: Colors.white, fontSize: 13.sp), - maxFontSize: 20, - ), - Image( - image: AssetImage("assets/images/camera_icon.png"), - width: 30, - ), - AutoSizeText( - "10 Juil. 2023", - style: GoogleFonts.plusJakartaSans( - color: Colors.white, fontSize: 13.sp), - maxFontSize: 20, - ), - ], - ), - ), Padding( padding: EdgeInsets.fromLTRB(15, 0, 10, 25), child: SizedBox( diff --git a/Sources/justMUSIC/lib/screens/feed_screen.dart b/Sources/justMUSIC/lib/screens/feed_screen.dart index afc113e..a369c4c 100644 --- a/Sources/justMUSIC/lib/screens/feed_screen.dart +++ b/Sources/justMUSIC/lib/screens/feed_screen.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:image_picker/image_picker.dart'; import '../components/comment_component.dart'; import '../components/post_component.dart'; import '../components/top_nav_bar_component.dart'; diff --git a/Sources/justMUSIC/lib/screens/post_screen.dart b/Sources/justMUSIC/lib/screens/post_screen.dart index e6a625b..51b2a27 100644 --- a/Sources/justMUSIC/lib/screens/post_screen.dart +++ b/Sources/justMUSIC/lib/screens/post_screen.dart @@ -103,10 +103,7 @@ class _PostScreenState extends State SizedBox( height: 100.h, ), - GestureDetector( - onTap: openDetailPost, - child: EditablePostComponent(), - ), + EditablePostComponent(callback: openDetailPost), SizedBox( height: 40.h, ), diff --git a/Sources/justMUSIC/lib/values/constants.dart b/Sources/justMUSIC/lib/values/constants.dart index f29ef36..e3512f9 100644 --- a/Sources/justMUSIC/lib/values/constants.dart +++ b/Sources/justMUSIC/lib/values/constants.dart @@ -20,6 +20,7 @@ const bgAppBar = Color(0xFF181818); const grayText = Color(0xFF898989); const settingColor = Color(0xFF232323); const searchBarColor = Color(0xFF161616); +const postbutton = Color(0xFF1B1B1B); // All constants important too us const defaultPadding = 30.0; diff --git a/Sources/justMUSIC/pubspec.lock b/Sources/justMUSIC/pubspec.lock index 706cf83..afce498 100644 --- a/Sources/justMUSIC/pubspec.lock +++ b/Sources/justMUSIC/pubspec.lock @@ -113,14 +113,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.17.1" + cross_file: + dependency: transitive + description: + name: cross_file + sha256: "0b0036e8cccbfbe0555fd83c1d31a6f30b77a96b598b35a5d36dd41f718695e9" + url: "https://pub.dev" + source: hosted + version: "0.3.3+4" crypto: dependency: transitive description: name: crypto - sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.0.3" cupertino_icons: dependency: "direct main" description: @@ -161,6 +169,38 @@ packages: url: "https://pub.dev" source: hosted version: "6.1.4" + file_selector_linux: + dependency: transitive + description: + name: file_selector_linux + sha256: "770eb1ab057b5ae4326d1c24cc57710758b9a46026349d021d6311bd27580046" + url: "https://pub.dev" + source: hosted + version: "0.9.2" + file_selector_macos: + dependency: transitive + description: + name: file_selector_macos + sha256: "4ada532862917bf16e3adb3891fe3a5917a58bae03293e497082203a80909412" + url: "https://pub.dev" + source: hosted + version: "0.9.3+1" + file_selector_platform_interface: + dependency: transitive + description: + name: file_selector_platform_interface + sha256: "412705a646a0ae90f33f37acfae6a0f7cbc02222d6cd34e479421c3e74d3853c" + url: "https://pub.dev" + source: hosted + version: "2.6.0" + file_selector_windows: + dependency: transitive + description: + name: file_selector_windows + sha256: "1372760c6b389842b77156203308940558a2817360154084368608413835fc26" + url: "https://pub.dev" + source: hosted + version: "0.9.3" flutter: dependency: "direct main" description: flutter @@ -182,14 +222,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: "950e77c2bbe1692bc0874fc7fb491b96a4dc340457f4ea1641443d0a6c1ea360" + url: "https://pub.dev" + source: hosted + version: "2.0.15" flutter_screenutil: dependency: "direct main" description: name: flutter_screenutil - sha256: "0a122936b450324cbdfd51be0819cc6fcebb093eb65585e9cd92263f7a1a8a39" + sha256: "1b61f8c4cbf965104b6ca7160880ff1af6755aad7fec70b58444245132453745" url: "https://pub.dev" source: hosted - version: "5.7.0" + version: "5.8.4" flutter_signin_button: dependency: "direct main" description: @@ -244,10 +292,10 @@ packages: dependency: "direct main" description: name: http - sha256: "6aa2946395183537c8b880962d935877325d6a09a2867c3970c05c0fed6ac482" + sha256: "5895291c13fa8a3bd82e76d5627f69e0d85ca6a30dcac95c4ea19a5d555879c2" url: "https://pub.dev" source: hosted - version: "0.13.5" + version: "0.13.6" http_parser: dependency: transitive description: @@ -256,6 +304,70 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + image_picker: + dependency: "direct main" + description: + name: image_picker + sha256: "6296e98782726d37f59663f0727d0e978eee1ced1ffed45ccaba591786a7f7b3" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + image_picker_android: + dependency: transitive + description: + name: image_picker_android + sha256: "8179b54039b50eee561676232304f487602e2950ffb3e8995ed9034d6505ca34" + url: "https://pub.dev" + source: hosted + version: "0.8.7+4" + image_picker_for_web: + dependency: transitive + description: + name: image_picker_for_web + sha256: "869fe8a64771b7afbc99fc433a5f7be2fea4d1cb3d7c11a48b6b579eb9c797f0" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + image_picker_ios: + dependency: transitive + description: + name: image_picker_ios + sha256: b3e2f21feb28b24dd73a35d7ad6e83f568337c70afab5eabac876e23803f264b + url: "https://pub.dev" + source: hosted + version: "0.8.8" + image_picker_linux: + dependency: transitive + description: + name: image_picker_linux + sha256: "02cbc21fe1706b97942b575966e5fbbeaac535e76deef70d3a242e4afb857831" + url: "https://pub.dev" + source: hosted + version: "0.2.1" + image_picker_macos: + dependency: transitive + description: + name: image_picker_macos + sha256: cee2aa86c56780c13af2c77b5f2f72973464db204569e1ba2dd744459a065af4 + url: "https://pub.dev" + source: hosted + version: "0.2.1" + image_picker_platform_interface: + dependency: transitive + description: + name: image_picker_platform_interface + sha256: c1134543ae2187e85299996d21c526b2f403854994026d575ae4cf30d7bb2a32 + url: "https://pub.dev" + source: hosted + version: "2.9.0" + image_picker_windows: + dependency: transitive + description: + name: image_picker_windows + sha256: c3066601ea42113922232c7b7b3330a2d86f029f685bba99d82c30e799914952 + url: "https://pub.dev" + source: hosted + version: "0.2.1" ionicons: dependency: "direct main" description: @@ -276,10 +388,10 @@ packages: dependency: transitive description: name: lints - sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.1" matcher: dependency: transitive description: @@ -304,6 +416,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" + mime: + dependency: transitive + description: + name: mime + sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + url: "https://pub.dev" + source: hosted + version: "1.0.4" modal_bottom_sheet: dependency: "direct main" description: @@ -497,10 +617,10 @@ packages: dependency: transitive description: name: win32 - sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" + sha256: f2add6fa510d3ae152903412227bda57d0d5a8da61d2c39c1fb022c9429a41c0 url: "https://pub.dev" source: hosted - version: "4.1.4" + version: "5.0.6" xdg_directories: dependency: transitive description: @@ -518,5 +638,5 @@ packages: source: hosted version: "1.1.0" sdks: - dart: ">=3.0.0-0 <4.0.0" - flutter: ">=3.3.0" + dart: ">=3.0.0 <4.0.0" + flutter: ">=3.10.0" diff --git a/Sources/justMUSIC/pubspec.yaml b/Sources/justMUSIC/pubspec.yaml index 1a52f91..13380a9 100644 --- a/Sources/justMUSIC/pubspec.yaml +++ b/Sources/justMUSIC/pubspec.yaml @@ -53,6 +53,7 @@ dependencies: audioplayers: ^4.1.0 ionicons: ^0.2.2 top_snackbar_flutter: ^3.1.0 + image_picker: ^1.0.1 dev_dependencies: flutter_test: From b520ad520479258708e8a90358673a2c755bf96f Mon Sep 17 00:00:00 2001 From: Lucas Delanier Date: Sun, 30 Jul 2023 05:15:15 +0200 Subject: [PATCH 2/2] start select image --- .../lib/components/buttonPostComponent.dart | 117 +++++++- .../components/editable_post_component.dart | 253 +++++++++++++----- .../lib/components/music_list_component.dart | 2 +- .../lib/components/play_button_component.dart | 8 +- .../justMUSIC/lib/screens/post_screen.dart | 66 ++--- .../lib/screens/search_song_screen.dart | 49 ++-- Sources/justMUSIC/lib/values/constants.dart | 1 + Sources/justMUSIC/pubspec.lock | 32 +++ Sources/justMUSIC/pubspec.yaml | 4 + 9 files changed, 406 insertions(+), 126 deletions(-) diff --git a/Sources/justMUSIC/lib/components/buttonPostComponent.dart b/Sources/justMUSIC/lib/components/buttonPostComponent.dart index 10be7f9..166f426 100644 --- a/Sources/justMUSIC/lib/components/buttonPostComponent.dart +++ b/Sources/justMUSIC/lib/components/buttonPostComponent.dart @@ -1,15 +1,120 @@ import 'package:flutter/Material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:ionicons/ionicons.dart'; import '../values/constants.dart'; -class ButtonPostComponent extends StatelessWidget { - const ButtonPostComponent({Key? key}) : super(key: key); +class PhotoPostComponent extends StatelessWidget { + final bool empty; + const PhotoPostComponent({Key? key, required this.empty}) : super(key: key); @override Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.fromLTRB(20, 5, 20, 5), - color: postbutton, - ); + return empty + ? Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: postbutton, borderRadius: BorderRadius.circular(8)), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Ionicons.camera, + size: 15, + color: Colors.white, + ), + SizedBox( + width: 10, + ), + Text( + 'Prendre un selfie', + style: GoogleFonts.plusJakartaSans( + color: Colors.white, fontSize: 12), + ) + ]), + ) + : Container( + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: fillButton, borderRadius: BorderRadius.circular(8)), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Selfie enregistré", + style: GoogleFonts.plusJakartaSans( + color: Colors.white, fontSize: 12), + ), + SizedBox( + width: 10, + ), + Icon( + Icons.close, + size: 12, + color: Colors.white, + ), + ]), + ); + } +} + +class LocationPostComponent extends StatelessWidget { + final bool empty; + const LocationPostComponent({Key? key, required this.empty}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return empty + ? Container( + width: double.infinity, + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: postbutton, borderRadius: BorderRadius.circular(8)), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + Icons.location_on, + size: 15, + color: Colors.white, + ), + SizedBox( + width: 10, + ), + Text( + 'Ajouter un lieu', + style: GoogleFonts.plusJakartaSans( + color: Colors.white, fontSize: 12), + ) + ]), + ) + : Container( + width: double.infinity, + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + color: fillButton, borderRadius: BorderRadius.circular(8)), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Lieu enregistré", + style: GoogleFonts.plusJakartaSans( + color: Colors.white, fontSize: 12), + ), + SizedBox( + width: 10, + ), + Icon( + Icons.close, + size: 12, + color: Colors.white, + ), + ]), + ); } } diff --git a/Sources/justMUSIC/lib/components/editable_post_component.dart b/Sources/justMUSIC/lib/components/editable_post_component.dart index 234974a..dda4c74 100644 --- a/Sources/justMUSIC/lib/components/editable_post_component.dart +++ b/Sources/justMUSIC/lib/components/editable_post_component.dart @@ -1,24 +1,33 @@ import 'dart:io'; +import 'package:animated_appear/animated_appear.dart'; import 'package:auto_size_text/auto_size_text.dart'; +import 'package:circular_reveal_animation/circular_reveal_animation.dart'; import 'package:flutter/Material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:insta_image_viewer/insta_image_viewer.dart'; import 'package:justmusic/values/constants.dart'; +import 'package:text_scroll/text_scroll.dart'; + +import '../model/Music.dart'; +import 'buttonPostComponent.dart'; class EditablePostComponent extends StatefulWidget { - final Function callback; - const EditablePostComponent({Key? key, required this.callback}) - : super(key: key); + final Music? music; + const EditablePostComponent({Key? key, this.music}) : super(key: key); @override State createState() => _EditablePostComponentState(); } -class _EditablePostComponentState extends State { +class _EditablePostComponentState extends State + with TickerProviderStateMixin { final ImagePicker picker = ImagePicker(); + late Animation animation; + late AnimationController animationController; File? image; Future pickImage() async { @@ -34,6 +43,20 @@ class _EditablePostComponentState extends State { } } + @override + void initState() { + animationController = AnimationController( + vsync: this, + duration: Duration(milliseconds: 400), + ); + animation = CurvedAnimation( + parent: animationController, + curve: Curves.easeInOutSine, + ); + animationController.forward(); + super.initState(); + } + @override Widget build(BuildContext context) { return ClipRRect( @@ -42,73 +65,165 @@ class _EditablePostComponentState extends State { constraints: BoxConstraints(maxWidth: 400, minHeight: 500), width: double.infinity, color: warningBttnColor, - child: Stack( - alignment: Alignment.topCenter, + child: Column( children: [ - AspectRatio( - aspectRatio: 1 / 1, - child: GestureDetector( - onTap: () { - print("cc"); - widget.callback; - }, - child: Container( - decoration: BoxDecoration( - // add border - border: Border.all(width: 3.0, color: grayColor), - // set border radius - borderRadius: BorderRadius.circular(20), - ), - child: ClipRRect( - borderRadius: BorderRadius.circular(18), - // implement image - child: const Image( - image: AssetImage("assets/images/exemple_cover.png"), - fit: BoxFit.cover, - width: double.infinity, + CircularRevealAnimation( + animation: animation, + centerOffset: Offset(30.w, -100), + child: Stack( + children: [ + AspectRatio( + aspectRatio: 1 / 1, + child: Container( + decoration: BoxDecoration( + // add border + border: Border.all(width: 3.0, color: grayColor), + // set border radius + borderRadius: BorderRadius.circular(20), + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(18), + // implement image + child: widget.music == null + ? Container( + color: grayColor, + width: double.infinity, + ) + : Image( + image: + NetworkImage(widget.music?.cover ?? ""), + fit: BoxFit.cover, + width: double.infinity, + ), + ), ), ), - ), + image != null + ? Positioned( + top: 10, + right: 10, + child: AnimatedAppear( + delay: Duration(milliseconds: 500), + duration: Duration(milliseconds: 400), + child: Container( + width: 110, + height: 110, + decoration: BoxDecoration( + image: DecorationImage( + image: FileImage(image!), + fit: BoxFit.cover, + ), + color: grayColor, + borderRadius: BorderRadius.circular(20), + border: Border.all( + style: BorderStyle.solid, + color: Colors.white, + width: 4)), + child: ClipRRect( + borderRadius: BorderRadius.circular(20), + child: InstaImageViewer( + backgroundIsTransparent: true, + child: Image( + image: FileImage(image!), + fit: BoxFit.cover, + ), + ), + ), + ), + )) + : Container() + ], )), - Positioned( - bottom: 40, - child: Padding( - padding: EdgeInsets.fromLTRB(15, 25, 15, 25), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AutoSizeText( - "France, Lyon", - style: GoogleFonts.plusJakartaSans( - color: Colors.white, fontSize: 13.sp), - maxFontSize: 20, - ), - image == null - ? GestureDetector( - child: Image( - image: - AssetImage("assets/images/camera_icon.png"), - width: 30, + widget.music != null + ? Padding( + padding: const EdgeInsets.all(10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Flexible( + flex: 8, + child: TextScroll( + (widget.music?.title)!, + style: GoogleFonts.plusJakartaSans( + height: 1, + color: Colors.white, + fontWeight: FontWeight.w600, + fontSize: 26.h), + mode: TextScrollMode.endless, + pauseBetween: Duration(milliseconds: 500), + velocity: + Velocity(pixelsPerSecond: Offset(20, 0)), + )), + Padding( + padding: EdgeInsets.only( + bottom: 10.h, right: 5.w, left: 5.w), + child: ClipOval( + child: Container( + width: 5.h, + height: 5.h, + color: Colors.white, ), - onTap: () { - print("cc2"); - - pickImage(); - }, - ) - : Container( - height: 80, - width: 80, - child: Image.file(image!), ), - AutoSizeText( - "10 Juil. 2023", - style: GoogleFonts.plusJakartaSans( - color: Colors.white, fontSize: 13.sp), - maxFontSize: 20, + ), + Flexible( + flex: 6, + child: Padding( + padding: EdgeInsets.only(bottom: 2), + child: TextScroll( + (widget.music?.artists[0].name)!, + style: GoogleFonts.plusJakartaSans( + height: 1, + color: Colors.white, + fontWeight: FontWeight.w300, + fontSize: 16.h), + mode: TextScrollMode.endless, + velocity: + Velocity(pixelsPerSecond: Offset(50, 20)), + pauseBetween: Duration(milliseconds: 500), + ), + )), + Container(width: 10), + AutoSizeText( + "2013", + style: GoogleFonts.plusJakartaSans( + color: Colors.white.withOpacity(0.5), + fontWeight: FontWeight.w300, + fontSize: 16.h), + textAlign: TextAlign.end, + maxFontSize: 20, + ), + ], ), - ], - ), + ) + : Container(), + Container( + padding: EdgeInsets.fromLTRB(15, 15, 15, 25), + width: double.infinity, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + flex: 5, + child: GestureDetector( + onTap: () { + manageImage(); + }, + child: PhotoPostComponent( + empty: image == null, + ), + ), + ), + SizedBox( + width: 15, + ), + Expanded( + flex: 5, + child: LocationPostComponent( + empty: true, + ), + ), + ], ), ), Padding( @@ -155,4 +270,14 @@ class _EditablePostComponentState extends State { ), )); } + + void manageImage() { + if (image != null) { + setState(() { + image = null; + }); + } else { + pickImage(); + } + } } diff --git a/Sources/justMUSIC/lib/components/music_list_component.dart b/Sources/justMUSIC/lib/components/music_list_component.dart index 1cbc516..93c5c42 100644 --- a/Sources/justMUSIC/lib/components/music_list_component.dart +++ b/Sources/justMUSIC/lib/components/music_list_component.dart @@ -9,7 +9,7 @@ class MusicListComponent extends StatelessWidget { final bool playing; final int index; final Function(int) callback; - const MusicListComponent({ + MusicListComponent({ Key? key, required this.music, required this.playing, diff --git a/Sources/justMUSIC/lib/components/play_button_component.dart b/Sources/justMUSIC/lib/components/play_button_component.dart index 9c4ebb0..237881d 100644 --- a/Sources/justMUSIC/lib/components/play_button_component.dart +++ b/Sources/justMUSIC/lib/components/play_button_component.dart @@ -10,8 +10,8 @@ class PlayButtonComponent extends StatefulWidget { final Music music; final Function callback; final int index; - bool playing; - PlayButtonComponent( + final bool playing; + const PlayButtonComponent( {Key? key, required this.music, required this.callback, @@ -63,7 +63,9 @@ class _PlayButtonComponentState extends State { child: AnimatedPlayButton( stopped: false, color: Colors.grey.withOpacity(0.3), - onPressed: () {}, + onPressed: () { + print("cc"); + }, ), )); } diff --git a/Sources/justMUSIC/lib/screens/post_screen.dart b/Sources/justMUSIC/lib/screens/post_screen.dart index 51b2a27..ecc1051 100644 --- a/Sources/justMUSIC/lib/screens/post_screen.dart +++ b/Sources/justMUSIC/lib/screens/post_screen.dart @@ -5,6 +5,7 @@ import 'package:justmusic/components/back_button.dart'; import 'package:justmusic/screens/search_song_screen.dart'; import '../components/editable_post_component.dart'; import '../components/post_button_component.dart'; +import '../model/Music.dart'; import '../values/constants.dart'; class PostScreen extends StatefulWidget { @@ -18,7 +19,8 @@ class _PostScreenState extends State with SingleTickerProviderStateMixin { final scrollController = ScrollController(); late AnimationController _controller; - late Animation _animation; + + Music? selectedMusic; @override void initState() { @@ -27,15 +29,16 @@ class _PostScreenState extends State duration: const Duration(milliseconds: 400), ); - _animation = Tween(begin: 0.0, end: 400.0).animate( - CurvedAnimation( - parent: _controller, - curve: Curves.easeOut, - ), - ); super.initState(); } + void _selectMusic(Music music) { + Navigator.pop(context); + setState(() { + selectedMusic = music; + }); + } + void openDetailPost() { showModalBottomSheet( transitionAnimationController: _controller, @@ -51,10 +54,10 @@ class _PostScreenState extends State borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20))), builder: ((context) { - return const ClipRRect( + return ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20)), - child: SearchSongScreen()); + child: SearchSongScreen(callback: _selectMusic)); }), ); } @@ -90,32 +93,29 @@ class _PostScreenState extends State fit: BoxFit.cover, ), ), - child: Stack( - alignment: Alignment.topCenter, - children: [ - ScrollConfiguration( - behavior: ScrollBehavior().copyWith(scrollbars: false), - child: SingleChildScrollView( - controller: scrollController, - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - SizedBox( - height: 100.h, - ), - EditablePostComponent(callback: openDetailPost), - SizedBox( - height: 40.h, - ), - PostButtonComponent(), - SizedBox( - height: 40.h, - ), - ], + child: ScrollConfiguration( + behavior: ScrollBehavior().copyWith(scrollbars: false), + child: SingleChildScrollView( + controller: scrollController, + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + SizedBox( + height: 100.h, + ), + GestureDetector( + onTap: openDetailPost, + child: EditablePostComponent(music: selectedMusic)), + SizedBox( + height: 40.h, ), - ), + PostButtonComponent(), + SizedBox( + height: 40.h, + ), + ], ), - ], + ), ), ), ); diff --git a/Sources/justMUSIC/lib/screens/search_song_screen.dart b/Sources/justMUSIC/lib/screens/search_song_screen.dart index 1042b6a..8ef2ecc 100644 --- a/Sources/justMUSIC/lib/screens/search_song_screen.dart +++ b/Sources/justMUSIC/lib/screens/search_song_screen.dart @@ -11,7 +11,8 @@ import '../values/constants.dart'; import '../main.dart'; class SearchSongScreen extends StatefulWidget { - const SearchSongScreen({Key? key}) : super(key: key); + final Function callback; + const SearchSongScreen({Key? key, required this.callback}) : super(key: key); @override State createState() => _SearchSongScreenState(); @@ -169,25 +170,35 @@ class _SearchSongScreenState extends State { itemCount: filteredData.length, itemBuilder: (context, index) { if (playingIndex == index) { - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 20), - child: MusicListComponent( - music: filteredData[index], - playing: true, - callback: playMusic, - index: index, - ), - ); + return InkWell( + onTap: () { + widget.callback(filteredData[index]); + }, + child: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 20), + child: MusicListComponent( + music: filteredData[index], + playing: true, + callback: playMusic, + index: index, + ), + )); } - return Padding( - padding: const EdgeInsets.symmetric(horizontal: 20), - child: MusicListComponent( - music: filteredData[index], - playing: false, - callback: playMusic, - index: index, - ), - ); + return InkWell( + onTap: () { + widget.callback(filteredData[index]); + }, + child: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 20), + child: MusicListComponent( + music: filteredData[index], + playing: false, + callback: playMusic, + index: index, + ), + )); }), )) ], diff --git a/Sources/justMUSIC/lib/values/constants.dart b/Sources/justMUSIC/lib/values/constants.dart index e3512f9..db5a300 100644 --- a/Sources/justMUSIC/lib/values/constants.dart +++ b/Sources/justMUSIC/lib/values/constants.dart @@ -21,6 +21,7 @@ const grayText = Color(0xFF898989); const settingColor = Color(0xFF232323); const searchBarColor = Color(0xFF161616); const postbutton = Color(0xFF1B1B1B); +const fillButton = Color(0xFF633AF4); // All constants important too us const defaultPadding = 30.0; diff --git a/Sources/justMUSIC/pubspec.lock b/Sources/justMUSIC/pubspec.lock index afce498..dfbd0a1 100644 --- a/Sources/justMUSIC/pubspec.lock +++ b/Sources/justMUSIC/pubspec.lock @@ -1,6 +1,14 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + animated_appear: + dependency: "direct main" + description: + name: animated_appear + sha256: "53097d7bb6d5e4a1a3a74c8f3028c47c87101c6ec8903f2002372d1eb5aee991" + url: "https://pub.dev" + source: hosted + version: "0.0.4" async: dependency: transitive description: @@ -368,6 +376,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.1" + insta_image_viewer: + dependency: "direct main" + description: + name: insta_image_viewer + sha256: "9a81432b1ab907ea91c255ec079440afe43f999533422badffaa482dfb7fdfbb" + url: "https://pub.dev" + source: hosted + version: "1.0.2" ionicons: dependency: "direct main" description: @@ -488,6 +504,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.7" + pinch_zoom: + dependency: "direct main" + description: + name: pinch_zoom + sha256: ad12872281742726afaf03438d99a4572c584a612630768953beb6dfd6f9389a + url: "https://pub.dev" + source: hosted + version: "1.0.0" platform: dependency: transitive description: @@ -517,6 +541,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" + smooth_list_view: + dependency: "direct main" + description: + name: smooth_list_view + sha256: d6eb3bed78881c50d4574b0dd466ed3321972477688c1c021178f3132155112a + url: "https://pub.dev" + source: hosted + version: "1.0.4" source_span: dependency: transitive description: diff --git a/Sources/justMUSIC/pubspec.yaml b/Sources/justMUSIC/pubspec.yaml index 13380a9..67c874a 100644 --- a/Sources/justMUSIC/pubspec.yaml +++ b/Sources/justMUSIC/pubspec.yaml @@ -54,6 +54,10 @@ dependencies: ionicons: ^0.2.2 top_snackbar_flutter: ^3.1.0 image_picker: ^1.0.1 + insta_image_viewer: ^1.0.2 + pinch_zoom: ^1.0.0 + smooth_list_view: ^1.0.4 + animated_appear: ^0.0.4 dev_dependencies: flutter_test: