auto complete
This commit is contained in:
+1
-4
@@ -38,12 +38,9 @@ void main() async {
|
|||||||
DeviceOrientation.portraitDown,
|
DeviceOrientation.portraitDown,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
const MyApp({super.key});
|
const MyApp({super.key});
|
||||||
|
|
||||||
@@ -67,7 +64,7 @@ class MyApp extends StatelessWidget {
|
|||||||
'/solicitudEnviada': (context) => const RequestSentScreen(),
|
'/solicitudEnviada': (context) => const RequestSentScreen(),
|
||||||
'/nuevaPassword': (context) => NewPasswordScreen(),
|
'/nuevaPassword': (context) => NewPasswordScreen(),
|
||||||
'/servicio': (context) => const ServiceScreen(),
|
'/servicio': (context) => const ServiceScreen(),
|
||||||
'/profilePro': (context) => const ProfilePro(),
|
'/profilePro': (context) => const ProfileProScreen(),
|
||||||
'/calendar': (context) => const CalendarScreen(),
|
'/calendar': (context) => const CalendarScreen(),
|
||||||
'/solicitud': (context) => SolicitudScreen(),
|
'/solicitud': (context) => SolicitudScreen(),
|
||||||
'/misserviciospro': (context) => const MyServicesProScreen(),
|
'/misserviciospro': (context) => const MyServicesProScreen(),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:firebase_auth/firebase_auth.dart';
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
|
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
|
||||||
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
||||||
@@ -11,6 +12,7 @@ import 'package:prosappco/src/screens/my_services_pro.dart';
|
|||||||
import 'package:prosappco/src/screens/professional.dart';
|
import 'package:prosappco/src/screens/professional.dart';
|
||||||
import 'package:prosappco/src/screens/profile.dart';
|
import 'package:prosappco/src/screens/profile.dart';
|
||||||
import 'package:prosappco/src/screens/profile_pro.dart';
|
import 'package:prosappco/src/screens/profile_pro.dart';
|
||||||
|
import 'package:prosappco/src/screens/profile_pro_web.dart';
|
||||||
import 'package:prosappco/src/screens/reputacion_pro.dart';
|
import 'package:prosappco/src/screens/reputacion_pro.dart';
|
||||||
import '../models/scores_model.dart';
|
import '../models/scores_model.dart';
|
||||||
import '../screens/configuracion.dart';
|
import '../screens/configuracion.dart';
|
||||||
@@ -139,7 +141,11 @@ class _DrawerProfessionalState extends State<DrawerProfessional> {
|
|||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return const ProfilePro();
|
if (kIsWeb) {
|
||||||
|
return const ProfileProWebScreen();
|
||||||
|
} else {
|
||||||
|
return const ProfileProScreen();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -195,7 +195,8 @@ class Schedule {
|
|||||||
final snapshot =
|
final snapshot =
|
||||||
await FirebaseFirestore.instance.collection('users').doc(uid).get();
|
await FirebaseFirestore.instance.collection('users').doc(uid).get();
|
||||||
final Map<String, dynamic>? data = snapshot.data();
|
final Map<String, dynamic>? data = snapshot.data();
|
||||||
return fromJson(data);
|
final Map<String, dynamic>? horarioData = data?['horario'];
|
||||||
|
return fromJson(horarioData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error getting user: $e');
|
print('Error getting user: $e');
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
||||||
import 'package:prosappco/src/components/pop_appbar.dart';
|
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 'package:prosappco/src/screens/profile_pro.dart';
|
|
||||||
|
|
||||||
import '../components/schedule_picker.dart';
|
import '../components/schedule_picker.dart';
|
||||||
|
|
||||||
class HorarioScreen extends StatefulWidget {
|
class HorarioScreen extends StatefulWidget {
|
||||||
@@ -21,6 +19,8 @@ class _HorarioScreenState extends State<HorarioScreen> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
|
print('horario a ${widget.horarios}');
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lunesValue = false;
|
bool lunesValue = false;
|
||||||
@@ -95,10 +95,7 @@ class _HorarioScreenState extends State<HorarioScreen> {
|
|||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: PopAppbar(
|
appBar: PopAppbar(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pushReplacement(
|
Navigator.pop(context);
|
||||||
context,
|
|
||||||
MaterialPageRoute(builder: (context) => const ProfilePro()),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
label: 'Horario'),
|
label: 'Horario'),
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
@@ -121,11 +118,8 @@ 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 {
|
||||||
updateHorario().then((value) => Navigator.pushReplacement(
|
await updateHorario();
|
||||||
context,
|
Navigator.pop(context);
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => const ProfilePro()),
|
|
||||||
));
|
|
||||||
},
|
},
|
||||||
label: 'Guardar',
|
label: 'Guardar',
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
import 'package:firebase_storage/firebase_storage.dart';
|
import 'package:firebase_storage/firebase_storage.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_animate/flutter_animate.dart';
|
import 'package:flutter_animate/flutter_animate.dart';
|
||||||
@@ -16,20 +16,21 @@ import 'package:prosappco/src/models/setting_model.dart';
|
|||||||
import 'package:prosappco/src/screens/horario.dart';
|
import 'package:prosappco/src/screens/horario.dart';
|
||||||
import 'package:prosappco/src/screens/professional.dart';
|
import 'package:prosappco/src/screens/professional.dart';
|
||||||
import 'package:prosappco/src/screens/professional_direccion.dart';
|
import 'package:prosappco/src/screens/professional_direccion.dart';
|
||||||
|
import 'package:prosappco/src/screens/ubicacion.dart';
|
||||||
import 'package:prosappco/src/services/select_image_profile.dart';
|
import 'package:prosappco/src/services/select_image_profile.dart';
|
||||||
|
|
||||||
class ProfilePro extends StatefulWidget {
|
class ProfileProScreen extends StatefulWidget {
|
||||||
const ProfilePro({super.key});
|
const ProfileProScreen({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<ProfilePro> createState() => _ProfileProState();
|
State<ProfileProScreen> createState() => _ProfileProScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ProfileProState extends State<ProfilePro> {
|
class _ProfileProScreenState extends State<ProfileProScreen> {
|
||||||
final uid = AuthenticationRepository.instance.getCurrentUserUid();
|
final uid = AuthenticationRepository.instance.getCurrentUserUid();
|
||||||
final TextEditingController _opcionalAddressController =
|
final TextEditingController _opcionalAddressController =
|
||||||
TextEditingController();
|
TextEditingController();
|
||||||
TextEditingController _tarifaController = TextEditingController();
|
final TextEditingController _tarifaController = TextEditingController();
|
||||||
|
|
||||||
File? image_portada;
|
File? image_portada;
|
||||||
File? imagen_to_upload;
|
File? imagen_to_upload;
|
||||||
@@ -71,11 +72,11 @@ class _ProfileProState extends State<ProfilePro> {
|
|||||||
|
|
||||||
if (_horarios == null) {
|
if (_horarios == null) {
|
||||||
Schedule.getHorarios(uid.toString()).then(
|
Schedule.getHorarios(uid.toString()).then(
|
||||||
(Map<String, Schedule> s) => setState(
|
(Map<String, Schedule> data) {
|
||||||
() {
|
setState(() {
|
||||||
_horarios = s;
|
_horarios = data;
|
||||||
},
|
});
|
||||||
),
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +184,6 @@ class _ProfileProState extends State<ProfilePro> {
|
|||||||
try {
|
try {
|
||||||
if (imagen_to_upload == null) {
|
if (imagen_to_upload == null) {
|
||||||
} else {
|
} else {
|
||||||
final uploaded = await uploadImage(imagen_to_upload!);
|
|
||||||
updateImage(photoTemp);
|
updateImage(photoTemp);
|
||||||
//image
|
//image
|
||||||
}
|
}
|
||||||
@@ -196,9 +196,24 @@ class _ProfileProState extends State<ProfilePro> {
|
|||||||
'Su información a sido actualizada con exito.',
|
'Su información a sido actualizada con exito.',
|
||||||
snackPosition: SnackPosition.TOP,
|
snackPosition: SnackPosition.TOP,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Navigator.pop(context);
|
||||||
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
|
||||||
@@ -432,7 +447,7 @@ class _ProfileProState extends State<ProfilePro> {
|
|||||||
),
|
),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
@@ -443,84 +458,137 @@ class _ProfileProState extends State<ProfilePro> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Padding(
|
||||||
children: [
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||||
const Padding(
|
child: Table(
|
||||||
padding: EdgeInsets.symmetric(vertical: 10),
|
defaultColumnWidth: const IntrinsicColumnWidth(),
|
||||||
child: Row(
|
children: [
|
||||||
|
TableRow(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
TableCell(
|
||||||
child: Padding(
|
child: Container(
|
||||||
padding: EdgeInsets.only(left: 30),
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text('Lunes'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(timeList(_horarios?['Lunes'], context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: const Text('Martes'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child:
|
||||||
|
Text(timeList(_horarios?['Martes'], context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: const Text('Miercoles'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Dia',
|
timeList(_horarios?['Miercoles'], context)),
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.w500),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(right: 170),
|
|
||||||
child: Text(
|
|
||||||
'Hora',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.black,
|
|
||||||
fontWeight: FontWeight.w500),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.only(right: 45),
|
|
||||||
child: Icon(Icons.edit_outlined),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
TableRow(
|
||||||
Padding(
|
|
||||||
padding: sitioValue
|
|
||||||
? const EdgeInsets.only(bottom: 30)
|
|
||||||
: const EdgeInsets.only(bottom: 70),
|
|
||||||
child: Row(
|
|
||||||
children: [
|
children: [
|
||||||
const Padding(
|
TableCell(
|
||||||
padding: EdgeInsets.only(left: 30),
|
child: Container(
|
||||||
child: Column(
|
padding: const EdgeInsets.all(8.0),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: const Text('Jueves'),
|
||||||
children: [
|
|
||||||
Text('Lunes'),
|
|
||||||
Text('Martes'),
|
|
||||||
Text('Miércoles'),
|
|
||||||
Text('Jueves'),
|
|
||||||
Text('Viernes'),
|
|
||||||
Text('Sábado'),
|
|
||||||
Text('Domingo'),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
TableCell(
|
||||||
padding: const EdgeInsets.only(left: 25),
|
child: Container(
|
||||||
child: Column(
|
padding: const EdgeInsets.all(8.0),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child:
|
||||||
children: [
|
Text(timeList(_horarios?['Jueves'], context)),
|
||||||
Text(timeList(_horarios?['Lunes'], context)),
|
|
||||||
Text(timeList(_horarios?['Martes'], context)),
|
|
||||||
Text(timeList(_horarios?['Miercoles'], context)),
|
|
||||||
Text(timeList(_horarios?['Jueves'], context)),
|
|
||||||
Text(timeList(_horarios?['Viernes'], context)),
|
|
||||||
Text(timeList(_horarios?['Sabado'], context)),
|
|
||||||
Text(timeList(_horarios?['Domingo'], context)),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
TableRow(
|
||||||
],
|
children: [
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: const Text('Viernes'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child:
|
||||||
|
Text(timeList(_horarios?['Viernes'], context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: const Text('Sabado'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child:
|
||||||
|
Text(timeList(_horarios?['Sabado'], context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: const Text('Domingo'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child:
|
||||||
|
Text(timeList(_horarios?['Domingo'], context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
PrimaryButtom(
|
PrimaryButtom(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
updateInfo();
|
updateInfo();
|
||||||
|
// name();
|
||||||
},
|
},
|
||||||
label: 'Guardar'),
|
label: 'Guardar'),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
@@ -568,7 +636,6 @@ class _ProfileProState extends State<ProfilePro> {
|
|||||||
if (schedule == null) {
|
if (schedule == null) {
|
||||||
return 'N/A';
|
return 'N/A';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!schedule.habilitado) {
|
if (!schedule.habilitado) {
|
||||||
return 'N/A';
|
return 'N/A';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,579 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:firebase_storage/firebase_storage.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
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';
|
||||||
|
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});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ProfileProWebScreen> createState() => _ProfileProWebScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ProfileProWebScreenState extends State<ProfileProWebScreen> {
|
||||||
|
final uid = AuthenticationRepository.instance.getCurrentUserUid();
|
||||||
|
|
||||||
|
final TextEditingController _opcionalAddressController =
|
||||||
|
TextEditingController();
|
||||||
|
final TextEditingController _tarifaController = TextEditingController();
|
||||||
|
final TextEditingController _ubicationController = TextEditingController();
|
||||||
|
|
||||||
|
double latUser = 0.0;
|
||||||
|
double lngUser = 0.0;
|
||||||
|
|
||||||
|
bool domicilioValue = false;
|
||||||
|
bool tarifaValue = false;
|
||||||
|
bool sitioValue = false;
|
||||||
|
var photoTemp = '';
|
||||||
|
|
||||||
|
var _direccion = '...';
|
||||||
|
var _ubicacion = '...';
|
||||||
|
var _opcionalAddress = '...';
|
||||||
|
int _tarifa = 0;
|
||||||
|
SettingModel? settings;
|
||||||
|
|
||||||
|
Map<String, Schedule>? _horarios;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
if (settings == null) {
|
||||||
|
SettingModel.getSettings().then(
|
||||||
|
(SettingModel value) => setState(() => settings = value),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final uid = AuthenticationRepository.instance.getCurrentUserUid();
|
||||||
|
|
||||||
|
if (_horarios == null) {
|
||||||
|
Schedule.getHorarios(uid.toString()).then(
|
||||||
|
(Map<String, Schedule> data) {
|
||||||
|
setState(() {
|
||||||
|
_horarios = data;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_direccion == '...') {
|
||||||
|
AuthenticationRepository.instance
|
||||||
|
.getAddress(uid.toString())
|
||||||
|
.then((String s) => setState(() {
|
||||||
|
_direccion = s;
|
||||||
|
_ubicationController.text = _direccion;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (_tarifa == 0) {
|
||||||
|
AuthenticationRepository.instance.getTarifa(uid.toString()).then(
|
||||||
|
(s) => setState(
|
||||||
|
() {
|
||||||
|
_tarifa = s;
|
||||||
|
|
||||||
|
if (_tarifa != 0) {
|
||||||
|
tarifaValue = true;
|
||||||
|
_tarifaController.text = _tarifa.toString();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> updateInfo() async {
|
||||||
|
if (_ubicationController.text.isNotEmpty) {
|
||||||
|
FirebaseFirestore.instance.collection('users').doc(uid).update({
|
||||||
|
'address': _ubicationController.text,
|
||||||
|
if (latUser != 0.0) 'latitude': latUser,
|
||||||
|
if (latUser != 0.0) 'longitude': lngUser,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (_opcionalAddressController.text.isNotEmpty) {
|
||||||
|
FirebaseFirestore.instance
|
||||||
|
.collection('users')
|
||||||
|
.doc(uid)
|
||||||
|
.update({'opcional_address': _opcionalAddressController.text});
|
||||||
|
}
|
||||||
|
if (tarifaValue && _tarifaController.text.isNotEmpty) {
|
||||||
|
FirebaseFirestore.instance
|
||||||
|
.collection('users')
|
||||||
|
.doc(uid)
|
||||||
|
.update({'tarifa': int.parse(_tarifaController.text)});
|
||||||
|
} else {
|
||||||
|
FirebaseFirestore.instance
|
||||||
|
.collection('users')
|
||||||
|
.doc(uid)
|
||||||
|
.update({'tarifa': 0});
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Get.snackbar(
|
||||||
|
'Información actualizada',
|
||||||
|
'Su información a sido actualizada con exito.',
|
||||||
|
snackPosition: SnackPosition.TOP,
|
||||||
|
);
|
||||||
|
|
||||||
|
Navigator.pop(context);
|
||||||
|
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
|
||||||
|
.collection('users')
|
||||||
|
.doc(uid)
|
||||||
|
.update({'banner': image});
|
||||||
|
|
||||||
|
print('imagen actualizada correctamente');
|
||||||
|
} catch (e) {
|
||||||
|
try {
|
||||||
|
await FirebaseFirestore.instance
|
||||||
|
.collection('users')
|
||||||
|
.doc(uid)
|
||||||
|
.set({'banner': image});
|
||||||
|
} catch (e) {
|
||||||
|
print('Error al agregar la imagen de perfil: $e');
|
||||||
|
}
|
||||||
|
|
||||||
|
print('Error al actualizar la imagen de perfil: $e');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> uploadImage(File image) async {
|
||||||
|
final String namefile = image.path.split('/').last;
|
||||||
|
|
||||||
|
Reference ref = storage
|
||||||
|
.ref()
|
||||||
|
.child('users')
|
||||||
|
.child(uid!)
|
||||||
|
.child('profile')
|
||||||
|
.child(namefile);
|
||||||
|
|
||||||
|
final UploadTask uploadTask = ref.putFile(image);
|
||||||
|
|
||||||
|
final TaskSnapshot snapshot = await uploadTask.whenComplete(() => true);
|
||||||
|
|
||||||
|
photoTemp = ref.fullPath;
|
||||||
|
|
||||||
|
if (snapshot.state == TaskState.success) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: PopAppbar(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
label: 'Perfil profesional'),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
reverse: true,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
if (settings?.tarifas == true)
|
||||||
|
const Divider(
|
||||||
|
color: Colors.white,
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
if (settings?.tarifas == true)
|
||||||
|
customSwitch(
|
||||||
|
'Tarifa',
|
||||||
|
tarifaValue,
|
||||||
|
(value) {
|
||||||
|
tarifaValue = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
tarifaValue
|
||||||
|
? Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.only(left: 40, right: 40, bottom: 15),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
TextFormField(
|
||||||
|
controller: _tarifaController,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
prefixIcon: Icon(Icons.attach_money),
|
||||||
|
hintText: 'COP'),
|
||||||
|
inputFormatters: [
|
||||||
|
FilteringTextInputFormatter.digitsOnly,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.animate()
|
||||||
|
.moveY(duration: const Duration(milliseconds: 100)),
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
if (settings?.domicilios == true)
|
||||||
|
const Divider(
|
||||||
|
color: Colors.white,
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
if (settings?.domicilios == true)
|
||||||
|
customSwitch(
|
||||||
|
'Servicio a domicilio',
|
||||||
|
domicilioValue,
|
||||||
|
(value) {
|
||||||
|
domicilioValue = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const Divider(),
|
||||||
|
customSwitch(
|
||||||
|
'Servicio en sitio',
|
||||||
|
sitioValue,
|
||||||
|
(value) {
|
||||||
|
sitioValue = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
sitioValue
|
||||||
|
? Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.only(left: 40, right: 40, bottom: 15),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
TextFormField(
|
||||||
|
controller: _ubicationController,
|
||||||
|
readOnly: true,
|
||||||
|
onTap: () async {
|
||||||
|
final List<dynamic> datos = await Navigator.push(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return const UbicacionScreen();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (datos.length == 3) {
|
||||||
|
final formattedAddress = datos[0];
|
||||||
|
final lat = datos[1];
|
||||||
|
final lng = datos[2];
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_ubicationController.text = formattedAddress;
|
||||||
|
latUser = lat;
|
||||||
|
lngUser = lng;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
hintText: 'Escribe tu ubicación',
|
||||||
|
prefixIcon: Icon(Icons.near_me),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
TextFormField(
|
||||||
|
controller: _opcionalAddressController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
|
hintText: 'Oficina / Piso / Conjunto'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
.animate()
|
||||||
|
.moveY(duration: const Duration(milliseconds: 100)),
|
||||||
|
)
|
||||||
|
: const SizedBox(),
|
||||||
|
const Divider(),
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 30),
|
||||||
|
child: SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: Text(
|
||||||
|
'Horario estandar',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
fontSize: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
context,
|
||||||
|
CupertinoPageRoute(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return HorarioScreen(
|
||||||
|
horarios: _horarios!,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||||
|
child: Table(
|
||||||
|
defaultColumnWidth: const IntrinsicColumnWidth(),
|
||||||
|
children: [
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text('Lunes'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(timeList(_horarios?['Lunes'], context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: const Text('Martes'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child:
|
||||||
|
Text(timeList(_horarios?['Martes'], context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: const Text('Miercoles'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(
|
||||||
|
timeList(_horarios?['Miercoles'], context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: const Text('Jueves'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child:
|
||||||
|
Text(timeList(_horarios?['Jueves'], context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: const Text('Viernes'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child:
|
||||||
|
Text(timeList(_horarios?['Viernes'], context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: const Text('Sabado'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child:
|
||||||
|
Text(timeList(_horarios?['Sabado'], context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TableRow(
|
||||||
|
children: [
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: const Text('Domingo'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TableCell(
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child:
|
||||||
|
Text(timeList(_horarios?['Domingo'], context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PrimaryButtom(
|
||||||
|
onPressed: () {
|
||||||
|
updateInfo();
|
||||||
|
// name();
|
||||||
|
},
|
||||||
|
label: 'Guardar'),
|
||||||
|
const SizedBox(
|
||||||
|
height: 20,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
customSwitch(String text, bool switchValue, ValueChanged<bool> onChanged) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 30),
|
||||||
|
child: SizedBox(
|
||||||
|
height: 40,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
text,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 15,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
Transform.scale(
|
||||||
|
scale: 1.2,
|
||||||
|
child: Switch(
|
||||||
|
value: switchValue,
|
||||||
|
onChanged: (bool newValue) {
|
||||||
|
setState(() {
|
||||||
|
onChanged(newValue);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String timeList(Schedule? schedule, BuildContext context) {
|
||||||
|
if (schedule == null) {
|
||||||
|
return 'N/A';
|
||||||
|
}
|
||||||
|
if (!schedule.habilitado) {
|
||||||
|
return 'N/A';
|
||||||
|
}
|
||||||
|
if (schedule.jornadaContinua) {
|
||||||
|
return '${schedule.range1Hour1?.format(context).toString()} - ${schedule.range2Hour2?.format(context).toString()}';
|
||||||
|
} else {
|
||||||
|
return '${schedule.range1Hour1?.format(context).toString()} - ${schedule.range1Hour2?.format(context).toString()}; ${schedule.range2Hour1?.format(context).toString()} - ${schedule.range2Hour2?.format(context).toString()}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user