-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc656e2
commit 0767c19
Showing
5 changed files
with
216 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters