Created
December 12, 2020 23:52
-
-
Save EightRice/1df39401460f4816f0fb2926b2bb74ed to your computer and use it in GitHub Desktop.
Food App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'dart:io'import 'dart:core'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/rendering.dart'; | |
import 'dart:io'; | |
void main() { | |
runApp( | |
MaterialApp( | |
title: 'Work work and sort of work', | |
initialRoute: FoodApp.route, | |
debugShowCheckedModeBanner: false, | |
routes: { | |
FoodApp.route: (context) => FoodApp(), | |
FoodApp2.route: (context) => FoodApp2(), | |
}, | |
), | |
); | |
} | |
class FadeRoute extends PageRouteBuilder { | |
final Widget page; | |
FadeRoute({this.page}) | |
: super( | |
pageBuilder: ( | |
BuildContext context, | |
Animation<double> animation, | |
Animation<double> secondaryAnimation, | |
) => | |
page, | |
transitionsBuilder: ( | |
BuildContext context, | |
Animation<double> animation, | |
Animation<double> secondaryAnimation, | |
Widget child, | |
) => | |
FadeTransition( | |
opacity: animation, | |
child: child, | |
), | |
); | |
} | |
class FoodApp extends StatefulWidget { | |
static const String route = "/foodapp"; | |
@override | |
_FoodAppState createState() => _FoodAppState(); | |
} | |
class _FoodAppState extends State<FoodApp> with TickerProviderStateMixin { | |
double target = 0.0; | |
double whereleft = -87.0; | |
AnimationController _controller; | |
void initState() { | |
_controller = AnimationController( | |
duration: const Duration(milliseconds: 700), | |
vsync: this, | |
); | |
super.initState(); | |
} | |
@override | |
void dispose() { | |
_controller.dispose(); | |
super.dispose(); | |
} | |
void _onTapHandler() { | |
target += 0.75; | |
whereleft = -690; | |
_controller.animateTo(target); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
child: Center( | |
child: Container( | |
decoration: BoxDecoration(border: Border.all(color: Colors.black)), | |
height: MediaQuery.of(context).size.height, | |
width: MediaQuery.of(context).size.height * 0.6, | |
child: Stack(children: [ | |
AnimatedPositioned( | |
right: whereleft, | |
top: MediaQuery.of(context).size.height * 0.1, | |
duration: Duration(milliseconds: 500), | |
child: RotationTransition( | |
turns: Tween(begin: 0.0, end: 1.0).animate(_controller), | |
child: Image.network( | |
"https://i.ibb.co/KFSm7b6/entire-plate.png", | |
width: MediaQuery.of(context).size.height * 0.49, | |
))), | |
Positioned( | |
bottom: 30, | |
child: Container( | |
width: MediaQuery.of(context).size.height * 0.6, | |
child: Center( | |
child: FlatButton( | |
onPressed: () => { | |
print("Pressed"), | |
setState(() { | |
_onTapHandler(); | |
// sleep(Duration(seconds: 1)); | |
Navigator.push(context, FadeRoute(page: FoodApp2())); | |
// Navigator.of(context).pushNamed(FoodApp2.route); | |
}) | |
}, | |
child: Image.network( | |
"https://i.ibb.co/qr9t9h6/get-started.png", | |
width: MediaQuery.of(context).size.height * 0.25), | |
)))), | |
Positioned( | |
bottom: MediaQuery.of(context).size.height * 0.2, | |
width: MediaQuery.of(context).size.height * 0.36, | |
child: Image.network("https://i.ibb.co/3Y2nC0z/deicious.jpg")) | |
])), | |
)); | |
} | |
} | |
class FoodApp2 extends StatefulWidget { | |
static const String route = "/foodapp2"; | |
@override | |
_FoodApp2State createState() => _FoodApp2State(); | |
} | |
class _FoodApp2State extends State<FoodApp2> with TickerProviderStateMixin { | |
AnimationController _controller; | |
var whereleft = -390.0; | |
double target = 0.0; | |
void initState() { | |
_controller = AnimationController( | |
duration: const Duration(milliseconds: 1250), | |
vsync: this, | |
); | |
_onTapHandler(); | |
WidgetsBinding.instance.addPostFrameCallback((_) => setState(() { | |
whereleft = -170.0; | |
})); | |
super.initState(); | |
// _onTapHandler(); | |
} | |
@override | |
void dispose() { | |
_controller.dispose(); | |
super.dispose(); | |
} | |
void _onTapHandler() { | |
setState(() { | |
target = 0.35; | |
}); | |
_controller.animateTo(target); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
child: Center( | |
child: Container( | |
decoration: BoxDecoration(border: Border.all(color: Colors.black)), | |
height: MediaQuery.of(context).size.height, | |
width: MediaQuery.of(context).size.height * 0.6, | |
child: Stack(children: [ | |
AnimatedPositioned( | |
left: whereleft, | |
top: MediaQuery.of(context).size.height * 0.1, | |
duration: Duration(milliseconds: 400), | |
child: RotationTransition( | |
turns: Tween(begin: 0.0, end: 1.0).animate(_controller), | |
child: Image.network( | |
"https://i.ibb.co/KFSm7b6/entire-plate.png", | |
width: MediaQuery.of(context).size.height * 0.49, | |
))), | |
Positioned( | |
bottom: 30, | |
child: Container( | |
width: MediaQuery.of(context).size.height * 0.6, | |
child: Center( | |
child: FlatButton( | |
onPressed: () => { | |
print("Pressed"), | |
setState(() { | |
// sleep(Duration(seconds: 1)); | |
Navigator.of(context).pushNamed(FoodApp.route); | |
}) | |
}, | |
child: Image.network( | |
"https://i.ibb.co/pwjXWMw/place-order.png", | |
width: MediaQuery.of(context).size.height * 0.25), | |
)))), | |
Positioned( | |
bottom: 120.0, | |
child: Container( | |
width: MediaQuery.of(context).size.height * 0.6, | |
child: Center( | |
child: Image.network( | |
"https://i.ibb.co/BNx6Vhq/datetrans.png", | |
width: MediaQuery.of(context).size.height * 0.45, | |
)))), | |
Positioned( | |
right: 0.0, | |
top: MediaQuery.of(context).size.height * 0.06, | |
child: Image.network( | |
"https://i.ibb.co/m8yPyM8/toate.png", | |
width: MediaQuery.of(context).size.height * 0.33, | |
), | |
) | |
])), | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment