diff --git a/README.md b/README.md index c3b927d..afb1633 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ A new Flutter project. +# Content of DAY 6 ([Tutorial](https://www.youtube.com/watch?v=6CwlHS388wI&list=PLrjrqTcKCnhTXI2GyPkaQF47inLp6LoIC&index=6)) + +- Stateful +- Animated Container +- Future Delay + ## Getting Started This project is a starting point for a Flutter application. diff --git a/lib/main.dart b/lib/main.dart index 81f5db5..7ba9441 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_catalog/pages/login_page.dart'; +import 'package:flutter_catalog/utils/routes.dart'; import 'package:google_fonts/google_fonts.dart'; import 'pages/home_page.dart'; @@ -22,8 +23,8 @@ class MyApp extends StatelessWidget { initialRoute: "/", routes: { "/": (context) => LoginPage(), - "/home": (context) => HomePage(), - "/login": (context) => LoginPage() + MyRoutes.homeRoute: (context) => HomePage(), + MyRoutes.loginRoute: (context) => LoginPage() }, ); } diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index 73465b5..2739751 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -1,61 +1,110 @@ import 'package:flutter/material.dart'; +import 'package:flutter_catalog/utils/routes.dart'; + +class LoginPage extends StatefulWidget { + @override + _LoginPageState createState() => _LoginPageState(); +} + +class _LoginPageState extends State { + String name = ""; + bool changeButton = false; -class LoginPage extends StatelessWidget { @override Widget build(BuildContext context) { return Material( color: Colors.white, - child: Column( - children: [ - Image.asset( - "assets/images/login_image.png", - fit: BoxFit.cover, - ), - SizedBox( - height: 20.0, - ), - Text( - "Welcome", - style: TextStyle( - fontSize: 24, - fontWeight: FontWeight.bold, + child: SingleChildScrollView( + child: Column( + children: [ + Image.asset( + "assets/images/login_image.png", + fit: BoxFit.cover, + ), + SizedBox( + height: 20.0, + ), + Text( + "Welcome $name", + style: TextStyle( + fontSize: 28, + fontWeight: FontWeight.bold, + ), ), - ), - SizedBox( - height: 20.0, - ), - Padding( - padding: - const EdgeInsets.symmetric(vertical: 16.0, horizontal: 32.0), - child: Column( - children: [ - TextFormField( - decoration: InputDecoration( - hintText: "Enter username", - labelText: "Username", + SizedBox( + height: 20.0, + ), + Padding( + padding: const EdgeInsets.symmetric( + vertical: 16.0, horizontal: 32.0), + child: Column( + children: [ + TextFormField( + decoration: InputDecoration( + hintText: "Enter username", + labelText: "Username", + ), + onChanged: (value) { + name = value; + setState(() {}); + }, ), - ), - TextFormField( - obscureText: true, - decoration: InputDecoration( - hintText: "Enter password", - labelText: "Password", + TextFormField( + obscureText: true, + decoration: InputDecoration( + hintText: "Enter password", + labelText: "Password", + ), ), - ), - SizedBox( - height: 20.0, - ), - ElevatedButton( - child: Text("Login"), - style: TextButton.styleFrom(), - onPressed: () { - print("Hi Codepur"); - }, - ) - ], - ), - ) - ], + SizedBox( + height: 40.0, + ), + + InkWell( + onTap: () async { + setState(() { + changeButton = true; + }); + await Future.delayed(Duration(seconds: 1)); + Navigator.pushNamed(context, MyRoutes.homeRoute); + }, + child: AnimatedContainer( + duration: Duration(seconds: 1), + width: changeButton ? 50 : 150, + height: 50, + alignment: Alignment.center, + child: changeButton + ? Icon( + Icons.done, + color: Colors.white, + ) + : Text( + "Login", + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 18), + ), + decoration: BoxDecoration( + color: Colors.deepPurple, + borderRadius: + BorderRadius.circular(changeButton ? 50 : 8), + ), + ), + ), + + // ElevatedButton( + // child: Text("Login"), + // style: TextButton.styleFrom(minimumSize: Size(150, 40)), + // onPressed: () { + // Navigator.pushNamed(context, MyRoutes.homeRoute); + // }, + // ) + ], + ), + ) + ], + ), )); } } diff --git a/lib/utils/routes.dart b/lib/utils/routes.dart new file mode 100644 index 0000000..510c16a --- /dev/null +++ b/lib/utils/routes.dart @@ -0,0 +1,4 @@ +class MyRoutes { + static String loginRoute = "/login"; + static String homeRoute = "/home"; +}