validaciones de inputs
This commit is contained in:
@@ -15,6 +15,7 @@ import 'package:prosappco/src/models/event_model.dart';
|
||||
import 'package:prosappco/src/models/user_model.dart';
|
||||
import 'package:prosappco/src/screens/professional.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:prosappco/src/screens/profile.dart';
|
||||
import 'package:prosappco/src/screens/service_after.dart';
|
||||
import 'package:prosappco/src/screens/service_type.dart';
|
||||
|
||||
@@ -108,6 +109,7 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
||||
final TimeOfDay? pickedTime = await showTimePicker(
|
||||
context: context,
|
||||
initialTime: TimeOfDay.now(),
|
||||
|
||||
// builder: (context, child) {
|
||||
// return Theme(data: ThemeData.dark(), child: child!);
|
||||
// },
|
||||
@@ -131,6 +133,7 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
||||
|
||||
final FirebaseStorage storage = FirebaseStorage.instance;
|
||||
final uid = AuthenticationRepository.instance.getCurrentUserUid();
|
||||
UserModel? user;
|
||||
final fcmToken = FirebaseMessaging.instance.getToken();
|
||||
|
||||
BitmapDescriptor? _markerIcon;
|
||||
@@ -150,6 +153,12 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
||||
}
|
||||
});
|
||||
|
||||
if (user == null) {
|
||||
UserModel.getUser(uid.toString()).then(
|
||||
(UserModel s) => setState(() => user = s),
|
||||
);
|
||||
}
|
||||
|
||||
BitmapDescriptor.fromAssetImage(
|
||||
const ImageConfiguration(size: Size(48, 48)),
|
||||
'images/pro_marke.png')
|
||||
@@ -566,51 +575,76 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
||||
const SizedBox(height: 20),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
final DateTime combinedDate = DateTime(
|
||||
_selectedDate!.year,
|
||||
_selectedDate!.month,
|
||||
_selectedDate!.day,
|
||||
_selectedTime!.hour,
|
||||
_selectedTime!.minute);
|
||||
if (user?.name == null ||
|
||||
user?.name == '' ||
|
||||
user?.phoneNumber == null ||
|
||||
user?.phoneNumber == '') {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return const ProfileScreen();
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
try {
|
||||
final DateTime combinedDate = DateTime(
|
||||
_selectedDate!.year,
|
||||
_selectedDate!.month,
|
||||
_selectedDate!.day,
|
||||
_selectedTime!.hour,
|
||||
_selectedTime!.minute);
|
||||
|
||||
DateTime time2 =
|
||||
combinedDate.add(const Duration(hours: 2));
|
||||
DateTime time2 = combinedDate
|
||||
.add(const Duration(hours: 2));
|
||||
|
||||
UserModel.getUser(uid.toString()).then((value) {
|
||||
eventoService
|
||||
.createEvent(
|
||||
value.name,
|
||||
_observacionController.text,
|
||||
'$_selectedDate',
|
||||
'$combinedDate',
|
||||
'$time2',
|
||||
professionalId,
|
||||
ubicacion,
|
||||
_locationController.text,
|
||||
ubicacion != 'sitio'
|
||||
? coordinates.latitude
|
||||
: professionalLatitude,
|
||||
ubicacion != 'sitio'
|
||||
? coordinates.longitude
|
||||
: professionalLongitude,
|
||||
'pendiente',
|
||||
professionalTarifa == 0
|
||||
? 0
|
||||
: professionalTarifa,
|
||||
)
|
||||
.then((value) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return ServiceAfterScreen(
|
||||
eventoId: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
UserModel.getUser(uid.toString())
|
||||
.then((value) {
|
||||
eventoService
|
||||
.createEvent(
|
||||
value.name,
|
||||
_observacionController.text,
|
||||
'$_selectedDate',
|
||||
'$combinedDate',
|
||||
'$time2',
|
||||
professionalId,
|
||||
ubicacion,
|
||||
_locationController.text,
|
||||
ubicacion != 'sitio'
|
||||
? coordinates.latitude
|
||||
: professionalLatitude,
|
||||
ubicacion != 'sitio'
|
||||
? coordinates.longitude
|
||||
: professionalLongitude,
|
||||
'pendiente',
|
||||
professionalTarifa == 0
|
||||
? 0
|
||||
: professionalTarifa,
|
||||
false,
|
||||
false,
|
||||
)
|
||||
.then((value) {
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return ServiceAfterScreen(
|
||||
eventoId: value,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
Get.snackbar(
|
||||
'Llena todos los campos',
|
||||
'Asegurate de llenar todos los campos.',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF2BA4EC),
|
||||
@@ -629,7 +663,7 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Text('${_selectedDate?.weekday}')
|
||||
Text('${_selectedDate?.weekday}'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user