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

UPGRADE PROJECT AND CONTRIBUTION #12

Open
wants to merge 16 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
1 change: 1 addition & 0 deletions .flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\cloud_firestore-4.1.0\\\\","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_auth","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_auth-4.1.4\\\\","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-2.3.0\\\\","native_build":true,"dependencies":[]},{"name":"google_sign_in_ios","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_sign_in_ios-5.5.1\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"cloud_firestore","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\cloud_firestore-4.1.0\\\\","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_auth","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_auth-4.1.4\\\\","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-2.3.0\\\\","native_build":true,"dependencies":[]},{"name":"google_sign_in_android","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_sign_in_android-6.1.4\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"cloud_firestore","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\cloud_firestore-4.1.0\\\\","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_auth","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_auth-4.1.4\\\\","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core-2.3.0\\\\","native_build":true,"dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"cloud_firestore_web","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\cloud_firestore_web-3.1.0\\\\","dependencies":["firebase_core_web"]},{"name":"firebase_auth_web","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_auth_web-5.1.3\\\\","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\firebase_core_web-2.0.1\\\\","dependencies":[]},{"name":"google_sign_in_web","path":"C:\\\\Users\\\\youne\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\google_sign_in_web-0.10.2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["cloud_firestore_web","firebase_core"]},{"name":"cloud_firestore_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_auth","dependencies":["firebase_auth_web","firebase_core"]},{"name":"firebase_auth_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]}],"date_created":"2022-11-25 17:17:05.611638","version":"3.3.6"}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,3 @@ ios/Runner/Info.plist
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
ios/Runner/Info.plist
7 changes: 4 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 33
ndkVersion flutter.ndkVersion

lintOptions {
disable 'InvalidPackage'
Expand All @@ -34,9 +35,9 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "tech.fnplus.enroll_me"
minSdkVersion 16
minSdkVersion 19
multiDexEnabled true
targetSdkVersion 28
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
8 changes: 7 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:name="${applicationName}"
android:label="Enroll Me"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:exported="true"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
Expand All @@ -26,6 +27,11 @@
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />

<meta-data
android:name="flutterEmbedding"
android:value="2" />

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
package tech.fnplus.enroll_me;

import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.embedding.android.FlutterActivity;

public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
}
}
8 changes: 5 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.2'
}
}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
12 changes: 7 additions & 5 deletions ios/Flutter/flutter_export_environment.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=/Users/ayushshekhar/development/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/ayushshekhar/projects/enroll-me-flutter"
export "FLUTTER_TARGET=/Users/ayushshekhar/projects/enroll-me-flutter/lib/main.dart"
export "FLUTTER_ROOT=C:\Users\youne\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Users\youne\AndroidStudioProjects\enroll-me-flutter"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "FLUTTER_FRAMEWORK_DIR=/Users/ayushshekhar/development/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.dart_tool/package_config.json"
2 changes: 1 addition & 1 deletion lib/app/enrollme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class _EnrollMeState extends State<EnrollMe> {
child: MultiProvider(
providers: [
ChangeNotifierProvider<AuthenticationService>(
builder: (_) => _authenticationService,
create: (_) => _authenticationService,
),
],
child: MaterialApp(
Expand Down
51 changes: 25 additions & 26 deletions lib/app/services/authenticationService.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:enroll_me/app/models/userDetailsModel.dart';
import 'package:enroll_me/app/models/userDetailsModel.dart' as UserModel;
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/widgets.dart';
import 'package:google_sign_in/google_sign_in.dart';
Expand All @@ -19,12 +19,12 @@ class AuthenticationService extends ChangeNotifier {

final GoogleSignIn _googleSignIn = GoogleSignIn();

final CollectionReference userDb = Firestore.instance.collection('users');
final CollectionReference userDb = FirebaseFirestore.instance.collection('users');

User _loggedInUser;
UserModel.User _loggedInUser;

//get current instance of user
User get loggedInUser => _loggedInUser;
UserModel.User get loggedInUser => _loggedInUser;

PublishSubject<AuthState> _authStateSubject = PublishSubject();

Expand All @@ -40,41 +40,42 @@ class AuthenticationService extends ChangeNotifier {
Future autoAuthenticateUser() async {
// Change auth state to processing
_authStateSubject.add(AuthState.Processing);
FirebaseUser user = await _auth.currentUser();
User user = await _auth.currentUser;
if (user != null) {
await processFirestoreEntryOfUser(user);
}
// Update authState
updateAuthState();
}

Future processFirestoreEntryOfUser(FirebaseUser user) async {
Future processFirestoreEntryOfUser(User user) async {
Map userData;

// Check if user exists in collection
QuerySnapshot checkQuery =
await userDb.where('uid', isEqualTo: user.uid).limit(1).getDocuments();
await userDb.where('uid', isEqualTo: user.uid).limit(1).get();

final List<DocumentSnapshot> results = checkQuery.documents;
final List<QueryDocumentSnapshot> results = checkQuery.docs;

if (results.length == 1)
userData = results[0].data;
if (results.length == 1){
userData = results[0].data() as Map<String, dynamic>;
}
else {
Map<String, dynamic> userDbEntry = {
'uid': user.uid,
'name': user.displayName,
'email': user.email,
'avatar': user.photoUrl,
'isEmailVerified': user.isEmailVerified
'avatar': user.photoURL,
'isEmailVerified': user.emailVerified
};

DocumentReference entryRef = await userDb.add(userDbEntry);
DocumentSnapshot docSnap = await entryRef.snapshots().first;
userData = docSnap.data;
userData = docSnap.data as Map<String, dynamic>;
}

if (userData['uid'] != null) {
_loggedInUser = User.fromMap(userData);
_loggedInUser = UserModel.User.fromMap(userData);
notifyListeners();
}
}
Expand All @@ -83,9 +84,10 @@ class AuthenticationService extends ChangeNotifier {
Future signInWithEmail(String email, String password) async {
try {
_authStateSubject.add(AuthState.Processing);
AuthResult result = await (_auth.signInWithEmailAndPassword(

var result = await (_auth.signInWithEmailAndPassword(
email: email, password: password));
FirebaseUser user = result.user;
User user = result.user;
print(user.displayName);
await processFirestoreEntryOfUser(user);
updateAuthState();
Expand All @@ -99,28 +101,25 @@ class AuthenticationService extends ChangeNotifier {
Future signUpWithEmail(String name, String email, String pass) async {
try {
_authStateSubject.add(AuthState.Processing);
FirebaseUser user = (await _auth.createUserWithEmailAndPassword(
User user = (await _auth.createUserWithEmailAndPassword(
email: email,
password: pass,
))
.user;

print("Signed up: " + user.email);

UserUpdateInfo userUpdateInfo = UserUpdateInfo();

userUpdateInfo.displayName = name;
await user.updateProfile(userUpdateInfo);
await user.updateDisplayName(name);
print("After updating the profile: ");
print(user.displayName);

await user.reload();
user = await _auth.currentUser();
user = _auth.currentUser;
//(referred from https://stackoverflow.com/questions/50986191/flutter-firebase-auth-updateprofile-method-is-not-working)

print("After reloading the profile: ");
print(user.displayName);
// await user.sendEmailVerification();
await user.sendEmailVerification();

// user.isEmailVerified
// ?
Expand All @@ -135,7 +134,7 @@ class AuthenticationService extends ChangeNotifier {
}

Future verifyEmail() async {
FirebaseUser user = await _auth.currentUser();
User user = _auth.currentUser;
await user.sendEmailVerification();
}

Expand All @@ -154,12 +153,12 @@ class AuthenticationService extends ChangeNotifier {
final GoogleSignInAuthentication googleAuth =
await googleUser.authentication;

final AuthCredential credential = GoogleAuthProvider.getCredential(
final AuthCredential credential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);

final FirebaseUser user =
final User user =
(await _auth.signInWithCredential(credential)).user;

print("Signed In " + user.displayName);
Expand Down
18 changes: 10 additions & 8 deletions lib/app/ui/pages/emailSignInPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,36 +93,38 @@ class LoginBtn extends StatelessWidget {

@override
Widget build(BuildContext context) {
return RaisedButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(18)),
return ElevatedButton(
style: ButtonStyle(
elevation: MaterialStateProperty.all(3),
backgroundColor: MaterialStateProperty.all(Color(0xFF401f3e)),
shape: MaterialStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(18))),
),
onPressed: () async {
print("Email " + _email.text);
print("Password " + _pass.text);
if (_email.text.isNotEmpty && _pass.text.isNotEmpty) {
await authService.signInWithEmail(_email.text, _pass.text);
}
else if (_email.text.isEmpty && _pass.text.isEmpty) {
Scaffold.of(context).showSnackBar(SnackBar(
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Enter valid Email and Password"),
));
}
else if (_email.text.isEmpty) {
Scaffold.of(context).showSnackBar(SnackBar(
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Please enter a valid Email ID"),
));
}
else if (_pass.text.isEmpty) {
Scaffold.of(context).showSnackBar(SnackBar(
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Password cannot be empty"),
));
}
},
elevation: 3,
child: Text(
"Login",
style: TextStyle(color: Colors.white),
),
color: Color(0xFF401f3e),
);
}
}
Expand Down Expand Up @@ -151,7 +153,7 @@ class ForgotPass extends StatelessWidget {
await authService.resetPass(_email.text);
} else {
// Show snackbar if email field is not filled
Scaffold.of(context).showSnackBar(SnackBar(
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
backgroundColor: Colors.red,
content: Row(
crossAxisAlignment: CrossAxisAlignment.center,
Expand Down
12 changes: 7 additions & 5 deletions lib/app/ui/pages/emailSignUpPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ class RegisterBtn extends StatelessWidget {

@override
Widget build(BuildContext context) {
return RaisedButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(18)),
return ElevatedButton(
style: ButtonStyle(
elevation: MaterialStateProperty.all(3),
backgroundColor: MaterialStateProperty.all(Color(0xFF401f3e)),
shape: MaterialStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(18))),
),
onPressed: () async {
print("Name received: " + _name.text);
print("Email received: " + _email.text);
Expand All @@ -110,7 +114,7 @@ class RegisterBtn extends StatelessWidget {
} else {
// Handle the passwords not match case
print("Both passwords do not match");
Scaffold.of(context).showSnackBar(SnackBar(
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
backgroundColor: Colors.red,
content: Row(
children: <Widget>[
Expand All @@ -128,12 +132,10 @@ class RegisterBtn extends StatelessWidget {
));
}
},
elevation: 3,
child: Text(
"Register",
style: TextStyle(color: Colors.white),
),
color: Color(0xFF401f3e),
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/app/widgets/customDrawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ class CustomDrawer extends StatelessWidget {
content:
Text("Are you sure you want to sign out?"),
actions: <Widget>[
FlatButton(
TextButton(
child: Text("Cancel"),
onPressed: () {
Navigator.pop(context);
},
),
FlatButton(
TextButton(
child: Text("Yes"),
onPressed: () {
_authService.signOut();
Expand Down
2 changes: 1 addition & 1 deletion lib/app/widgets/scoreCard.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_tags/tag.dart';
import 'package:flutter_tags/flutter_tags.dart';

class ScoreCard extends StatelessWidget {
final List<String> _groups = [
Expand Down
Empty file added lib/generated/assets.dart
Empty file.
Loading