Skip to content

Commit

Permalink
Merge pull request #125 from SamarpanCoder2002/Samarpan2
Browse files Browse the repository at this point in the history
Dropdown for Courses, Stream Added with add data to firebase
  • Loading branch information
avinashkranjan authored Mar 30, 2021
2 parents f0b77f9 + 5ec2931 commit 45037b0
Show file tree
Hide file tree
Showing 8 changed files with 493 additions and 65 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (localPropertiesFile.exists()) {

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ buildscript {

dependencies {
// Google Services Dependency
classpath 'com.google.gms:google-services:4.3.4'
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.android.tools.build:gradle:4.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
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-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
16 changes: 8 additions & 8 deletions lib/screens/profile_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ class _ProfileScreenState extends State<ProfileScreen> {
uploadPictures(File image) async {
// uploads picture(s) to storage and return it's URL
final Reference ref =
_storageReference.child('${Path.basename(image.path)}}');
_storageReference.child('${Path.basename(image.path)}}');

final UploadTask uploadTask = ref.putFile(image);
String pictureUrl;

await uploadTask.then(
(taskSnapshot) async {
(taskSnapshot) async {
pictureUrl = await taskSnapshot.ref.getDownloadURL();
},
);
Expand All @@ -55,7 +55,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
// String pictureUrl = uploadTaskSnapshot.downloadUrl.toString();

final userInfoProvider =
Provider.of<UserInfoServices>(context, listen: false);
Provider.of<UserInfoServices>(context, listen: false);

Users currentUser = userInfoProvider.user;
currentUser.profilePictureUrl = pictureUrl;
Expand Down Expand Up @@ -183,7 +183,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
context,
MaterialPageRoute(
builder: (_) => OnboardingPage()),
(Route<dynamic> route) => false,
(Route<dynamic> route) => false,
);
}
}
Expand Down Expand Up @@ -217,9 +217,9 @@ class _ProfileScreenState extends State<ProfileScreen> {
child: CircleAvatar(
radius: profilePictureDiameter / 2,
backgroundImage:
_user != null && _user.profilePictureUrl.isNotEmpty
? NetworkImage(_user.profilePictureUrl)
: AssetImage("assets/images/profile_pic.jpg"),
_user != null && _user.profilePictureUrl.isNotEmpty
? NetworkImage(_user.profilePictureUrl)
: AssetImage("assets/images/profile_pic.jpg"),
backgroundColor: Colors.transparent,
foregroundColor: Theme.of(context).backgroundColor,
),
Expand Down Expand Up @@ -270,4 +270,4 @@ Widget buildDetails(String title, String detail) {
),
],
);
}
}
47 changes: 47 additions & 0 deletions lib/services/classes_db_services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,53 @@ class ClassesDBServices {
})
});
}

Future<void> verifyCollegeFieldAndUpdate(
String _collegeName, String _course, String _dept) async {
DocumentSnapshot documentSnapshot =
await FirebaseFirestore.instance.doc('colleges/$_collegeName').get();

print(documentSnapshot.data()['courses']);

if (documentSnapshot.data()['courses'] == null) {
print("No Course Registered");
FirebaseFirestore.instance.doc('colleges/$_collegeName').set({
'courses': {
_course: [_dept],
},
});
} else {
print("At least one course present");
if (documentSnapshot.data()['courses'].keys.contains(_course)) {
print("Same Course Present");
print(documentSnapshot.data()['courses'][_course]);

if (documentSnapshot.data()['courses'][_course].contains(_dept)) {
print("Same Dept Present");
} else {
print("Dept not present");
print(_dept);

Map<String, dynamic> _currCourses =
documentSnapshot.data()['courses'];
_currCourses[_course].add(_dept);

FirebaseFirestore.instance.doc('colleges/$_collegeName').update({
'courses': _currCourses,
});
}
} else {
print("That new Course not present");
Map<String, dynamic> take = documentSnapshot.data()['courses'];
take.addAll({
_course: [_dept],
});
FirebaseFirestore.instance.doc('colleges/$_collegeName').update({
'courses': take,
});
}
}
}
}

ClassesDBServices classesDBServices = ClassesDBServices();
Loading

0 comments on commit 45037b0

Please sign in to comment.