diff --git a/book_reader/android/app/build.gradle b/book_reader/android/app/build.gradle index 0047647..26a99db 100644 --- a/book_reader/android/app/build.gradle +++ b/book_reader/android/app/build.gradle @@ -22,6 +22,13 @@ if (flutterVersionName == null) { } apply plugin: 'com.android.application' +<<<<<<< HEAD +<<<<<<< HEAD +apply plugin: 'com.google.gms.google-services' +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" @@ -41,6 +48,13 @@ android { applicationId "com.example.book_reader" minSdkVersion 16 targetSdkVersion 28 +<<<<<<< HEAD +<<<<<<< HEAD + multiDexEnabled true +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/book_reader/android/app/google-services.json b/book_reader/android/app/google-services.json new file mode 100644 index 0000000..1d773ee --- /dev/null +++ b/book_reader/android/app/google-services.json @@ -0,0 +1,48 @@ +{ + "project_info": { + "project_number": "203064539896", + "firebase_url": "https://bookreader-f51ec.firebaseio.com", + "project_id": "bookreader-f51ec", + "storage_bucket": "bookreader-f51ec.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:203064539896:android:cb8f756342208cd5e7990d", + "android_client_info": { + "package_name": "com.example.book_reader" + } + }, + "oauth_client": [ + { + "client_id": "203064539896-evpmps91md5g2cnjmgu6tk1htk138p3t.apps.googleusercontent.com", + "client_type": 1, + "android_info": { + "package_name": "com.example.book_reader", + "certificate_hash": "e4213537a29c22c4db76dee1e9efc796b8d765be" + } + }, + { + "client_id": "203064539896-jv5nld3lk0usosg61mbseb65o7ae1ibd.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyAINwPBFShbQVCIyNdPtUaWd75Q1AIDp9U" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "203064539896-jv5nld3lk0usosg61mbseb65o7ae1ibd.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/book_reader/android/build.gradle b/book_reader/android/build.gradle index 3100ad2..6853e5b 100644 --- a/book_reader/android/build.gradle +++ b/book_reader/android/build.gradle @@ -8,6 +8,13 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:3.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" +<<<<<<< HEAD +<<<<<<< HEAD + classpath 'com.google.gms:google-services:4.3.3' +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d } } diff --git a/book_reader/assets/google_logo.png b/book_reader/assets/google_logo.png new file mode 100644 index 0000000..d2d96bb Binary files /dev/null and b/book_reader/assets/google_logo.png differ diff --git a/book_reader/lib/home.dart b/book_reader/lib/home.dart index 21a21de..d7d2255 100644 --- a/book_reader/lib/home.dart +++ b/book_reader/lib/home.dart @@ -1,11 +1,148 @@ import 'package:flutter/material.dart'; import 'package:book_reader/Animation/FadeAnimation.dart'; import 'package:book_reader/main.dart'; +<<<<<<< HEAD +<<<<<<< HEAD +import 'package:flutter/services.dart'; + + + + +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d class MainPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( +<<<<<<< HEAD +<<<<<<< HEAD + resizeToAvoidBottomInset: false, + backgroundColor: Colors.white, + appBar: AppBar( + elevation: 0, + brightness: Brightness.light, + backgroundColor: Colors.white, + leading: IconButton( + onPressed: () { + Navigator.pop(context); + }, + icon: Icon( + Icons.arrow_back_ios, + size: 20, + color: Colors.black, + ), + ), + actions: [ + IconButton( + icon: Icon( + Icons.gps_off, + color: Colors.black, + ), + onPressed: () { + Navigator.push(context, MaterialPageRoute(builder: (context) => HomePage())); + }, + ) + ], + ), + body: Container( + height: MediaQuery.of(context).size.height, + width: double.infinity, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Column( + children: [ + FadeAnimation( + 1, + Text( + "Book Reader", + style: TextStyle( + fontSize: 30, fontWeight: FontWeight.bold), + )), + SizedBox( + height: 20, + ), + FadeAnimation( + 1.2, + Text( + "Write the name of the book", + style: + TextStyle(fontSize: 15, color: Colors.grey[700]), + ), + ), + FadeAnimation( + 1.2, + Text( + "and we will read it for you!", + style: TextStyle( + fontSize: 15, color: Colors.grey[700]), + )), + ], + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 40), + child: Column( + children: [ + FadeAnimation(1.2, makeInput(label: "Book Name")), + ], + ), + ), + FadeAnimation( + 1.4, + Padding( + padding: EdgeInsets.symmetric(horizontal: 40), + child: Container( + padding: EdgeInsets.only(top: 3, left: 3), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(50), + border: Border( + bottom: BorderSide(color: Colors.black), + top: BorderSide(color: Colors.black), + left: BorderSide(color: Colors.black), + right: BorderSide(color: Colors.black), + )), + child: MaterialButton( + minWidth: double.infinity, + height: 60, + onPressed: () {}, + color: Colors.greenAccent, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(50)), + child: Text( + "Read!", + style: TextStyle( + fontWeight: FontWeight.w600, fontSize: 18), + ), + ), + ), + )), + ], + ), + ), + FadeAnimation( + 1.2, + Container( + height: MediaQuery.of(context).size.height / 3, + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/background.png'), + fit: BoxFit.cover)), + )) + ], + ), + ), + ); +======= +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d resizeToAvoidBottomInset: false, backgroundColor: Colors.white, appBar: AppBar( @@ -127,6 +264,10 @@ class MainPage extends StatelessWidget { ), ), ); +<<<<<<< HEAD +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d } Widget makeInput({label, obscureText = false}) { @@ -157,4 +298,12 @@ class MainPage extends StatelessWidget { ], ); } +<<<<<<< HEAD +<<<<<<< HEAD +} +======= +} +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= } +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d diff --git a/book_reader/lib/login.dart b/book_reader/lib/login.dart index 148c715..98e71a1 100644 --- a/book_reader/lib/login.dart +++ b/book_reader/lib/login.dart @@ -1,4 +1,339 @@ import 'package:flutter/material.dart'; +<<<<<<< HEAD +<<<<<<< HEAD +import 'Animation/FadeAnimation.dart'; +import 'package:email_validator/email_validator.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:google_sign_in/google_sign_in.dart'; +import 'package:modal_progress_hud/modal_progress_hud.dart'; + + + +final _auth=FirebaseAuth.instance; +final _firestore=FirebaseFirestore.instance; +final GoogleSignIn googleSignIn=GoogleSignIn(); + +class LoginPage extends StatefulWidget { + @override + _LoginPageState createState() => _LoginPageState(); +} + +class _LoginPageState extends State { + final _formKey=GlobalKey(); + String email,pass; + bool showSpinner=false; + final myController1=TextEditingController(); + final myController2=TextEditingController(); + final _scaffoldKey=GlobalKey(); + + bool _secureText=true; + void toggle(){ + setState(() { + _secureText=!_secureText; + }); + + } + + + @override + Widget build(BuildContext context) { + return Scaffold( + key: _scaffoldKey, + body: FadeAnimation(2.0, + Stack( + children: [ + Positioned( + bottom: 0.0, + left: 0.0, + child: Container( + height: MediaQuery.of(context).size.height / 3, + width: MediaQuery.of(context).size.width, + child: Image.asset('assets/background.png'), + + + + ), + ), + ModalProgressHUD( + inAsyncCall:showSpinner , + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Center( + child: Form( + key: _formKey, + child:ListView( + shrinkWrap: true, + children: [ + Container( + child: Column( + children: [ + Text("Sign In", style: TextStyle( + fontSize: 30, + fontWeight: FontWeight.bold + ),), + SizedBox(height: 20), + Text("Sign In to explore the world of Books", style: TextStyle( + fontSize: 15, + color: Colors.grey[700] + ),) + ], + ), + ), + SizedBox(height: 20), + + + TextFormField( + enableSuggestions: true, + controller: myController1, + keyboardType: TextInputType.emailAddress, + keyboardAppearance: Brightness.dark, + validator: (value){ + if(value.isEmpty){ + return "Enter your Email ID"; + } + else if(!EmailValidator.validate(value)){ + return "Enter a Valid Email ID"; + + } + return null; + }, + onChanged: (value){ + email=value; + }, + + decoration: InputDecoration( + labelText: "Email ID", + border: const OutlineInputBorder(), + icon: const Padding( + padding: const EdgeInsets.only(top: 15.0), + child: const Icon(Icons.email)), + ) , + + + ), + + + SizedBox( + height: 20.0, + ), + TextFormField( + controller: myController2, + decoration: InputDecoration( + labelText: "Password", + suffixIcon: FlatButton(onPressed: (){ + setState(() { + toggle(); + }); + }, child: Icon(Icons.remove_red_eye)), + border: const OutlineInputBorder(), + icon: const Padding( + padding: const EdgeInsets.only(top: 15.0), + child: const Icon(Icons.live_help)), + + ) , + validator: (value) => value.length < 6 ? 'Password too short.' : null, + onChanged: (value){ + pass=value; + }, + + obscureText: _secureText, + ), + + + SizedBox( + height: 20.0, + ), + + Center( + child: RaisedButton( + + onPressed: () async{ + bool isUser; + UserCredential userCredential; + if(_formKey.currentState.validate()){ + setState(() { + showSpinner=true; + }); + try { + final user=await _auth.signInWithEmailAndPassword(email: email, password: pass); + print(user); + if(user!=null){ + Navigator.pushNamed(context,"home"); + } + + + + }on FirebaseAuthException catch(e){ + if(e.code=='user-not-found'){ + isUser=false; + } + print('${e.code}'); + } + catch (e) { + print(e.toString()); + Navigator.pushNamed(context, "register"); + + }finally{ + + setState(() { + showSpinner=false; + }); + if(!isUser){ + Navigator.pushNamed(context,"register"); + } + } + + + + + + } + + }, + color: Colors.lightGreenAccent, + splashColor: Colors.cyan, + elevation: 10.0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(50) + ), + child: Text("Sign In", style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 20.0 + ),), + ), + ), + + getSeparateDivider(), + SizedBox( + height: 20.0, + ), + + _signInGoogle(context), + + SizedBox( + height: 40.0, + ), + + + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text("Don't have an account ? "), + Material( + color: Colors.white.withOpacity(0.0), + child: InkWell( + splashColor: Colors.orange, + child:Text(" Sign Up", style: TextStyle( + fontWeight: FontWeight.w600, fontSize: 18 + ),), + onTap: (){ + Navigator.pushNamed(context,"register"); + }, + ), + ) + + + ], + ), + + ], + )), + + ), + ), + ), + ], + ), + ), + ); + } +} + + + + + +Future _signInWithGoogle() async{ + bool isSignedIn=await googleSignIn.isSignedIn(); + if(isSignedIn){ + final user= _auth.currentUser; + return user; + }else{ + final GoogleSignInAccount googleSignInAccount=await googleSignIn.signIn(); + final GoogleSignInAuthentication googleSignInAuthentication=await googleSignInAccount.authentication; + + final AuthCredential credential=GoogleAuthProvider.credential( + accessToken: googleSignInAuthentication.accessToken, + idToken: googleSignInAuthentication.idToken + ); + + final result =await _auth.signInWithCredential(credential); + final User user=result.user; + + assert(!user.isAnonymous); + assert(await user.getIdToken() !=null); + + final currentUser =_auth.currentUser; + assert(currentUser.uid==user.uid); + + _firestore.collection("users").add({ + "name":currentUser.displayName, + "email":currentUser.email + }); + print(currentUser.email); + + return user; + + } + + + +} + +Widget _signInGoogle(BuildContext context) { + return RaisedButton( + elevation: 10.0, + splashColor: Colors.lightBlueAccent, + onPressed: () async{ + try { + final user= await _signInWithGoogle(); + if(user!=null){ + Navigator.pushNamed(context, "home"); + } + + + }on FirebaseAuthException catch(e){ + print('${e.code}'); + } + catch (e) { + print(e.toString()); + } + + }, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)), + highlightElevation: 0, + padding: EdgeInsets.all(10.0), + child: Row( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset("assets/google_logo.png",height: 20.0), + Padding( + padding: const EdgeInsets.only(left: 10), + child: Text( + 'Sign In', + style: TextStyle( + fontSize: 20, + color: Colors.grey, + ), + ), + ), + + ], +======= +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d import 'package:book_reader/Animation/FadeAnimation.dart'; import 'package:book_reader/signup.dart'; import 'package:book_reader/home.dart'; @@ -129,10 +464,71 @@ class LoginPage extends StatelessWidget { )) ], ), +<<<<<<< HEAD +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d ), ); } +<<<<<<< HEAD +<<<<<<< HEAD + + + + + +//Horizontal Divider + +class Drawhorizontalline extends CustomPainter { + Paint _paint; + bool reverse; + + Drawhorizontalline(this.reverse) { + _paint = Paint() + ..color = Colors.black + ..strokeWidth = 1 + ..strokeCap = StrokeCap.round; + } + + @override + void paint(Canvas canvas, Size size) { + if (reverse) { + canvas.drawLine(Offset(-250.0, 0.0), Offset(-10.0, 0.0), _paint); + } else { + canvas.drawLine(Offset(10.0, 0.0), Offset(250.0, 0.0), _paint); + } + } + + @override + bool shouldRepaint(CustomPainter oldDelegate) { + return false; + } +} + + +Widget getSeparateDivider() { +return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CustomPaint(painter: Drawhorizontalline(true)), + Text( + "OR", + style: TextStyle( + color: Colors.black38, + fontWeight: FontWeight.bold, + fontSize: 10.0), + ), + CustomPaint(painter: Drawhorizontalline(false)) + ], + ); +} + + +======= +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d Widget makeInput({label, obscureText = false}) { return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -162,3 +558,7 @@ class LoginPage extends StatelessWidget { ); } } +<<<<<<< HEAD +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d diff --git a/book_reader/lib/main.dart b/book_reader/lib/main.dart index b2684b9..d2e3ef2 100644 --- a/book_reader/lib/main.dart +++ b/book_reader/lib/main.dart @@ -3,6 +3,61 @@ import 'package:flutter/widgets.dart'; import 'package:book_reader/Animation/FadeAnimation.dart'; import 'package:book_reader/login.dart'; import 'package:book_reader/signup.dart'; +<<<<<<< HEAD +<<<<<<< HEAD +import 'package:gradient_text/gradient_text.dart'; +import 'package:loading/loading.dart'; +import 'package:loading/indicator/ball_pulse_indicator.dart'; +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/services.dart'; +import 'home.dart'; + + +Future main() async{ + WidgetsFlutterBinding.ensureInitialized(); + // jwt=prefs.getBool('verifyUser')??false; + runApp(MyApp()); + +} + + +class MyApp extends StatelessWidget { + @override + Widget build(BuildContext context) { + + SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( + statusBarColor:Color(0x00000000) + )); + + return FutureBuilder( + future: Firebase.initializeApp(), + builder:(context,snapshot){ + if(snapshot.hasError){ + print("Something Wrong to Initialize FLutter Firebase"); + return null; + } + else if(snapshot.connectionState ==ConnectionState.done){ + return MaterialApp( + debugShowCheckedModeBanner: false, + + home: HomePage(), + routes: { + "login":(context)=>LoginPage(), + "register":(context)=>SignupPage(), + "home":(context)=>MainPage(), + + }, + + ); + } + return Loading(indicator: BallPulseIndicator(),size: 100.0,color:Colors.blue); + + } + ); + } +======= +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d void main() { @@ -12,6 +67,10 @@ void main() { home: HomePage(), ) ); +<<<<<<< HEAD +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d } class HomePage extends StatelessWidget { @@ -34,12 +93,38 @@ class HomePage extends StatelessWidget { fontSize: 30 ),)), SizedBox(height: 20,), +<<<<<<< HEAD +<<<<<<< HEAD + FadeAnimation(1.2, Row( + mainAxisAlignment: MainAxisAlignment.center, + children:[ + Text("Welcome to the ", + style: TextStyle( + color: Colors.grey[700], + fontSize: 20 + ),), + grad(), + Text("app ", + style: TextStyle( + color: Colors.grey[700], + fontSize: 20 + ),), + + ] + )), +======= +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d FadeAnimation(1.2, Text("Welcome to the book reader app", textAlign: TextAlign.center, style: TextStyle( color: Colors.grey[700], fontSize: 15 ),)), +<<<<<<< HEAD +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d ], ), FadeAnimation(1.4, Container( @@ -106,4 +191,23 @@ class HomePage extends StatelessWidget { ), ); } -} \ No newline at end of file +<<<<<<< HEAD +<<<<<<< HEAD +} + + +Widget grad(){ + return GradientText("Book Reader ", + gradient: LinearGradient( + colors: [Colors.deepPurple, Colors.deepOrange, Colors.yellow]), + style: TextStyle(fontSize: 20), + ); +} + + +======= +} +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= +} +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d diff --git a/book_reader/lib/signup.dart b/book_reader/lib/signup.dart index c60663e..69d65b2 100644 --- a/book_reader/lib/signup.dart +++ b/book_reader/lib/signup.dart @@ -1,5 +1,447 @@ import 'package:flutter/material.dart'; import 'package:book_reader/Animation/FadeAnimation.dart'; +<<<<<<< HEAD +<<<<<<< HEAD +import 'package:email_validator/email_validator.dart'; +import 'package:modal_progress_hud/modal_progress_hud.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:google_sign_in/google_sign_in.dart'; + +final _auth=FirebaseAuth.instance; +final _firestore=FirebaseFirestore.instance; +final GoogleSignIn googleSignIn=GoogleSignIn(); + +class SignupPage extends StatefulWidget { + @override + _SignupPageState createState() => _SignupPageState(); +} + +class _SignupPageState extends State { + + final _formKey=GlobalKey(); + final myController1=TextEditingController(); + final myController2=TextEditingController(); + final myController3=TextEditingController(); + bool showSpinner=false; + String name,email,pass; + + + + + bool _secureText=true; + void toggle(){ + setState(() { + _secureText=!_secureText; + }); + + } + + + @override + Widget build(BuildContext context) { + return Scaffold( + body: FadeAnimation(2.0, + Stack( + children: [ + + Positioned( + bottom: 0.0, + left: 0.0, + child: Container( + height: MediaQuery.of(context).size.height / 3, + width: MediaQuery.of(context).size.width, + child: Image.asset('assets/background.png'), + + + + ), + ), + + ModalProgressHUD( + inAsyncCall: showSpinner, + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Center( + child: Form( + key: _formKey, + child:ListView( + shrinkWrap: true, + children: [ + Container( + child: Column( + children: [ + Text("Sign up", style: TextStyle( + fontSize: 30, + fontWeight: FontWeight.bold + ),), + SizedBox(height: 20), + Text("Create an account, It's free", style: TextStyle( + fontSize: 15, + color: Colors.grey[700] + ),) + ], + ), + ), + SizedBox(height: 20), + TextFormField( + enableSuggestions: true, + controller: myController1, + keyboardType: TextInputType.name, + keyboardAppearance: Brightness.dark, + validator: (value){ + if(value.isEmpty){ + return "Enter Your Name"; + } + return null; + }, + onChanged: (value){ + name=value; + + }, + + decoration: InputDecoration( + labelText:"Name", + + + alignLabelWithHint:true, + hintText:"Enter your Name ...", + border: const OutlineInputBorder(), + icon: const Padding( + padding: const EdgeInsets.only(top: 10.0), + child: const Icon(Icons.person_pin)), + ), + ), + + SizedBox( + height: 20.0, + ), + TextFormField( + enableSuggestions: true, + controller: myController2, + keyboardType: TextInputType.emailAddress, + keyboardAppearance: Brightness.dark, + validator: (value){ + if(value.isEmpty){ + return "Enter your Email ID"; + } + else if(!EmailValidator.validate(value)){ + return "Enter a Valid Email ID"; + + } + return null; + }, + onChanged: (value){ + email=value; + }, + + decoration: InputDecoration( + labelText: "Email ID", + border: const OutlineInputBorder(), + icon: const Padding( + padding: const EdgeInsets.only(top: 15.0), + child: const Icon(Icons.email)), + ) , + + + ), + + SizedBox( + height: 20.0, + ), + TextFormField( + controller: myController3, + decoration: InputDecoration( + labelText: "Password", + suffixIcon: FlatButton(onPressed: (){ + setState(() { + toggle(); + }); + }, child: Icon(Icons.remove_red_eye)), + border: const OutlineInputBorder(), + icon: const Padding( + padding: const EdgeInsets.only(top: 15.0), + child: const Icon(Icons.live_help)), + + ) , + validator: (value) => value.length < 6 ? 'Password too short.' : null, + onChanged: (value){ + pass=value; + }, + + obscureText: _secureText, + ), + + + + + SizedBox( + height: 20.0, + ), + + Center( + child: RaisedButton( + + onPressed: () async{ + bool isUser; + UserCredential userCredential ; + if(_formKey.currentState.validate()){ + setState(() { + showSpinner=true; + }); + + try { + userCredential = await _auth.createUserWithEmailAndPassword( + email: email, password: pass); + if(userCredential!=null){ + _firestore.collection("users").add({ + "name":name, + "email":email + }); + } + + + } on FirebaseAuthException catch (e) { + if (e.code == 'weak-password') { + print("${e.code}"); + + + } else if (e.code == 'email-already-in-use') { + print("${e.code}"); + isUser=true; + } + } catch (e) { + print(e.toString()); + }finally{ + + setState(() { + showSpinner=false; + }); + if(isUser){ + Navigator.pushNamed(context,"login"); + } + } + + if(userCredential!=null){ + Navigator.pushNamed(context,"home"); + } + + + + } + + }, + color: Colors.lightGreenAccent, + padding: EdgeInsets.all(10.0), + splashColor: Colors.cyan, + elevation: 10.0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(50) + ), + child: Text("Sign Up", style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 20.0 + ),), + ), + ), + + getSeparateDivider(), + SizedBox( + height: 20.0, + ), + + _signUpGoogle(context), + + SizedBox( + height: 40.0, + ), + + + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text("Already have an account?"), + Material( + color: Colors.white.withOpacity(0.0), + child: InkWell( + splashColor: Colors.orange, + child:Text(" Login", style: TextStyle( + fontWeight: FontWeight.w600, fontSize: 18 + ),), + onTap: (){ + Navigator.pushNamed(context,"login"); + }, + ), + ) + + + ], + ), + + + + + + ], + + )), + ), + ), + ), + ], + ), + ), + ); + } +} + + + +Future _signUpWithGoogle() async{ + bool isSignedIn=await googleSignIn.isSignedIn(); + if(isSignedIn){ + final user= _auth.currentUser; + return user; + }else{ + final GoogleSignInAccount googleSignInAccount=await googleSignIn.signIn(); + final GoogleSignInAuthentication googleSignInAuthentication=await googleSignInAccount.authentication; + + final AuthCredential credential=GoogleAuthProvider.credential( + accessToken: googleSignInAuthentication.accessToken, + idToken: googleSignInAuthentication.idToken + ); + + final result =await _auth.signInWithCredential(credential); + final User user=result.user; + + assert(!user.isAnonymous); + assert(await user.getIdToken() !=null); + + final currentUser =_auth.currentUser; + assert(currentUser.uid==user.uid); + + _firestore.collection("users").add({ + "name":currentUser.displayName, + "email":currentUser.email + }); + print(currentUser.email); + + return user; + + } + + + +} + +Widget _signUpGoogle(BuildContext context) { + return RaisedButton( + splashColor: Colors.lightBlueAccent, + elevation: 10.0, + onPressed: () async{ + try { + final user= await _signUpWithGoogle(); + + + }on FirebaseAuthException catch(e){ + print('${e.code}'); + + + } + catch (e) { + print(e.toString()); + } + + Navigator.pushNamed(context, "home"); + + + }, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)), + highlightElevation: 0, + padding: EdgeInsets.only(top:10.0,bottom:10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset("assets/google_logo.png",height: 20.0), + Padding( + padding: const EdgeInsets.only(left:5.0), + child: Text( + 'Sign up with Google', + style: TextStyle( + fontSize: 20, + color: Colors.black, + ), + ), + ), + + ], + ), + ); + } + + + + + + +//Horizontal Divider + +class Drawhorizontalline extends CustomPainter { + Paint _paint; + bool reverse; + + Drawhorizontalline(this.reverse) { + _paint = Paint() + ..color = Colors.black + ..strokeWidth = 1 + ..strokeCap = StrokeCap.round; + } + + @override + void paint(Canvas canvas, Size size) { + if (reverse) { + canvas.drawLine(Offset(-250.0, 0.0), Offset(-10.0, 0.0), _paint); + } else { + canvas.drawLine(Offset(10.0, 0.0), Offset(250.0, 0.0), _paint); + } + } + + @override + bool shouldRepaint(CustomPainter oldDelegate) { + return false; + } +} + + +Widget getSeparateDivider() { +return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CustomPaint(painter: Drawhorizontalline(true)), + Text( + "OR", + style: TextStyle( + color: Colors.black38, + fontWeight: FontWeight.bold, + fontSize: 10.0), + ), + CustomPaint(painter: Drawhorizontalline(false)) + ], + ); +} + + + + + + + + + + +======= +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d import 'package:book_reader/login.dart'; import 'package:book_reader/home.dart'; @@ -123,4 +565,9 @@ class SignupPage extends StatelessWidget { ], ); } -} \ No newline at end of file +<<<<<<< HEAD +} +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= +} +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d diff --git a/book_reader/pubspec.lock b/book_reader/pubspec.lock index b107327..4093954 100644 --- a/book_reader/pubspec.lock +++ b/book_reader/pubspec.lock @@ -7,42 +7,111 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "2.4.2" +======= version: "2.5.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= + version: "2.5.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d boolean_selector: dependency: transitive description: name: boolean_selector url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "2.0.0" +======= + version: "2.1.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= version: "2.1.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d characters: dependency: transitive description: name: characters url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "1.0.0" +======= + version: "1.1.0-nullsafety.2" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= version: "1.1.0-nullsafety.2" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "1.1.3" +======= version: "1.2.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= + version: "1.2.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d clock: dependency: transitive description: name: clock url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "1.0.1" + cloud_firestore: + dependency: "direct main" + description: + name: cloud_firestore + url: "https://pub.dartlang.org" + source: hosted + version: "0.14.0+2" + cloud_firestore_platform_interface: + dependency: transitive + description: + name: cloud_firestore_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + cloud_firestore_web: + dependency: transitive + description: + name: cloud_firestore_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0+1" +======= version: "1.1.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= + version: "1.1.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "1.14.13" +======= + version: "1.15.0-nullsafety.2" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= version: "1.15.0-nullsafety.2" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d cupertino_icons: dependency: "direct main" description: @@ -50,13 +119,90 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" +<<<<<<< HEAD +<<<<<<< HEAD + email_validator: + dependency: "direct main" + description: + name: email_validator + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.5" +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "1.1.0" + file: + dependency: transitive + description: + name: file + url: "https://pub.dartlang.org" + source: hosted + version: "5.2.1" + firebase: + dependency: transitive + description: + name: firebase + url: "https://pub.dartlang.org" + source: hosted + version: "7.3.0" + firebase_auth: + dependency: "direct main" + description: + name: firebase_auth + url: "https://pub.dartlang.org" + source: hosted + version: "0.18.0+1" + firebase_auth_platform_interface: + dependency: transitive + description: + name: firebase_auth_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + firebase_auth_web: + dependency: transitive + description: + name: firebase_auth_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.0+1" + firebase_core: + dependency: "direct main" + description: + name: firebase_core + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.0" + firebase_core_platform_interface: + dependency: transitive + description: + name: firebase_core_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" + firebase_core_web: + dependency: transitive + description: + name: firebase_core_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" +======= + version: "1.1.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= version: "1.1.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d flutter: dependency: "direct main" description: flutter @@ -67,27 +213,216 @@ packages: description: flutter source: sdk version: "0.0.0" +<<<<<<< HEAD +<<<<<<< HEAD + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + google_sign_in: + dependency: "direct main" + description: + name: google_sign_in + url: "https://pub.dartlang.org" + source: hosted + version: "4.5.3" + google_sign_in_platform_interface: + dependency: transitive + description: + name: google_sign_in_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.2" + google_sign_in_web: + dependency: transitive + description: + name: google_sign_in_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.9.2" + gradient_text: + dependency: "direct main" + description: + name: gradient_text + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + http: + dependency: transitive + description: + name: http + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.2" + http_parser: + dependency: transitive + description: + name: http_parser + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.4" + intl: + dependency: transitive + description: + name: intl + url: "https://pub.dartlang.org" + source: hosted + version: "0.16.1" + js: + dependency: transitive + description: + name: js + url: "https://pub.dartlang.org" + source: hosted + version: "0.6.2" + loading: + dependency: "direct main" + description: + name: loading + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d matcher: dependency: transitive description: name: matcher url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "0.12.8" +======= + version: "0.12.10-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= version: "0.12.10-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "1.1.8" + modal_progress_hud: + dependency: "direct main" + description: + name: modal_progress_hud + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" +======= + version: "1.3.0-nullsafety.2" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= version: "1.3.0-nullsafety.2" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "1.7.0" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.1+2" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + pedantic: + dependency: transitive + description: + name: pedantic + url: "https://pub.dartlang.org" + source: hosted + version: "1.9.0" + platform: + dependency: transitive + description: + name: platform + url: "https://pub.dartlang.org" + source: hosted + version: "2.2.1" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.2" + process: + dependency: transitive + description: + name: process + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.13" + quiver: + dependency: transitive + description: + name: quiver + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.3" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.10" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.2+2" + shared_preferences_macos: + dependency: transitive + description: + name: shared_preferences_macos + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.1+10" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.2+7" +======= + version: "1.8.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= version: "1.8.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d simple_animations: dependency: "direct main" description: @@ -106,55 +441,131 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "1.7.0" +======= version: "1.8.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= + version: "1.8.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "1.9.5" +======= + version: "1.10.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= version: "1.10.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "2.0.0" +======= + version: "2.1.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= version: "2.1.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "1.0.5" +======= version: "1.1.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= + version: "1.1.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "1.1.0" +======= + version: "1.2.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= version: "1.2.0-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "0.2.17" +======= version: "0.2.19-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= + version: "0.2.19-nullsafety" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "1.2.0" +======= + version: "1.3.0-nullsafety.2" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= version: "1.3.0-nullsafety.2" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted +<<<<<<< HEAD +<<<<<<< HEAD + version: "2.0.8" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.0" +sdks: + dart: ">=2.9.0-14.0.dev <3.0.0" + flutter: ">=1.12.13+hotfix.5 <2.0.0" +======= + version: "2.1.0-nullsafety.2" +sdks: + dart: ">=2.10.0-0.0.dev <2.10.0" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= version: "2.1.0-nullsafety.2" sdks: dart: ">=2.10.0-0.0.dev <2.10.0" +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d diff --git a/book_reader/pubspec.yaml b/book_reader/pubspec.yaml index 17548da..d36135b 100644 --- a/book_reader/pubspec.yaml +++ b/book_reader/pubspec.yaml @@ -24,6 +24,24 @@ dependencies: flutter: sdk: flutter simple_animations: ^1.3.3 +<<<<<<< HEAD +<<<<<<< HEAD + gradient_text: ^1.0.2 + loading: ^1.0.2 + modal_progress_hud: ^0.1.3 + shared_preferences: ^0.5.10 + email_validator: ^1.0.5 + google_sign_in: ^4.5.3 + + + firebase_core: ^0.5.0 + firebase_auth: ^0.18.0+1 + cloud_firestore: ^0.14.0+2 + +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. @@ -44,8 +62,17 @@ flutter: # the material Icons class. uses-material-design: true assets: +<<<<<<< HEAD +<<<<<<< HEAD + - assets/ +======= + - assets/background.png + - assets/illustration.png +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d +======= - assets/background.png - assets/illustration.png +>>>>>>> fa96300360c16a737f001b7a592b920de0213c4d # To add assets to your application, add an assets section, like this: # assets: