datos para el servicio
This commit is contained in:
+7
-2
@@ -6,6 +6,7 @@ import 'package:prosappco/blocs/my_user_bloc/my_user_bloc.dart';
|
||||
import 'package:prosappco/blocs/professional_bloc/professional_bloc.dart';
|
||||
import 'package:prosappco/blocs/professional_profile_bloc/professional_profile_bloc.dart';
|
||||
import 'package:prosappco/blocs/profile_bloc/profile_bloc.dart';
|
||||
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||
|
||||
import 'app_view.dart';
|
||||
|
||||
@@ -29,8 +30,12 @@ class MainApp extends StatelessWidget {
|
||||
create: (context) => Injector.appInstance.get<ProfessionalBloc>(),
|
||||
),
|
||||
BlocProvider<ProfessionalProfileBloc>(
|
||||
create: (context) => Injector.appInstance.get<ProfessionalProfileBloc>(),
|
||||
)
|
||||
create: (context) =>
|
||||
Injector.appInstance.get<ProfessionalProfileBloc>(),
|
||||
),
|
||||
BlocProvider<ServiceBloc>(
|
||||
create: (context) => Injector.appInstance.get<ServiceBloc>(),
|
||||
),
|
||||
],
|
||||
child: BlocBuilder<MyUserBloc, MyUserState>(
|
||||
builder: (context, state) {
|
||||
|
||||
@@ -12,12 +12,8 @@ class ProfessionalBloc extends Bloc<ProfessionalEvent, ProfessionalState> {
|
||||
final FirebaseProfessionalRepository _professionalRepository;
|
||||
final UserRepository _userRepository;
|
||||
|
||||
ProfessionalBloc(
|
||||
{required FirebaseProfessionalRepository professionalRepository,
|
||||
required UserRepository userRepository})
|
||||
: _professionalRepository = professionalRepository,
|
||||
_userRepository = userRepository,
|
||||
super(ProfessionalInitial()) {
|
||||
ProfessionalBloc({required FirebaseProfessionalRepository professionalRepository, required UserRepository userRepository})
|
||||
: _professionalRepository = professionalRepository, _userRepository = userRepository, super(ProfessionalInitial()) {
|
||||
bool isProModeActive = _professionalRepository.isProModeActive;
|
||||
final proInfo = _professionalRepository.lastProInfo();
|
||||
emit(LoadedModeProState(isProModeActive, proInfo));
|
||||
|
||||
@@ -44,7 +44,6 @@ class ProfessionalProfileBloc
|
||||
event.longitude,
|
||||
event.schedules,
|
||||
event.paymentMethods,
|
||||
|
||||
);
|
||||
|
||||
emit(const UpdateProfessionalInfoSuccess());
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
@@ -11,7 +15,38 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
||||
|
||||
ServiceBloc({required FirebaseServiceRepository serviceRepository})
|
||||
: _serviceRepository = serviceRepository,
|
||||
super(ServiceInitial()) {
|
||||
|
||||
}
|
||||
super(CreateServiceInitial()) {
|
||||
on<CreateService>(_onCreateService);
|
||||
}
|
||||
|
||||
void _onCreateService(CreateService event, Emitter<ServiceState> emit) async {
|
||||
try {
|
||||
ServiceEntity service = ServiceEntity(
|
||||
professionalId: event.professionalId,
|
||||
professionalScored: false,
|
||||
userId: event.userId,
|
||||
userScored: false,
|
||||
address: event.address,
|
||||
aditionalAddress: event.aditionalAddress,
|
||||
latitude: event.latitude,
|
||||
longitude: event.longitude,
|
||||
day: event.day,
|
||||
createdAt: event.createdAt,
|
||||
description: event.description,
|
||||
range1Hour1: event.range1Hour1,
|
||||
range1Hour2: event.range1Hour2,
|
||||
rate: event.rate,
|
||||
status: ServiceStatus.pending,
|
||||
location: event.location,
|
||||
);
|
||||
|
||||
log('xd -- $service');
|
||||
|
||||
await _serviceRepository.createService(service);
|
||||
|
||||
emit(const CreateServiceSuccess());
|
||||
} catch (e) {
|
||||
emit(CreateServiceFailure());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,63 @@ abstract class ServiceEvent extends Equatable {
|
||||
const ServiceEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class CreateService extends ServiceEvent {
|
||||
final String professionalId;
|
||||
final bool? professionalScored;
|
||||
final String userId;
|
||||
final bool? userScored;
|
||||
final String address;
|
||||
final String aditionalAddress;
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
final String day;
|
||||
final Timestamp createdAt;
|
||||
final String description;
|
||||
final TimeOfDay range1Hour1;
|
||||
final TimeOfDay range1Hour2;
|
||||
final String rate;
|
||||
final ServiceStatus? status;
|
||||
final ServiceLocationPreferences location;
|
||||
|
||||
const CreateService({
|
||||
required this.professionalId,
|
||||
this.professionalScored,
|
||||
required this.userId,
|
||||
this.userScored,
|
||||
required this.address,
|
||||
required this.aditionalAddress,
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
required this.day,
|
||||
required this.createdAt,
|
||||
required this.description,
|
||||
required this.range1Hour1,
|
||||
required this.range1Hour2,
|
||||
required this.rate,
|
||||
this.status,
|
||||
required this.location,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
professionalId,
|
||||
professionalScored,
|
||||
userId,
|
||||
userScored,
|
||||
address,
|
||||
aditionalAddress,
|
||||
latitude,
|
||||
longitude,
|
||||
day,
|
||||
createdAt,
|
||||
description,
|
||||
range1Hour1,
|
||||
range1Hour2,
|
||||
rate,
|
||||
status,
|
||||
location,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -7,4 +7,15 @@ abstract class ServiceState extends Equatable {
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ServiceInitial extends ServiceState {}
|
||||
class CreateServiceInitial extends ServiceState {}
|
||||
|
||||
class CreateServiceFailure extends ServiceState {}
|
||||
|
||||
class CreateServiceLoading extends ServiceState {}
|
||||
|
||||
class CreateServiceSuccess extends ServiceState {
|
||||
const CreateServiceSuccess();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
@@ -9,9 +9,11 @@ import 'package:prosappco/blocs/professional_bloc/professional_bloc.dart';
|
||||
import 'package:prosappco/blocs/professional_list_bloc/professional_list_bloc.dart';
|
||||
import 'package:prosappco/blocs/professional_profile_bloc/professional_profile_bloc.dart';
|
||||
import 'package:prosappco/blocs/profile_bloc/profile_bloc.dart';
|
||||
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||
import 'package:prosappco/blocs/setting_bloc/setting_bloc.dart';
|
||||
import 'package:prosappco/blocs/sign_up_bloc/sign_up_bloc.dart';
|
||||
import 'package:prosappco/blocs/sing_in_bloc/sign_in_bloc.dart';
|
||||
import 'package:service_repository/service_repository.dart';
|
||||
import 'package:user_repository/user_repository.dart';
|
||||
import 'package:city_repository/city_repository.dart';
|
||||
import 'package:setting_repository/setting_repository.dart';
|
||||
@@ -31,9 +33,8 @@ class AppDI {
|
||||
injector.registerSingleton<SettingRepository>(
|
||||
() => FirebaseSettingRepository());
|
||||
|
||||
injector.registerSingleton(
|
||||
() => FirebaseProfessionalRepository(),
|
||||
);
|
||||
injector.registerSingleton(() => FirebaseProfessionalRepository());
|
||||
injector.registerSingleton(() => FirebaseServiceRepository());
|
||||
|
||||
injector.registerSingleton<AuthenticationBloc>((() =>
|
||||
AuthenticationBloc(myUserRepository: injector.get<UserRepository>())));
|
||||
@@ -51,19 +52,19 @@ class AppDI {
|
||||
);
|
||||
|
||||
injector.registerDependency<SignInBloc>(
|
||||
(() => SignInBloc(userRepository: injector.get<UserRepository>())));
|
||||
() => SignInBloc(userRepository: injector.get<UserRepository>()));
|
||||
|
||||
injector.registerDependency<SignUpBloc>(
|
||||
(() => SignUpBloc(userRepository: injector.get<UserRepository>())));
|
||||
() => SignUpBloc(userRepository: injector.get<UserRepository>()));
|
||||
|
||||
injector.registerDependency<SettingBloc>(
|
||||
(() => SettingBloc(userRepository: injector.get<UserRepository>())));
|
||||
() => SettingBloc(userRepository: injector.get<UserRepository>()));
|
||||
|
||||
injector.registerDependency<AuthBloc>(
|
||||
(() => AuthBloc(userRepository: injector.get<UserRepository>())));
|
||||
() => AuthBloc(userRepository: injector.get<UserRepository>()));
|
||||
|
||||
injector.registerSingleton<ProfessionalProfileBloc>((() =>
|
||||
ProfessionalProfileBloc(professionalRepository: injector.get())));
|
||||
injector.registerSingleton<ProfessionalProfileBloc>(
|
||||
() => ProfessionalProfileBloc(professionalRepository: injector.get()));
|
||||
|
||||
injector.registerDependency<ProfessionalListBloc>(
|
||||
() => ProfessionalListBloc(
|
||||
@@ -71,5 +72,8 @@ class AppDI {
|
||||
firebaseProfessonalRepository:
|
||||
injector.get<FirebaseProfessionalRepository>()),
|
||||
);
|
||||
|
||||
injector.registerSingleton<ServiceBloc>(() => ServiceBloc(
|
||||
serviceRepository: injector.get<FirebaseServiceRepository>()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:injector/injector.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:professional_repository/professional_repository.dart';
|
||||
import 'package:prosappco/blocs/professional_list_bloc/professional_list_bloc.dart';
|
||||
import 'package:prosappco/utils/time_of_day_utils.dart';
|
||||
import 'package:service_repository/service_repository.dart';
|
||||
import 'package:setting_repository/setting_repository.dart';
|
||||
import 'package:table_calendar/table_calendar.dart';
|
||||
|
||||
class UserCalendarScreen extends StatefulWidget {
|
||||
@@ -17,6 +19,9 @@ class UserCalendarScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class UserCalendarScreenState extends State<UserCalendarScreen> {
|
||||
final settingRepository = Injector.appInstance.get<SettingRepository>();
|
||||
SettingEntity? settings;
|
||||
|
||||
DateTime today = DateTime.now();
|
||||
DateTime now = DateTime.now();
|
||||
late int numDay;
|
||||
@@ -29,6 +34,16 @@ class UserCalendarScreenState extends State<UserCalendarScreen> {
|
||||
|
||||
today = DateTime.utc(today.year, today.month, today.day);
|
||||
numDay = today.weekday;
|
||||
|
||||
_loadSettings();
|
||||
}
|
||||
|
||||
void _loadSettings() {
|
||||
settingRepository.getSettings().then(
|
||||
(value) => setState(() {
|
||||
settings = value;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
void _onDaySelected(DateTime day, DateTime focusedDay) {
|
||||
@@ -135,7 +150,12 @@ class UserCalendarScreenState extends State<UserCalendarScreen> {
|
||||
schedule.enabled == false ||
|
||||
schedule.range1Hour1 == null ||
|
||||
schedule.range2Hour2 == null) {
|
||||
return [const Text("No hay horarios disponibles")];
|
||||
return [
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 25),
|
||||
child: Text("No hay horarios disponibles"),
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
if (schedule.continuousDay) {
|
||||
@@ -241,7 +261,74 @@ class UserCalendarScreenState extends State<UserCalendarScreen> {
|
||||
),
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
Navigator.pop(context, [today, time, widget.userProfessional]);
|
||||
if (settings?.domicilios == true) {
|
||||
if (widget.userProfessional.professionalInfo
|
||||
.locationPreferences ==
|
||||
LocationPreferences.both) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
content: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context, [
|
||||
today,
|
||||
time,
|
||||
ServiceLocationPreferences.delivery,
|
||||
widget.userProfessional,
|
||||
]);
|
||||
},
|
||||
child: const Text('A domicilio'),
|
||||
),
|
||||
const Divider(color: Colors.black54),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(context, [
|
||||
today,
|
||||
time,
|
||||
ServiceLocationPreferences.office,
|
||||
widget.userProfessional,
|
||||
]);
|
||||
},
|
||||
child: const Text('En sitio'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else if (widget.userProfessional.professionalInfo
|
||||
.locationPreferences ==
|
||||
LocationPreferences.delivery) {
|
||||
Navigator.pop(context, [
|
||||
today,
|
||||
time,
|
||||
ServiceLocationPreferences.delivery,
|
||||
widget.userProfessional,
|
||||
]);
|
||||
} else {
|
||||
Navigator.pop(context, [
|
||||
today,
|
||||
time,
|
||||
ServiceLocationPreferences.office,
|
||||
widget.userProfessional,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
Navigator.pop(context, [
|
||||
today,
|
||||
time,
|
||||
ServiceLocationPreferences.office,
|
||||
widget.userProfessional,
|
||||
]);
|
||||
}
|
||||
},
|
||||
contentPadding: const EdgeInsets.all(16),
|
||||
leading: Container(
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:geocoding/geocoding.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:injector/injector.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:prosappco/blocs/my_user_bloc/my_user_bloc.dart';
|
||||
import 'package:prosappco/blocs/professional_list_bloc/professional_list_bloc.dart';
|
||||
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||
import 'package:prosappco/screens/lists/professional_list_screen.dart';
|
||||
import 'package:prosappco/utils/time_of_day_extension.dart';
|
||||
import 'package:service_repository/service_repository.dart';
|
||||
import 'package:setting_repository/setting_repository.dart';
|
||||
|
||||
class UserMapScreen extends StatefulWidget {
|
||||
@@ -24,13 +28,21 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
Completer<GoogleMapController>();
|
||||
LatLng? _currentP;
|
||||
|
||||
final TextEditingController _addressController = TextEditingController();
|
||||
final TextEditingController _observationController = TextEditingController();
|
||||
|
||||
final settingRepository = Injector.appInstance.get<SettingRepository>();
|
||||
SettingEntity? settings;
|
||||
|
||||
final DateFormat formatter = DateFormat('dd/MM/yyyy');
|
||||
|
||||
LatLng coordenadas = const LatLng(7.1253900, -73.1198000);
|
||||
DateTime? fechaSeleccionada;
|
||||
TimeOfDay? horaSeleccionada;
|
||||
ServiceLocationPreferences? serviceLocationPreference;
|
||||
UserProfessional? profesionalSeleccionado;
|
||||
|
||||
bool isClearButtonVisible = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -49,105 +61,120 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<MyUserBloc, MyUserState>(
|
||||
builder: (context, state) {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
GoogleMap(
|
||||
myLocationEnabled: true,
|
||||
onMapCreated: (GoogleMapController controller) {
|
||||
_mapController.complete(controller);
|
||||
},
|
||||
initialCameraPosition: const CameraPosition(
|
||||
target: LatLng(
|
||||
// 7.078511421411328, -73.08832615613937
|
||||
7.1253900,
|
||||
-73.1198000
|
||||
// currentPosition.latitude, currentPosition.longitude
|
||||
),
|
||||
zoom: 16,
|
||||
),
|
||||
myLocationButtonEnabled: false,
|
||||
),
|
||||
Positioned(
|
||||
top: 10,
|
||||
left: 0,
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
shape: const CircleBorder(),
|
||||
elevation: 3,
|
||||
minimumSize: const Size(50, 50),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.menu,
|
||||
color: Colors.black,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () {
|
||||
Scaffold.of(context).openDrawer();
|
||||
},
|
||||
);
|
||||
return BlocProvider<ServiceBloc>(
|
||||
create: (context) => Injector.appInstance.get<ServiceBloc>(),
|
||||
child: BlocBuilder<MyUserBloc, MyUserState>(
|
||||
builder: (context, state) {
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
GoogleMap(
|
||||
myLocationEnabled: true,
|
||||
// polylines: Set<Polyline>.of(polylines.values),
|
||||
onMapCreated: (GoogleMapController controller) {
|
||||
_mapController.complete(controller);
|
||||
},
|
||||
),
|
||||
),
|
||||
const Positioned(
|
||||
bottom: 30,
|
||||
right: 0,
|
||||
left: 0,
|
||||
top: 0,
|
||||
child: Icon(
|
||||
Icons.location_on,
|
||||
size: 40,
|
||||
color: Color(0xFFFF0000),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 10,
|
||||
right: 10,
|
||||
child: FloatingActionButton(
|
||||
onPressed: () async {
|
||||
try {
|
||||
Position position = await _determinePosition();
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_currentP = LatLng(
|
||||
position.latitude,
|
||||
position.longitude,
|
||||
);
|
||||
});
|
||||
|
||||
_animateCameraToPosition(_currentP!);
|
||||
}
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).clearSnackBars();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Por favor activa la ubicacion'),
|
||||
),
|
||||
);
|
||||
onCameraIdle: () {
|
||||
getLocationName(
|
||||
coordenadas.latitude, coordenadas.longitude)
|
||||
.then((value) => setState(() {
|
||||
_addressController.text = value;
|
||||
}));
|
||||
},
|
||||
onCameraMove: (position) {
|
||||
if (serviceLocationPreference !=
|
||||
ServiceLocationPreferences.office) {
|
||||
coordenadas = position.target;
|
||||
}
|
||||
},
|
||||
elevation: 0,
|
||||
child: const Icon(
|
||||
Icons.gps_fixed,
|
||||
size: 30,
|
||||
initialCameraPosition: const CameraPosition(
|
||||
target: LatLng(7.1253900, -73.1198000),
|
||||
zoom: 16,
|
||||
),
|
||||
myLocationButtonEnabled: false,
|
||||
),
|
||||
Positioned(
|
||||
top: 10,
|
||||
left: 0,
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
shape: const CircleBorder(),
|
||||
elevation: 3,
|
||||
minimumSize: const Size(50, 50),
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.menu,
|
||||
color: Colors.black,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () {
|
||||
Scaffold.of(context).openDrawer();
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
const Positioned(
|
||||
bottom: 30,
|
||||
right: 0,
|
||||
left: 0,
|
||||
top: 0,
|
||||
child: Icon(
|
||||
Icons.location_on,
|
||||
size: 40,
|
||||
color: Color(0xFFFF0000),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 10,
|
||||
right: 10,
|
||||
child: FloatingActionButton(
|
||||
onPressed: () async {
|
||||
try {
|
||||
Position position = await _determinePosition();
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_currentP = LatLng(
|
||||
position.latitude,
|
||||
position.longitude,
|
||||
);
|
||||
});
|
||||
|
||||
_animateCameraToPosition(_currentP!);
|
||||
}
|
||||
} catch (e) {
|
||||
ScaffoldMessenger.of(context).clearSnackBars();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Por favor activa la ubicacion'),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
elevation: 0,
|
||||
child: const Icon(
|
||||
Icons.gps_fixed,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
buildBottom(context, state),
|
||||
],
|
||||
);
|
||||
},
|
||||
BlocListener<ServiceBloc, ServiceState>(
|
||||
listener: (context, state) {},
|
||||
child: buildBottom(context, state),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -159,6 +186,11 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextField(
|
||||
controller: TextEditingController(
|
||||
text: profesionalSeleccionado == null
|
||||
? ''
|
||||
: '${profesionalSeleccionado?.myUser.name ?? ''} - ${profesionalSeleccionado?.professionalInfo.profession ?? ''}',
|
||||
),
|
||||
readOnly: true,
|
||||
onTap: () async {
|
||||
var datos = await Navigator.push(context,
|
||||
@@ -166,16 +198,31 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
return const ProfessionalListScreen();
|
||||
}));
|
||||
|
||||
log('xd -- datos $datos');
|
||||
|
||||
if (datos != null) {
|
||||
fechaSeleccionada = datos[0];
|
||||
horaSeleccionada = datos[1];
|
||||
|
||||
log('xd -- $fechaSeleccionada');
|
||||
log('xd -- $horaSeleccionada');
|
||||
serviceLocationPreference = datos[2];
|
||||
profesionalSeleccionado = datos[3];
|
||||
|
||||
setState(() {});
|
||||
if (serviceLocationPreference ==
|
||||
ServiceLocationPreferences.office) {
|
||||
_addressController.text =
|
||||
profesionalSeleccionado?.professionalInfo.address ?? '';
|
||||
|
||||
_animateCameraToPosition(
|
||||
LatLng(
|
||||
profesionalSeleccionado!.professionalInfo.latitude,
|
||||
profesionalSeleccionado!.professionalInfo.longitude,
|
||||
),
|
||||
);
|
||||
coordenadas = LatLng(
|
||||
profesionalSeleccionado!.professionalInfo.latitude,
|
||||
profesionalSeleccionado!.professionalInfo.longitude,
|
||||
);
|
||||
} else {}
|
||||
|
||||
isClearButtonVisible = true;
|
||||
}
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
@@ -185,9 +232,10 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 15),
|
||||
const TextField(
|
||||
TextField(
|
||||
readOnly: true,
|
||||
decoration: InputDecoration(
|
||||
controller: _addressController,
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(Icons.location_on),
|
||||
hintText: 'Dirección',
|
||||
),
|
||||
@@ -221,7 +269,7 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
? ''
|
||||
: horaSeleccionada!.format(context),
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
decoration: const InputDecoration(
|
||||
prefixIcon: Icon(Icons.watch_later_outlined),
|
||||
hintText: 'Hora',
|
||||
),
|
||||
@@ -245,7 +293,37 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: FilledButton(
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
if (serviceLocationPreference ==
|
||||
ServiceLocationPreferences.office) {
|
||||
context.read<ServiceBloc>().add(
|
||||
CreateService(
|
||||
professionalId:
|
||||
profesionalSeleccionado!.professionalInfo.id,
|
||||
userId: state.user!.id,
|
||||
address: profesionalSeleccionado!
|
||||
.professionalInfo.address,
|
||||
aditionalAddress: profesionalSeleccionado!
|
||||
.professionalInfo.address,
|
||||
latitude: profesionalSeleccionado!
|
||||
.professionalInfo.latitude,
|
||||
longitude: profesionalSeleccionado!
|
||||
.professionalInfo.longitude,
|
||||
day: fechaSeleccionada.toString(),
|
||||
createdAt: Timestamp.now(),
|
||||
description: _observationController.text,
|
||||
range1Hour1: horaSeleccionada!,
|
||||
range1Hour2: horaSeleccionada!.add(hour: 2),
|
||||
rate: '0',
|
||||
location: serviceLocationPreference!,
|
||||
),
|
||||
);
|
||||
} else if (serviceLocationPreference ==
|
||||
ServiceLocationPreferences.delivery) {
|
||||
} else {
|
||||
// TODO: error inesperado
|
||||
}
|
||||
},
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
@@ -253,34 +331,41 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
// padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(10),
|
||||
// ),
|
||||
// ),
|
||||
child: const Text(
|
||||
'Pedir cita',
|
||||
style: TextStyle(color: Colors.white, fontSize: 18),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
FilledButton(
|
||||
onPressed: () {},
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
Visibility(
|
||||
visible: isClearButtonVisible,
|
||||
child: const SizedBox(width: 10),
|
||||
),
|
||||
Visibility(
|
||||
visible: isClearButtonVisible,
|
||||
child: FilledButton(
|
||||
onPressed: () {
|
||||
fechaSeleccionada = null;
|
||||
horaSeleccionada = null;
|
||||
profesionalSeleccionado = null;
|
||||
isClearButtonVisible = false;
|
||||
_observationController.text = '';
|
||||
serviceLocationPreference = null;
|
||||
setState(() {});
|
||||
},
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
//x
|
||||
child: const Icon(
|
||||
CupertinoIcons.xmark,
|
||||
color: Colors.white,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
//x
|
||||
child: const Icon(
|
||||
CupertinoIcons.xmark,
|
||||
color: Colors.white,
|
||||
size: 30,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -302,6 +387,21 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> getLocationName(double latitude, double longitude) async {
|
||||
String address;
|
||||
List<Placemark> placemarks =
|
||||
await placemarkFromCoordinates(latitude, longitude);
|
||||
Placemark place = placemarks[0];
|
||||
|
||||
if (place.thoroughfare != '' || place.subThoroughfare != '') {
|
||||
address =
|
||||
"${place.thoroughfare} ${place.subThoroughfare} ${place.subLocality}, ${place.locality}, ${place.administrativeArea}";
|
||||
} else {
|
||||
address = '';
|
||||
}
|
||||
return address;
|
||||
}
|
||||
|
||||
Future<Position> _determinePosition() async {
|
||||
bool serviceEnabled;
|
||||
LocationPermission permission;
|
||||
|
||||
+8
-5
@@ -8,14 +8,17 @@ import 'package:professional_repository/professional_repository.dart';
|
||||
import 'package:firebase_storage/firebase_storage.dart';
|
||||
|
||||
class FirebaseProfessionalRepository {
|
||||
final professionalCollection = FirebaseFirestore.instance.collection('professional_info');
|
||||
final professionalCollection =
|
||||
FirebaseFirestore.instance.collection('professional_info');
|
||||
|
||||
ProfessionalEntity? _proInfo;
|
||||
final StreamController<ProfessionalEntity?> _proInfoBroadcast = StreamController<ProfessionalEntity?>.broadcast();
|
||||
final StreamController<ProfessionalEntity?> _proInfoBroadcast =
|
||||
StreamController<ProfessionalEntity?>.broadcast();
|
||||
|
||||
bool isProModeActive = false;
|
||||
|
||||
final StreamController<bool> _isProModeActiveBroadcast = StreamController.broadcast();
|
||||
final StreamController<bool> _isProModeActiveBroadcast =
|
||||
StreamController.broadcast();
|
||||
|
||||
FirebaseProfessionalRepository() {
|
||||
_isProModeActiveBroadcast.add(isProModeActive);
|
||||
@@ -48,7 +51,6 @@ class FirebaseProfessionalRepository {
|
||||
_proInfo = proInfo;
|
||||
_proInfoBroadcast.add(proInfo);
|
||||
} catch (e) {
|
||||
log('xd -- Error updating from firebase ${e.toString()}');
|
||||
_proInfo = null;
|
||||
_proInfoBroadcast.add(null);
|
||||
}
|
||||
@@ -177,7 +179,8 @@ class FirebaseProfessionalRepository {
|
||||
|
||||
Future<List<ProfessionalEntity>> getProfessionalInfo() async {
|
||||
try {
|
||||
QuerySnapshot<Map<String, dynamic>> querySnapshot = await professionalCollection.get();
|
||||
QuerySnapshot<Map<String, dynamic>> querySnapshot =
|
||||
await professionalCollection.get();
|
||||
return querySnapshot.docs
|
||||
.map((e) => ProfessionalEntity.fromDocument(e.data()))
|
||||
.toList();
|
||||
|
||||
@@ -19,7 +19,7 @@ class ServiceEntity extends Equatable {
|
||||
final TimeOfDay range1Hour2;
|
||||
final String rate;
|
||||
final ServiceStatus status;
|
||||
final LocationPreferences location;
|
||||
final ServiceLocationPreferences location;
|
||||
|
||||
const ServiceEntity({
|
||||
required this.professionalId,
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
export 'location_preferences.dart';
|
||||
|
||||
enum LocationPreferences { office, delivery }
|
||||
|
||||
int enumToInt(LocationPreferences state) {
|
||||
return state.index;
|
||||
}
|
||||
|
||||
LocationPreferences intToEnum(int value) {
|
||||
return LocationPreferences.values[value];
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
export 'location_preferences.dart';
|
||||
export 'service_location_preferences.dart';
|
||||
export 'service_status.dart';
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
export 'service_location_preferences.dart';
|
||||
|
||||
enum ServiceLocationPreferences { office, delivery }
|
||||
|
||||
int enumToInt(ServiceLocationPreferences state) {
|
||||
return state.index;
|
||||
}
|
||||
|
||||
ServiceLocationPreferences intToEnum(int value) {
|
||||
return ServiceLocationPreferences.values[value];
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:service_repository/service_repository.dart';
|
||||
|
||||
@@ -5,6 +7,7 @@ class FirebaseServiceRepository {
|
||||
final serviceCollection = FirebaseFirestore.instance.collection('services');
|
||||
|
||||
Future<void> createService(ServiceEntity entity) async {
|
||||
await serviceCollection.doc().set(entity.toDocument());
|
||||
log('xd -- ${entity.toString()}');
|
||||
await serviceCollection.add(entity.toDocument());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user