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