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

HomePage and Auth Page refactored #52

Open
wants to merge 5 commits into
base: master
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
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
12 changes: 12 additions & 0 deletions lib/constants/StringConstt.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
const String DIRECTOR_MSG =
"Being the Director of an ‘Institution of National Importance’it is a matter of pride as well as responsibility. Now, as the baton has passed on to me, I realize that it is for me to lay a roadmap that would take this institution to even greater heights. Having come from a research background and having seen, at close quarters, what meaningful research output can do for the growth and prestige of the country, I am convinced that research has to be a thrust area for our institutions of higher learning. I would strive to provide that thrust in this institution. If we succeed in enthusing our faculty, staff and students towards this end, our institute would become a cradle of creative and innovative ideas that can help develop new technologies, which, in turn, would transform our country. As a young institute, IIIT Sonepat has a unique opportunity to make a difference not only to Indian IT industry and the academic research community, but also the people of the entire region of Haryana. With this environment and rapidly improving connectivity to the IT capital New Delhi and the business city Gurugram, IIIT Sonepat is strategically positioned to develop into one of the best institutes of national importance in the country, under able and caring mentorship by NIT-Kurukshetra. In the coming years, with the support of its eminent Chairperson and Governing Body, the Institute will make every effort to construct and move to its spacious permanent campus located in a pristine setting near Sonepat. IIIT Sonepat is keen to push an effective research agenda and enhance its academic offerings by adding postgraduate and research programmes as well as more specializations of current relevance in undergraduate studies. Postgraduate studies and research will be a key factor for improving our visibility to the world. I also seek support of all stake holders in steering the institute to a great future. We have lots of work to do as multiple fronts. We have to create quality infrastructure, develop labs for academic and research activities, enhance research potential, expand the academic programs. We have to achieve all these in the fast changing education system. Let's all work together to achieve these goals.";
String greetingMessage() {
var timeNow = DateTime.now().hour;

if (timeNow <= 12) {
return 'Good Morning';
} else if ((timeNow > 12) && (timeNow <= 16)) {
return 'Good Afternoon';
} else {
return 'Good Evening';
}
}
String greeting = greetingMessage();
39 changes: 39 additions & 0 deletions lib/constants/decorations.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import 'package:flutter/material.dart';
InputDecoration inputDecor({String hint, IconData prefix, bool obscure, IconData suffix, Function toogle}) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not need to be refactored

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed some functionality of it too as it was using two bools before and doing an and operation on them now it only takes one and removed setState from it.

return InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.transparent),
borderRadius: BorderRadius.all(
Radius.circular(30.0),
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(30.0),
),
borderSide: BorderSide(color: Colors.grey[100]),
),
hintText: hint,
filled: true,
fillColor: Colors.grey.shade200,
prefixIcon: Icon(
prefix,
size: 25.0,
color: Colors.black,
),
suffixIcon: IconButton(
onPressed: toogle,
icon: Icon(
obscure ? Icons.visibility_off : suffix,
size: 25.0,
color: Colors.black,
),
),
hintStyle: TextStyle(
color: Colors.grey,
fontSize: 12.0,
fontWeight: FontWeight.w900,
fontStyle: FontStyle.normal,
),
);
}
6 changes: 1 addition & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';

import 'package:iiit_sonepat_stable/constants/routes.dart';
import 'package:iiit_sonepat_stable/ui/Auth/Login_Page/SplashScreen.dart';
import 'package:iiit_sonepat_stable/ui/Auth/Login_Page/Landing.dart';

