form pro - sin imagenes

This commit is contained in:
Felipe
2024-03-14 22:07:46 -05:00
parent 66125235dd
commit a3c50cf2c8
123 changed files with 2077 additions and 18345 deletions
@@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
class ProfessionalDeniedScreen extends StatelessWidget {
const ProfessionalDeniedScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Perfil profesional')),
body: const Center(child: Text('Cuenta denegada')),
);
}
}
@@ -0,0 +1,337 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:injector/injector.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:image_picker/image_picker.dart';
import 'package:prosappco/blocs/auth_bloc/auth_bloc.dart';
import 'package:prosappco/blocs/my_user_bloc/my_user_bloc.dart';
import 'package:prosappco/blocs/professional_bloc/professional_bloc.dart';
import 'package:prosappco/screens/profession/profession_screen.dart';
class ProfessionalFormScreen extends StatefulWidget {
const ProfessionalFormScreen({super.key});
@override
State<ProfessionalFormScreen> createState() => _ProfessionalFormScreenState();
}
class _ProfessionalFormScreenState extends State<ProfessionalFormScreen> {
final TextEditingController _cedulaController = TextEditingController();
final TextEditingController _professionController = TextEditingController();
final TextEditingController _controller = TextEditingController();
final List<String> _items = [];
XFile? _imageFile;
late final AuthBloc authBloc;
@override
void initState() {
super.initState();
authBloc = Injector.appInstance.get<AuthBloc>();
}
@override
void dispose() {
_cedulaController.dispose();
_professionController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return BlocProvider<AuthBloc>(
create: (context) => authBloc,
child: Scaffold(
appBar: AppBar(
title: const Text('Perfil profesional'),
),
body: BlocBuilder<MyUserBloc, MyUserState>(
builder: (context, state) {
return SingleChildScrollView(
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 40, vertical: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
pictureWidget(state, context),
const SizedBox(height: 30),
TextFormField(
controller: _cedulaController,
decoration: const InputDecoration(
labelText: 'Cedula',
prefixIcon: Icon(Icons.assignment_ind),
hintText: 'Ingresa tu cedula',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10.0),
)),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.red),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.red, width: 2.0),
),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Por favor, ingrese su nombre';
}
return null;
},
),
const SizedBox(height: 20.0),
TextFormField(
controller: _professionController,
readOnly: true,
onTap: () async {
final professionName = await Navigator.push(
context,
CupertinoPageRoute(
builder: (BuildContext context) {
return const ProfessionScreen();
},
),
);
if (professionName != null) {
_professionController.text = professionName;
}
},
decoration: const InputDecoration(
labelText: 'Profesión',
prefixIcon: Icon(Icons.work_rounded),
hintText: 'Elige tu profesión',
border: OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10.0),
)),
errorBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.red),
),
focusedErrorBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.red, width: 2.0),
),
),
validator: (value) {
if (value == null || value.isEmpty) {
return 'Por favor, ingrese su nombre';
}
return null;
},
),
const SizedBox(height: 20.0),
TextField(
controller: _controller,
onSubmitted: (value) {
_addItemToList();
},
decoration: InputDecoration(
labelText: 'Especializaciones',
prefixIcon: const Icon(Icons.assignment_rounded),
suffixIcon: IconButton(
onPressed: () {
_addItemToList();
},
icon: const Icon(Icons.add)),
hintText: 'Ingresa tus especializaciones',
border: const OutlineInputBorder(
borderRadius: BorderRadius.all(
Radius.circular(10.0),
)),
errorBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Colors.red),
),
focusedErrorBorder: const OutlineInputBorder(
borderSide: BorderSide(color: Colors.red, width: 2.0),
),
),
),
const SizedBox(height: 10.0),
Wrap(
spacing: 8.0,
runSpacing: 4.0,
children: _items
.map((item) => Chip(
label: Text(item),
backgroundColor: Theme.of(context).primaryColor,
labelStyle:
const TextStyle(color: Colors.white),
deleteIconColor: Colors.white,
onDeleted: () {
_removeItemFromList(item);
},
))
.toList(),
),
const SizedBox(height: 60.0),
saveButton(state, context),
],
),
),
);
},
),
),
);
}
void _addItemToList() {
setState(() {
String newItem = _controller.text.trim();
if (newItem.isNotEmpty) {
_items.add(newItem);
_controller.clear();
}
});
}
void _removeItemFromList(String item) {
setState(() {
_items.remove(item);
});
}
Widget saveButton(MyUserState state, BuildContext context) {
return ElevatedButton(
onPressed: () {
final userId = context.read<MyUserBloc>().state.user!.id;
context.read<ProfessionalBloc>().add(SendProfessionalToReviewEvent(
id: userId,
identification: _cedulaController.text,
identificationPicture: _cedulaController.text,
profession: _professionController.text,
certificatePicture: _professionController.text,
specializations: _items,
specializationsPictures: _items,
));
// if (isLoading) {
// return;
// }
// if (_nameController.text.isEmpty) {
// ScaffoldMessenger.of(context).clearSnackBars();
// ScaffoldMessenger.of(context).showSnackBar(
// const SnackBar(content: Text('Por favor, ingrese su nombre')));
// return;
// }
// if (_cityController.text.isEmpty) {
// ScaffoldMessenger.of(context).clearSnackBars();
// ScaffoldMessenger.of(context).showSnackBar(
// const SnackBar(content: Text('Por favor, ingrese su ciudad')));
// }
// final myUser = state.user!.copyWith(
// name: _nameController.text,
// city: _cityController.text,
// nickname: _nameController.text.trim().toLowerCase(),
// email: _emailController.text,
// phone: _phoneController.text,
// birthday: _birthdayController.text,
// gender: _genderController.text,
// );
// context
// .read<ProfileBloc>()
// .add(UpdateUserInfo(myUser: myUser, filePicture: _imageFile?.path));
ScaffoldMessenger.of(context).clearSnackBars();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Información actualizada...')),
);
Navigator.pop(context);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
padding: const EdgeInsets.symmetric(vertical: 5),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
shadowColor: Colors.grey,
// elevation: 0,
),
child: Container(
constraints: const BoxConstraints(maxWidth: 300.0, minHeight: 50.0),
alignment: Alignment.center,
child: const Text(
'Actualizar',
style: TextStyle(
color: Colors.white,
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
),
);
}
Widget pictureWidget(MyUserState state, BuildContext context) {
final pictureUrl = state.user?.picture;
final pathImageFile = _imageFile?.path;
ImageProvider<Object>? imageProvider;
if (pathImageFile != null && pathImageFile.isNotEmpty) {
imageProvider = FileImage(File(pathImageFile));
} else if (pictureUrl != null && pictureUrl.isNotEmpty) {
imageProvider = NetworkImage(pictureUrl);
}
return GestureDetector(
onTap: () async {
final ImagePicker picker = ImagePicker();
final XFile? image = await picker.pickImage(
source: ImageSource.gallery,
maxHeight: 500,
maxWidth: 500,
imageQuality: 40,
);
if (image != null) {
setState(() {
_imageFile = image;
});
}
},
child: Hero(
tag: 'picture-profile',
child: pictureContainerWidget(imageProvider),
),
);
}
Widget pictureContainerWidget(ImageProvider<Object>? imageProvider) {
final image = imageProvider == null
? null
: DecorationImage(
image: imageProvider,
fit: BoxFit.contain,
);
final widget = image == null
? Icon(
CupertinoIcons.person,
color: Colors.grey.shade400,
size: 40,
)
: null;
return Container(
width: 120,
height: 120,
decoration: BoxDecoration(
color: Colors.grey.shade300,
shape: BoxShape.circle,
image: image,
),
child: widget,
);
}
}
@@ -0,0 +1,81 @@
import 'package:flutter/material.dart';
class ProfessionalPendingScreen extends StatelessWidget {
const ProfessionalPendingScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Perfil profesional')),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.only(top: 40),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.access_time,
color: Color(0xFF2BA4EC),
),
SizedBox(width: 8),
Text(
'Información en revisión',
style: TextStyle(
color: Color(0xFF2BA4EC),
fontSize: 17,
fontWeight: FontWeight.w500,
),
),
],
),
Image(
image: const AssetImage('images/checklist.gif'),
width: MediaQuery.of(context).size.width * 0.7,
),
Container(
margin: const EdgeInsets.only(left: 40, right: 40, top: 20),
decoration: BoxDecoration(
color: const Color(0xFFD6F4FF),
borderRadius: BorderRadius.circular(30),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3),
),
],
),
padding:
const EdgeInsets.symmetric(vertical: 15, horizontal: 25),
child: Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.8,
child: const Column(
children: [
Text(
'Gracias por proporcionar tu información. Actualmente, estamos revisando tus datos y una vez aprobados, podrás acceder al perfil profesional sin problemas. Te notificaremos tan pronto como tu cuenta esté lista.',
style: TextStyle(fontSize: 14),
),
SizedBox(height: 10),
Text(
'¡Gracias por tu paciencia!',
style: TextStyle(fontSize: 14),
),
],
),
),
],
),
),
],
),
),
),
);
}
}