From 84fef5767beff22bc769d977b7486009ea7a0b8e Mon Sep 17 00:00:00 2001 From: iampawan Date: Fri, 5 Feb 2021 18:22:21 +0530 Subject: [PATCH 1/4] day 5 completed --- lib/main.dart | 5 +- lib/pages/login_page.dart | 99 ++++++++++++++++++++------------------- lib/utils/routes.dart | 4 ++ 3 files changed, 58 insertions(+), 50 deletions(-) create mode 100644 lib/utils/routes.dart 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..541acbc 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -1,61 +1,64 @@ import 'package:flutter/material.dart'; +import 'package:flutter_catalog/utils/routes.dart'; 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, - ), - 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, + ), + Text( + "Welcome", + 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", + ), ), - ), - 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, + ), + 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"; +} From 0e57c79befdf26615e4491467a219b69d3538b70 Mon Sep 17 00:00:00 2001 From: iampawan Date: Sat, 6 Feb 2021 17:17:30 +0530 Subject: [PATCH 2/4] day 6 completed --- lib/pages/login_page.dart | 60 ++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index 541acbc..2739751 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -1,7 +1,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_catalog/utils/routes.dart'; -class LoginPage extends StatelessWidget { +class LoginPage extends StatefulWidget { + @override + _LoginPageState createState() => _LoginPageState(); +} + +class _LoginPageState extends State { + String name = ""; + bool changeButton = false; + @override Widget build(BuildContext context) { return Material( @@ -17,7 +25,7 @@ class LoginPage extends StatelessWidget { height: 20.0, ), Text( - "Welcome", + "Welcome $name", style: TextStyle( fontSize: 28, fontWeight: FontWeight.bold, @@ -36,6 +44,10 @@ class LoginPage extends StatelessWidget { hintText: "Enter username", labelText: "Username", ), + onChanged: (value) { + name = value; + setState(() {}); + }, ), TextFormField( obscureText: true, @@ -47,13 +59,47 @@ class LoginPage extends StatelessWidget { SizedBox( height: 40.0, ), - ElevatedButton( - child: Text("Login"), - style: TextButton.styleFrom(minimumSize: Size(150, 40)), - onPressed: () { + + 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); + // }, + // ) ], ), ) From b9ceceba17a03372c4569c6f4c24b226012a5a7a Mon Sep 17 00:00:00 2001 From: Arpan Patel <47818179+arps18@users.noreply.github.com> Date: Sun, 21 Feb 2021 18:12:58 +0530 Subject: [PATCH 3/4] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index c3b927d..443e331 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=WtGQuA_Yu1E&list=PLrjrqTcKCnhTXI2GyPkaQF47inLp6LoIC&index=4)) + +- Stateful +- Animated Container +- Future Delay + ## Getting Started This project is a starting point for a Flutter application. From 25774872d099966092423e77f65b71ca18846316 Mon Sep 17 00:00:00 2001 From: Arpan Patel <47818179+arps18@users.noreply.github.com> Date: Sun, 21 Feb 2021 18:16:00 +0530 Subject: [PATCH 4/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 443e331..afb1633 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ A new Flutter project. -# Content of DAY 6 ([Tutorial](https://www.youtube.com/watch?v=WtGQuA_Yu1E&list=PLrjrqTcKCnhTXI2GyPkaQF47inLp6LoIC&index=4)) +# Content of DAY 6 ([Tutorial](https://www.youtube.com/watch?v=6CwlHS388wI&list=PLrjrqTcKCnhTXI2GyPkaQF47inLp6LoIC&index=6)) - Stateful - Animated Container