void main() async {
// WidgetsFlutterBinding.ensureInitialized();
// await Firebase.initializeApp();
runApp(
MyApp(),
);
Expand All @@ -19,7 +15,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
title: 'IIIT Sonepat App',
theme: ThemeData(
primarySwatch: Colors.blue,
),
Expand Down
139 changes: 46 additions & 93 deletions lib/ui/Auth/Login_Page/Auth.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import 'package:flutter/material.dart';
import 'package:iiit_sonepat_stable/constants/routes.dart';
import 'package:iiit_sonepat_stable/constants/screenSize.dart';
import 'package:iiit_sonepat_stable/constants/theme.dart';
import 'package:iiit_sonepat_stable/constants/validators.dart';
import 'package:iiit_sonepat_stable/ui/Auth/Login_Page/Landing.dart';
import 'package:iiit_sonepat_stable/main.dart';
import 'package:iiit_sonepat_stable/ui/Home/homepage.dart';
import 'FogetPasswordPage.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:iiit_sonepat_stable/constants/decorations.dart';

class Auth extends StatefulWidget {
@override
_AuthState createState() => _AuthState();
}

class _AuthState extends State<Auth> {
final _scaffoldKey = GlobalKey<ScaffoldState>();

final TextEditingController emailController = new TextEditingController();

final TextEditingController passwordController = new TextEditingController();
Expand All @@ -24,50 +21,6 @@ class _AuthState extends State<Auth> {

bool isObscure = true;

InputDecoration inputDecor(
String hint, IconData prefix, bool obscure, IconData suffix) {
return InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.transparent),
borderRadius: BorderRadius.all(
Radius.circular(30.0),
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(30.0),
),
borderSide: BorderSide(color: Colors.grey[100]),
),
hintText: hint,
filled: true,
fillColor: Colors.grey.shade200,
prefixIcon: Icon(
prefix,
size: 25.0,
color: Colors.black,
),
suffixIcon: IconButton(
onPressed: () {
setState(() {
isObscure = !isObscure;
});
},
icon: Icon(
isObscure && obscure ? Icons.visibility_off : suffix,
size: 25.0,
color: Colors.black,
),
),
hintStyle: TextStyle(
color: Colors.grey,
fontSize: 12.0,
fontWeight: FontWeight.w900,
fontStyle: FontStyle.normal,
),
);
}

@override
Widget build(BuildContext context) {
SizeConfig().init(context);
Expand Down Expand Up @@ -140,24 +93,28 @@ class _AuthState extends State<Auth> {
child: Column(
children: [
TextFormField(
// autovalidateMode: AutovalidateMode.always,
autovalidateMode:
AutovalidateMode.onUserInteraction,
validator: emailValidator,
style: TextStyle(
color: Colors.black,
fontSize: 15,
),
controller: emailController,
decoration: inputDecor(
"[email protected]",
Icons.mail_outline,
false,
null),
hint: "[email protected]",
prefix: Icons.mail_outline,
obscure: false,
suffix: null,
toogle: null,
),
),
SizedBox(
height: 12.0,
),
TextFormField(
//autovalidateMode: AutovalidateMode.always,
autovalidateMode:
AutovalidateMode.onUserInteraction,
validator: pwdValidator,
style: TextStyle(
color: Colors.black,
Expand All @@ -166,10 +123,15 @@ class _AuthState extends State<Auth> {
obscureText: isObscure,
controller: passwordController,
decoration: inputDecor(
"Password",
Icons.lock_outline_rounded,
true,
Icons.visibility),
hint: "Password",
prefix: Icons.lock_outline_rounded,
obscure: isObscure,
suffix: Icons.visibility,
toogle: () {
setState(() {
isObscure = !isObscure;
});
}),
),
],
),
Expand All @@ -192,17 +154,6 @@ class _AuthState extends State<Auth> {
onTap: () {
//[TODO] add direct mail facilty to contact admin
Fluttertoast.showToast(msg: "Contact Admin");
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) =>
// ForgetPassword(
// rollController,
// phoneController,
// nameController,
// ),
// ),
// );
}),
),
),
Expand All @@ -211,30 +162,32 @@ class _AuthState extends State<Auth> {
child: ButtonTheme(
minWidth: 250,
height: 60,
// ignore: deprecated_member_use
child: RaisedButton(
color: Colors.black87,
child: Text(
"Sign In",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w600,
color: Colors.white),
),
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(30.0),
),
onPressed: () {
if (!formAuthKey.currentState.validate()) {
Fluttertoast.showToast(
msg: 'Oops something went wrong');
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => HomeScreen()),
);
}
}),
color: Colors.black87,
child: Text(
"Sign In",
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.w600,
color: Colors.white),
),
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(30.0),
),
onPressed: () {
if (!formAuthKey.currentState.validate()) {
Fluttertoast.showToast(
msg: 'Oops something went wrong');
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => HomeScreen()),
);
}
},
),
),
),
],
Expand Down
Loading