Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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()
},
);
}
Expand Down
147 changes: 98 additions & 49 deletions lib/pages/login_page.dart
Original file line number Diff line number Diff line change
@@ -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<LoginPage> {
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);
// },
// )
],
),
)
],
),
));
}
}
4 changes: 4 additions & 0 deletions lib/utils/routes.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class MyRoutes {
static String loginRoute = "/login";
static String homeRoute = "/home";
}