update
This commit is contained in:
@@ -5,24 +5,11 @@ import 'package:prosappco/src/components/pop_appbar.dart';
|
|||||||
import 'package:prosappco/src/components/primary_btn.dart';
|
import 'package:prosappco/src/components/primary_btn.dart';
|
||||||
import '../components/schedule_picker.dart';
|
import '../components/schedule_picker.dart';
|
||||||
|
|
||||||
class HorarioScreen extends StatefulWidget {
|
class HorarioScreen extends StatelessWidget {
|
||||||
Map<String, Schedule> horarios;
|
Map<String, Schedule> horarios;
|
||||||
HorarioScreen({super.key, required this.horarios});
|
HorarioScreen({super.key, required this.horarios});
|
||||||
|
|
||||||
@override
|
|
||||||
State<HorarioScreen> createState() => _HorarioScreenState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _HorarioScreenState extends State<HorarioScreen> {
|
|
||||||
final uid = AuthenticationRepository.instance.getCurrentUserUid();
|
final uid = AuthenticationRepository.instance.getCurrentUserUid();
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
|
|
||||||
print('horario a ${widget.horarios}');
|
|
||||||
}
|
|
||||||
|
|
||||||
bool lunesValue = false;
|
bool lunesValue = false;
|
||||||
bool martesValue = false;
|
bool martesValue = false;
|
||||||
bool miercolesValue = false;
|
bool miercolesValue = false;
|
||||||
@@ -32,10 +19,10 @@ class _HorarioScreenState extends State<HorarioScreen> {
|
|||||||
bool domingoValue = false;
|
bool domingoValue = false;
|
||||||
bool jornadaContinuaLunes = false;
|
bool jornadaContinuaLunes = false;
|
||||||
|
|
||||||
Future<void> updateHorario() async {
|
Future<void> updateHorario(BuildContext context) async {
|
||||||
try {
|
try {
|
||||||
Map<String, dynamic> horariosMap = {};
|
Map<String, dynamic> horariosMap = {};
|
||||||
widget.horarios.forEach((key, value) {
|
horarios.forEach((key, value) {
|
||||||
horariosMap[key] = {
|
horariosMap[key] = {
|
||||||
'habilitado': value.habilitado,
|
'habilitado': value.habilitado,
|
||||||
'jornadaContinua': value.jornadaContinua,
|
'jornadaContinua': value.jornadaContinua,
|
||||||
@@ -87,7 +74,7 @@ class _HorarioScreenState extends State<HorarioScreen> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final sortedHorarios = Map.fromEntries(
|
final sortedHorarios = Map.fromEntries(
|
||||||
widget.horarios.entries.toList()
|
horarios.entries.toList()
|
||||||
..sort(
|
..sort(
|
||||||
(a, b) => _dayOfWeekToInt(a.key).compareTo(_dayOfWeekToInt(b.key))),
|
(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),
|
padding: const EdgeInsets.only(top: 30, bottom: 30),
|
||||||
child: PrimaryButtom(
|
child: PrimaryButtom(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await updateHorario();
|
await updateHorario(context);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
label: 'Guardar',
|
label: 'Guardar',
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:get/get.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),
|
margin: const EdgeInsets.only(top: 210, left: 50, right: 50),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
!isIOS
|
!isIOS && !kIsWeb
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 20),
|
padding: const EdgeInsets.only(bottom: 20),
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
@@ -126,7 +127,7 @@ class _LoginEmailScreenState extends State<LoginEmailScreen> {
|
|||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
: const SizedBox(),
|
: const SizedBox(),
|
||||||
!isIOS
|
!isIOS && !kIsWeb
|
||||||
? const Padding(
|
? const Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 5),
|
padding: EdgeInsets.symmetric(vertical: 5),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@@ -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/setting_model.dart';
|
||||||
import 'package:prosappco/src/models/user_model.dart';
|
import 'package:prosappco/src/models/user_model.dart';
|
||||||
import 'package:prosappco/src/screens/professional_info.dart';
|
import 'package:prosappco/src/screens/professional_info.dart';
|
||||||
|
|
||||||
import '../models/scores_model.dart';
|
import '../models/scores_model.dart';
|
||||||
|
|
||||||
class ProfessionalScreen extends StatefulWidget {
|
class ProfessionalScreen extends StatefulWidget {
|
||||||
@@ -227,10 +226,8 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
|
|||||||
try {
|
try {
|
||||||
QuerySnapshot users = await usersCollection.get();
|
QuerySnapshot users = await usersCollection.get();
|
||||||
for (DocumentSnapshot user in users.docs) {
|
for (DocumentSnapshot user in users.docs) {
|
||||||
// Acceder a los datos de cada usuario
|
|
||||||
Map<String, dynamic> data = user.data() as Map<String, dynamic>;
|
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);
|
_photo = await AuthenticationRepository.instance.getPhoto(user.id);
|
||||||
|
|
||||||
if (data['estado'] == 'activo') {
|
if (data['estado'] == 'activo') {
|
||||||
@@ -242,7 +239,9 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
|
|||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
if (widget.profession == data['profesion'] ||
|
if (widget.profession == data['profesion'] ||
|
||||||
widget.profession == '' && userme?.city == data['city']) {
|
widget.profession == '' &&
|
||||||
|
userme?.city == data['city'] &&
|
||||||
|
data['ubicacion'] != null) {
|
||||||
Professional professional = Professional(
|
Professional professional = Professional(
|
||||||
id: user.id,
|
id: user.id,
|
||||||
name: data['name'],
|
name: data['name'],
|
||||||
|
|||||||
@@ -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 {
|
Future<void> updateInfo() async {
|
||||||
if (_opcionalAddressController.text.isNotEmpty) {
|
if (_opcionalAddressController.text.isNotEmpty) {
|
||||||
FirebaseFirestore.instance
|
FirebaseFirestore.instance
|
||||||
@@ -445,16 +530,7 @@ class _ProfileProScreenState extends State<ProfileProScreen> {
|
|||||||
),
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pushReplacement(
|
createSchedules();
|
||||||
context,
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return HorarioScreen(
|
|
||||||
horarios: _horarios!,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||||
|
|||||||
@@ -186,19 +186,6 @@ class _ProfileProWebScreenState extends State<ProfileProWebScreen> {
|
|||||||
return;
|
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 {
|
Future<void> updateImage(image) async {
|
||||||
try {
|
try {
|
||||||
await FirebaseFirestore.instance
|
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 {
|
Future<bool> uploadImage(File image) async {
|
||||||
final String namefile = image.path.split('/').last;
|
final String namefile = image.path.split('/').last;
|
||||||
|
|
||||||
@@ -376,16 +448,7 @@ class _ProfileProWebScreenState extends State<ProfileProWebScreen> {
|
|||||||
),
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pushReplacement(
|
createSchedules();
|
||||||
context,
|
|
||||||
CupertinoPageRoute(
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return HorarioScreen(
|
|
||||||
horarios: _horarios!,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||||
@@ -517,7 +580,6 @@ class _ProfileProWebScreenState extends State<ProfileProWebScreen> {
|
|||||||
PrimaryButtom(
|
PrimaryButtom(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
updateInfo();
|
updateInfo();
|
||||||
// name();
|
|
||||||
},
|
},
|
||||||
label: 'Guardar'),
|
label: 'Guardar'),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
|||||||
@@ -145,6 +145,17 @@ class _ProfileWebScreenState extends State<ProfileWebScreen> {
|
|||||||
snackPosition: SnackPosition.BOTTOM,
|
snackPosition: SnackPosition.BOTTOM,
|
||||||
);
|
);
|
||||||
return;
|
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) {
|
if (newEmail.isEmpty) {
|
||||||
// Si el nuevo nombre está vacío, no lo actualizamos y mostramos un mensaje al usuario
|
// Si el nuevo nombre está vacío, no lo actualizamos y mostramos un mensaje al usuario
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:firebase_auth/firebase_auth.dart';
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:get/get.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),
|
margin: const EdgeInsets.only(top: 200, left: 50, right: 50),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
!isIOS
|
!isIOS && !kIsWeb
|
||||||
? Padding(
|
? Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 20),
|
padding: const EdgeInsets.only(bottom: 20),
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
@@ -129,7 +130,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
|||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
: const SizedBox(),
|
: const SizedBox(),
|
||||||
!isIOS
|
!isIOS && !kIsWeb
|
||||||
? const Padding(
|
? const Padding(
|
||||||
padding: EdgeInsets.symmetric(vertical: 0),
|
padding: EdgeInsets.symmetric(vertical: 0),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
Reference in New Issue
Block a user