subir y recoger pdf
This commit is contained in:
@@ -174,7 +174,7 @@ class _ProfessionalProfileWebScreenState
|
||||
if (uploadedPhotoPaths.isNotEmpty) {
|
||||
// Las imágenes se cargaron correctamente
|
||||
// Actualiza las imágenes en Firestore
|
||||
await updateImagesEspecializaciones(uploadedPhotoPaths);
|
||||
await updateFilesEspecializaciones(uploadedPhotoPaths);
|
||||
|
||||
// Navega a la siguiente pantalla
|
||||
Navigator.pushReplacementNamed(context, '/solicitudEnviada');
|
||||
@@ -310,31 +310,61 @@ class _ProfessionalProfileWebScreenState
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<String>> uploadEspecializaciones(List<Uint8List> images) async {
|
||||
List<String> photoPaths = [];
|
||||
// Future<List<String>> uploadEspecializaciones(List<Uint8List> images) async {
|
||||
// List<String> photoPaths = [];
|
||||
|
||||
for (Uint8List imageBytes in images) {
|
||||
Reference ref = storage
|
||||
// for (Uint8List imageBytes in images) {
|
||||
// Reference ref = storage
|
||||
// .ref()
|
||||
// .child('users')
|
||||
// .child(uid!)
|
||||
// .child('especializaciones')
|
||||
// .child('e${DateTime.now().millisecondsSinceEpoch}.jpg');
|
||||
|
||||
// final UploadTask uploadTask = ref.putData(imageBytes);
|
||||
|
||||
// final TaskSnapshot snapshot = await uploadTask.whenComplete(() => true);
|
||||
|
||||
// if (snapshot.state == TaskState.success) {
|
||||
// photoPaths.add(ref.fullPath);
|
||||
// } else {
|
||||
// await updateImagesEspecializaciones(photoPaths);
|
||||
// return [];
|
||||
// }
|
||||
// }
|
||||
|
||||
// await updateImagesEspecializaciones(photoPaths);
|
||||
// return photoPaths;
|
||||
// }
|
||||
|
||||
Future<List<String>> uploadEspecializaciones(List<Uint8List> files) async {
|
||||
List<String> filePaths = [];
|
||||
|
||||
for (Uint8List fileBytes in files) {
|
||||
final Reference ref = FirebaseStorage.instance
|
||||
.ref()
|
||||
.child('users')
|
||||
.child(uid!)
|
||||
.child('especializaciones')
|
||||
.child('e${DateTime.now().millisecondsSinceEpoch}.jpg');
|
||||
.child('e${DateTime.now().millisecondsSinceEpoch}.pdf');
|
||||
|
||||
final UploadTask uploadTask = ref.putData(imageBytes);
|
||||
final SettableMetadata metaData =
|
||||
SettableMetadata(contentType: 'application/pdf');
|
||||
|
||||
final UploadTask uploadTask = ref.putData(fileBytes, metaData);
|
||||
|
||||
final TaskSnapshot snapshot = await uploadTask.whenComplete(() => true);
|
||||
|
||||
if (snapshot.state == TaskState.success) {
|
||||
photoPaths.add(ref.fullPath);
|
||||
filePaths.add(ref.fullPath);
|
||||
} else {
|
||||
await updateImagesEspecializaciones(photoPaths);
|
||||
await updateFilesEspecializaciones(filePaths);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
await updateImagesEspecializaciones(photoPaths);
|
||||
return photoPaths;
|
||||
await updateFilesEspecializaciones(filePaths);
|
||||
return filePaths;
|
||||
}
|
||||
|
||||
Future<void> updateImageCedula(image) async {
|
||||
@@ -393,21 +423,41 @@ class _ProfessionalProfileWebScreenState
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateImagesEspecializaciones(List<String> photoPaths) async {
|
||||
// Future<void> updateImagesEspecializaciones(List<String> photoPaths) async {
|
||||
// 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> updateFilesEspecializaciones(List<String> filePaths) async {
|
||||
try {
|
||||
final userRef = FirebaseFirestore.instance.collection('users').doc(uid);
|
||||
final userSnapshot = await userRef.get();
|
||||
|
||||
if (userSnapshot.exists) {
|
||||
await userRef.update({'imgEspecializaciones': photoPaths});
|
||||
await userRef.update({'imgEspecializaciones': filePaths});
|
||||
|
||||
print('¡Imágenes de especializaciones actualizadas correctamente!');
|
||||
} else {
|
||||
await userRef.set({'imgEspecializaciones': photoPaths});
|
||||
await userRef.set({'imgEspecializaciones': filePaths});
|
||||
print('¡Imágenes de especializaciones agregadas correctamente!');
|
||||
}
|
||||
|
||||
print('Archivos de especializaciones actualizados correctamente');
|
||||
} catch (e) {
|
||||
print(
|
||||
'Error al agregar o actualizar las imágenes de especializaciones: $e');
|
||||
print('Error al actualizar los archivos de especializaciones: $e');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
||||
import 'package:prosappco/src/components/banner_photo.dart';
|
||||
import 'package:prosappco/src/components/pop_appbar.dart';
|
||||
import 'package:prosappco/src/components/primary_btn.dart';
|
||||
import 'package:prosappco/src/components/schedule_picker.dart';
|
||||
@@ -15,7 +14,6 @@ import 'package:prosappco/src/models/setting_model.dart';
|
||||
import 'package:prosappco/src/screens/horario.dart';
|
||||
import 'package:prosappco/src/screens/professional.dart';
|
||||
import 'package:prosappco/src/screens/ubicacion.dart';
|
||||
import 'package:prosappco/src/services/select_image_profile.dart';
|
||||
|
||||
class ProfileProWebScreen extends StatefulWidget {
|
||||
const ProfileProWebScreen({super.key});
|
||||
@@ -399,7 +397,7 @@ class _ProfileProWebScreenState extends State<ProfileProWebScreen> {
|
||||
TableCell(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text('Lunes'),
|
||||
child: const Text('Lunes'),
|
||||
),
|
||||
),
|
||||
TableCell(
|
||||
|
||||
@@ -192,6 +192,15 @@ class _ProfileWebScreenState extends State<ProfileWebScreen> {
|
||||
print('e');
|
||||
}
|
||||
|
||||
try {
|
||||
await FirebaseFirestore.instance
|
||||
.collection('users')
|
||||
.doc(uid)
|
||||
.update({'email': newEmail});
|
||||
} catch (e) {
|
||||
print('e');
|
||||
}
|
||||
|
||||
try {
|
||||
if (selectedImagInBytes == null) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user