This commit is contained in:
Juan Felipe Duarte
2023-06-26 17:38:13 -05:00
parent 580d1eeba0
commit 352bb40145
7 changed files with 197 additions and 60 deletions
+5 -18
View File
@@ -5,24 +5,11 @@ import 'package:prosappco/src/components/pop_appbar.dart';
import 'package:prosappco/src/components/primary_btn.dart';
import '../components/schedule_picker.dart';
class HorarioScreen extends StatefulWidget {
class HorarioScreen extends StatelessWidget {
Map<String, Schedule> horarios;
HorarioScreen({super.key, required this.horarios});
@override
State<HorarioScreen> createState() => _HorarioScreenState();
}
class _HorarioScreenState extends State<HorarioScreen> {
final uid = AuthenticationRepository.instance.getCurrentUserUid();
@override
void initState() {
super.initState();
print('horario a ${widget.horarios}');
}
bool lunesValue = false;
bool martesValue = false;
bool miercolesValue = false;
@@ -32,10 +19,10 @@ class _HorarioScreenState extends State<HorarioScreen> {
bool domingoValue = false;
bool jornadaContinuaLunes = false;
Future<void> updateHorario() async {
Future<void> updateHorario(BuildContext context) async {
try {
Map<String, dynamic> horariosMap = {};
widget.horarios.forEach((key, value) {
horarios.forEach((key, value) {
horariosMap[key] = {
'habilitado': value.habilitado,
'jornadaContinua': value.jornadaContinua,
@@ -87,7 +74,7 @@ class _HorarioScreenState extends State<HorarioScreen> {
@override
Widget build(BuildContext context) {
final sortedHorarios = Map.fromEntries(
widget.horarios.entries.toList()
horarios.entries.toList()
..sort(
(a, b) => _dayOfWeekToInt(a.key).compareTo(_dayOfWeekToInt(b.key))),
);
@@ -118,7 +105,7 @@ class _HorarioScreenState extends State<HorarioScreen> {
padding: const EdgeInsets.only(top: 30, bottom: 30),
child: PrimaryButtom(
onPressed: () async {
await updateHorario();
await updateHorario(context);
Navigator.pop(context);
},
label: 'Guardar',
+3 -2
View File
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';
@@ -93,7 +94,7 @@ class _LoginEmailScreenState extends State<LoginEmailScreen> {
margin: const EdgeInsets.only(top: 210, left: 50, right: 50),
child: Column(
children: [
!isIOS
!isIOS && !kIsWeb
? Padding(
padding: const EdgeInsets.only(bottom: 20),
child: ElevatedButton(
@@ -126,7 +127,7 @@ class _LoginEmailScreenState extends State<LoginEmailScreen> {
)),
)
: const SizedBox(),
!isIOS
!isIOS && !kIsWeb
? const Padding(
padding: EdgeInsets.symmetric(vertical: 5),
child: Row(
+3 -4
View File
@@ -10,7 +10,6 @@ import 'package:prosappco/src/components/pop_appbar.dart';
import 'package:prosappco/src/models/setting_model.dart';
import 'package:prosappco/src/models/user_model.dart';
import 'package:prosappco/src/screens/professional_info.dart';
import '../models/scores_model.dart';
class ProfessionalScreen extends StatefulWidget {
@@ -227,10 +226,8 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
try {
QuerySnapshot users = await usersCollection.get();
for (DocumentSnapshot user in users.docs) {
// Acceder a los datos de cada usuario
Map<String, dynamic> data = user.data() as Map<String, dynamic>;
// Crear un objeto Professional a partir de los datos del usuario
_photo = await AuthenticationRepository.instance.getPhoto(user.id);
if (data['estado'] == 'activo') {
@@ -242,7 +239,9 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
.toList();
if (widget.profession == data['profesion'] ||
widget.profession == '' && userme?.city == data['city']) {
widget.profession == '' &&
userme?.city == data['city'] &&
data['ubicacion'] != null) {
Professional professional = Professional(
id: user.id,
name: data['name'],
+86 -10
View File
@@ -131,6 +131,91 @@ class _ProfileProScreenState extends State<ProfileProScreen> {
}
}
void createSchedules() async {
if (_horarios == null || _horarios!.isEmpty) {
final defaultSchedule = {
'Lunes': {
'habilitado': false,
'jornadaContinua': false,
'range1Hour1': null,
'range1Hour2': null,
'range2Hour1': null,
'range2Hour2': null
},
'Martes': {
'habilitado': false,
'jornadaContinua': false,
'range1Hour1': null,
'range1Hour2': null,
'range2Hour1': null,
'range2Hour2': null
},
'Miercoles': {
'habilitado': false,
'jornadaContinua': false,
'range1Hour1': null,
'range1Hour2': null,
'range2Hour1': null,
'range2Hour2': null
},
'Jueves': {
'habilitado': false,
'jornadaContinua': false,
'range1Hour1': null,
'range1Hour2': null,
'range2Hour1': null,
'range2Hour2': null
},
'Viernes': {
'habilitado': false,
'jornadaContinua': false,
'range1Hour1': null,
'range1Hour2': null,
'range2Hour1': null,
'range2Hour2': null
},
'Sabado': {
'habilitado': false,
'jornadaContinua': false,
'range1Hour1': null,
'range1Hour2': null,
'range2Hour1': null,
'range2Hour2': null
},
'Domingo': {
'habilitado': false,
'jornadaContinua': false,
'range1Hour1': null,
'range1Hour2': null,
'range2Hour1': null,
'range2Hour2': null
}
};
try {
await FirebaseFirestore.instance
.collection('users')
.doc(uid)
.update({'horario': defaultSchedule});
Navigator.pop(context);
} catch (e) {
print(e);
}
} else {
Navigator.pushReplacement(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return HorarioScreen(
horarios: _horarios!,
);
},
),
);
}
}
Future<void> updateInfo() async {
if (_opcionalAddressController.text.isNotEmpty) {
FirebaseFirestore.instance
@@ -445,16 +530,7 @@ class _ProfileProScreenState extends State<ProfileProScreen> {
),
GestureDetector(
onTap: () {
Navigator.pushReplacement(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return HorarioScreen(
horarios: _horarios!,
);
},
),
);
createSchedules();
},
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
+86 -24
View File
@@ -186,19 +186,6 @@ class _ProfileProWebScreenState extends State<ProfileProWebScreen> {
return;
}
void name() {
_horarios!.forEach((dia, horario) {
print('Día: $dia');
print('Habilitado: ${horario.habilitado}');
print('Jornada Continua: ${horario.jornadaContinua}');
print('Rango 1 Hora 1: ${horario.range1Hour1}');
print('Rango 1 Hora 2: ${horario.range1Hour2}');
print('Rango 2 Hora 1: ${horario.range2Hour1}');
print('Rango 2 Hora 2: ${horario.range2Hour2}');
print('-----------------------------------');
});
}
Future<void> updateImage(image) async {
try {
await FirebaseFirestore.instance
@@ -221,6 +208,91 @@ class _ProfileProWebScreenState extends State<ProfileProWebScreen> {
}
}
void createSchedules() async {
if (_horarios == null || _horarios!.isEmpty) {
final defaultSchedule = {
'Lunes': {
'habilitado': false,
'jornadaContinua': false,
'range1Hour1': null,
'range1Hour2': null,
'range2Hour1': null,
'range2Hour2': null
},
'Martes': {
'habilitado': false,
'jornadaContinua': false,
'range1Hour1': null,
'range1Hour2': null,
'range2Hour1': null,
'range2Hour2': null
},
'Miercoles': {
'habilitado': false,
'jornadaContinua': false,
'range1Hour1': null,
'range1Hour2': null,
'range2Hour1': null,
'range2Hour2': null
},
'Jueves': {
'habilitado': false,
'jornadaContinua': false,
'range1Hour1': null,
'range1Hour2': null,
'range2Hour1': null,
'range2Hour2': null
},
'Viernes': {
'habilitado': false,
'jornadaContinua': false,
'range1Hour1': null,
'range1Hour2': null,
'range2Hour1': null,
'range2Hour2': null
},
'Sabado': {
'habilitado': false,
'jornadaContinua': false,
'range1Hour1': null,
'range1Hour2': null,
'range2Hour1': null,
'range2Hour2': null
},
'Domingo': {
'habilitado': false,
'jornadaContinua': false,
'range1Hour1': null,
'range1Hour2': null,
'range2Hour1': null,
'range2Hour2': null
}
};
try {
await FirebaseFirestore.instance
.collection('users')
.doc(uid)
.update({'horario': defaultSchedule});
Navigator.pop(context);
} catch (e) {
print(e);
}
} else {
Navigator.pushReplacement(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return HorarioScreen(
horarios: _horarios!,
);
},
),
);
}
}
Future<bool> uploadImage(File image) async {
final String namefile = image.path.split('/').last;
@@ -376,16 +448,7 @@ class _ProfileProWebScreenState extends State<ProfileProWebScreen> {
),
GestureDetector(
onTap: () {
Navigator.pushReplacement(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return HorarioScreen(
horarios: _horarios!,
);
},
),
);
createSchedules();
},
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
@@ -517,7 +580,6 @@ class _ProfileProWebScreenState extends State<ProfileProWebScreen> {
PrimaryButtom(
onPressed: () {
updateInfo();
// name();
},
label: 'Guardar'),
const SizedBox(
+11
View File
@@ -145,6 +145,17 @@ class _ProfileWebScreenState extends State<ProfileWebScreen> {
snackPosition: SnackPosition.BOTTOM,
);
return;
} else {
try {
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) {
print('Error al actualizar el nombre: $e');
}
}
if (newEmail.isEmpty) {
// Si el nuevo nombre está vacío, no lo actualizamos y mostramos un mensaje al usuario
+3 -2
View File
@@ -1,4 +1,5 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:get/get.dart';
@@ -96,7 +97,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
margin: const EdgeInsets.only(top: 200, left: 50, right: 50),
child: Column(
children: [
!isIOS
!isIOS && !kIsWeb
? Padding(
padding: const EdgeInsets.only(bottom: 20),
child: ElevatedButton(
@@ -129,7 +130,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
)),
)
: const SizedBox(),
!isIOS
!isIOS && !kIsWeb
? const Padding(
padding: EdgeInsets.symmetric(vertical: 0),
child: Row(