update faltan los ifs
This commit is contained in:
@@ -13,6 +13,7 @@ import 'package:prosappco/components/general_drawer_header.dart';
|
||||
import 'package:prosappco/components/general_drawer_item.dart';
|
||||
import 'package:prosappco/screens/configuration/configuration_screen.dart';
|
||||
import 'package:prosappco/screens/configuration/configuration_support_screen.dart';
|
||||
import 'package:prosappco/screens/lists/dropwdon.dart';
|
||||
import 'package:prosappco/screens/lists/professional_score_list_screen.dart';
|
||||
import 'package:prosappco/screens/lists/professional_service_history_list_screen.dart';
|
||||
import 'package:prosappco/screens/lists/professional_service_list_screen.dart';
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:injector/injector.dart';
|
||||
import 'package:profession_repository/profession_repository.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
class DropdownListScreen extends StatefulWidget {
|
||||
const DropdownListScreen({super.key});
|
||||
|
||||
@override
|
||||
State<DropdownListScreen> createState() => _DropdownListScreenState();
|
||||
}
|
||||
|
||||
class _DropdownListScreenState extends State<DropdownListScreen> {
|
||||
final professionRepository = Injector.appInstance.get<ProfessionRepository>();
|
||||
List<String>? _professions;
|
||||
List<String>? _filteredProfessions;
|
||||
String? _selectedProfession;
|
||||
bool _isLoading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadProfessions();
|
||||
}
|
||||
|
||||
void _loadProfessions() {
|
||||
professionRepository.getProfessions().then((Professions element) {
|
||||
setState(() {
|
||||
_professions = element.professions;
|
||||
_filteredProfessions = _professions;
|
||||
_isLoading = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Profesiones'),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_isLoading
|
||||
? _buildShimmerEffect()
|
||||
: Expanded(
|
||||
child: _filteredProfessions != null &&
|
||||
_filteredProfessions!.isNotEmpty
|
||||
? DropdownButton<String>(
|
||||
isExpanded: true,
|
||||
value: _selectedProfession,
|
||||
hint: const Text('Seleccione una profesión'),
|
||||
items: _filteredProfessions!.map((String profession) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: profession,
|
||||
child: Text(profession),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (String? newValue) {
|
||||
setState(() {
|
||||
_selectedProfession = newValue;
|
||||
});
|
||||
},
|
||||
)
|
||||
: const Center(
|
||||
child: Text('No se encontraron coincidencias'),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildShimmerEffect() {
|
||||
return Expanded(
|
||||
child: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: ListView.builder(
|
||||
itemCount: 8,
|
||||
itemBuilder: (_, __) => const ListTileShimmer(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ListTileShimmer extends StatelessWidget {
|
||||
const ListTileShimmer({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey.withOpacity(0.4)),
|
||||
),
|
||||
),
|
||||
child: ListTile(
|
||||
title: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.8,
|
||||
height: 20.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
subtitle: Row(
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.3,
|
||||
height: 15.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.3,
|
||||
height: 15.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:injector/injector.dart';
|
||||
import 'package:intl_phone_field/helpers.dart';
|
||||
import 'package:profession_repository/profession_repository.dart';
|
||||
import 'package:professional_repository/professional_repository.dart';
|
||||
import 'package:prosappco/blocs/professional_list_bloc/professional_list_bloc.dart';
|
||||
import 'package:prosappco/screens/lists/city_list_screen.dart';
|
||||
import 'package:prosappco/screens/user/user_calendar_screen.dart';
|
||||
import 'package:prosappco/screens/user/user_view_profile_screen.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
@@ -19,6 +21,13 @@ class ProfessionalListScreen extends StatefulWidget {
|
||||
|
||||
class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
|
||||
final _searchController = TextEditingController();
|
||||
final professionRepository = Injector.appInstance.get<ProfessionRepository>();
|
||||
List<String>? _professions;
|
||||
List<String>? _filteredProfessions;
|
||||
String? _selectedProfession;
|
||||
|
||||
bool _isLoading = true;
|
||||
|
||||
late final ProfessionalListBloc bloc;
|
||||
|
||||
@override
|
||||
@@ -26,6 +35,18 @@ class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
|
||||
super.initState();
|
||||
bloc = Injector.appInstance.get<ProfessionalListBloc>();
|
||||
bloc.add(const ProfessionalListFetch());
|
||||
|
||||
_loadProfessions();
|
||||
}
|
||||
|
||||
void _loadProfessions() {
|
||||
professionRepository.getProfessions().then((Professions element) {
|
||||
setState(() {
|
||||
_professions = element.professions;
|
||||
_filteredProfessions = _professions;
|
||||
_isLoading = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -36,10 +57,59 @@ class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
|
||||
builder: (context, state) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Selecciona un profesional'),
|
||||
actions: [
|
||||
_selectedProfession != null
|
||||
? IconButton(
|
||||
icon: const Icon(
|
||||
Icons.clear,
|
||||
color: Colors.red,
|
||||
size: 32,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_selectedProfession = null;
|
||||
});
|
||||
},
|
||||
)
|
||||
: Container()
|
||||
],
|
||||
title: _selectedProfession != null
|
||||
? Text(_selectedProfession!)
|
||||
: const Text('Selecciona un profesional'),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
_isLoading
|
||||
? _buildShimmerEffect()
|
||||
: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: Colors.grey[400]!,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: DropdownButtonHideUnderline(
|
||||
child: DropdownButton<String>(
|
||||
isExpanded: true,
|
||||
value: _selectedProfession,
|
||||
hint: const Text('Seleccione una profesión'),
|
||||
items:
|
||||
_filteredProfessions?.map((String profession) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: profession,
|
||||
child: Text(profession),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (String? newValue) {
|
||||
setState(() {
|
||||
_selectedProfession = newValue;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
TextField(
|
||||
controller: _searchController,
|
||||
onChanged: (value) {
|
||||
@@ -267,4 +337,17 @@ class _ProfessionalListScreenState extends State<ProfessionalListScreen> {
|
||||
|
||||
return 'Disponibilidad: domicilio, en sitio.';
|
||||
}
|
||||
|
||||
Widget _buildShimmerEffect() {
|
||||
return Expanded(
|
||||
child: Shimmer.fromColors(
|
||||
baseColor: Colors.grey[300]!,
|
||||
highlightColor: Colors.grey[100]!,
|
||||
child: ListView.builder(
|
||||
itemCount: 8,
|
||||
itemBuilder: (_, __) => const ListTileShimmer(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import 'dart:developer';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -9,10 +7,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:injector/injector.dart';
|
||||
import 'package:professional_repository/professional_repository.dart';
|
||||
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/components/general_primary_button.dart';
|
||||
import 'package:prosappco/screens/professional/professional_map_screen.dart';
|
||||
import 'package:prosappco/screens/professional/professional_schedule_screen.dart';
|
||||
import 'package:setting_repository/setting_repository.dart';
|
||||
@@ -484,41 +480,67 @@ class _ProfessionalProfileScreenState extends State<ProfessionalProfileScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(height: 0),
|
||||
const SizedBox(height: 20),
|
||||
GeneralPrimaryButton(
|
||||
onPressed: () {
|
||||
context.read<ProfessionalProfileBloc>().add(
|
||||
UpdateProfessionalProfileInfo(
|
||||
address: _addressController.text,
|
||||
aditionalAddress: _aditionalAddressController.text,
|
||||
latitude: _latitudeController,
|
||||
longitude: _longitudeController,
|
||||
locationPreferences: officeValue && deliveryValue
|
||||
? LocationPreferences.both
|
||||
: officeValue && !deliveryValue
|
||||
? LocationPreferences.office
|
||||
: deliveryValue && !officeValue
|
||||
? LocationPreferences.delivery
|
||||
: LocationPreferences.office,
|
||||
paymentMethods: PaymentMethodEntity(
|
||||
datafono: isDatafonoActive,
|
||||
nequi: isNequiActive,
|
||||
transferencia: isTransferActive,
|
||||
const Divider(
|
||||
height: 1,
|
||||
thickness: 0.5,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 10,
|
||||
horizontal: 15,
|
||||
),
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
context.read<ProfessionalProfileBloc>().add(
|
||||
UpdateProfessionalProfileInfo(
|
||||
address: _addressController.text,
|
||||
aditionalAddress: _aditionalAddressController.text,
|
||||
latitude: _latitudeController,
|
||||
longitude: _longitudeController,
|
||||
locationPreferences: officeValue && deliveryValue
|
||||
? LocationPreferences.both
|
||||
: officeValue && !deliveryValue
|
||||
? LocationPreferences.office
|
||||
: deliveryValue && !officeValue
|
||||
? LocationPreferences.delivery
|
||||
: LocationPreferences.office,
|
||||
paymentMethods: PaymentMethodEntity(
|
||||
datafono: isDatafonoActive,
|
||||
nequi: isNequiActive,
|
||||
transferencia: isTransferActive,
|
||||
),
|
||||
schedules: schedules,
|
||||
rate: _rateController.text,
|
||||
),
|
||||
schedules: schedules,
|
||||
rate: _rateController.text,
|
||||
),
|
||||
);
|
||||
context.read<ProfessionalProfileBloc>().add(
|
||||
UpdateProfessionalBannerInfo(fileBanner: _imageFile?.path),
|
||||
);
|
||||
);
|
||||
context.read<ProfessionalProfileBloc>().add(
|
||||
UpdateProfessionalBannerInfo(fileBanner: _imageFile?.path),
|
||||
);
|
||||
|
||||
log('xd -- si pasa');
|
||||
},
|
||||
label: 'Guardar',
|
||||
ScaffoldMessenger.of(context).clearSnackBars();
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||
content: Text('Información actualizada correctamente'),
|
||||
));
|
||||
},
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
'Guardar',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
+2
@@ -105,6 +105,8 @@ class FirebaseProfessionalRepository {
|
||||
'schedules': schedules.toJson(),
|
||||
'payment_methods': paymentMethods.toDocument(),
|
||||
});
|
||||
|
||||
await updateFromFirebase(userId: _proInfo!.id);
|
||||
}
|
||||
|
||||
Future<void> saveProfessionalInfo(ProfessionalEntity entity) async {
|
||||
|
||||
@@ -407,7 +407,8 @@ class FirebaseUserRepository implements UserRepository {
|
||||
@override
|
||||
Future<List<MyUser>> getUsersFromIds(Iterable<String> ids) async {
|
||||
try {
|
||||
final querySnapshot = await usersCollection.where(FieldPath.documentId, whereIn: ids).get();
|
||||
final querySnapshot =
|
||||
await usersCollection.where(FieldPath.documentId, whereIn: ids).get();
|
||||
|
||||
return querySnapshot.docs
|
||||
.map((e) => MyUser.fromEntity(MyUserEntity.fromDocument(e.data())))
|
||||
|
||||
Reference in New Issue
Block a user