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_bloc/professional_bloc.dart';
|
||||||
import 'package:prosappco/blocs/professional_profile_bloc/professional_profile_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/profile_bloc/profile_bloc.dart';
|
||||||
|
import 'package:prosappco/blocs/service_bloc/service_bloc.dart';
|
||||||
|
|
||||||
import 'app_view.dart';
|
import 'app_view.dart';
|
||||||
|
|
||||||
@@ -29,8 +30,12 @@ class MainApp extends StatelessWidget {
|
|||||||
create: (context) => Injector.appInstance.get<ProfessionalBloc>(),
|
create: (context) => Injector.appInstance.get<ProfessionalBloc>(),
|
||||||
),
|
),
|
||||||
BlocProvider<ProfessionalProfileBloc>(
|
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>(
|
child: BlocBuilder<MyUserBloc, MyUserState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
|||||||
@@ -12,12 +12,8 @@ class ProfessionalBloc extends Bloc<ProfessionalEvent, ProfessionalState> {
|
|||||||
final FirebaseProfessionalRepository _professionalRepository;
|
final FirebaseProfessionalRepository _professionalRepository;
|
||||||
final UserRepository _userRepository;
|
final UserRepository _userRepository;
|
||||||
|
|
||||||
ProfessionalBloc(
|
ProfessionalBloc({required FirebaseProfessionalRepository professionalRepository, required UserRepository userRepository})
|
||||||
{required FirebaseProfessionalRepository professionalRepository,
|
: _professionalRepository = professionalRepository, _userRepository = userRepository, super(ProfessionalInitial()) {
|
||||||
required UserRepository userRepository})
|
|
||||||
: _professionalRepository = professionalRepository,
|
|
||||||
_userRepository = userRepository,
|
|
||||||
super(ProfessionalInitial()) {
|
|
||||||
bool isProModeActive = _professionalRepository.isProModeActive;
|
bool isProModeActive = _professionalRepository.isProModeActive;
|
||||||
final proInfo = _professionalRepository.lastProInfo();
|
final proInfo = _professionalRepository.lastProInfo();
|
||||||
emit(LoadedModeProState(isProModeActive, proInfo));
|
emit(LoadedModeProState(isProModeActive, proInfo));
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ class ProfessionalProfileBloc
|
|||||||
event.longitude,
|
event.longitude,
|
||||||
event.schedules,
|
event.schedules,
|
||||||
event.paymentMethods,
|
event.paymentMethods,
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
emit(const UpdateProfessionalInfoSuccess());
|
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:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
@@ -11,7 +15,38 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
|||||||
|
|
||||||
ServiceBloc({required FirebaseServiceRepository serviceRepository})
|
ServiceBloc({required FirebaseServiceRepository serviceRepository})
|
||||||
: _serviceRepository = 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();
|
const ServiceEvent();
|
||||||
|
|
||||||
@override
|
@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 => [];
|
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_list_bloc/professional_list_bloc.dart';
|
||||||
import 'package:prosappco/blocs/professional_profile_bloc/professional_profile_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/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/setting_bloc/setting_bloc.dart';
|
||||||
import 'package:prosappco/blocs/sign_up_bloc/sign_up_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: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:user_repository/user_repository.dart';
|
||||||
import 'package:city_repository/city_repository.dart';
|
import 'package:city_repository/city_repository.dart';
|
||||||
import 'package:setting_repository/setting_repository.dart';
|
import 'package:setting_repository/setting_repository.dart';
|
||||||
@@ -31,9 +33,8 @@ class AppDI {
|
|||||||
injector.registerSingleton<SettingRepository>(
|
injector.registerSingleton<SettingRepository>(
|
||||||
() => FirebaseSettingRepository());
|
() => FirebaseSettingRepository());
|
||||||
|
|
||||||
injector.registerSingleton(
|
injector.registerSingleton(() => FirebaseProfessionalRepository());
|
||||||
() => FirebaseProfessionalRepository(),
|
injector.registerSingleton(() => FirebaseServiceRepository());
|
||||||
);
|
|
||||||
|
|
||||||
injector.registerSingleton<AuthenticationBloc>((() =>
|
injector.registerSingleton<AuthenticationBloc>((() =>
|
||||||
AuthenticationBloc(myUserRepository: injector.get<UserRepository>())));
|
AuthenticationBloc(myUserRepository: injector.get<UserRepository>())));
|
||||||
@@ -51,19 +52,19 @@ class AppDI {
|
|||||||
);
|
);
|
||||||
|
|
||||||
injector.registerDependency<SignInBloc>(
|
injector.registerDependency<SignInBloc>(
|
||||||
(() => SignInBloc(userRepository: injector.get<UserRepository>())));
|
() => SignInBloc(userRepository: injector.get<UserRepository>()));
|
||||||
|
|
||||||
injector.registerDependency<SignUpBloc>(
|
injector.registerDependency<SignUpBloc>(
|
||||||
(() => SignUpBloc(userRepository: injector.get<UserRepository>())));
|
() => SignUpBloc(userRepository: injector.get<UserRepository>()));
|
||||||
|
|
||||||
injector.registerDependency<SettingBloc>(
|
injector.registerDependency<SettingBloc>(
|
||||||
(() => SettingBloc(userRepository: injector.get<UserRepository>())));
|
() => SettingBloc(userRepository: injector.get<UserRepository>()));
|
||||||
|
|
||||||
injector.registerDependency<AuthBloc>(
|
injector.registerDependency<AuthBloc>(
|
||||||
(() => AuthBloc(userRepository: injector.get<UserRepository>())));
|
() => AuthBloc(userRepository: injector.get<UserRepository>()));
|
||||||
|
|
||||||
injector.registerSingleton<ProfessionalProfileBloc>((() =>
|
injector.registerSingleton<ProfessionalProfileBloc>(
|
||||||
ProfessionalProfileBloc(professionalRepository: injector.get())));
|
() => ProfessionalProfileBloc(professionalRepository: injector.get()));
|
||||||
|
|
||||||
injector.registerDependency<ProfessionalListBloc>(
|
injector.registerDependency<ProfessionalListBloc>(
|
||||||
() => ProfessionalListBloc(
|
() => ProfessionalListBloc(
|
||||||
@@ -71,5 +72,8 @@ class AppDI {
|
|||||||
firebaseProfessonalRepository:
|
firebaseProfessonalRepository:
|
||||||
injector.get<FirebaseProfessionalRepository>()),
|
injector.get<FirebaseProfessionalRepository>()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
injector.registerSingleton<ServiceBloc>(() => ServiceBloc(
|
||||||
|
serviceRepository: injector.get<FirebaseServiceRepository>()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:injector/injector.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:professional_repository/professional_repository.dart';
|
import 'package:professional_repository/professional_repository.dart';
|
||||||
import 'package:prosappco/blocs/professional_list_bloc/professional_list_bloc.dart';
|
import 'package:prosappco/blocs/professional_list_bloc/professional_list_bloc.dart';
|
||||||
import 'package:prosappco/utils/time_of_day_utils.dart';
|
import 'package:prosappco/utils/time_of_day_utils.dart';
|
||||||
import 'package:service_repository/service_repository.dart';
|
import 'package:service_repository/service_repository.dart';
|
||||||
|
import 'package:setting_repository/setting_repository.dart';
|
||||||
import 'package:table_calendar/table_calendar.dart';
|
import 'package:table_calendar/table_calendar.dart';
|
||||||
|
|
||||||
class UserCalendarScreen extends StatefulWidget {
|
class UserCalendarScreen extends StatefulWidget {
|
||||||
@@ -17,6 +19,9 @@ class UserCalendarScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class UserCalendarScreenState extends State<UserCalendarScreen> {
|
class UserCalendarScreenState extends State<UserCalendarScreen> {
|
||||||
|
final settingRepository = Injector.appInstance.get<SettingRepository>();
|
||||||
|
SettingEntity? settings;
|
||||||
|
|
||||||
DateTime today = DateTime.now();
|
DateTime today = DateTime.now();
|
||||||
DateTime now = DateTime.now();
|
DateTime now = DateTime.now();
|
||||||
late int numDay;
|
late int numDay;
|
||||||
@@ -29,6 +34,16 @@ class UserCalendarScreenState extends State<UserCalendarScreen> {
|
|||||||
|
|
||||||
today = DateTime.utc(today.year, today.month, today.day);
|
today = DateTime.utc(today.year, today.month, today.day);
|
||||||
numDay = today.weekday;
|
numDay = today.weekday;
|
||||||
|
|
||||||
|
_loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _loadSettings() {
|
||||||
|
settingRepository.getSettings().then(
|
||||||
|
(value) => setState(() {
|
||||||
|
settings = value;
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onDaySelected(DateTime day, DateTime focusedDay) {
|
void _onDaySelected(DateTime day, DateTime focusedDay) {
|
||||||
@@ -135,7 +150,12 @@ class UserCalendarScreenState extends State<UserCalendarScreen> {
|
|||||||
schedule.enabled == false ||
|
schedule.enabled == false ||
|
||||||
schedule.range1Hour1 == null ||
|
schedule.range1Hour1 == null ||
|
||||||
schedule.range2Hour2 == 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) {
|
if (schedule.continuousDay) {
|
||||||
@@ -241,7 +261,74 @@ class UserCalendarScreenState extends State<UserCalendarScreen> {
|
|||||||
),
|
),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
onTap: () {
|
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),
|
contentPadding: const EdgeInsets.all(16),
|
||||||
leading: Container(
|
leading: Container(
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:developer';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:geocoding/geocoding.dart';
|
||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
import 'package:injector/injector.dart';
|
import 'package:injector/injector.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:prosappco/blocs/my_user_bloc/my_user_bloc.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/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';
|
import 'package:setting_repository/setting_repository.dart';
|
||||||
|
|
||||||
class UserMapScreen extends StatefulWidget {
|
class UserMapScreen extends StatefulWidget {
|
||||||
@@ -24,13 +28,21 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
|||||||
Completer<GoogleMapController>();
|
Completer<GoogleMapController>();
|
||||||
LatLng? _currentP;
|
LatLng? _currentP;
|
||||||
|
|
||||||
|
final TextEditingController _addressController = TextEditingController();
|
||||||
|
final TextEditingController _observationController = TextEditingController();
|
||||||
|
|
||||||
final settingRepository = Injector.appInstance.get<SettingRepository>();
|
final settingRepository = Injector.appInstance.get<SettingRepository>();
|
||||||
SettingEntity? settings;
|
SettingEntity? settings;
|
||||||
|
|
||||||
final DateFormat formatter = DateFormat('dd/MM/yyyy');
|
final DateFormat formatter = DateFormat('dd/MM/yyyy');
|
||||||
|
|
||||||
|
LatLng coordenadas = const LatLng(7.1253900, -73.1198000);
|
||||||
DateTime? fechaSeleccionada;
|
DateTime? fechaSeleccionada;
|
||||||
TimeOfDay? horaSeleccionada;
|
TimeOfDay? horaSeleccionada;
|
||||||
|
ServiceLocationPreferences? serviceLocationPreference;
|
||||||
|
UserProfessional? profesionalSeleccionado;
|
||||||
|
|
||||||
|
bool isClearButtonVisible = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -49,105 +61,120 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<MyUserBloc, MyUserState>(
|
return BlocProvider<ServiceBloc>(
|
||||||
builder: (context, state) {
|
create: (context) => Injector.appInstance.get<ServiceBloc>(),
|
||||||
return Column(
|
child: BlocBuilder<MyUserBloc, MyUserState>(
|
||||||
children: [
|
builder: (context, state) {
|
||||||
Expanded(
|
return Column(
|
||||||
child: Stack(
|
children: [
|
||||||
children: [
|
Expanded(
|
||||||
GoogleMap(
|
child: Stack(
|
||||||
myLocationEnabled: true,
|
children: [
|
||||||
onMapCreated: (GoogleMapController controller) {
|
GoogleMap(
|
||||||
_mapController.complete(controller);
|
myLocationEnabled: true,
|
||||||
},
|
// polylines: Set<Polyline>.of(polylines.values),
|
||||||
initialCameraPosition: const CameraPosition(
|
onMapCreated: (GoogleMapController controller) {
|
||||||
target: LatLng(
|
_mapController.complete(controller);
|
||||||
// 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();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
onCameraIdle: () {
|
||||||
),
|
getLocationName(
|
||||||
const Positioned(
|
coordenadas.latitude, coordenadas.longitude)
|
||||||
bottom: 30,
|
.then((value) => setState(() {
|
||||||
right: 0,
|
_addressController.text = value;
|
||||||
left: 0,
|
}));
|
||||||
top: 0,
|
},
|
||||||
child: Icon(
|
onCameraMove: (position) {
|
||||||
Icons.location_on,
|
if (serviceLocationPreference !=
|
||||||
size: 40,
|
ServiceLocationPreferences.office) {
|
||||||
color: Color(0xFFFF0000),
|
coordenadas = position.target;
|
||||||
),
|
|
||||||
),
|
|
||||||
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,
|
initialCameraPosition: const CameraPosition(
|
||||||
child: const Icon(
|
target: LatLng(7.1253900, -73.1198000),
|
||||||
Icons.gps_fixed,
|
zoom: 16,
|
||||||
size: 30,
|
),
|
||||||
|
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
BlocListener<ServiceBloc, ServiceState>(
|
||||||
buildBottom(context, state),
|
listener: (context, state) {},
|
||||||
],
|
child: buildBottom(context, state),
|
||||||
);
|
),
|
||||||
},
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +186,11 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
TextField(
|
TextField(
|
||||||
|
controller: TextEditingController(
|
||||||
|
text: profesionalSeleccionado == null
|
||||||
|
? ''
|
||||||
|
: '${profesionalSeleccionado?.myUser.name ?? ''} - ${profesionalSeleccionado?.professionalInfo.profession ?? ''}',
|
||||||
|
),
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
var datos = await Navigator.push(context,
|
var datos = await Navigator.push(context,
|
||||||
@@ -166,16 +198,31 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
|||||||
return const ProfessionalListScreen();
|
return const ProfessionalListScreen();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
log('xd -- datos $datos');
|
|
||||||
|
|
||||||
if (datos != null) {
|
if (datos != null) {
|
||||||
fechaSeleccionada = datos[0];
|
fechaSeleccionada = datos[0];
|
||||||
horaSeleccionada = datos[1];
|
horaSeleccionada = datos[1];
|
||||||
|
serviceLocationPreference = datos[2];
|
||||||
log('xd -- $fechaSeleccionada');
|
profesionalSeleccionado = datos[3];
|
||||||
log('xd -- $horaSeleccionada');
|
|
||||||
|
|
||||||
setState(() {});
|
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(
|
decoration: const InputDecoration(
|
||||||
@@ -185,9 +232,10 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 15),
|
const SizedBox(height: 15),
|
||||||
const TextField(
|
TextField(
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
decoration: InputDecoration(
|
controller: _addressController,
|
||||||
|
decoration: const InputDecoration(
|
||||||
prefixIcon: Icon(Icons.location_on),
|
prefixIcon: Icon(Icons.location_on),
|
||||||
hintText: 'Dirección',
|
hintText: 'Dirección',
|
||||||
),
|
),
|
||||||
@@ -221,7 +269,7 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
|||||||
? ''
|
? ''
|
||||||
: horaSeleccionada!.format(context),
|
: horaSeleccionada!.format(context),
|
||||||
),
|
),
|
||||||
decoration: InputDecoration(
|
decoration: const InputDecoration(
|
||||||
prefixIcon: Icon(Icons.watch_later_outlined),
|
prefixIcon: Icon(Icons.watch_later_outlined),
|
||||||
hintText: 'Hora',
|
hintText: 'Hora',
|
||||||
),
|
),
|
||||||
@@ -245,7 +293,37 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: FilledButton(
|
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(
|
style: FilledButton.styleFrom(
|
||||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||||
@@ -253,34 +331,41 @@ class _UserMapScreenState extends State<UserMapScreen> {
|
|||||||
borderRadius: BorderRadius.circular(10),
|
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(
|
child: const Text(
|
||||||
'Pedir cita',
|
'Pedir cita',
|
||||||
style: TextStyle(color: Colors.white, fontSize: 18),
|
style: TextStyle(color: Colors.white, fontSize: 18),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
Visibility(
|
||||||
FilledButton(
|
visible: isClearButtonVisible,
|
||||||
onPressed: () {},
|
child: const SizedBox(width: 10),
|
||||||
style: FilledButton.styleFrom(
|
),
|
||||||
backgroundColor: Colors.red,
|
Visibility(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
visible: isClearButtonVisible,
|
||||||
shape: RoundedRectangleBorder(
|
child: FilledButton(
|
||||||
borderRadius: BorderRadius.circular(10),
|
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 {
|
Future<Position> _determinePosition() async {
|
||||||
bool serviceEnabled;
|
bool serviceEnabled;
|
||||||
LocationPermission permission;
|
LocationPermission permission;
|
||||||
|
|||||||
+8
-5
@@ -8,14 +8,17 @@ import 'package:professional_repository/professional_repository.dart';
|
|||||||
import 'package:firebase_storage/firebase_storage.dart';
|
import 'package:firebase_storage/firebase_storage.dart';
|
||||||
|
|
||||||
class FirebaseProfessionalRepository {
|
class FirebaseProfessionalRepository {
|
||||||
final professionalCollection = FirebaseFirestore.instance.collection('professional_info');
|
final professionalCollection =
|
||||||
|
FirebaseFirestore.instance.collection('professional_info');
|
||||||
|
|
||||||
ProfessionalEntity? _proInfo;
|
ProfessionalEntity? _proInfo;
|
||||||
final StreamController<ProfessionalEntity?> _proInfoBroadcast = StreamController<ProfessionalEntity?>.broadcast();
|
final StreamController<ProfessionalEntity?> _proInfoBroadcast =
|
||||||
|
StreamController<ProfessionalEntity?>.broadcast();
|
||||||
|
|
||||||
bool isProModeActive = false;
|
bool isProModeActive = false;
|
||||||
|
|
||||||
final StreamController<bool> _isProModeActiveBroadcast = StreamController.broadcast();
|
final StreamController<bool> _isProModeActiveBroadcast =
|
||||||
|
StreamController.broadcast();
|
||||||
|
|
||||||
FirebaseProfessionalRepository() {
|
FirebaseProfessionalRepository() {
|
||||||
_isProModeActiveBroadcast.add(isProModeActive);
|
_isProModeActiveBroadcast.add(isProModeActive);
|
||||||
@@ -48,7 +51,6 @@ class FirebaseProfessionalRepository {
|
|||||||
_proInfo = proInfo;
|
_proInfo = proInfo;
|
||||||
_proInfoBroadcast.add(proInfo);
|
_proInfoBroadcast.add(proInfo);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log('xd -- Error updating from firebase ${e.toString()}');
|
|
||||||
_proInfo = null;
|
_proInfo = null;
|
||||||
_proInfoBroadcast.add(null);
|
_proInfoBroadcast.add(null);
|
||||||
}
|
}
|
||||||
@@ -177,7 +179,8 @@ class FirebaseProfessionalRepository {
|
|||||||
|
|
||||||
Future<List<ProfessionalEntity>> getProfessionalInfo() async {
|
Future<List<ProfessionalEntity>> getProfessionalInfo() async {
|
||||||
try {
|
try {
|
||||||
QuerySnapshot<Map<String, dynamic>> querySnapshot = await professionalCollection.get();
|
QuerySnapshot<Map<String, dynamic>> querySnapshot =
|
||||||
|
await professionalCollection.get();
|
||||||
return querySnapshot.docs
|
return querySnapshot.docs
|
||||||
.map((e) => ProfessionalEntity.fromDocument(e.data()))
|
.map((e) => ProfessionalEntity.fromDocument(e.data()))
|
||||||
.toList();
|
.toList();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class ServiceEntity extends Equatable {
|
|||||||
final TimeOfDay range1Hour2;
|
final TimeOfDay range1Hour2;
|
||||||
final String rate;
|
final String rate;
|
||||||
final ServiceStatus status;
|
final ServiceStatus status;
|
||||||
final LocationPreferences location;
|
final ServiceLocationPreferences location;
|
||||||
|
|
||||||
const ServiceEntity({
|
const ServiceEntity({
|
||||||
required this.professionalId,
|
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';
|
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:cloud_firestore/cloud_firestore.dart';
|
||||||
import 'package:service_repository/service_repository.dart';
|
import 'package:service_repository/service_repository.dart';
|
||||||
|
|
||||||
@@ -5,6 +7,7 @@ class FirebaseServiceRepository {
|
|||||||
final serviceCollection = FirebaseFirestore.instance.collection('services');
|
final serviceCollection = FirebaseFirestore.instance.collection('services');
|
||||||
|
|
||||||
Future<void> createService(ServiceEntity entity) async {
|
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