POSTS_FRIENDS_EKA-LDE #32
Merged
emre.kartal
merged 8 commits from POSTS_FRIENDS_EKA-LDE
into master
2 years ago
@ -0,0 +1 @@
|
|||||||
|
{"nm":"newScene","ddd":0,"h":506,"w":246,"meta":{"g":"LottieFiles Figma v38"},"layers":[{"ty":4,"nm":"","sr":1,"st":0,"op":55,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"ef":[],"shapes":[{"ty":"gr","bm":0,"hd":false,"nm":"","it":[{"ty":"sh","bm":0,"hd":false,"nm":"","d":1,"ks":{"a":0,"k":{"c":true,"i":[[0,0],[18.31699999999998,-14.117000000000019],[0,0],[4.924000000000007,-5.552999999999997],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[-2.176000000000016,8.12299999999999],[0,0],[-4.0330000000000155,15.050000000000011],[0,0],[0,0]],"o":[[-15.049000000000007,-4.031999999999982],[0,0],[-8.12299999999999,-2.1759999999999877],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[7.271000000000015,-1.488999999999976],[0,0],[21.383999999999986,-8.803999999999974],[0,0],[0,0],[0,0]],"v":[[229.562,323.522],[173.235,338.521],[161.993,335.509],[142.666,343.701],[136.075,351.133],[146.207,353.848],[156.351,356.566],[164.059,369.916],[171.766,383.266],[169.048,393.41],[166.333,403.542],[176.065,401.551],[192.823,388.908],[195.836,377.666],[236.989,336.385],[239.707,326.24],[229.562,323.522]]}}},{"ty":"sh","bm":0,"hd":false,"nm":"","d":1,"ks":{"a":0,"k":{"c":true,"i":[[0,0],[1.0389999999999873,-3.8759999999999764],[3.8770000000000095,1.038000000000011],[-1.0389999999999873,3.8770000000000095],[-3.8770000000000095,-1.0389999999999873]],"o":[[3.8760000000000048,1.038000000000011],[-1.0390000000000157,3.8770000000000095],[-3.8770000000000095,-1.0389999999999873],[1.038000000000011,-3.8770000000000095],[0,0]],"v":[[205.989,339.775],[211.127,348.674],[202.227,353.813],[197.089,344.913],[205.989,339.775]]}}},{"ty":"sh","bm":0,"hd":false,"nm":"","d":1,"ks":{"a":0,"k":{"c":true,"i":[[0,0],[0,0],[0,0],[-7.138000000000005,4.120999999999981],[0,0],[0,0]],"o":[[0,0],[-6.4269999999999925,3.7110000000000127],[0,0],[0,0],[0,0],[0,0]],"v":[[149.08,369.664],[144.63,372.233],[132.909,387.9],[152.338,385.583],[156.788,383.014],[149.08,369.664]]}}},{"ty":"fl","bm":0,"hd":false,"nm":"","c":{"a":0,"k":[1,1,1]},"r":1,"o":{"a":0,"k":100}},{"ty":"tr","a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[0,0]},"r":{"a":1,"k":[{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[90],"t":0},{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[90],"t":5},{"s":[0],"t":25}]},"sa":{"a":0,"k":0},"o":{"a":1,"k":[{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[0],"t":0},{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[0],"t":5},{"s":[100],"t":25}]}}]}],"ind":1}],"v":"5.7.0","fr":60,"op":55,"ip":0,"assets":[]}
|
@ -0,0 +1,114 @@
|
|||||||
|
import 'package:flutter/Material.dart';
|
||||||
|
import 'package:lottie/lottie.dart';
|
||||||
|
|
||||||
|
import '../values/constants.dart';
|
||||||
|
|
||||||
|
class LaunchingRocketScreen extends StatefulWidget {
|
||||||
|
const LaunchingRocketScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<LaunchingRocketScreen> createState() => _LaunchingRocketScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LaunchingRocketScreenState extends State<LaunchingRocketScreen> with TickerProviderStateMixin {
|
||||||
|
late final AnimationController _controller;
|
||||||
|
|
||||||
|
late AnimationController _controller2;
|
||||||
|
late Animation<double> _animation;
|
||||||
|
|
||||||
|
@override
|
||||||
|
initState() {
|
||||||
|
_controller = AnimationController(vsync: this, duration: Duration(seconds: 3));
|
||||||
|
|
||||||
|
_controller2 = AnimationController(
|
||||||
|
vsync: this,
|
||||||
|
duration: Duration(milliseconds: 800),
|
||||||
|
);
|
||||||
|
|
||||||
|
final CurvedAnimation curve = CurvedAnimation(parent: _controller2, curve: Curves.easeIn);
|
||||||
|
|
||||||
|
_animation = Tween<double>(
|
||||||
|
begin: 0,
|
||||||
|
end: 1,
|
||||||
|
).animate(curve);
|
||||||
|
|
||||||
|
_controller2.addStatusListener((status) {
|
||||||
|
print("cccccccc");
|
||||||
|
if (status == AnimationStatus.completed) {
|
||||||
|
Navigator.of(context).popUntil((route) => route.settings.name == '/feed');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_controller.dispose();
|
||||||
|
_controller2.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
bool animationCompleted = false;
|
||||||
|
return Scaffold(
|
||||||
|
backgroundColor: primaryColor,
|
||||||
|
body: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Lottie.asset(
|
||||||
|
'assets/animations/rocket.json',
|
||||||
|
height: 600,
|
||||||
|
frameRate: FrameRate(60),
|
||||||
|
fit: BoxFit.contain,
|
||||||
|
controller: _controller,
|
||||||
|
onLoaded: (composition) {
|
||||||
|
_controller
|
||||||
|
..duration = composition.duration
|
||||||
|
..forward().whenComplete(() {
|
||||||
|
setState(() {
|
||||||
|
animationCompleted = true;
|
||||||
|
});
|
||||||
|
_controller2.forward();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Center(
|
||||||
|
child: AnimatedBuilder(
|
||||||
|
animation: _animation,
|
||||||
|
builder: (context, child) {
|
||||||
|
double circlePosition = MediaQuery.of(context).size.height * _animation.value;
|
||||||
|
return CustomPaint(
|
||||||
|
painter: CirclePainter(circlePosition),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CirclePainter extends CustomPainter {
|
||||||
|
final double circlePosition;
|
||||||
|
|
||||||
|
CirclePainter(this.circlePosition);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(Canvas canvas, Size size) {
|
||||||
|
Paint paint = Paint()..color = Colors.white;
|
||||||
|
double radius = 50 * circlePosition; // Remplacez par le rayon souhaité de votre cercle
|
||||||
|
Offset center = Offset(size.width / 2, size.height / 2);
|
||||||
|
|
||||||
|
canvas.drawCircle(center, radius, paint);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRepaint(CustomPainter oldDelegate) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,47 @@
|
|||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
|
||||||
import '../model/User.dart';
|
|
||||||
import '../main.dart';
|
import '../main.dart';
|
||||||
|
|
||||||
class UserService {
|
class UserService {
|
||||||
acceptFriend(User user, String idFriend) {
|
Future<List<QueryDocumentSnapshot<Map<String, dynamic>>>> getUsersByIdUnique(String uniqueId) async {
|
||||||
MyApp.db.collection("users").doc(user.id).update({
|
QuerySnapshot<Map<String, dynamic>> response = await FirebaseFirestore.instance
|
||||||
"friends": FieldValue.arrayUnion([idFriend])
|
.collection("users")
|
||||||
});
|
.where("unique_id", isGreaterThanOrEqualTo: uniqueId)
|
||||||
MyApp.db.collection("users").doc(idFriend).update({
|
.where("unique_id", isLessThanOrEqualTo: uniqueId + "zzzzzzzzzzzzzzzzzzzzzzzzzzzz")
|
||||||
"friends": FieldValue.arrayUnion([user.id])
|
.limit(20)
|
||||||
});
|
.get();
|
||||||
|
var users = response.docs.where((doc) {
|
||||||
|
String id = doc["unique_id"];
|
||||||
|
return id != MyApp.userViewModel.userCurrent.uniquePseudo;
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
addOrDeleteFriend(String id) async {
|
||||||
|
var userRef = MyApp.db.collection("users").doc(MyApp.userViewModel.userCurrent.id);
|
||||||
|
var actionUserRef = MyApp.db.collection("users").doc(id);
|
||||||
|
|
||||||
|
if (MyApp.userViewModel.isFriend(id)) {
|
||||||
|
await MyApp.db.runTransaction((transaction) async {
|
||||||
|
transaction.update(userRef, {
|
||||||
|
'followed': FieldValue.arrayRemove([id])
|
||||||
|
});
|
||||||
|
transaction.update(actionUserRef, {
|
||||||
|
'followers': FieldValue.arrayRemove([id])
|
||||||
|
});
|
||||||
|
});
|
||||||
|
MyApp.userViewModel.userCurrent.followed.remove(id);
|
||||||
|
} else {
|
||||||
|
await MyApp.db.runTransaction((transaction) async {
|
||||||
|
transaction.update(userRef, {
|
||||||
|
'followed': FieldValue.arrayUnion([id])
|
||||||
|
});
|
||||||
|
transaction.update(actionUserRef, {
|
||||||
|
'followers': FieldValue.arrayUnion([id])
|
||||||
|
});
|
||||||
|
});
|
||||||
|
MyApp.userViewModel.userCurrent.followed.add(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue