Suite API
continuous-integration/drone/push Build is passing Details

messagerie_lucas_test
Félix MIELCAREK 3 years ago
parent b1addf51bb
commit 98f5ed17e2

@ -15,11 +15,9 @@ void main() {
} }
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
// This widget is the root of your application. // This widget is the root of your application.
@override @override
Widget build(BuildContext context){ Widget build(BuildContext context) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky); SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
return ChangeNotifierProvider( return ChangeNotifierProvider(
create: (context) => CardProvider(), 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<String> _urlImages = []; List<String> _urlImages = [];
bool _isDragging = false; bool _isDragging = false;
double _angle = 0; double _angle = 0;
@ -65,7 +63,6 @@ class CardProvider extends ChangeNotifier{
notifyListeners(); notifyListeners();
} }
void setScreenSize(Size screenSize) => _screenSize = screenSize; void setScreenSize(Size screenSize) => _screenSize = screenSize;
void startPosition(DragStartDetails details) { void startPosition(DragStartDetails details) {
@ -88,7 +85,6 @@ class CardProvider extends ChangeNotifier{
final status = getStatus(force: true); final status = getStatus(force: true);
switch (status) { switch (status) {
case CardStatus.like: case CardStatus.like:
like(context); like(context);
@ -106,6 +102,7 @@ class CardProvider extends ChangeNotifier{
resetPosition(); resetPosition();
} }
} }
void resetPosition() { void resetPosition() {
_isDragging = false; _isDragging = false;
_position = Offset.zero; _position = Offset.zero;
@ -128,32 +125,33 @@ class CardProvider extends ChangeNotifier{
final forceDiscovery = x.abs() < 80; final forceDiscovery = x.abs() < 80;
final forceMessage = x.abs() < 100; final forceMessage = x.abs() < 100;
if(force) { if (force) {
final delta = 100; final delta = 100;
if (x >= delta) { if (x >= delta) {
return CardStatus.like; return CardStatus.like;
} else if ( x <= -delta){ } else if (x <= -delta) {
return CardStatus.disLike; return CardStatus.disLike;
} else if ( y <= -delta/2 && forceDiscovery){ } else if (y <= -delta / 2 && forceDiscovery) {
return CardStatus.message; return CardStatus.message;
} else if (y >= delta * 2 && x.abs() < 100) { } else if (y >= delta * 2 && x.abs() < 100) {
return CardStatus.discovery; return CardStatus.discovery;
} }
} else{ } else {
final delta = 20; final delta = 20;
if(y <= -delta * 2 && forceDiscovery) { if (y <= -delta * 2 && forceDiscovery) {
return CardStatus.message; return CardStatus.message;
} else if (y >= delta *2 && x.abs() < 80) { } else if (y >= delta * 2 && x.abs() < 80) {
return CardStatus.discovery; return CardStatus.discovery;
}else if ( x >= delta) { } else if (x >= delta) {
return CardStatus.like; return CardStatus.like;
} else if ( x <= -delta) { } else if (x <= -delta) {
return CardStatus.disLike; return CardStatus.disLike;
} }
} }
} }
void dislike() { void dislike() {
Vibration.vibrate(duration: 20, amplitude: 60); Vibration.vibrate(duration: 20, amplitude: 60);
print("dislike"); print("dislike");
@ -176,8 +174,7 @@ class CardProvider extends ChangeNotifier{
gravity: ToastGravity.TOP, gravity: ToastGravity.TOP,
timeInSecForIosWeb: 2, timeInSecForIosWeb: 2,
backgroundColor: Colors.deepPurple, backgroundColor: Colors.deepPurple,
textColor: Colors.white textColor: Colors.white);
);
notifyListeners(); notifyListeners();
} }
@ -198,9 +195,11 @@ class CardProvider extends ChangeNotifier{
maxWidth: 600, maxWidth: 600,
maxHeight: double.infinity, maxHeight: double.infinity,
), ),
builder: (context) => buildSheet(),); builder: (context) => buildSheet(),
);
notifyListeners(); notifyListeners();
} }
Widget buildSheet() => Container( Widget buildSheet() => Container(
height: 550, height: 550,
width: 350, width: 350,
@ -220,7 +219,7 @@ class CardProvider extends ChangeNotifier{
offset: const Offset(0.0, 0.0), offset: const Offset(0.0, 0.0),
blurRadius: 0.0, blurRadius: 0.0,
spreadRadius: 0.0, spreadRadius: 0.0,
),//BoxShadow//BoxShadow ), //BoxShadow//BoxShadow
], ],
color: Color(0xFF232123), color: Color(0xFF232123),
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
@ -232,7 +231,6 @@ class CardProvider extends ChangeNotifier{
padding: EdgeInsets.fromLTRB(20, 10, 20, 10), padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
child: Column( child: Column(
children: [ children: [
Container( Container(
height: 5, height: 5,
width: 130, width: 130,
@ -241,7 +239,9 @@ class CardProvider extends ChangeNotifier{
color: Color(0xFF8A8A8A), color: Color(0xFF8A8A8A),
), ),
), ),
SizedBox(height: 30,), SizedBox(
height: 30,
),
Container( Container(
width: double.infinity, width: double.infinity,
height: 300, height: 300,
@ -253,7 +253,11 @@ class CardProvider extends ChangeNotifier{
padding: EdgeInsets.all(20), padding: EdgeInsets.all(20),
child: TextField( child: TextField(
maxLength: 300, maxLength: 300,
style: TextStyle(fontFamily: 'DMSans', color: Colors.white.withOpacity(1) ,fontSize: 17, fontWeight: FontWeight.w200), style: TextStyle(
fontFamily: 'DMSans',
color: Colors.white.withOpacity(1),
fontSize: 17,
fontWeight: FontWeight.w200),
expands: true, expands: true,
maxLines: null, maxLines: null,
keyboardType: TextInputType.multiline, keyboardType: TextInputType.multiline,
@ -267,7 +271,9 @@ class CardProvider extends ChangeNotifier{
), ),
), ),
), ),
SizedBox(height: 20,), SizedBox(
height: 20,
),
SizedBox( SizedBox(
width: double.infinity, width: double.infinity,
height: 70, height: 70,
@ -275,19 +281,21 @@ class CardProvider extends ChangeNotifier{
onPressed: () {}, onPressed: () {},
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: Color(0xFF3F1DC3), primary: Color(0xFF3F1DC3),
textStyle: TextStyle( textStyle:
fontSize: 20, TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
fontWeight: FontWeight.bold),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(17) borderRadius: BorderRadius.circular(17)),
),
), ),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
Text("Envoyer"), Text("Envoyer"),
Opacity(opacity: 0.2, Opacity(
child: Image.asset("assets/images/send_logo.png",),) opacity: 0.2,
child: Image.asset(
"assets/images/send_logo.png",
),
)
], ],
), ),
), ),
@ -295,10 +303,8 @@ class CardProvider extends ChangeNotifier{
], ],
), ),
), ),
); );
void like(context) { void like(context) {
Vibration.vibrate(duration: 20, amplitude: 60); Vibration.vibrate(duration: 20, amplitude: 60);
print("like"); print("like");
@ -306,11 +312,10 @@ class CardProvider extends ChangeNotifier{
_position += Offset(2 * _screenSize.width, 0); _position += Offset(2 * _screenSize.width, 0);
_nextCard(); _nextCard();
notifyListeners(); notifyListeners();
} }
Future _nextCard() async { Future _nextCard() async {
if ( _urlImages.isEmpty) return; if (_urlImages.isEmpty) return;
await Future.delayed(Duration(milliseconds: 200)); await Future.delayed(Duration(milliseconds: 200));
_urlImages.removeLast(); _urlImages.removeLast();
@ -326,10 +331,8 @@ class CardProvider extends ChangeNotifier{
await Future.delayed(Duration(milliseconds: 200)); await Future.delayed(Duration(milliseconds: 200));
resetPosition(); resetPosition();
} }
} }
class Splash extends StatefulWidget { class Splash extends StatefulWidget {
const Splash({Key? key}) : super(key: key); const Splash({Key? key}) : super(key: key);
@ -338,24 +341,17 @@ class Splash extends StatefulWidget {
} }
class _SplashState extends State<Splash> { class _SplashState extends State<Splash> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
WidgetsBinding.instance.addPostFrameCallback((timeStamp) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
Timer(Duration(seconds: 2), () { Timer(Duration(seconds: 2), () {
Navigator.pushReplacement(context, Navigator.pushReplacement(
MaterialPageRoute(builder: context, MaterialPageRoute(builder: (context) => MainPage()));
(context) =>MainPage()
)
);
}); });
}); });
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(

Loading…
Cancel
Save