Skip to content

Commit

Permalink
Push the v0.1.4 (#82)
Browse files Browse the repository at this point in the history
- Fixing the username name, colors and picture randomization
- Adding the redirection to home at the end of the registering process
- Adding the password obscursion
  • Loading branch information
MistzSoftware authored Jun 20, 2024
2 parents f4aabf8 + ecaabb9 commit 77ce463
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/adopte_un_candidat/lib/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:adopte_un_candidat/modules/authentication.dart';
import 'package:adopte_un_candidat/modules/database.dart';
import 'package:adopte_un_candidat/widgets/navigation_bar.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart';
Expand Down
30 changes: 24 additions & 6 deletions src/adopte_un_candidat/lib/modules/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -438,20 +438,20 @@ class Database {
}
return ["FFFFFF", "FFFFFF"];
}

initializeUser(String email, String password, String firstName, String lastName, String userName, String picture, List<String> colors) async {
FirebaseAuth.instance.createUserWithEmailAndPassword(
Future<String> initializeUser(String email, String password, String firstName, String lastName, String userName, String picture, List<String> colors) async {
return FirebaseAuth.instance.createUserWithEmailAndPassword(
email: email,
password: password,
).then((userCredential) {
// User creation successful
User? user = userCredential.user;
// Add additional user data to Firestore
createUser(user!.uid, email, firstName, lastName, userName, picture, colors);
return user.uid;
}).catchError((error) {
// User creation failed
// User creation fail
if (kDebugMode) {
print("Error creating user: $error");
print("Error creating ur: $error");
}
});
}
Expand All @@ -471,7 +471,12 @@ class Database {
'colors': colors,
'professional_status': '',
'profile_picture': picture,
'soft_skills': {}
'soft_skills': {
'Analytical': [],
'Self-management': [],
'Interpersonal': [],
'Social': []
}
});
}

Expand Down Expand Up @@ -560,6 +565,19 @@ class Database {
});
}

updatePictureAndColors(String id, String picture, List<String> colors) async {
await FirebaseFirestore.instance.collection("user").doc(id).update({
'profile_picture': picture,
'colors': colors,
});
}

updateUsername(String id, String username) async {
await FirebaseFirestore.instance.collection("user").doc(id).update({
'name': username,
});
}

// Future<void> softSkillsUpdate(String id, Map softSkills) async {
// await FirebaseFirestore.instance.collection("user").doc(id).update({
// 'soft_skills': softSkills,
Expand Down
16 changes: 12 additions & 4 deletions src/adopte_un_candidat/lib/register.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class RegisterState extends State<Register> {
List<String> colors = ["FFFFFF", "FFFFFF"];
String pictureLink = "";
String userName = "River Stone";
String userId = "";

@override
void initState() {
Expand Down Expand Up @@ -507,6 +508,7 @@ class RegisterState extends State<Register> {
right: 40, left: 40, top: 10),
child: TextField(
controller: passwordController,
obscureText: true,
decoration: InputDecoration(
filled: true,
fillColor: const Color(0xFFEEEEEE),
Expand Down Expand Up @@ -681,9 +683,11 @@ class RegisterState extends State<Register> {
child: NextButton(
onPressed: () async {
if (userInformation()) {
await Database().initializeUser(emailController.text.trim(), passwordController.text.trim(), firstNameController.text.trim(), lastNameController.text.trim(), userName, pictureLink, colors);
setState(() {
page = 6;
await Database().initializeUser(emailController.text.trim(), passwordController.text.trim(), firstNameController.text.trim(), lastNameController.text.trim(), userName, pictureLink, colors).then((value) {
setState(() {
page = 6;
userId = value;
});
});
} else {
if (kDebugMode) {
Expand Down Expand Up @@ -829,6 +833,7 @@ class RegisterState extends State<Register> {
setState(() {
page = 7;
});
Database().updateUsername(userId, userName);
},
),
),
Expand Down Expand Up @@ -962,6 +967,7 @@ class RegisterState extends State<Register> {
onPressed: () {
setState(() {
page = 8;
Database().updatePictureAndColors(userId, pictureLink, colors);
});
},
),
Expand Down Expand Up @@ -1185,7 +1191,9 @@ class RegisterState extends State<Register> {
alignment: Alignment.centerRight,
padding: const EdgeInsets.only(right: 40),
child: NextButton(
onPressed: () {},
onPressed: () {
context.replaceNamed('home');
},
),
),
)
Expand Down

0 comments on commit 77ce463

Please sign in to comment.