updates
This commit is contained in:
@@ -36,6 +36,8 @@ class ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
|
||||
List<File> images_especializacion = [];
|
||||
var _profession = '...';
|
||||
var photoTemp = '';
|
||||
var photoCedulaTemp = '';
|
||||
var photoCertificadoTemp = '';
|
||||
var _photo = '...';
|
||||
|
||||
@override
|
||||
@@ -208,40 +210,32 @@ class ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
|
||||
|
||||
final TaskSnapshot snapshot = await uploadTask.whenComplete(() => true);
|
||||
|
||||
photoTemp = ref.fullPath;
|
||||
photoCedulaTemp = ref.fullPath;
|
||||
|
||||
if (snapshot.state == TaskState.success) {
|
||||
updateImageCedula(photoCedulaTemp);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<String>> uploadEspecializaciones(List<File> images) async {
|
||||
List<String> photoPaths = [];
|
||||
Future<void> updateImageCedula(image) async {
|
||||
try {
|
||||
final userRef = FirebaseFirestore.instance.collection('users').doc(uid);
|
||||
final userSnapshot = await userRef.get();
|
||||
|
||||
for (File image in images) {
|
||||
final String namefile = image.path.split('/').last;
|
||||
|
||||
Reference ref = storage
|
||||
.ref()
|
||||
.child('users')
|
||||
.child(uid!)
|
||||
.child('especializaciones')
|
||||
.child(namefile);
|
||||
|
||||
final UploadTask uploadTask = ref.putFile(image);
|
||||
|
||||
final TaskSnapshot snapshot = await uploadTask.whenComplete(() => true);
|
||||
|
||||
photoPaths.add(ref.fullPath);
|
||||
|
||||
if (snapshot.state != TaskState.success) {
|
||||
return [];
|
||||
if (userSnapshot.exists) {
|
||||
await userRef.update({'imgCedula': image});
|
||||
print('¡Imagen de cédula actualizada correctamente!');
|
||||
} else {
|
||||
await userRef.set({'imgCedula': image});
|
||||
print('¡Imagen de cédula agregada correctamente!');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error al agregar o actualizar la imagen de cédula: $e');
|
||||
}
|
||||
|
||||
return photoPaths;
|
||||
}
|
||||
|
||||
Future<bool> uploadCertificado(File image) async {
|
||||
@@ -258,15 +252,34 @@ class ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
|
||||
|
||||
final TaskSnapshot snapshot = await uploadTask.whenComplete(() => true);
|
||||
|
||||
photoTemp = ref.fullPath;
|
||||
photoCertificadoTemp = ref.fullPath;
|
||||
|
||||
if (snapshot.state == TaskState.success) {
|
||||
updateImageCertificado(photoCertificadoTemp);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateImageCertificado(image) async {
|
||||
try {
|
||||
final userRef = FirebaseFirestore.instance.collection('users').doc(uid);
|
||||
final userSnapshot = await userRef.get();
|
||||
|
||||
if (userSnapshot.exists) {
|
||||
await userRef.update({'imgCertificado': image});
|
||||
print('¡Imagen de certificado actualizada correctamente!');
|
||||
} else {
|
||||
await userRef.set({'imgCertificado': image});
|
||||
print('¡Imagen de certificado agregada correctamente!');
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error al agregar o actualizar la imagen de certificado: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateImage(image) async {
|
||||
try {
|
||||
await FirebaseFirestore.instance
|
||||
@@ -312,6 +325,55 @@ class ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<String>> uploadEspecializaciones(List<File> images) async {
|
||||
List<String> photoPaths = [];
|
||||
|
||||
for (File image in images) {
|
||||
final String namefile = image.path.split('/').last;
|
||||
|
||||
Reference ref = storage
|
||||
.ref()
|
||||
.child('users')
|
||||
.child(uid!)
|
||||
.child('especializaciones')
|
||||
.child(namefile);
|
||||
|
||||
final UploadTask uploadTask = ref.putFile(image);
|
||||
|
||||
final TaskSnapshot snapshot = await uploadTask.whenComplete(() => true);
|
||||
|
||||
if (snapshot.state == TaskState.success) {
|
||||
photoPaths.add(ref.fullPath);
|
||||
} else {
|
||||
updateImagesEspecializaciones(photoPaths);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
updateImagesEspecializaciones(photoPaths);
|
||||
return photoPaths;
|
||||
}
|
||||
|
||||
Future<void> updateImagesEspecializaciones(List<String> photoPaths) async {
|
||||
print('abc $photoPaths');
|
||||
|
||||
try {
|
||||
final userRef = FirebaseFirestore.instance.collection('users').doc(uid);
|
||||
final userSnapshot = await userRef.get();
|
||||
|
||||
if (userSnapshot.exists) {
|
||||
await userRef.update({'imgEspecializaciones': photoPaths});
|
||||
print('¡Imágenes de especializaciones actualizadas correctamente!');
|
||||
} else {
|
||||
await userRef.set({'imgEspecializaciones': photoPaths});
|
||||
print('¡Imágenes de especializaciones agregadas correctamente!');
|
||||
}
|
||||
} catch (e) {
|
||||
print(
|
||||
'Error al agregar o actualizar las imágenes de especializaciones: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> sendInfo() async {
|
||||
final String cedula = _cedulaController.text.trim();
|
||||
final String especializacion = _especializacionController.text.trim();
|
||||
@@ -349,7 +411,6 @@ class ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
|
||||
if (imagen_to_upload != null) {
|
||||
updateImage(photoTemp);
|
||||
}
|
||||
|
||||
// Navega a la siguiente pantalla
|
||||
Navigator.pushReplacementNamed(context, '/solicitudEnviada');
|
||||
}
|
||||
|
||||
@@ -245,6 +245,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
await FirebaseAuth.instance.currentUser!.updateDisplayName(newName);
|
||||
await FirebaseFirestore.instance.collection('users').doc(uid).update({
|
||||
'name': newName,
|
||||
'lowerName': newName.toLowerCase(),
|
||||
});
|
||||
print('Nombre actualizado correctamente');
|
||||
} catch (e) {
|
||||
@@ -254,6 +255,9 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
|
||||
if (currentUser?.email != newEmail) {
|
||||
if (newPassword.isNotEmpty) {
|
||||
await FirebaseFirestore.instance.collection('users').doc(uid).update({
|
||||
'email': newEmail,
|
||||
});
|
||||
updateEmailAndPassword(newEmail, newPassword);
|
||||
} else {
|
||||
Get.snackbar(
|
||||
@@ -439,6 +443,15 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
: TextFormField(
|
||||
controller: _passwordController,
|
||||
obscureText: _obscureText,
|
||||
validator: (value) {
|
||||
if (value == null || value.isEmpty) {
|
||||
return 'Porfavor ingrese una contraseña.';
|
||||
}
|
||||
if (value.length < 5) {
|
||||
return 'Debe tener al menos 5 caracteres.';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: const Icon(Icons.lock_outline),
|
||||
suffixIcon: IconButton(
|
||||
|
||||
Reference in New Issue
Block a user