direccion para mobile
This commit is contained in:
@@ -22,6 +22,7 @@ import 'package:prosappco/src/screens/service_after.dart';
|
||||
import 'package:prosappco/src/screens/service_type.dart';
|
||||
import 'package:prosappco/src/screens/ubicacion.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:prosappco/src/components/network_utility.dart';
|
||||
|
||||
class ServiceScreen extends StatefulWidget {
|
||||
const ServiceScreen({super.key});
|
||||
@@ -99,6 +100,9 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
||||
String _professional = '';
|
||||
final DateFormat formatter = DateFormat('dd/MM/yyyy');
|
||||
final DateTime now = DateTime.now();
|
||||
List<dynamic> _placesList = [];
|
||||
String selectedPlace = '';
|
||||
String _coordsOfCity = '0.0,0.0';
|
||||
|
||||
DateTime? _selectedDate;
|
||||
TimeOfDay? _selectedTime;
|
||||
@@ -218,6 +222,14 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
if (_coordsOfCity == '0.0,0.0') {
|
||||
AuthenticationRepository.instance
|
||||
.getCoordsOfCity(uid.toString())
|
||||
.then((String s) => setState(() {
|
||||
_coordsOfCity = s;
|
||||
}));
|
||||
}
|
||||
|
||||
_saveToken();
|
||||
|
||||
if (user == null) {
|
||||
@@ -281,6 +293,21 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
||||
return address;
|
||||
}
|
||||
|
||||
void placeAutoComplete(String query) async {
|
||||
Uri uri = Uri.https("admin.prosapp.co", "/autocomplete", {
|
||||
"input": query,
|
||||
"location": _coordsOfCity,
|
||||
});
|
||||
|
||||
String? response = await NetworkUtility.fetchUrl(uri);
|
||||
|
||||
if (response != null) {
|
||||
setState(() {
|
||||
_placesList = jsonDecode(response.toString())['results'];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (kIsWeb) {
|
||||
@@ -833,7 +860,50 @@ class _ServiceScreenState extends State<ServiceScreen> {
|
||||
prefixIcon: Icon(Icons.near_me),
|
||||
hintText: 'Dirección',
|
||||
),
|
||||
onChanged: (value) {
|
||||
String modifiedValue =
|
||||
value.replaceAll(' ', '_');
|
||||
placeAutoComplete(modifiedValue);
|
||||
},
|
||||
),
|
||||
Container(
|
||||
height: _placesList.isNotEmpty
|
||||
? 200
|
||||
: 0, // Ajusta la altura según tus necesidades
|
||||
child: ListView.builder(
|
||||
itemCount: _placesList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return ListTile(
|
||||
onTap: () {
|
||||
final selectedAddress = _placesList[index]
|
||||
['formatted_address'];
|
||||
final selectedLatitude =
|
||||
_placesList[index]['geometry']
|
||||
['location']['lat'];
|
||||
final selectedLongitude =
|
||||
_placesList[index]['geometry']
|
||||
['location']['lng'];
|
||||
|
||||
_locationController.text =
|
||||
selectedAddress;
|
||||
|
||||
final newCoordinates = LatLng(
|
||||
selectedLatitude, selectedLongitude);
|
||||
googleMapController?.animateCamera(
|
||||
CameraUpdate.newLatLng(newCoordinates),
|
||||
);
|
||||
|
||||
setState(() {
|
||||
_placesList = [];
|
||||
});
|
||||
},
|
||||
title: Text(_placesList[index]
|
||||
['formatted_address']),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 15),
|
||||
Row(
|
||||
children: [
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ dependencies:
|
||||
firebase_auth: ^4.6.2
|
||||
firebase_core: ^2.13.1
|
||||
file_picker: ^5.3.2
|
||||
google_sign_in:
|
||||
google_sign_in: ^6.1.4
|
||||
provider:
|
||||
get:
|
||||
font_awesome_flutter: ^10.4.0
|
||||
@@ -54,6 +54,7 @@ dependencies:
|
||||
table_calendar:
|
||||
intl:
|
||||
google_maps_flutter: ^2.2.5
|
||||
http: ^0.13.5
|
||||
geolocator: ^9.0.2
|
||||
geocoding: ^2.1.0
|
||||
url_launcher: ^6.1.10
|
||||
@@ -63,7 +64,6 @@ dependencies:
|
||||
firebase_storage: ^11.2.2
|
||||
responsive_builder: ^0.7.0
|
||||
flutter_local_notifications: ^14.1.1
|
||||
http: ^0.13.5
|
||||
flutter_dialogs: ^3.0.0
|
||||
universal_html: ^2.2.3
|
||||
firebase_messaging: ^14.6.3
|
||||
|
||||
Reference in New Issue
Block a user