Skip to content
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

Update signup screen to match Figma design #57

Open
wants to merge 4 commits into
base: phase1
Choose a base branch
from
Open
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
295 changes: 267 additions & 28 deletions lib/presentation/screens/signup/signup_screen.dart
Original file line number Diff line number Diff line change
@@ -1,41 +1,280 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'signup_view_model.dart';
import 'package:flutter/services.dart';
import 'signup_view_model.dart';

class SignUpScreen extends StatelessWidget {
final SignUpViewModel _viewModel = SignUpViewModel();
class SignUpScreen extends StatefulWidget {
final SignUpViewModel _viewModel = SignUpViewModel();

SignUpScreen({super.key});

@override
_SignUpScreenState createState() => _SignUpScreenState();
}

class _SignUpScreenState extends State<SignUpScreen> {
bool _isChecked = false;
bool _usernameValid = false;
bool _emailValid = false;
bool _passwordValid = false;

final _formKey = GlobalKey<FormState>();

@override
Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.white,
));

final buttonColor = Colors.deepPurple;
final textColor = Colors.black;
final inputFillColor = Color(0xFFF5F5F5);

return Scaffold(
appBar: AppBar(title: const Text('Sign Up')),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextField(
controller: _viewModel.userNameController,
decoration: const InputDecoration(labelText: 'Username'),
),
TextField(
controller: _viewModel.emailController,
decoration: const InputDecoration(labelText: 'Email'),
),
TextField(
controller: _viewModel.passwordController,
decoration: const InputDecoration(labelText: 'Password'),
obscureText: true,
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () => _viewModel.signUp(context),
child: const Text('Sign Up'),
backgroundColor: Color(0xFFECECEC),
body: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: SingleChildScrollView(
child: Padding(
padding: EdgeInsets.all(24),
child: Form(
key: _formKey,
child: Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(height: 40),
Align(
alignment: Alignment.centerLeft,
child: IconButton(
icon: Icon(Icons.arrow_back, color: buttonColor, size: 30),
onPressed: () => Navigator.of(context).pop(),
),
),
SizedBox(height: 16),
Text('Sign Up', style: TextStyle(fontSize: 26, fontWeight: FontWeight.bold, color: textColor)),
SizedBox(height: 8),
Row(
children: [
Text('Hello,', style: TextStyle(fontSize: 26, fontWeight: FontWeight.bold, color: textColor)),
Text(' Welcome!', style: TextStyle(fontSize: 26, fontWeight: FontWeight.bold, color: buttonColor)),
],
),
SizedBox(height: 8),
Text('Please sign up to continue', style: TextStyle(color: textColor.withOpacity(0.5))),
SizedBox(height: 150),

TextFormField(
controller: widget._viewModel.userNameController,
onChanged: (text) {
setState(() {
_usernameValid = text.isNotEmpty;
});
},
decoration: InputDecoration(
hintText: 'Username',
suffixIcon: _usernameValid
? Icon(Icons.check, color: buttonColor, size: 24)
: null,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
),
filled: true,
fillColor: inputFillColor,
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
),
onEditingComplete: () {
setState(() {
_usernameValid = widget._viewModel.userNameController.text.isNotEmpty;
});
FocusScope.of(context).nextFocus();
},
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter a username';
}
return null;
},
),
SizedBox(height: 16),
TextFormField(
controller: widget._viewModel.emailController,
onChanged: (text) {
setState(() {
_emailValid = text.isNotEmpty && text.contains('@');
});
},
decoration: InputDecoration(
hintText: 'Email',
suffixIcon: _emailValid
? Icon(Icons.check, color: buttonColor, size: 24)
: null,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
),
filled: true,
fillColor: inputFillColor,
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
),
onEditingComplete: () {
setState(() {
_emailValid = widget._viewModel.emailController.text.isNotEmpty &&
widget._viewModel.emailController.text.contains('@');
});
FocusScope.of(context).nextFocus();
},
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter an email';
}
if (!value.contains('@')) {
return 'Please enter a valid email';
}
return null;
},
),
SizedBox(height: 16),
TextFormField(
controller: widget._viewModel.passwordController,
obscureText: true,
onChanged: (text) {
setState(() {
_passwordValid = text.isNotEmpty;
});
},
decoration: InputDecoration(
hintText: 'Password',
suffixIcon: _passwordValid
? Icon(Icons.lock, color: buttonColor, size: 24)
: null,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide.none,
),
filled: true,
fillColor: inputFillColor,
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 16),
),
onEditingComplete: () {
setState(() {
_passwordValid = widget._viewModel.passwordController.text.isNotEmpty;
});
},
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter a password';
}
return null;
},
),
SizedBox(height: 8),
Padding(
padding: EdgeInsets.only(left: 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Checkbox(
value: _isChecked,
onChanged: (bool? value) {
setState(() {
_isChecked = value ?? false;
});
},
),
Expanded(
child: RichText(
text: TextSpan(
text: 'I agree to the ',
style: TextStyle(color: textColor, fontWeight: FontWeight.bold, fontSize: 17),
children: <TextSpan>[
TextSpan(
text: 'Terms',
style: TextStyle(
decoration: TextDecoration.underline,
color: buttonColor,
fontWeight: FontWeight.bold,
fontSize: 17,
),
recognizer: TapGestureRecognizer()
..onTap = () {
print("Terms clicked");
},
),
TextSpan(
text: ' and ',
style: TextStyle(color: textColor, fontWeight: FontWeight.bold, fontSize: 17),
),
TextSpan(
text: 'Privacy Policy',
style: TextStyle(
decoration: TextDecoration.underline,
color: buttonColor,
fontWeight: FontWeight.bold,
fontSize: 17,
),
recognizer: TapGestureRecognizer()
..onTap = () {
print("Privacy Policy clicked");
},
),
],
),
),
),
],
),
),
SizedBox(height: 40),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
widget._viewModel.signUp(context);
}
},
child: Text('Sign Up', style: TextStyle(fontSize: 17, fontWeight: FontWeight.bold)),
style: ElevatedButton.styleFrom(
backgroundColor: buttonColor,
foregroundColor: Colors.white,
minimumSize: Size(double.infinity, 50),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
),
SizedBox(height: 32),
Center(
child: RichText(
text: TextSpan(
text: 'Already have an account? ',
style: TextStyle(color: textColor, fontWeight: FontWeight.bold, fontSize: 17),
children: <TextSpan>[
TextSpan(
text: 'Sign in',
style: TextStyle(
decoration: TextDecoration.underline,
color: buttonColor,
fontWeight: FontWeight.bold,
fontSize: 18,
),
recognizer: TapGestureRecognizer()
..onTap = () {
Navigator.pushNamed(context, '/login');
},
),
],
),
),
),
],
),
),
),
],
),
),
),
);
}
}
}