perfil profesional terminado
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:firebase_storage/firebase_storage.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.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/drawer_professional.dart';
|
||||
@@ -25,6 +26,8 @@ class ProfilePro extends StatefulWidget {
|
||||
|
||||
class _ProfileProState extends State<ProfilePro> {
|
||||
final uid = AuthenticationRepository.instance.getCurrentUserUid();
|
||||
final TextEditingController _opcionalAddressController =
|
||||
TextEditingController();
|
||||
|
||||
File? image_portada;
|
||||
File? imagen_to_upload;
|
||||
@@ -35,6 +38,8 @@ class _ProfileProState extends State<ProfilePro> {
|
||||
|
||||
var _photo = '...';
|
||||
var _direccion = '...';
|
||||
var _ubicacion = '...';
|
||||
var _opcionalAddress = '...';
|
||||
|
||||
Map<String, Schedule>? _horarios;
|
||||
|
||||
@@ -71,12 +76,77 @@ class _ProfileProState extends State<ProfilePro> {
|
||||
_direccion = s;
|
||||
}));
|
||||
}
|
||||
if (_ubicacion == '...') {
|
||||
AuthenticationRepository.instance.getUbicacion(uid.toString()).then(
|
||||
(String s) => setState(
|
||||
() {
|
||||
_ubicacion = s;
|
||||
if (_ubicacion == 'ambos') {
|
||||
sitioValue = true;
|
||||
domicilioValue = true;
|
||||
} else if (_ubicacion == 'sitio') {
|
||||
sitioValue = true;
|
||||
} else if (_ubicacion == 'domicilio') {
|
||||
domicilioValue = true;
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
if (_opcionalAddress == '...') {
|
||||
AuthenticationRepository.instance.getOpcionalAddress(uid.toString()).then(
|
||||
(String s) => setState(
|
||||
() {
|
||||
_opcionalAddress = s;
|
||||
|
||||
if (_opcionalAddress != '...') {
|
||||
_opcionalAddressController.text = _opcionalAddress;
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateInfo() async {
|
||||
if (_opcionalAddressController.text.isNotEmpty) {
|
||||
FirebaseFirestore.instance
|
||||
.collection('users')
|
||||
.doc(uid)
|
||||
.update({'opcional_address': _opcionalAddressController.text});
|
||||
}
|
||||
|
||||
if (domicilioValue && sitioValue) {
|
||||
FirebaseFirestore.instance
|
||||
.collection('users')
|
||||
.doc(uid)
|
||||
.update({'ubicacion': 'ambos'});
|
||||
} else if (domicilioValue) {
|
||||
FirebaseFirestore.instance
|
||||
.collection('users')
|
||||
.doc(uid)
|
||||
.update({'ubicacion': 'domicilio'});
|
||||
} else if (sitioValue) {
|
||||
FirebaseFirestore.instance
|
||||
.collection('users')
|
||||
.doc(uid)
|
||||
.update({'ubicacion': 'sitio'});
|
||||
} else {
|
||||
Get.snackbar(
|
||||
'Elige como vas a dar tu servicio',
|
||||
'Selecciona si tu servicio es a domicilio o en tu consultorio.',
|
||||
snackPosition: SnackPosition.TOP,
|
||||
backgroundColor: Colors.black.withOpacity(0.2),
|
||||
messageText: const Text(
|
||||
'Selecciona si tu servicio es a domicilio o en tu consultorio.',
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (imagen_to_upload == null) {
|
||||
return;
|
||||
} else {
|
||||
final uploaded = await uploadImage(imagen_to_upload!);
|
||||
updateImage(photoTemp);
|
||||
@@ -85,6 +155,13 @@ class _ProfileProState extends State<ProfilePro> {
|
||||
} catch (e) {
|
||||
print('Error al actualizar la imagen de perfil $e');
|
||||
}
|
||||
|
||||
Get.snackbar(
|
||||
'Información actualizada',
|
||||
'Su información a sido actualizada con exito.',
|
||||
snackPosition: SnackPosition.TOP,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Future<void> updateImage(image) async {
|
||||
@@ -269,7 +346,7 @@ class _ProfileProState extends State<ProfilePro> {
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextFormField(
|
||||
// controller: _emailController,
|
||||
controller: _opcionalAddressController,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Oficina / Piso / Conjunto'),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user