formularios fondo azul

This commit is contained in:
Juan Felipe Duarte
2023-06-17 10:15:35 -05:00
parent f69201e0dd
commit d357d543d9
2 changed files with 443 additions and 444 deletions
+179 -183
View File
@@ -249,209 +249,205 @@ class _ProfileWebScreenState extends State<ProfileWebScreen> {
String city = _ciudad.toString(); String city = _ciudad.toString();
return Scaffold( return Scaffold(
backgroundColor: const Color(0xFFD6F4FF),
appBar: PopAppbar( appBar: PopAppbar(
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
}, },
label: 'Perfil'), label: 'Perfil'),
body: SingleChildScrollView( body: Center(
reverse: true, child: SizedBox(
child: Center( width: 300,
child: Column( height: 550,
children: [ child: Card(
Container( shape: RoundedRectangleBorder(
padding: const EdgeInsets.only(top: 20), borderRadius: BorderRadius.circular(10),
child: (selectedImagInBytes != null) ),
? LocalPhotoWeb(file: selectedImagInBytes) color: Colors.white,
: ReferencePhotoWeb(ref: storage.ref().child(_photo)), child: Padding(
), padding: const EdgeInsets.symmetric(horizontal: 20.0),
// Padding( child: Form(
// padding: const EdgeInsets.symmetric(vertical: 10), key: _formKey,
// child: ElevatedButton.icon( child: Column(
// onPressed: () { crossAxisAlignment: CrossAxisAlignment.center,
// _selectFile(true); mainAxisAlignment: MainAxisAlignment.center,
// }, children: [
// icon: const Icon(Icons.image), Container(
// label: const Text('Elige una imagen'), padding: const EdgeInsets.only(top: 20, bottom: 20),
// ), child: (selectedImagInBytes != null)
// ), ? LocalPhotoWeb(file: selectedImagInBytes)
Container( : ReferencePhotoWeb(ref: storage.ref().child(_photo)),
width: 300, ),
child: Form( TextFormField(
key: _formKey, controller: _nameController,
child: Column( maxLength: 50,
children: [ validator: (value) {
TextFormField( if (value == null || value.isEmpty) {
controller: _nameController, return 'Porfavor ingrese un nombre.';
maxLength: 50, }
validator: (value) { if (value.length < 5) {
if (value == null || value.isEmpty) { return 'Debe tener al menos 5 caracteres.';
return 'Porfavor ingrese un nombre.'; }
} return null;
if (value.length < 5) { },
return 'Debe tener al menos 5 caracteres.'; decoration: const InputDecoration(
} prefixIcon: Icon(Icons.person_outline),
return null; hintText: 'Nombre (Obligatorio)',
},
decoration: const InputDecoration(
prefixIcon: Icon(Icons.person_outline),
hintText: 'Nombre (Obligatorio)',
),
), ),
_email != null ),
? TextFormField( _email != null
onTap: () { ? TextFormField(
Navigator.push(context, CupertinoPageRoute( onTap: () {
builder: (BuildContext context) { Navigator.push(context, CupertinoPageRoute(
return NewPasswordScreen(); builder: (BuildContext context) {
}, return NewPasswordScreen();
)); },
}, ));
readOnly: true, },
controller: _emailController, readOnly: true,
decoration: const InputDecoration( controller: _emailController,
prefixIcon: Icon(Icons.email_outlined), decoration: const InputDecoration(
hintText: 'Email (Obligatorio)', prefixIcon: Icon(Icons.email_outlined),
), hintText: 'Email (Obligatorio)',
)
: TextFormField(
controller: _emailController,
validator: (String? value) {
if (value == null || value.isEmpty) {
return 'Por favor ingrese un email';
}
final RegExp emailRegExp =
RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
if (!emailRegExp.hasMatch(value)) {
return 'Por favor ingrese un email válido';
}
return null;
},
decoration: const InputDecoration(
prefixIcon: Icon(Icons.email_outlined),
hintText: 'Email (Obligatorio)',
),
), ),
const SizedBox(height: 20.0), )
_email != null : TextFormField(
? const SizedBox.shrink() controller: _emailController,
: TextFormField( validator: (String? value) {
controller: _passwordController, if (value == null || value.isEmpty) {
obscureText: _obscureText, return 'Por favor ingrese un email';
validator: (value) { }
if (value == null || value.isEmpty) { final RegExp emailRegExp =
return 'Porfavor ingrese una contraseña.'; RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$');
} if (!emailRegExp.hasMatch(value)) {
if (value.length < 5) { return 'Por favor ingrese un email válido';
return 'Debe tener al menos 5 caracteres.'; }
} return null;
return null; },
}, decoration: const InputDecoration(
decoration: InputDecoration( prefixIcon: Icon(Icons.email_outlined),
prefixIcon: const Icon(Icons.lock_outline), hintText: 'Email (Obligatorio)',
suffixIcon: IconButton( ),
icon: Icon( ),
_obscureText const SizedBox(height: 20.0),
? Icons.visibility _email != null
: Icons.visibility_off, ? const SizedBox.shrink()
color: Colors.grey, : TextFormField(
), controller: _passwordController,
onPressed: () { obscureText: _obscureText,
setState(() { validator: (value) {
_obscureText = !_obscureText; if (value == null || value.isEmpty) {
}); return 'Porfavor ingrese una contraseña.';
}, }
if (value.length < 5) {
return 'Debe tener al menos 5 caracteres.';
}
return null;
},
decoration: InputDecoration(
prefixIcon: const Icon(Icons.lock_outline),
suffixIcon: IconButton(
icon: Icon(
_obscureText
? Icons.visibility
: Icons.visibility_off,
color: Colors.grey,
), ),
hintText: 'Contraseña (Obligatorio)', onPressed: () {
setState(() {
_obscureText = !_obscureText;
});
},
), ),
hintText: 'Contraseña (Obligatorio)',
), ),
_email != null ),
? const SizedBox.shrink() _email != null
: const SizedBox(height: 20.0), ? const SizedBox.shrink()
TextFormField( : const SizedBox(height: 20.0),
readOnly: true, TextFormField(
onTap: () async { readOnly: true,
final String? ciudad = await Navigator.push( onTap: () async {
context, final String? ciudad = await Navigator.push(
CupertinoPageRoute( context,
builder: (BuildContext context) { CupertinoPageRoute(
return const CityScreen(); builder: (BuildContext context) {
}, return const CityScreen();
), },
) as String?; ),
) as String?;
if (ciudad != null) { if (ciudad != null) {
setState(() { setState(() {
_ciudad = ciudad; _ciudad = ciudad;
});
}
},
decoration: InputDecoration(
prefixIcon: const Icon(Icons.near_me),
suffixIcon: const Icon(Icons.arrow_drop_down),
hintStyle: city == ''
? const TextStyle()
: const TextStyle(color: Colors.black87),
hintText: city == '' ? 'Ciudad' : city,
),
),
const SizedBox(height: 20.0),
TextFormField(
controller: _phoneNumberController,
readOnly: true,
onTap: () {
Navigator.of(context).push(
CupertinoPageRoute(
builder: (BuildContext context) {
return const NewNumberScreen();
},
),
);
},
decoration: const InputDecoration(
prefixIcon: Icon(Icons.phone_android),
suffixIcon: Icon(Icons.edit_outlined),
hintText: '+57'),
),
Container(
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 50),
padding: const EdgeInsets.only(bottom: 30),
child: ElevatedButton(
onPressed: () async {
if (_formKey.currentState!.validate()) {
await updateInfo().whenComplete(() {
Get.snackbar(
'Perfil',
'Información actualizada correctamente.',
snackPosition: SnackPosition.TOP,
);
}); });
} }
}, },
decoration: InputDecoration( style: ElevatedButton.styleFrom(
prefixIcon: const Icon(Icons.near_me), backgroundColor: const Color(0xFF2BA4EC),
suffixIcon: const Icon(Icons.arrow_drop_down), shape: RoundedRectangleBorder(
hintStyle: city == '' borderRadius: BorderRadius.circular(50),
? const TextStyle()
: const TextStyle(color: Colors.black87),
hintText: city == '' ? 'Ciudad' : city,
),
),
const SizedBox(height: 20.0),
TextFormField(
controller: _phoneNumberController,
readOnly: true,
onTap: () {
Navigator.of(context).push(
CupertinoPageRoute(
builder: (BuildContext context) {
return const NewNumberScreen();
},
),
);
},
decoration: const InputDecoration(
prefixIcon: Icon(Icons.phone_android),
suffixIcon: Icon(Icons.edit_outlined),
hintText: '+57'),
),
Container(
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(top: 50),
padding: const EdgeInsets.only(bottom: 30),
child: ElevatedButton(
onPressed: () async {
if (_formKey.currentState!.validate()) {
await updateInfo().whenComplete(() {
Get.snackbar(
'Perfil',
'Información actualizada correctamente.',
snackPosition: SnackPosition.TOP,
);
});
}
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF2BA4EC),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
elevation: 0,
minimumSize: const Size(200, 50),
), ),
child: const Text( elevation: 0,
'Guardar', minimumSize: const Size(200, 50),
style: TextStyle( ),
color: Colors.white, child: const Text(
fontWeight: FontWeight.bold, 'Guardar',
fontSize: 17, style: TextStyle(
), color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 17,
), ),
), ),
), ),
], ),
), ],
), ),
), ),
], ),
), ),
), ),
), ),
+264 -261
View File
@@ -210,272 +210,275 @@ class _ServiceScreenState extends State<ServiceScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (kIsWeb) { if (kIsWeb) {
return Scaffold( return Scaffold(
backgroundColor: const Color(0xFFD6F4FF),
drawer: DrawerMenu(), drawer: DrawerMenu(),
appBar: AppBar( appBar: AppBar(
elevation: 0, elevation: 0,
title: Row( title: const Text(
children: [ 'Prosapp',
Container( style: TextStyle(
padding: const EdgeInsets.only(right: 10), color: Colors.white,
decoration: const BoxDecoration( fontSize: 20,
border: Border( ),
right: BorderSide( )),
color: Colors.white, body: Center(
width: 1.0, child: SizedBox(
width: 300,
height: 470,
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
color: Colors.white,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
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.location_on),
),
), ),
), const SizedBox(height: 20.0),
), TextFormField(
child: const Text( controller: _profesionalController,
'Prosapp', readOnly: true,
onTap: () async {
final dynamic datos = await Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return ProfessionalScreen(
profession: _serviceTypeController.text,
);
},
),
);
if (datos != null) {
Professional? profesional = datos[0];
ubicacion = datos[1];
if (profesional != null) {
setState(() {
_profesionalController.text =
profesional.name.toString();
professionalId = profesional.id;
professionalTarifa = profesional.tarifa ?? 0;
professionalUbicacion = profesional.ubicacion;
professionalAddress = _ubicationController.text;
if (ubicacion == 'sitio') {
professionalAddress = profesional.realAddress;
_ubicationController.text =
profesional.realAddress;
latUser = profesional.latitude;
lngUser = profesional.longitude;
}
});
}
}
},
decoration: const InputDecoration(
prefixIcon: Icon(Icons.assignment_ind_rounded),
suffixIcon: Icon(Icons.arrow_drop_down),
hintText: 'Seleccionar profesional'),
),
const SizedBox(height: 20.0),
TextFormField(
onTap: () {
if (_profesionalController.text.isNotEmpty) {
_selectDate(context);
} else {
final snackBar = SnackBar(
backgroundColor: Colors.blue,
content: const Text(
'Selecciona un profesional',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
elevation: 8.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
},
readOnly: true,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.calendar_month),
suffixIcon: _selectedDate == null
? const Icon(Icons.arrow_drop_down)
: null,
hintText: 'Fecha',
),
controller: TextEditingController(
text: _selectedDate == null
? ''
: formatter.format(_selectedDate!)),
),
const SizedBox(height: 20.0),
TextFormField(
onTap: () {
if (_profesionalController.text.isNotEmpty) {
_selectTime(context);
} else {
final snackBar = SnackBar(
backgroundColor: Colors.blue,
content: const Text(
'Selecciona un profesional',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
elevation: 8.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
},
readOnly: true,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.access_time),
suffixIcon: Icon(Icons.arrow_drop_down),
hintText: 'Hora',
),
controller: TextEditingController(
text: _selectedTime == null
? ''
: ' ${_selectedTime!.format(context)}'),
),
const SizedBox(height: 20.0),
TextFormField(
controller: _observacionController,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.message_outlined),
hintText: 'Observaciones'),
),
const SizedBox(height: 40.0),
ElevatedButton(
onPressed: () {
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));
UserModel.getUser(uid.toString()).then((value) {
eventoService
.createEvent(
value.name,
_observacionController.text,
'$_selectedDate',
'$combinedDate',
'$time2',
professionalId,
ubicacion,
professionalAddress,
latUser,
lngUser,
'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),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
elevation: 0,
minimumSize: const Size(230, 50),
),
child: const Text(
'Solicitar servicio',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
),
],
), ),
), ),
],
), // Texto del título
),
body: Center(
child: Container(
width: 300,
child: Column(
children: [
const SizedBox(height: 20.0),
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.location_on),
),
),
const SizedBox(height: 20.0),
TextFormField(
controller: _profesionalController,
readOnly: true,
onTap: () async {
final dynamic datos = await Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return ProfessionalScreen(
profession: _serviceTypeController.text,
);
},
),
);
if (datos != null) {
Professional? profesional = datos[0];
ubicacion = datos[1];
if (profesional != null) {
setState(() {
_profesionalController.text =
profesional.name.toString();
professionalId = profesional.id;
professionalTarifa = profesional.tarifa ?? 0;
professionalUbicacion = profesional.ubicacion;
professionalAddress = _ubicationController.text;
if (ubicacion == 'sitio') {
professionalAddress = profesional.realAddress;
_ubicationController.text = profesional.realAddress;
latUser = profesional.latitude;
lngUser = profesional.longitude;
}
});
}
}
},
decoration: const InputDecoration(
prefixIcon: Icon(Icons.assignment_ind_rounded),
suffixIcon: Icon(Icons.arrow_drop_down),
hintText: 'Seleccionar profesional'),
),
const SizedBox(height: 20.0),
TextFormField(
onTap: () {
if (_profesionalController.text.isNotEmpty) {
_selectDate(context);
} else {
final snackBar = SnackBar(
backgroundColor: Colors.blue,
content: const Text(
'Selecciona un profesional',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
elevation: 8.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
},
readOnly: true,
decoration: InputDecoration(
prefixIcon: const Icon(Icons.calendar_month),
suffixIcon: _selectedDate == null
? const Icon(Icons.arrow_drop_down)
: null,
hintText: 'Fecha',
),
controller: TextEditingController(
text: _selectedDate == null
? ''
: formatter.format(_selectedDate!)),
),
const SizedBox(height: 20.0),
TextFormField(
onTap: () {
if (_profesionalController.text.isNotEmpty) {
_selectTime(context);
} else {
final snackBar = SnackBar(
backgroundColor: Colors.blue,
content: const Text(
'Selecciona un profesional',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
elevation: 8.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
},
readOnly: true,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.access_time),
suffixIcon: Icon(Icons.arrow_drop_down),
hintText: 'Hora',
),
controller: TextEditingController(
text: _selectedTime == null
? ''
: ' ${_selectedTime!.format(context)}'),
),
const SizedBox(height: 20.0),
TextFormField(
controller: _observacionController,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.message_outlined),
hintText: 'Observaciones'),
),
const SizedBox(height: 20.0),
ElevatedButton(
onPressed: () {
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));
UserModel.getUser(uid.toString()).then((value) {
eventoService
.createEvent(
value.name,
_observacionController.text,
'$_selectedDate',
'$combinedDate',
'$time2',
professionalId,
ubicacion,
professionalAddress,
latUser,
lngUser,
'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),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
elevation: 0,
minimumSize: const Size(230, 50),
),
child: const Text(
'Solicitar servicio',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
),
],
), ),
), ),
), ),