Skip to content

Commit

Permalink
user login/signup UI
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragtyagi2003 committed Jun 8, 2024
1 parent bc656e2 commit 0767c19
Show file tree
Hide file tree
Showing 5 changed files with 216 additions and 1 deletion.
16 changes: 16 additions & 0 deletions lib/models/login.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Model
class LoginModel {
String _email = '';
String _password = '';

String get email => _email;
String get password => _password;

set email(String value) {
_email = value;
}

set password(String value) {
_password = value;
}
}
22 changes: 22 additions & 0 deletions lib/models/signup.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Model
class SignUpModel {
String _name = '';
String _email = '';
String _password = '';

String get name => _name;
String get email => _email;
String get password => _password;

set name(String value) {
_name = value;
}

set email(String value) {
_email = value;
}

set password(String value) {
_password = value;
}
}
79 changes: 79 additions & 0 deletions lib/user_login.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import 'package:firebase_editor_gsoc/home_screen.dart';
import 'package:firebase_editor_gsoc/models/login.dart';
import 'package:flutter/material.dart';

class LoginScreen extends StatefulWidget {
@override
_LoginScreenState createState() => _LoginScreenState();
}

class _LoginScreenState extends State<LoginScreen> {
final _model = LoginModel();
final _formKey = GlobalKey<FormState>();

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Login'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: Column(
children: [
TextFormField(
decoration: InputDecoration(
labelText: 'Email',
),
validator: (value) {
if (value!.isEmpty) {
return 'Please enter your email';
}
return null;
},
onChanged: (value) {
_model.email = value;
},
),
TextFormField(
decoration: InputDecoration(
labelText: 'Password',
),
obscureText: true,
validator: (value) {
if (value!.isEmpty) {
return 'Please enter your password';
}
return null;
},
onChanged: (value) {
_model.password = value;
},
),
SizedBox(height: 16.0),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
// Perform login logic here
print('Email: ${_model.email}');
print('Password: ${_model.password}');
}
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => HomeScreen(),
),
);

},
child: Text('Login'),
),
],
),
),
),
);
}
}
97 changes: 97 additions & 0 deletions lib/user_signup.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import 'package:firebase_editor_gsoc/home_screen.dart';
import 'package:firebase_editor_gsoc/models/signup.dart';
import 'package:flutter/material.dart';

// View
class SignUpScreen extends StatefulWidget {
@override
_SignUpScreenState createState() => _SignUpScreenState();
}

class _SignUpScreenState extends State<SignUpScreen> {
final _model = SignUpModel();
final _formKey = GlobalKey<FormState>();

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Sign Up'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: Column(
children: [
TextFormField(
decoration: InputDecoration(
labelText: 'Name',
),
validator: (value) {
if (value!.isEmpty) {
return 'Please enter your name';
}
return null;
},
onChanged: (value) {
_model.name = value;
},
),
TextFormField(
decoration: InputDecoration(
labelText: 'Email',
),
validator: (value) {
if (value!.isEmpty) {
return 'Please enter your email';
}
return null;
},
onChanged: (value) {
_model.email = value;
},
),
TextFormField(
decoration: InputDecoration(
labelText: 'Password',
),
obscureText: true,
validator: (value) {
if (value!.isEmpty) {
return 'Please enter your password';
}
return null;
},
onChanged: (value) {
_model.password = value;
},
),
SizedBox(height: 16.0),
ElevatedButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
// Perform sign-up logic here
print('Name: ${_model.name}');
print('Email: ${_model.email}');
print('Password: ${_model.password}');


}

Navigator.push(
context,
MaterialPageRoute(
builder: (context) => HomeScreen(),
),
);
},
child: Text('Sign Up'),
),
],
),
),
),
);
}
}
3 changes: 2 additions & 1 deletion lib/views/list_databases.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:firebase_editor_gsoc/views/database_overview.dart';
import 'package:firebase_editor_gsoc/views/define_schema.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -28,7 +29,7 @@ class DatabaseList extends StatelessWidget {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DefineSchema(),
builder: (context) => DatabaseOverview(),
),
);
print('Tapped on ${database.databaseName}');
Expand Down

0 comments on commit 0767c19

Please sign in to comment.