From 98f5ed17e2c955769bf8c5602524666b3d225acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Mielcarek?= Date: Sun, 30 Oct 2022 19:35:39 +0100 Subject: [PATCH] Suite API --- Sources/dafl_project_flutter/lib/main.dart | 238 ++++++++++----------- 1 file changed, 117 insertions(+), 121 deletions(-) diff --git a/Sources/dafl_project_flutter/lib/main.dart b/Sources/dafl_project_flutter/lib/main.dart index 2ab1678..68fd00c 100644 --- a/Sources/dafl_project_flutter/lib/main.dart +++ b/Sources/dafl_project_flutter/lib/main.dart @@ -15,11 +15,9 @@ void main() { } class MyApp extends StatelessWidget { - - // This widget is the root of your application. @override - Widget build(BuildContext context){ + Widget build(BuildContext context) { SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky); return ChangeNotifierProvider( create: (context) => CardProvider(), @@ -32,9 +30,9 @@ class MyApp extends StatelessWidget { } } -enum CardStatus { like, disLike, discovery, message} +enum CardStatus { like, disLike, discovery, message } -class CardProvider extends ChangeNotifier{ +class CardProvider extends ChangeNotifier { List _urlImages = []; bool _isDragging = false; double _angle = 0; @@ -65,7 +63,6 @@ class CardProvider extends ChangeNotifier{ notifyListeners(); } - void setScreenSize(Size screenSize) => _screenSize = screenSize; void startPosition(DragStartDetails details) { @@ -88,7 +85,6 @@ class CardProvider extends ChangeNotifier{ final status = getStatus(force: true); - switch (status) { case CardStatus.like: like(context); @@ -106,6 +102,7 @@ class CardProvider extends ChangeNotifier{ resetPosition(); } } + void resetPosition() { _isDragging = false; _position = Offset.zero; @@ -128,32 +125,33 @@ class CardProvider extends ChangeNotifier{ final forceDiscovery = x.abs() < 80; final forceMessage = x.abs() < 100; - if(force) { + if (force) { final delta = 100; if (x >= delta) { return CardStatus.like; - } else if ( x <= -delta){ + } else if (x <= -delta) { return CardStatus.disLike; - } else if ( y <= -delta/2 && forceDiscovery){ + } else if (y <= -delta / 2 && forceDiscovery) { return CardStatus.message; } else if (y >= delta * 2 && x.abs() < 100) { return CardStatus.discovery; } - } else{ + } else { final delta = 20; - if(y <= -delta * 2 && forceDiscovery) { + if (y <= -delta * 2 && forceDiscovery) { return CardStatus.message; - } else if (y >= delta *2 && x.abs() < 80) { + } else if (y >= delta * 2 && x.abs() < 80) { return CardStatus.discovery; - }else if ( x >= delta) { + } else if (x >= delta) { return CardStatus.like; - } else if ( x <= -delta) { + } else if (x <= -delta) { return CardStatus.disLike; } } } + void dislike() { Vibration.vibrate(duration: 20, amplitude: 60); print("dislike"); @@ -176,8 +174,7 @@ class CardProvider extends ChangeNotifier{ gravity: ToastGravity.TOP, timeInSecForIosWeb: 2, backgroundColor: Colors.deepPurple, - textColor: Colors.white - ); + textColor: Colors.white); notifyListeners(); } @@ -195,109 +192,118 @@ class CardProvider extends ChangeNotifier{ backgroundColor: Colors.transparent, context: context, constraints: BoxConstraints( - maxWidth: 600, + maxWidth: 600, maxHeight: double.infinity, ), - builder: (context) => buildSheet(),); + builder: (context) => buildSheet(), + ); notifyListeners(); } + Widget buildSheet() => Container( - height: 550, - width: 350, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.4), - offset: const Offset( - 0, - 0, - ), - blurRadius: 10.0, - spreadRadius: 2.0, - ), - BoxShadow( - color: Colors.white.withOpacity(0.3), - offset: const Offset(0.0, 0.0), - blurRadius: 0.0, - spreadRadius: 0.0, - ),//BoxShadow//BoxShadow - ], - color: Color(0xFF232123), - borderRadius: BorderRadius.only( - topRight: Radius.circular(30), - topLeft: Radius.circular(30), - ), - ), - child: Padding( - padding: EdgeInsets.fromLTRB(20, 10, 20, 10), - child: Column( - children: [ - - Container( - height: 5, - width: 130, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - color: Color(0xFF8A8A8A), + height: 550, + width: 350, + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.4), + offset: const Offset( + 0, + 0, + ), + blurRadius: 10.0, + spreadRadius: 2.0, ), + BoxShadow( + color: Colors.white.withOpacity(0.3), + offset: const Offset(0.0, 0.0), + blurRadius: 0.0, + spreadRadius: 0.0, + ), //BoxShadow//BoxShadow + ], + color: Color(0xFF232123), + borderRadius: BorderRadius.only( + topRight: Radius.circular(30), + topLeft: Radius.circular(30), ), - SizedBox(height: 30,), - Container( - width: double.infinity, - height: 300, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(20), - color: Color(0xFF302C30), - ), - child: Padding( - padding: EdgeInsets.all(20), - child: TextField( - maxLength: 300, - style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(1) ,fontSize: 17, fontWeight: FontWeight.w200), - expands: true, - maxLines: null, - keyboardType: TextInputType.multiline, - decoration: InputDecoration( - hintStyle: TextStyle( - color: Colors.white, - ), - border: InputBorder.none, - hintText: "Mon message", + ), + child: Padding( + padding: EdgeInsets.fromLTRB(20, 10, 20, 10), + child: Column( + children: [ + Container( + height: 5, + width: 130, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: Color(0xFF8A8A8A), ), ), - ), - ), - SizedBox(height: 20,), - SizedBox( - width: double.infinity, - height: 70, - child: ElevatedButton( - onPressed: () {}, - style: ElevatedButton.styleFrom( - primary: Color(0xFF3F1DC3), - textStyle: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(17) + SizedBox( + height: 30, + ), + Container( + width: double.infinity, + height: 300, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: Color(0xFF302C30), + ), + child: Padding( + padding: EdgeInsets.all(20), + child: TextField( + maxLength: 300, + style: TextStyle( + fontFamily: 'DMSans', + color: Colors.white.withOpacity(1), + fontSize: 17, + fontWeight: FontWeight.w200), + expands: true, + maxLines: null, + keyboardType: TextInputType.multiline, + decoration: InputDecoration( + hintStyle: TextStyle( + color: Colors.white, + ), + border: InputBorder.none, + hintText: "Mon message", + ), ), + ), ), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Text("Envoyer"), - Opacity(opacity: 0.2, - child: Image.asset("assets/images/send_logo.png",),) - ], + SizedBox( + height: 20, ), - ), - ) - ], - ), - ), - - ); - + SizedBox( + width: double.infinity, + height: 70, + child: ElevatedButton( + onPressed: () {}, + style: ElevatedButton.styleFrom( + primary: Color(0xFF3F1DC3), + textStyle: + TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(17)), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Text("Envoyer"), + Opacity( + opacity: 0.2, + child: Image.asset( + "assets/images/send_logo.png", + ), + ) + ], + ), + ), + ) + ], + ), + ), + ); void like(context) { Vibration.vibrate(duration: 20, amplitude: 60); @@ -306,11 +312,10 @@ class CardProvider extends ChangeNotifier{ _position += Offset(2 * _screenSize.width, 0); _nextCard(); notifyListeners(); - } Future _nextCard() async { - if ( _urlImages.isEmpty) return; + if (_urlImages.isEmpty) return; await Future.delayed(Duration(milliseconds: 200)); _urlImages.removeLast(); @@ -326,10 +331,8 @@ class CardProvider extends ChangeNotifier{ await Future.delayed(Duration(milliseconds: 200)); resetPosition(); } - } - class Splash extends StatefulWidget { const Splash({Key? key}) : super(key: key); @@ -338,24 +341,17 @@ class Splash extends StatefulWidget { } class _SplashState extends State { - @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((timeStamp) { Timer(Duration(seconds: 2), () { - Navigator.pushReplacement(context, - MaterialPageRoute(builder: - (context) =>MainPage() - ) - ); + Navigator.pushReplacement( + context, MaterialPageRoute(builder: (context) => MainPage())); }); }); - - } - @override Widget build(BuildContext context) { return Scaffold(