Sign In Screen Simple UI

 import "package:flutter/material.dart";

import "package:wscubetech_app_ui/HomePage/HomePage_Screen.dart";
import "package:wscubetech_app_ui/SignUp_Password_Screens/Forgot_Password.dart";
import "package:wscubetech_app_ui/SignUp_Password_Screens/SignUp_Screen.dart";

class SignIn extends StatefulWidget {
const SignIn({super.key});

@override
State<SignIn> createState() {
return SignInState();
}
}

class SignInState extends State<SignIn> {
TextEditingController usernameController = TextEditingController();
TextEditingController passwordController = TextEditingController();

bool _obscureText = true;

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
return FocusManager.instance.primaryFocus?.unfocus();
},
child: Scaffold(
body: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Colors.blue.shade700,
Colors.blue.shade100,
Colors.blue.shade50,
],
begin: const FractionalOffset(1.0, 0.0),
end: const FractionalOffset(0.0, 1.0),
),
),
child: Center(
child: Container(
width: 360.0,
height: 480.0,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
color: Colors.white,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text(
"Sign In",
style:
TextStyle(fontWeight: FontWeight.bold, fontSize: 20.0),
),
const SizedBox(height: 50.0),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(11.0),
color: Colors.grey.shade300,
),
width: 330.0,
child: TextFormField(
controller: usernameController,
decoration: const InputDecoration(
border: InputBorder.none,
hintText: "Username",
hintStyle: TextStyle(fontWeight: FontWeight.w300),
prefixIcon: Icon(Icons.account_circle_outlined),
),
),
),
const SizedBox(height: 30.0),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(11.0),
color: Colors.grey.shade300,
),
width: 330.0,
child: TextFormField(
controller: passwordController,
obscureText: _obscureText,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Password",
hintStyle: const TextStyle(fontWeight: FontWeight.w300),
prefixIcon: const Icon(Icons.lock_outline),
suffixIcon: IconButton(
onPressed: () {
setState(
() {
_obscureText = !_obscureText;
},
);
},
icon: Icon(_obscureText
? Icons.visibility
: Icons.visibility_off),
),
),
),
),
const SizedBox(height: 30.0),
Row(
children: [
const SizedBox(width: 20.0),
ElevatedButton(
onPressed: () {
var username = usernameController.text;
var password = passwordController.text;

if (username.isEmpty || password.isEmpty) {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text(
"Please fill all details",
style:
TextStyle(fontWeight: FontWeight.bold),
),
content: const Text("Enter required details"),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text(
"Ok",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
),
],
);
},
);
}
else
{
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return HomePage();
},
),
);
}
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
fixedSize: const Size(150.0, 50.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(11.0),
),
),
child: const Text(
"Sign In",
style: TextStyle(color: Colors.white),
),
),
const SizedBox(width: 25.0),
TextButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return ForgotPassword();
},
),
);
},
child: const Text(
"Forgotten Password?",
style: TextStyle(color: Colors.blue),
),
),
],
),
const SizedBox(height: 50.0),
TextButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) {
return SignUp();
},
),
);
},
child: const Text(
"Create a new Account",
style: TextStyle(color: Colors.blue),
),
),
],
),
),
),
),
),
);
}
}


Comments