Skip to content

Added Sign up and Login Page #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
226 changes: 224 additions & 2 deletions lib/Signup_screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:habit_tracker/login_screen.dart';

class SignUpScreen extends StatefulWidget {
const SignUpScreen({super.key});
Expand All @@ -8,8 +9,229 @@ class SignUpScreen extends StatefulWidget {
}

class _SignUpScreenState extends State<SignUpScreen> {
TextEditingController firstNameC = TextEditingController();
TextEditingController lastNameC = TextEditingController();
TextEditingController emailC = TextEditingController();
TextEditingController passwordC = TextEditingController();
bool isCheck = true;
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return const Scaffold();
final media = MediaQuery.of(context).size;
return Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Form(
key: _formKey,
child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: media.width * 0.05,
),
const Text(
"Hey there",
style: TextStyle(fontSize: 16, color: Colors.black),
),
const Text(
"Create an Account",
style: TextStyle(
fontSize: 20,
color: Colors.black,
fontWeight: FontWeight.bold),
),
SizedBox(
height: media.width * 0.05,
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: RoundTextField(
hintText: "First Name",
controller: firstNameC,
icon: Icons.person_outline_rounded,
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: RoundTextField(
hintText: "Last Name",
controller: lastNameC,
icon: Icons.person_outline_rounded,
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: RoundTextField(
hintText: "Email",
controller: emailC,
icon: Icons.mail_outline_rounded,
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: RoundTextField(
hintText: "Password",
controller: passwordC,
icon: Icons.lock_outline_rounded,
),
),
Row(
children: [
IconButton(
onPressed: () {
setState(() {
isCheck = !isCheck;
});
},
icon: Icon(
isCheck
? Icons.check_box_rounded
: Icons.check_box_outline_blank_rounded,
color: Colors.grey,
)),
const Expanded(
child: Text(
"By continuing you accept our Privacy Policy and Terms of Use",
style: TextStyle(
fontSize: 11,
color: Colors.grey,
),
),
),
],
),
SizedBox(height: media.width * 0.1),
Container(
decoration: BoxDecoration(
color: Colors.green[700],
borderRadius: BorderRadius.circular(5),
),
child: MaterialButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => LoginScreen()));
}
},
height: 50,
minWidth: double.maxFinite,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5)),
child: const Text(
"Register",
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w700),
),
),
),
SizedBox(
height: media.width * 0.04,
),
Row(
children: [
Expanded(
child: Container(
width: double.maxFinite,
height: 1,
color: Colors.grey.withOpacity(0.5),
),
),
Text(
" Or ",
style: TextStyle(fontSize: 12, color: Colors.black),
),
Expanded(
child: Container(
width: double.maxFinite,
height: 1,
color: Colors.grey.withOpacity(0.5),
),
),
],
),
SizedBox(
height: media.width * 0.04,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
const Text(
"Already have an Account?",
style: TextStyle(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.w700),
),
TextButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LoginScreen()));
},
child: Text(
"Login",
style: TextStyle(
color: Colors.green[700],
fontSize: 14,
fontWeight: FontWeight.w700),
)),
],
),
SizedBox(
height: media.width * 0.04,
),
],
),
),
)),
),
);
}
}
}

class RoundTextField extends StatelessWidget {
final String hintText;
final TextEditingController controller;
final IconData icon;
const RoundTextField(
{super.key,
required this.hintText,
required this.controller,
required this.icon});

@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.grey[100],
),
child: TextField(
controller: controller,
decoration: InputDecoration(
border: OutlineInputBorder(),
contentPadding:
const EdgeInsets.symmetric(vertical: 15, horizontal: 15),
hintText: hintText,
hintStyle: TextStyle(color: Colors.grey, fontSize: 12),
prefixIcon: Icon(
icon as IconData?,
size: 22,
color: Colors.grey,
),
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none),
),
);
}
}
Loading