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 {
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<EditablePostComponent> createState() => _EditablePostComponentState();
@ -60,16 +69,24 @@ class _EditablePostComponentState extends State<EditablePostComponent>
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<String, String> location) {
Navigator.pop(context);
setState(() {
selectedCity = location;
widget.callBackCity(location);
});
}
@ -96,6 +113,13 @@ class _EditablePostComponentState extends State<EditablePostComponent>
);
}
@override
void dispose() {
_controller.dispose();
animationController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ClipRRect(
@ -276,6 +300,9 @@ class _EditablePostComponentState extends State<EditablePostComponent>
child: SizedBox(
width: double.infinity,
child: TextFormField(
onChanged: (value) {
_updateDescription(value);
},
keyboardAppearance: Brightness.dark,
minLines: 1,
cursorColor: primaryColor,

@ -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<PostButtonComponent> createState() => _PostButtonComponentState();
@ -67,86 +70,93 @@ class _PostButtonComponentState extends State<PostButtonComponent>
),
);
}
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,
),
),
)
],
)
],
),
),
);
}

@ -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<PostScreen>
late AnimationController _controller;
Music? selectedMusic;
File? selectedImage;
Tuple2<String, String>? selectedCity;
String? description;
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
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() {
showModalBottomSheet(
transitionAnimationController: _controller,
@ -64,6 +91,12 @@ class _PostScreenState extends State<PostScreen>
);
}
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<PostScreen>
),
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,
),

Loading…
Cancel
Save