148 lines
6.5 KiB
Dart
148 lines
6.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:ride/constant/table_names.dart';
|
|
|
|
import '../../../constant/colors.dart';
|
|
import '../../../constant/style.dart';
|
|
import '../../../controller/home/map_page_controller.dart';
|
|
import '../../../main.dart';
|
|
import '../../../models/db_sql.dart';
|
|
|
|
GetBuilder<MapController> formSearchPlaces() {
|
|
// DbSql sql = DbSql.instance;
|
|
return GetBuilder<MapController>(
|
|
builder: (controller) => Positioned(
|
|
top: 5,
|
|
// width: Get.width * .8,
|
|
left: 50,
|
|
right: 0,
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
height: controller.places.isNotEmpty ? controller.height : 0,
|
|
color: AppColor.secondaryColor,
|
|
child: ListView.builder(
|
|
itemCount: controller.places.length,
|
|
itemBuilder: (BuildContext context, int index) {
|
|
var res = controller.places[index];
|
|
return InkWell(
|
|
onTap: () {
|
|
controller.changeHeight();
|
|
Get.defaultDialog(
|
|
title: 'Are You sure to ride to ${res['name']}',
|
|
middleText: '',
|
|
onConfirm: () {
|
|
controller.clearpolyline();
|
|
controller.getMap(
|
|
'${controller.mylocation.latitude.toString()},${controller.mylocation.longitude.toString()}',
|
|
"${res['geometry']['location']['lat']},${res['geometry']['location']['lng']}");
|
|
controller.places = [];
|
|
controller.placeController.clear();
|
|
Get.back();
|
|
controller.bottomSheet();
|
|
// Get.back();
|
|
},
|
|
);
|
|
},
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment:
|
|
MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Column(
|
|
children: [
|
|
Image.network(
|
|
res['icon'],
|
|
width: 20,
|
|
),
|
|
IconButton(
|
|
onPressed: () async {
|
|
await sql.insertData({
|
|
'latitude': res['geometry']
|
|
['location']['lat'],
|
|
'longitude': res['geometry']
|
|
['location']['lng'],
|
|
'name': res['name'].toString(),
|
|
'rate': res['rating'].toString(),
|
|
}, TableName.placesFavorite);
|
|
},
|
|
icon: const Icon(Icons.favorite_border),
|
|
),
|
|
],
|
|
),
|
|
Column(
|
|
children: [
|
|
Text(
|
|
res['name'].toString(),
|
|
style: AppStyle.title,
|
|
),
|
|
Text(
|
|
res['vicinity'].toString(),
|
|
style: AppStyle.subtitle,
|
|
),
|
|
],
|
|
),
|
|
Column(
|
|
children: [
|
|
Text(
|
|
'rate',
|
|
style: AppStyle.subtitle,
|
|
),
|
|
Text(
|
|
res['rating'].toString(),
|
|
style: AppStyle.subtitle,
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
const Divider(
|
|
thickness: 1,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Container(
|
|
decoration:
|
|
const BoxDecoration(color: AppColor.secondaryColor),
|
|
child: TextField(
|
|
decoration: InputDecoration(
|
|
suffixIcon: const Icon(Icons.search),
|
|
hintText: 'Type here Place',
|
|
hintMaxLines: 1,
|
|
prefixIcon: IconButton(
|
|
onPressed: () {
|
|
controller.placeController.clear();
|
|
controller.clearPlaces();
|
|
},
|
|
icon: Icon(
|
|
Icons.clear,
|
|
color: Colors.red[300],
|
|
),
|
|
),
|
|
),
|
|
controller: controller.placeController,
|
|
onChanged: (value) {
|
|
if (controller.placeController.text.length > 5) {
|
|
controller.getPlaces();
|
|
controller.changeHeight();
|
|
}
|
|
},
|
|
// onEditingComplete: () => controller.changeHeight(),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
));
|
|
}
|