diff --git a/Sources/justMUSIC/lib/components/editable_post_component.dart b/Sources/justMUSIC/lib/components/editable_post_component.dart index 7bc2714..107116b 100644 --- a/Sources/justMUSIC/lib/components/editable_post_component.dart +++ b/Sources/justMUSIC/lib/components/editable_post_component.dart @@ -20,7 +20,16 @@ import 'buttonPostComponent.dart'; class EditablePostComponent extends StatefulWidget { final Music? music; - const EditablePostComponent({Key? key, this.music}) : super(key: key); + final Function callBackImage; + final Function callBackCity; + final Function callBackDescription; + const EditablePostComponent( + {Key? key, + this.music, + required this.callBackImage, + required this.callBackCity, + required this.callBackDescription}) + : super(key: key); @override State createState() => _EditablePostComponentState(); @@ -60,16 +69,24 @@ class _EditablePostComponentState extends State final imageTemp = File(image.path); setState(() { this.image = imageTemp; + widget.callBackImage(imageTemp); }); } on PlatformException catch (e) { print('Failed to pick image: $e'); } } + void _updateDescription(String text) { + setState(() { + widget.callBackDescription(text); + }); + } + void _selectLocation(Tuple2 location) { Navigator.pop(context); setState(() { selectedCity = location; + widget.callBackCity(location); }); } @@ -96,6 +113,13 @@ class _EditablePostComponentState extends State ); } + @override + void dispose() { + _controller.dispose(); + animationController.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return ClipRRect( @@ -276,6 +300,9 @@ class _EditablePostComponentState extends State child: SizedBox( width: double.infinity, child: TextFormField( + onChanged: (value) { + _updateDescription(value); + }, keyboardAppearance: Brightness.dark, minLines: 1, cursorColor: primaryColor, diff --git a/Sources/justMUSIC/lib/components/post_button_component.dart b/Sources/justMUSIC/lib/components/post_button_component.dart index 45b2c47..e8db142 100644 --- a/Sources/justMUSIC/lib/components/post_button_component.dart +++ b/Sources/justMUSIC/lib/components/post_button_component.dart @@ -5,7 +5,10 @@ import 'package:google_fonts/google_fonts.dart'; class PostButtonComponent extends StatefulWidget { final bool empty; - const PostButtonComponent({Key? key, required this.empty}) : super(key: key); + final Function callback; + const PostButtonComponent( + {Key? key, required this.empty, required this.callback}) + : super(key: key); @override State createState() => _PostButtonComponentState(); @@ -67,86 +70,93 @@ class _PostButtonComponentState extends State ), ); } - return Container( - width: double.infinity, - height: 90, - clipBehavior: Clip.hardEdge, - decoration: BoxDecoration( - color: Colors.transparent, borderRadius: BorderRadius.circular(1000)), - child: Stack( - children: [ - AnimatedBuilder( - animation: _controller, - builder: (context, child) { - return Transform.translate( - offset: Offset( - _controller.value * (MediaQuery.of(context).size.width - 200), - 0, + return GestureDetector( + onTap: () { + widget.callback(); + }, + child: Container( + width: double.infinity, + height: 90, + clipBehavior: Clip.hardEdge, + decoration: BoxDecoration( + color: Colors.transparent, + borderRadius: BorderRadius.circular(1000)), + child: Stack( + children: [ + AnimatedBuilder( + animation: _controller, + builder: (context, child) { + return Transform.translate( + offset: Offset( + _controller.value * + (MediaQuery.of(context).size.width - 200), + 0, + ), + child: child, + ); + }, + child: Container( + width: 120, + height: 80, + alignment: Alignment.center, + decoration: BoxDecoration( + gradient: LinearGradient(colors: [ + Color(0xFF9E78FF).withOpacity(0.0), + Color(0xFFFDFDFF), + Color(0xFFFFFFFF), + Color(0xFF9E78FF).withOpacity(0.0) + ], stops: const [ + 0, + 0.4, + 0.5, + 1 + ]), ), - child: child, - ); - }, - child: Container( - width: 120, - height: 80, - alignment: Alignment.center, - decoration: BoxDecoration( - gradient: LinearGradient(colors: [ - Color(0xFF9E78FF).withOpacity(0.0), - Color(0xFFFDFDFF), - Color(0xFFFFFFFF), - Color(0xFF9E78FF).withOpacity(0.0) - ], stops: const [ - 0, - 0.4, - 0.5, - 1 - ]), ), ), - ), - BackdropFilter( - filter: ImageFilter.blur( - sigmaX: 10.0, - sigmaY: 10.0, - ), - child: Opacity( - opacity: 0.9, - child: Container( - constraints: BoxConstraints(maxWidth: 400), - decoration: BoxDecoration( - gradient: LinearGradient(colors: [ - Color(0xFF633AF4), - Color(0xFF9367FF), - Color(0xFF633AF4) - ]), - border: Border.all(width: 5, color: Color(0xFF1C1C1C)), - borderRadius: BorderRadius.circular(10000)), - padding: EdgeInsets.symmetric(vertical: 25), - width: double.infinity, - child: Padding( - padding: EdgeInsets.only(left: 100), - child: Text( - "Publier la capsule", - style: GoogleFonts.plusJakartaSans( - color: Colors.white, - fontWeight: FontWeight.w700, - fontStyle: FontStyle.italic, - fontSize: 22), + BackdropFilter( + filter: ImageFilter.blur( + sigmaX: 10.0, + sigmaY: 10.0, + ), + child: Opacity( + opacity: 0.9, + child: Container( + constraints: BoxConstraints(maxWidth: 400), + decoration: BoxDecoration( + gradient: LinearGradient(colors: [ + Color(0xFF633AF4), + Color(0xFF9367FF), + Color(0xFF633AF4) + ]), + border: Border.all(width: 5, color: Color(0xFF1C1C1C)), + borderRadius: BorderRadius.circular(10000)), + padding: EdgeInsets.symmetric(vertical: 25), + width: double.infinity, + child: Padding( + padding: EdgeInsets.only(left: 100), + child: Text( + "Publier la capsule", + style: GoogleFonts.plusJakartaSans( + color: Colors.white, + fontWeight: FontWeight.w700, + fontStyle: FontStyle.italic, + fontSize: 22), + ), ), ), + )), + ClipOval( + child: Padding( + padding: const EdgeInsets.only(left: 5, top: 5), + child: Image( + image: AssetImage("assets/images/rocket_button.png"), + height: 65, ), - )), - ClipOval( - child: Padding( - padding: const EdgeInsets.only(left: 5, top: 5), - child: Image( - image: AssetImage("assets/images/rocket_button.png"), - height: 65, ), - ), - ) - ], + ) + ], + ), ), ); } diff --git a/Sources/justMUSIC/lib/screens/post_screen.dart b/Sources/justMUSIC/lib/screens/post_screen.dart index 65cc130..1c68a80 100644 --- a/Sources/justMUSIC/lib/screens/post_screen.dart +++ b/Sources/justMUSIC/lib/screens/post_screen.dart @@ -1,3 +1,4 @@ +import 'dart:io'; import 'dart:ui'; import 'package:flutter/Material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -22,7 +23,15 @@ class _PostScreenState extends State late AnimationController _controller; Music? selectedMusic; + File? selectedImage; Tuple2? selectedCity; + String? description; + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } @override void initState() { @@ -41,6 +50,24 @@ class _PostScreenState extends State }); } + void _selectImage(File image) { + setState(() { + selectedImage = image; + }); + } + + void _descritpion(String text) { + setState(() { + description = text; + }); + } + + void _selectLocation(Tuple2 location) { + setState(() { + selectedCity = location; + }); + } + void openSearchSong() { showModalBottomSheet( transitionAnimationController: _controller, @@ -64,6 +91,12 @@ class _PostScreenState extends State ); } + displayinfo() { + print("cc"); + print( + "${selectedCity},${selectedMusic?.title},${selectedImage?.path},${description}"); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -107,11 +140,18 @@ class _PostScreenState extends State ), GestureDetector( onTap: openSearchSong, - child: EditablePostComponent(music: selectedMusic)), + child: EditablePostComponent( + music: selectedMusic, + callBackImage: _selectImage, + callBackDescription: _descritpion, + callBackCity: _selectLocation)), SizedBox( height: 40.h, ), - PostButtonComponent(empty: selectedMusic == null), + PostButtonComponent( + empty: selectedMusic == null, + callback: displayinfo, + ), SizedBox( height: 40.h, ),