callback info

pull/29/head
Lucas Delanier 2 years ago
parent 1b132c3e58
commit ae948c0417

@ -20,7 +20,16 @@ import 'buttonPostComponent.dart';
class EditablePostComponent extends StatefulWidget { class EditablePostComponent extends StatefulWidget {
final Music? music; 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 @override
State<EditablePostComponent> createState() => _EditablePostComponentState(); State<EditablePostComponent> createState() => _EditablePostComponentState();
@ -60,16 +69,24 @@ class _EditablePostComponentState extends State<EditablePostComponent>
final imageTemp = File(image.path); final imageTemp = File(image.path);
setState(() { setState(() {
this.image = imageTemp; this.image = imageTemp;
widget.callBackImage(imageTemp);
}); });
} on PlatformException catch (e) { } on PlatformException catch (e) {
print('Failed to pick image: $e'); print('Failed to pick image: $e');
} }
} }
void _updateDescription(String text) {
setState(() {
widget.callBackDescription(text);
});
}
void _selectLocation(Tuple2<String, String> location) { void _selectLocation(Tuple2<String, String> location) {
Navigator.pop(context); Navigator.pop(context);
setState(() { setState(() {
selectedCity = location; selectedCity = location;
widget.callBackCity(location);
}); });
} }
@ -96,6 +113,13 @@ class _EditablePostComponentState extends State<EditablePostComponent>
); );
} }
@override
void dispose() {
_controller.dispose();
animationController.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ClipRRect( return ClipRRect(
@ -276,6 +300,9 @@ class _EditablePostComponentState extends State<EditablePostComponent>
child: SizedBox( child: SizedBox(
width: double.infinity, width: double.infinity,
child: TextFormField( child: TextFormField(
onChanged: (value) {
_updateDescription(value);
},
keyboardAppearance: Brightness.dark, keyboardAppearance: Brightness.dark,
minLines: 1, minLines: 1,
cursorColor: primaryColor, cursorColor: primaryColor,

@ -5,7 +5,10 @@ import 'package:google_fonts/google_fonts.dart';
class PostButtonComponent extends StatefulWidget { class PostButtonComponent extends StatefulWidget {
final bool empty; 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 @override
State<PostButtonComponent> createState() => _PostButtonComponentState(); State<PostButtonComponent> createState() => _PostButtonComponentState();
@ -67,86 +70,93 @@ class _PostButtonComponentState extends State<PostButtonComponent>
), ),
); );
} }
return Container( return GestureDetector(
width: double.infinity, onTap: () {
height: 90, widget.callback();
clipBehavior: Clip.hardEdge, },
decoration: BoxDecoration( child: Container(
color: Colors.transparent, borderRadius: BorderRadius.circular(1000)), width: double.infinity,
child: Stack( height: 90,
children: [ clipBehavior: Clip.hardEdge,
AnimatedBuilder( decoration: BoxDecoration(
animation: _controller, color: Colors.transparent,
builder: (context, child) { borderRadius: BorderRadius.circular(1000)),
return Transform.translate( child: Stack(
offset: Offset( children: [
_controller.value * (MediaQuery.of(context).size.width - 200), AnimatedBuilder(
0, 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(
BackdropFilter( filter: ImageFilter.blur(
filter: ImageFilter.blur( sigmaX: 10.0,
sigmaX: 10.0, sigmaY: 10.0,
sigmaY: 10.0, ),
), child: Opacity(
child: Opacity( opacity: 0.9,
opacity: 0.9, child: Container(
child: Container( constraints: BoxConstraints(maxWidth: 400),
constraints: BoxConstraints(maxWidth: 400), decoration: BoxDecoration(
decoration: BoxDecoration( gradient: LinearGradient(colors: [
gradient: LinearGradient(colors: [ Color(0xFF633AF4),
Color(0xFF633AF4), Color(0xFF9367FF),
Color(0xFF9367FF), Color(0xFF633AF4)
Color(0xFF633AF4) ]),
]), border: Border.all(width: 5, color: Color(0xFF1C1C1C)),
border: Border.all(width: 5, color: Color(0xFF1C1C1C)), borderRadius: BorderRadius.circular(10000)),
borderRadius: BorderRadius.circular(10000)), padding: EdgeInsets.symmetric(vertical: 25),
padding: EdgeInsets.symmetric(vertical: 25), width: double.infinity,
width: double.infinity, child: Padding(
child: Padding( padding: EdgeInsets.only(left: 100),
padding: EdgeInsets.only(left: 100), child: Text(
child: Text( "Publier la capsule",
"Publier la capsule", style: GoogleFonts.plusJakartaSans(
style: GoogleFonts.plusJakartaSans( color: Colors.white,
color: Colors.white, fontWeight: FontWeight.w700,
fontWeight: FontWeight.w700, fontStyle: FontStyle.italic,
fontStyle: FontStyle.italic, fontSize: 22),
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,
), ),
), )
) ],
], ),
), ),
); );
} }

@ -1,3 +1,4 @@
import 'dart:io';
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/Material.dart'; import 'package:flutter/Material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -22,7 +23,15 @@ class _PostScreenState extends State<PostScreen>
late AnimationController _controller; late AnimationController _controller;
Music? selectedMusic; Music? selectedMusic;
File? selectedImage;
Tuple2<String, String>? selectedCity; Tuple2<String, String>? selectedCity;
String? description;
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override @override
void initState() { void initState() {
@ -41,6 +50,24 @@ class _PostScreenState extends State<PostScreen>
}); });
} }
void _selectImage(File image) {
setState(() {
selectedImage = image;
});
}
void _descritpion(String text) {
setState(() {
description = text;
});
}
void _selectLocation(Tuple2<String, String> location) {
setState(() {
selectedCity = location;
});
}
void openSearchSong() { void openSearchSong() {
showModalBottomSheet( showModalBottomSheet(
transitionAnimationController: _controller, transitionAnimationController: _controller,
@ -64,6 +91,12 @@ class _PostScreenState extends State<PostScreen>
); );
} }
displayinfo() {
print("cc");
print(
"${selectedCity},${selectedMusic?.title},${selectedImage?.path},${description}");
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -107,11 +140,18 @@ class _PostScreenState extends State<PostScreen>
), ),
GestureDetector( GestureDetector(
onTap: openSearchSong, onTap: openSearchSong,
child: EditablePostComponent(music: selectedMusic)), child: EditablePostComponent(
music: selectedMusic,
callBackImage: _selectImage,
callBackDescription: _descritpion,
callBackCity: _selectLocation)),
SizedBox( SizedBox(
height: 40.h, height: 40.h,
), ),
PostButtonComponent(empty: selectedMusic == null), PostButtonComponent(
empty: selectedMusic == null,
callback: displayinfo,
),
SizedBox( SizedBox(
height: 40.h, height: 40.h,
), ),

Loading…
Cancel
Save