BASE: Finish Cab Type Section UI.

This commit is contained in:
2025-11-28 18:41:40 +05:00
parent 50aae9ce1a
commit b2cb9b5dc5
3 changed files with 298 additions and 191 deletions

View File

@@ -1,8 +1,11 @@
import 'dart:developer';
import 'package:customer/themes/app_them_data.dart';
import 'package:customer/themes/round_button_fill.dart';
import 'package:customer/widget/osm_map/map_controller.dart';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:latlong2/latlong.dart';
import '../../controllers/theme_controller.dart';
@@ -18,38 +21,68 @@ class MapPickerPage extends StatelessWidget {
final themeController = Get.find<ThemeController>();
final isDark = themeController.isDark.value;
return Scaffold(
appBar: AppBar(
backgroundColor: isDark ? AppThemeData.surfaceDark : AppThemeData.surface,
centerTitle: false,
titleSpacing: 0,
title: Text("PickUp Location".tr, textAlign: TextAlign.start, style: TextStyle(fontFamily: AppThemeData.medium, fontSize: 16, color: isDark ? AppThemeData.grey50 : AppThemeData.grey900)),
),
// appBar: AppBar(
// backgroundColor:
// isDark ? AppThemeData.surfaceDark : AppThemeData.surface,
// centerTitle: false,
// titleSpacing: 0,
// title: Text(
// "PickUp Location".tr,
// textAlign: TextAlign.start,
// style: TextStyle(
// fontFamily: AppThemeData.medium,
// fontSize: 16,
// color: isDark ? AppThemeData.grey50 : AppThemeData.grey900,
// ),
// ),
// ),
body: Stack(
children: [
Obx(
() => FlutterMap(
mapController: controller.mapController,
options: MapOptions(
initialCenter: controller.pickedPlace.value?.coordinates ?? LatLng(20.5937, 78.9629), // Default India center
initialCenter:
controller.pickedPlace.value?.coordinates ??
LatLng(20.5937, 78.9629), // Default India center
initialZoom: 13,
onTap: (tapPos, latlng) {
controller.addLatLngOnly(latlng);
controller.mapController.move(latlng, controller.mapController.camera.zoom);
controller.mapController.move(
latlng,
controller.mapController.camera.zoom,
);
},
),
children: [
TileLayer(urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', subdomains: const ['a', 'b', 'c'], userAgentPackageName: 'com.emart.app'),
TileLayer(
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: const ['a', 'b', 'c'],
userAgentPackageName: 'com.emart.app',
),
MarkerLayer(
markers:
controller.pickedPlace.value != null
? [Marker(point: controller.pickedPlace.value!.coordinates, width: 40, height: 40, child: const Icon(Icons.location_pin, size: 36, color: Colors.red))]
? [
Marker(
point: controller.pickedPlace.value!.coordinates,
width: 40,
height: 40,
child: const Icon(
Icons.location_pin,
size: 36,
color: Colors.red,
),
),
]
: [],
),
],
),
),
Positioned(
top: 16,
top: MediaQuery.of(context).size.height / 9,
left: 16,
right: 16,
child: Column(
@@ -59,10 +92,18 @@ class MapPickerPage extends StatelessWidget {
borderRadius: BorderRadius.circular(8),
child: TextField(
controller: searchController,
style: TextStyle(color: isDark ? AppThemeData.grey900 : AppThemeData.grey900),
style: TextStyle(
color:
isDark ? AppThemeData.grey900 : AppThemeData.grey900,
),
decoration: InputDecoration(
hintText: 'Search location...'.tr,
hintStyle: TextStyle(color: isDark ? AppThemeData.grey900 : AppThemeData.grey900),
hintStyle: TextStyle(
color:
isDark
? AppThemeData.grey900
: AppThemeData.grey900,
),
contentPadding: EdgeInsets.all(12),
border: InputBorder.none,
prefixIcon: Icon(Icons.search),
@@ -76,7 +117,10 @@ class MapPickerPage extends StatelessWidget {
}
return Container(
margin: const EdgeInsets.only(top: 4),
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
child: ListView.builder(
shrinkWrap: true,
itemCount: controller.searchResults.length,
@@ -111,8 +155,13 @@ class MapPickerPage extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Text(
controller.pickedPlace.value != null ? "Picked Location:".tr : "No Location Picked".tr,
style: TextStyle(color: isDark ? AppThemeData.primary300 : AppThemeData.primary300, fontFamily: AppThemeData.semiBold, fontWeight: FontWeight.w600),
controller.pickedPlace.value != null
? "Picked Location:".tr
: "No Location Picked".tr,
style: AppThemeData.boldTextStyle(
color: AppThemeData.grey900,
fontSize: 17.sp,
),
),
const SizedBox(height: 4),
if (controller.pickedPlace.value != null)
@@ -129,20 +178,25 @@ class MapPickerPage extends StatelessWidget {
Expanded(
child: RoundedButtonFill(
title: "Confirm Location".tr,
color: AppThemeData.primary300,
color: AppThemeData.mainColor,
textColor: AppThemeData.grey50,
height: 5,
height: 4.h,
onPress: () async {
final selected = controller.pickedPlace.value;
if (selected != null) {
Get.back(result: selected); // ✅ Return the selected place
print("Selected location: $selected");
Get.back(
result: selected,
); // ✅ Return the selected place
log("Selected location: $selected");
}
},
),
),
const SizedBox(width: 10),
IconButton(icon: const Icon(Icons.delete_forever, color: Colors.red), onPressed: controller.clearAll),
SizedBox(width: 10.w),
IconButton(
icon: const Icon(Icons.delete_forever, color: Colors.red),
onPressed: controller.clearAll,
),
],
),
],